From: Vladimír Vondruš Date: Sat, 16 Nov 2019 22:41:23 +0000 (+0100) Subject: documentation/doxygen: support adding classes to \ref. X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~cjwatson/git?a=commitdiff_plain;h=7341b9853c26e1f39bc1da3309594ae8585a5fed;p=blog.git documentation/doxygen: support adding classes to \ref. --- diff --git a/documentation/doxygen.py b/documentation/doxygen.py index e89568dd..6d4e4d54 100755 --- a/documentation/doxygen.py +++ b/documentation/doxygen.py @@ -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 '{}'.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 += '{}'.format( diff --git a/documentation/test_doxygen/contents_custom/index.html b/documentation/test_doxygen/contents_custom/index.html index 4b8c6768..ace7534a 100644 --- a/documentation/test_doxygen/contents_custom/index.html +++ b/documentation/test_doxygen/contents_custom/index.html @@ -22,7 +22,7 @@

My Project

-
This paragraph is rendered in a dim note, centered.

This paragraph contains a red text in a normal text flow and then small strong italics, blue italics and https://mcss.mosra.cz (big-ass link).

A button
with subtitle

A paragraph that is not affected by the inline classes from above.

Bold, non-indented paragraph.

Bold text that should not have the same class as the paragraph.

A paragraph that doesn't have any class applied. Next, a full-width image:

Image
Image
A flat figure

A fullwidth table:

Table headerAnother
CellAnother cell
Next rowLast.

An unstyled list:

This has to be here otherwise doxygen puts the next @m_class call into the above note. WHAT THE HELL!!!

// this is the code
+
This paragraph is rendered in a dim note, centered.

This paragraph contains a red text in a normal text flow and then small strong italics, blue italics and https://mcss.mosra.cz (big-ass link). A styled page ref: The math page.

A paragraph that is not affected by the inline classes from above.

Bold, non-indented paragraph.

Bold text that should not have the same class as the paragraph.

A paragraph that doesn't have any class applied. Next, a full-width image:

Image
Image
A flat figure

A fullwidth table:

Table headerAnother
CellAnother cell
Next rowLast.

An unstyled list:

  • First item without a dot
  • Second item without a dot

This has to be here otherwise doxygen puts the next @m_class call into the above note. WHAT THE HELL!!!

// this is the code
 printf("The answer to the universe and everything is %d.", 5*9)

The answer to the universe and everything is 42.

diff --git a/documentation/test_doxygen/contents_custom/input.dox b/documentation/test_doxygen/contents_custom/input.dox index d0fcc30e..b3ae71d6 100644 --- a/documentation/test_doxygen/contents_custom/input.dox +++ b/documentation/test_doxygen/contents_custom/input.dox @@ -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} @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 @m_enddiv