has_block_elements = True
parsed = parse_desc_internal(state, i)
- assert parsed.section
- assert not parsed.templates and not parsed.params and not parsed.return_value
+
+ # Render as <section> in toplevel desc
+ if state.parsing_toplevel_desc:
+ assert parsed.section
+ assert not parsed.templates and not parsed.params and not parsed.return_value and not parsed.return_values and not parsed.exceptions
+
+ # Top-level section has no ID or title
+ if not out.section: out.section = ('', '', [])
+ out.section = (out.section[0], out.section[1], out.section[2] + [parsed.section])
+ out.parsed += '<section id="{}">{}</section>'.format(extract_id_hash(state, i), parsed.parsed)
+
+ # Render directly the contents otherwise, propagate parsed stuff up
+ else:
+ merge_parsed_subsections(parsed)
+ out.parsed += parsed.parsed
+
if parsed.search_keywords:
out.search_keywords += parsed.search_keywords
- # Top-level section has no ID or title
- if not out.section: out.section = ('', '', [])
- out.section = (out.section[0], out.section[1], out.section[2] + [parsed.section])
- out.parsed += '<section id="{}">{}</section>'.format(extract_id_hash(state, i), parsed.parsed)
-
elif i.tag == 'title':
assert element.tag != 'para' # should be top-level block element
has_block_elements = True
- if element.tag == 'sect1':
- tag = 'h2'
- elif element.tag == 'sect2':
- tag = 'h3'
- elif element.tag == 'sect3':
- tag = 'h4'
- elif not element.tag == 'simplesect':
- assert False # pragma: no cover
+ # Top-level description
+ if state.parsing_toplevel_desc:
+ if element.tag == 'sect1':
+ tag = 'h2'
+ elif element.tag == 'sect2':
+ tag = 'h3'
+ elif element.tag == 'sect3':
+ tag = 'h4'
+ elif not element.tag == 'simplesect':
+ assert False # pragma: no cover
+
+ # Function/enum/... descriptions are inside <h3> for function
+ # header, which is inside <h2> for detailed definition section, so
+ # it needs to be <h4> and below
+ else:
+ if element.tag == 'sect1':
+ tag = 'h4'
+ elif element.tag == 'sect2':
+ tag = 'h5'
+ elif element.tag == 'sect3':
+ tag = 'h6'
+ elif not element.tag == 'simplesect':
+ assert False # pragma: no cover
# simplesect titles are handled directly inside simplesect
if not element.tag == 'simplesect':
id = extract_id_hash(state, element)
title = html.escape(i.text)
- # Populate section info
- assert not out.section
- out.section = (id, title, [])
- out.parsed += '<{0}><a href="#{1}">{2}</a></{0}>'.format(tag, id, title)
+ # Populate section info for top-level desc
+ if state.parsing_toplevel_desc:
+ assert not out.section
+ out.section = (id, title, [])
+ out.parsed += '<{0}><a href="#{1}">{2}</a></{0}>'.format(tag, id, title)
+
+ # Otherwise add the ID directly to the heading
+ else:
+ out.parsed += '<{0} id="{1}">{2}</{0}>'.format(tag, id, title)
elif i.tag == 'heading':
assert element.tag == 'para' # is inside a paragraph :/
<h2><a href="#func-members">Functions</a></h2>
<dl class="m-dox">
<dt>
- <span class="m-dox-wrap-bumper">void <a href="#ac07863d69ae41a4e395b31f73b35fbcd" class="m-dox">foo</a>(</span><span class="m-dox-wrap">)</span>
+ <span class="m-dox-wrap-bumper">void <a href="#adc5bb4b0f2fddd234994abbe97abb8b1" class="m-dox">foo</a>(</span><span class="m-dox-wrap">int bar)</span>
</dt>
<dd>A function.</dd>
</dl>
</section>
<section>
<h2>Function documentation</h2>
- <section class="m-dox-details" id="ac07863d69ae41a4e395b31f73b35fbcd"><div>
+ <section class="m-dox-details" id="adc5bb4b0f2fddd234994abbe97abb8b1"><div>
<h3>
- <span class="m-dox-wrap-bumper">void </span><span class="m-dox-wrap"><span class="m-dox-wrap-bumper"><a href="#ac07863d69ae41a4e395b31f73b35fbcd" class="m-dox-self">foo</a>(</span><span class="m-dox-wrap">)</span></span>
+ <span class="m-dox-wrap-bumper">void </span><span class="m-dox-wrap"><span class="m-dox-wrap-bumper"><a href="#adc5bb4b0f2fddd234994abbe97abb8b1" class="m-dox-self">foo</a>(</span><span class="m-dox-wrap">int bar)</span></span>
</h3>
<p>A function.</p>
-<h4>A top-level header</h4><h5>A second-level header</h5><h6>A third-level header</h6><h6>A fourth-level header</h6>
+ <table class="m-table m-fullwidth m-flat">
+ <thead>
+ <tr><th colspan="2">Parameters</th></tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td style="width: 1%">bar</td>
+ <td>A param.</td>
+ </tr>
+ </tbody>
+ <tfoot>
+ <tr>
+ <th>Returns</th>
+ <td>Does not return anything.</td>
+ </tr>
+ </tfoot>
+ </table>
+<h4>A top-level header</h4><h5>A second-level header</h5><h6>A third-level header</h6><h6>A fourth-level header</h6><h4 id="foo-usage">Usage</h4><p>This is usage.</p><h5 id="foo-usage-more">More</h5><p>A subsection.</p><h6 id="foo-usage-more-more">More.</h6><p>Mooore.</p>
</div></section>
</section>
</div>