From 50a7fc5324198f45cde042c87c7a0b4f651b3d25 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Fri, 13 Sep 2024 23:47:00 +0200 Subject: [PATCH] documentation/doxygen: normalize spacing around inline tags. Those are \xmlonly, and Doxygen 1.12 (or anything between 1.12 and 1.8.16) seems to put one more space there, causing useless differences in test files. Replacing those with just one space to have a consistent output across all versions. --- documentation/doxygen.py | 25 ++++++++++++++++--- .../test_doxygen/contents_custom/index.html | 4 +-- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/documentation/doxygen.py b/documentation/doxygen.py index 397d3563..025dfaf4 100755 --- a/documentation/doxygen.py +++ b/documentation/doxygen.py @@ -1156,6 +1156,15 @@ def parse_desc_internal(state: State, element: ET.Element, immediate_parent: ET. # Adding a custom CSS class to the immediately following block/inline # element elif i.tag == '{http://mcss.mosra.cz/doxygen/}class': + # Doxygen may put one or more spaces before, depending on the + # version. Replace them with just one to have consistent output + # across all versions. Have to keep at least one as it's often + # intentional, block elements such as have both the + # leading and trailing spaces stripped always. Sane is done for + # below. + if out.parsed.endswith(' '): + out.parsed = out.parsed.rstrip() + ' ' + # Bubble up in case we are alone in a paragraph, as that's meant to # affect the next paragraph content. if len([listing for listing in element]) == 1: @@ -1397,6 +1406,15 @@ def parse_desc_internal(state: State, element: ET.Element, immediate_parent: ET. # in _document_all_stuff(). In that case the class attribute is not # present. elif i.tag == '{http://mcss.mosra.cz/doxygen/}span': + # Doxygen may put one or more spaces before, depending on the + # version. Replace them with just one to have consistent output + # across all versions. Have to keep at least one as it's often + # intentional, block elements such as have both the + # leading and trailing spaces stripped always. Sane is done for + # above. + if out.parsed.endswith(' '): + out.parsed = out.parsed.rstrip() + ' ' + content = parse_inline_desc(state, i).strip() if '{http://mcss.mosra.cz/doxygen/}class' in i.attrib: out.parsed += '{}'.format(i.attrib['{http://mcss.mosra.cz/doxygen/}class'], content) @@ -1694,13 +1712,14 @@ def parse_desc_internal(state: State, element: ET.Element, immediate_parent: ET. # is done by the caller. out.parsed += html.escape(i.tail.lstrip()) - # Otherwise strip if requested by the caller or if this is right after - # a line break + # Otherwise strip if requested by the caller, if this is right after a + # line break or a , or if was before (which + # likely had a space before itself as well) elif i.tail: tail: str = html.escape(i.tail) if trim: tail = tail.strip() - elif out.parsed.endswith('
'): + elif out.parsed.endswith('
') or i.tag in ['{http://mcss.mosra.cz/doxygen/}div', '{http://mcss.mosra.cz/doxygen/}class']: tail = tail.lstrip() out.parsed += tail diff --git a/documentation/test_doxygen/contents_custom/index.html b/documentation/test_doxygen/contents_custom/index.html index 164b229f..d27e67f1 100644 --- a/documentation/test_doxygen/contents_custom/index.html +++ b/documentation/test_doxygen/contents_custom/index.html @@ -22,8 +22,8 @@

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 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.

A paragraph containing a footnote 27 reference.

27.
And a styled footnote, overriding the default styling which is used for TODO pages and other xrefitems, like Third-party license info.
+
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.

A paragraph containing a footnote 27 reference.

27.
And a styled footnote, overriding the default styling which is used for TODO pages and other xrefitems, like Third-party license info.
-- 2.30.2