mirror of
https://github.com/boostorg/boostbook.git
synced 2025-05-11 21:33:58 +00:00
Fix boostbook tests for platform inconsistencies.
[SVN r84164]
This commit is contained in:
parent
29690b73b0
commit
24d607e6b6
@ -12,6 +12,7 @@ Usage: python build_docs.py [--generate-gold]
|
|||||||
import difflib, getopt, os, re, sys
|
import difflib, getopt, os, re, sys
|
||||||
import lxml.ElementInclude
|
import lxml.ElementInclude
|
||||||
from lxml import etree
|
from lxml import etree
|
||||||
|
from collections import defaultdict
|
||||||
|
|
||||||
# Globals
|
# Globals
|
||||||
|
|
||||||
@ -82,7 +83,7 @@ def run_boostbook(parser, boostbook_xsl, file):
|
|||||||
|
|
||||||
def normalize_boostbook_ids(doc):
|
def normalize_boostbook_ids(doc):
|
||||||
ids = {}
|
ids = {}
|
||||||
id_bases = {}
|
id_bases = defaultdict(int)
|
||||||
|
|
||||||
for node in doc.xpath("//*[starts-with(@id, 'id') or contains(@id, '_id')]"):
|
for node in doc.xpath("//*[starts-with(@id, 'id') or contains(@id, '_id')]"):
|
||||||
id = node.get('id')
|
id = node.get('id')
|
||||||
@ -90,13 +91,14 @@ def normalize_boostbook_ids(doc):
|
|||||||
if(id in ids):
|
if(id in ids):
|
||||||
print 'Duplicate id: ' + id
|
print 'Duplicate id: ' + id
|
||||||
|
|
||||||
match = re.match("(id|.+_id)([mp]?\d+)((?:-bb)?)", id)
|
match = re.match("(.+_id|id)([mp]?\d+)((?:-bb)?)", id)
|
||||||
if(match):
|
if(match):
|
||||||
count = 1
|
# Truncate id name, as it sometimes has different lengths...
|
||||||
if(match.group(1) in id_bases):
|
match2 = re.match("(.*?)([^.]*?)(_?id)", match.group(1))
|
||||||
count = id_bases[match.group(1)] + 1
|
base = match2.group(1) + match2.group(2)[:14] + match2.group(3)
|
||||||
id_bases[match.group(1)] = count
|
count = id_bases[base] + 1
|
||||||
ids[id] = match.group(1) + str(count) + match.group(3)
|
id_bases[base] = count
|
||||||
|
ids[id] = base + str(count) + match.group(3)
|
||||||
|
|
||||||
for node in doc.xpath("//*[@linkend or @id]"):
|
for node in doc.xpath("//*[@linkend or @id]"):
|
||||||
x = node.get('linkend')
|
x = node.get('linkend')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user