return base_url, id[i+2:]
def extract_id_hash(state: State, element: ET.Element) -> str:
- base_url, id = parse_id(element)
- assert base_url == state.current_compound.url
- return id
+ # Can't use parse_id() here as sections with _1 in it have it verbatim
+ # unescaped and mess up with the rindex(). OTOH, can't use this approach in
+ # parse_id() because for example enums can be present in both file and
+ # namespace documentation, having the base_url either the file one or the
+ # namespace one, depending on what's documented better. Ugh. See the
+ # contents_section_underscore_one test for a verification.
+ id = element.attrib['id']
+ assert id.startswith(state.current_compound.url_base)
+ return id[len(state.current_compound.url_base)+2:]
def fix_type_spacing(type: str) -> str:
return type.replace('< ', '<').replace(' >', '>').replace(' &', '&').replace(' *', '*')
# is for groups.
compound.name = compounddef.find('title').text if compound.kind in ['page', 'group'] and compounddef.findtext('title') else compounddef.find('compoundname').text
# Compound URL is ID, except for index page
- compound.url = (compounddef.find('compoundname').text if compound.kind == 'page' else compound.id) + '.html'
+ compound.url_base = (compounddef.find('compoundname').text if compound.kind == 'page' else compound.id)
+ compound.url = compound.url_base + '.html'
# Save current compound URL for search data building and ID extraction
state.current_compound = compound
compound.has_template_details = False
--- /dev/null
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <meta charset="UTF-8" />
+ <title>My Project</title>
+ <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:400,400i,600,600i%7CSource+Code+Pro:400,400i,600" />
+ <link rel="stylesheet" href="m-dark+doxygen.compiled.css" />
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
+</head>
+<body>
+<header><nav id="navigation">
+ <div class="m-container">
+ <div class="m-row">
+ <a href="index.html" id="m-navbar-brand" class="m-col-t-8 m-col-m-none m-left-m">My Project</a>
+ </div>
+ </div>
+</nav></header>
+<main><article>
+ <div class="m-container m-container-inflatable">
+ <div class="m-row">
+ <div class="m-col-l-10 m-push-l-1">
+ <h1>
+ My Project
+ </h1>
+<section id="section_1"><h2><a href="#section_1">A section</a></h2><p>The section name has <code>_1</code> in it, which is the same as the compound/section separator that Doxygen puts in. It shouldn't assert.</p></section>
+ </div>
+ </div>
+ </div>
+</article></main>
+</body>
+</html>
def test(self):
self.run_dox2html5(wildcard='namespaceNamespace.xml')
self.assertEqual(*self.actual_expected_contents('namespaceNamespace.html'))
+
+class SectionUnderscoreOne(IntegrationTestCase):
+ def __init__(self, *args, **kwargs):
+ super().__init__(__file__, 'section_underscore_one', *args, **kwargs)
+
+ def test(self):
+ self.run_dox2html5(wildcard='indexpage.xml')
+ self.assertEqual(*self.actual_expected_contents('index.html'))