chiark / gitweb /
documentation/doxygen: support adding classes to \ref.
authorVladimír Vondruš <mosra@centrum.cz>
Sat, 16 Nov 2019 22:41:23 +0000 (23:41 +0100)
committerVladimír Vondruš <mosra@centrum.cz>
Sat, 16 Nov 2019 22:43:30 +0000 (23:43 +0100)
documentation/doxygen.py
documentation/test_doxygen/contents_custom/index.html
documentation/test_doxygen/contents_custom/input.dox

index e89568dd20cd30ae66481887baf6428fca38c274..6d4e4d545fe84ea085f3215dca9487730e1511c3 100755 (executable)
@@ -152,7 +152,7 @@ def add_wbr(text: str) -> str:
     else:
         return text
 
-def parse_ref(state: State, element: ET.Element) -> str:
+def parse_ref(state: State, element: ET.Element, add_inline_css_class: str = None) -> str:
     id = element.attrib['refid']
 
     if element.attrib['kindref'] == 'compound':
@@ -176,6 +176,8 @@ def parse_ref(state: State, element: ET.Element) -> str:
         class_ = 'm-doc-external'
     else:
         class_ = 'm-doc'
+    if add_inline_css_class: # Overrides the default set above
+        class_ = add_inline_css_class
 
     return '<a href="{}" class="{}">{}</a>'.format(url, class_, add_wbr(parse_inline_desc(state, element).strip()))
 
@@ -1221,7 +1223,7 @@ def parse_desc_internal(state: State, element: ET.Element, immediate_parent: ET.
                 content)
 
         elif i.tag == 'ref':
-            out.parsed += parse_ref(state, i)
+            out.parsed += parse_ref(state, i, add_inline_css_class)
 
         elif i.tag == 'ulink':
             out.parsed += '<a href="{}"{}>{}</a>'.format(
index 4b8c6768213701499723b11ee2e7c1594cefbdb4..ace7534a17e30e365c65228027161eda442aa175 100644 (file)
@@ -22,7 +22,7 @@
         <h1>
           My Project
         </h1>
-<div class="m-note m-dim m-text-center">This paragraph <em>is</em> rendered in a dim note, centered.</div><p>This paragraph contains a <span class="m-text m-danger"><em>red</em> text</span> in a normal text flow and then  <strong class="m-text m-em m-small">small strong italics</strong>,   <em class="m-text m-info">blue italics</em> and  <a href="https://mcss.mosra.cz" class="m-text m-big">https:/<wbr />/<wbr />mcss.mosra.cz</a> (big-ass link).</p><div class="m-button m-primary"><a href="#"><div class="m-big">A button</div> <div class="m-small"><span class="m-text m-em">with</span>  <strong class="m-text m-em">subtitle</strong></div></a></div><p>A paragraph that is not affected by the inline classes from above.</p><p class="m-text m-strong m-noindent">Bold, non-indented paragraph.</p><p class="m-text m-primary"><strong>Bold text that should not have</strong> the same class as the paragraph.</p><p>A paragraph that doesn&#x27;t have any class applied. Next, a full-width image:</p><img class="m-image m-fullwidth" src="ship-small.jpg" alt="Image" /><figure class="m-figure m-flat"><img src="ship-small.jpg" alt="Image" /><figcaption>A flat figure</figcaption></figure><p>A fullwidth table:</p><table class="m-table m-fullwidth"><thead><tr><th>Table header</th><th>Another</th></tr></thead><tbody><tr><td>Cell</td><td>Another cell</td></tr><tr><td>Next row</td><td>Last.</td></tr></tbody></table><p>An unstyled list:</p><ul class="m-unstyled"><li>First item without a dot</li><li>Second item without a dot</li></ul><aside class="m-block m-info"><h3>A info block with some paragraphs inside</h3><div><p>Hello.</p><p>This is good, finally.</p></div></aside><aside class="m-frame"><h3>Note</h3><p>A note styled as a frame.</p></aside><p>This has to be here otherwise doxygen puts the next <code>@m_class</code> call into the above note. WHAT THE HELL!!!</p><aside class="m-block m-success"><h3><a href="licenses.html#_licenses000001" class="m-doc">Third-party license info</a></h3><p>This package is licensed under MIT. All is good.</p></aside><div class="m-code-figure"><pre class="m-code"><span class="c1">// this is the code</span>
+<div class="m-note m-dim m-text-center">This paragraph <em>is</em> rendered in a dim note, centered.</div><p>This paragraph contains a <span class="m-text m-danger"><em>red</em> text</span> in a normal text flow and then  <strong class="m-text m-em m-small">small strong italics</strong>,   <em class="m-text m-info">blue italics</em> and  <a href="https://mcss.mosra.cz" class="m-text m-big">https:/<wbr />/<wbr />mcss.mosra.cz</a> (big-ass link). A styled page ref:   <a href="math.html" class="m-label m-success">The math page</a>.</p><div class="m-button m-primary"><a href="#"><div class="m-big">A button</div> <div class="m-small"><span class="m-text m-em">with</span>  <strong class="m-text m-em">subtitle</strong></div></a></div><p>A paragraph that is not affected by the inline classes from above.</p><p class="m-text m-strong m-noindent">Bold, non-indented paragraph.</p><p class="m-text m-primary"><strong>Bold text that should not have</strong> the same class as the paragraph.</p><p>A paragraph that doesn&#x27;t have any class applied. Next, a full-width image:</p><img class="m-image m-fullwidth" src="ship-small.jpg" alt="Image" /><figure class="m-figure m-flat"><img src="ship-small.jpg" alt="Image" /><figcaption>A flat figure</figcaption></figure><p>A fullwidth table:</p><table class="m-table m-fullwidth"><thead><tr><th>Table header</th><th>Another</th></tr></thead><tbody><tr><td>Cell</td><td>Another cell</td></tr><tr><td>Next row</td><td>Last.</td></tr></tbody></table><p>An unstyled list:</p><ul class="m-unstyled"><li>First item without a dot</li><li>Second item without a dot</li></ul><aside class="m-block m-info"><h3>A info block with some paragraphs inside</h3><div><p>Hello.</p><p>This is good, finally.</p></div></aside><aside class="m-frame"><h3>Note</h3><p>A note styled as a frame.</p></aside><p>This has to be here otherwise doxygen puts the next <code>@m_class</code> call into the above note. WHAT THE HELL!!!</p><aside class="m-block m-success"><h3><a href="licenses.html#_licenses000001" class="m-doc">Third-party license info</a></h3><p>This package is licensed under MIT. All is good.</p></aside><div class="m-code-figure"><pre class="m-code"><span class="c1">// this is the code</span>
 <span class="n">printf</span><span class="p">(</span><span class="s">&quot;The answer to the universe and everything is %d.&quot;</span><span class="p">,</span> <span class="mi">5</span><span class="o">*</span><span class="mi">9</span><span class="p">)</span></pre><p>The answer to the universe and everything is 42.</p></div>
       </div>
     </div>
index d0fcc30ef6bf47ec777edd167aa04070fc9f529e..b3ae71d65cb0bd571de33b1c1105b8fdd49f3fda 100644 (file)
@@ -6,7 +6,8 @@ centered. @m_enddiv
 This paragraph contains a @m_span{m-text m-danger} *red* text @m_endspan in
 a normal text flow and then @m_class{m-text m-em m-small} **small strong italics**,
 @m_class{m-text m-info} *blue italics* and @m_class{m-text m-big} https://mcss.mosra.cz
-(big-ass link).
+(big-ass link). A styled page ref:
+@m_class{m-label m-success} @ref math "The math page".
 
 @m_div{m-button m-primary} <a href="#">@m_div{m-big} A button @m_enddiv @m_div{m-small} @m_span{m-text m-em} with @m_endspan @m_class{m-text m-em} **subtitle** @m_enddiv </a> @m_enddiv