From f706d7a016134317f74c69031ec8ee14bcfbedf4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Mon, 16 Sep 2024 13:59:57 +0200 Subject: [PATCH] m.code: adapt to pygments 2.10 to 2.18. The new versions properly qualify whitespace as such instead of as text, and do so gradually, which is responsible for most changes in the output. Besides that, until 2.14 there were certain cases of empty in the output, which 2.14 fixes, so I add a postprocessing step to clean those up to not need to further branch the tests. The CI now tests various pygments versions, with only the last job taking the latest version. --- doc/build-status.html.in | 12 +-- documentation/doxygen.py | 7 ++ .../contents_blockquote/index-pygments29.html | 33 +++++++ .../contents_blockquote/index.html | 2 +- .../contents_code/index-pygments29.html | 35 +++++++ .../test_doxygen/contents_code/index.html | 8 +- .../contents_code/warnings-pygments29.html | 34 +++++++ .../test_doxygen/contents_code/warnings.html | 2 +- .../index-pygments210.html | 33 +++++++ .../contents_code_filters/index.html | 4 +- .../index-pygments213.html | 36 +++++++ .../index-pygments29.html | 36 +++++++ .../contents_code_language/index.html | 8 +- .../contents_custom/index-pygments29.html | 32 ++++++ .../test_doxygen/contents_custom/index.html | 2 +- .../contents_tagfile/index-pygments29.html | 31 ++++++ .../test_doxygen/contents_tagfile/index.html | 2 +- ..._2CMakeLists_8txt-example-pygments210.html | 39 ++++++++ .../path-prefix_2CMakeLists_8txt-example.html | 6 +- ...-prefix_2main_8cpp-example-pygments29.html | 43 ++++++++ .../path-prefix_2main_8cpp-example.html | 12 +-- documentation/test_doxygen/test_contents.py | 59 +++++++++-- documentation/test_doxygen/test_example.py | 16 ++- package/ci/circleci.yml | 26 ++++- plugins/m/code.py | 6 ++ plugins/m/test/code/page-210.html | 98 +++++++++++++++++++ plugins/m/test/code/page-29.html | 98 +++++++++++++++++++ plugins/m/test/code/page.html | 38 +++---- plugins/m/test/test_code.py | 12 ++- 29 files changed, 708 insertions(+), 62 deletions(-) create mode 100644 documentation/test_doxygen/contents_blockquote/index-pygments29.html create mode 100644 documentation/test_doxygen/contents_code/index-pygments29.html create mode 100644 documentation/test_doxygen/contents_code/warnings-pygments29.html create mode 100644 documentation/test_doxygen/contents_code_filters/index-pygments210.html create mode 100644 documentation/test_doxygen/contents_code_language/index-pygments213.html create mode 100644 documentation/test_doxygen/contents_code_language/index-pygments29.html create mode 100644 documentation/test_doxygen/contents_custom/index-pygments29.html create mode 100644 documentation/test_doxygen/contents_tagfile/index-pygments29.html create mode 100644 documentation/test_doxygen/example/path-prefix_2CMakeLists_8txt-example-pygments210.html create mode 100644 documentation/test_doxygen/example/path-prefix_2main_8cpp-example-pygments29.html create mode 100644 plugins/m/test/code/page-210.html create mode 100644 plugins/m/test/code/page-29.html diff --git a/doc/build-status.html.in b/doc/build-status.html.in index b64d60a6..70a3875a 100644 --- a/doc/build-status.html.in +++ b/doc/build-status.html.in @@ -3,12 +3,12 @@ - Python
3.6
- Python
3.7
- Python
3.8
- Python
3.9
- Python
3.10
- Python
3.11
+ Python
3.6
+ Python
3.7
+ Python
3.8
+ Python
3.9
+ Python
3.10
+ Python
3.11
Python
3.12
diff --git a/documentation/doxygen.py b/documentation/doxygen.py index 17faec3c..88a2d80d 100755 --- a/documentation/doxygen.py +++ b/documentation/doxygen.py @@ -1375,6 +1375,13 @@ def parse_desc_internal(state: State, element: ET.Element, immediate_parent: ET. if filter: code = filter(code) highlighted = highlight(code, lexer, formatter).rstrip() + # Pygments < 2.14 leave useless empty spans in the output. Filter + # them out to have the markup consistent across versions for easier + # testing. + # TODO same is in m.code, remove once support for < 2.14 is dropped + highlighted = (highlighted + .replace('', '') + .replace('', '')) # Strip whitespace around if inline code, strip only trailing # whitespace if a block if not code_block: highlighted = highlighted.lstrip() diff --git a/documentation/test_doxygen/contents_blockquote/index-pygments29.html b/documentation/test_doxygen/contents_blockquote/index-pygments29.html new file mode 100644 index 00000000..350ff819 --- /dev/null +++ b/documentation/test_doxygen/contents_blockquote/index-pygments29.html @@ -0,0 +1,33 @@ + + + + + My Project + + + + + +
+
+
+
+
+

+ My Project +

+

Mainly containing tests for Doxygen 1.9 parsing regressions and weirdness.

A blockquote. In 1.9 it has a ZWJ added in the XML, which should get stripped away again.

Preformatted text after a blockquote. In 1.9 it will get parsed just as a
+regular paragraph unless there's a dot before.
+

Another blockquote.

// code block that shouldn't be treated as inline
// quoted code block that should be neither inline nor in a paragraph

A delimiting paragraph, just to not have a blockqoute right after another blockquote.

Another blockquote.

"inline" + code in a usual paragraph.

Another blockquote.

"inline" + code with a tag after.

+
+
+
+
+ + diff --git a/documentation/test_doxygen/contents_blockquote/index.html b/documentation/test_doxygen/contents_blockquote/index.html index 350ff819..e008ef9e 100644 --- a/documentation/test_doxygen/contents_blockquote/index.html +++ b/documentation/test_doxygen/contents_blockquote/index.html @@ -24,7 +24,7 @@

Mainly containing tests for Doxygen 1.9 parsing regressions and weirdness.

A blockquote. In 1.9 it has a ZWJ added in the XML, which should get stripped away again.

Preformatted text after a blockquote. In 1.9 it will get parsed just as a
 regular paragraph unless there's a dot before.
-

Another blockquote.

// code block that shouldn't be treated as inline
// quoted code block that should be neither inline nor in a paragraph

A delimiting paragraph, just to not have a blockqoute right after another blockquote.

Another blockquote.

"inline" + code in a usual paragraph.

Another blockquote.

"inline" + code with a tag after.

+

Another blockquote.

// code block that shouldn't be treated as inline
// quoted code block that should be neither inline nor in a paragraph

A delimiting paragraph, just to not have a blockqoute right after another blockquote.

Another blockquote.

"inline" + code in a usual paragraph.

Another blockquote.

"inline" + code with a tag after.

diff --git a/documentation/test_doxygen/contents_code/index-pygments29.html b/documentation/test_doxygen/contents_code/index-pygments29.html new file mode 100644 index 00000000..4d8ef825 --- /dev/null +++ b/documentation/test_doxygen/contents_code/index-pygments29.html @@ -0,0 +1,35 @@ + + + + + My Project + + + + + +
+
+
+
+
+

+ My Project +

+
// A code block.
+// Spanning multiple lines.

Inline=code; at the start of a line. Then a code that is inside of true || false a text, should be delimited by spaces. But not when it is in (std::exit(2);) parentheses.

    // a block
+        // that is indented
+    // but has a lot of trailing whitespace which should be removed
+}
// this is a new block
// code?

And code block after a blockquote as well:

// another block

The constexpr functions are pure.

inline variables are a thing?

Code block inside a list (has to be done using HTML):

  • A paragraph.

    #include <os>
  • Another paragraph.

    Yet another

  • A single paragraph, rendered without the wrapping tag
+
+
+
+
+ + diff --git a/documentation/test_doxygen/contents_code/index.html b/documentation/test_doxygen/contents_code/index.html index 9c072f6e..329259e9 100644 --- a/documentation/test_doxygen/contents_code/index.html +++ b/documentation/test_doxygen/contents_code/index.html @@ -23,10 +23,10 @@ My Project
// A code block.
-// Spanning multiple lines.

Inline=code; at the start of a line. Then a code that is inside of true || false a text, should be delimited by spaces. But not when it is in (std::exit(2);) parentheses.

    // a block
-        // that is indented
-    // but has a lot of trailing whitespace which should be removed
-}
// this is a new block
// code?

And code block after a blockquote as well:

// another block

The constexpr functions are pure.

inline variables are a thing?

Code block inside a list (has to be done using HTML):

+// Spanning multiple lines.

Inline=code; at the start of a line. Then a code that is inside of true || false a text, should be delimited by spaces. But not when it is in (std::exit(2);) parentheses.

    // a block
+        // that is indented
+    // but has a lot of trailing whitespace which should be removed
+}
// this is a new block
// code?

And code block after a blockquote as well:

// another block

The constexpr functions are pure.

inline variables are a thing?

Code block inside a list (has to be done using HTML):

diff --git a/documentation/test_doxygen/contents_code/warnings-pygments29.html b/documentation/test_doxygen/contents_code/warnings-pygments29.html new file mode 100644 index 00000000..f578422a --- /dev/null +++ b/documentation/test_doxygen/contents_code/warnings-pygments29.html @@ -0,0 +1,34 @@ + + + + + Code that produces warnings | My Project + + + + + +
+
+
+
+
+

+ Code that produces warnings +

+
// Code without language
+// description

A paragraph.

multi=line;
+code="that is a part of a paragraph.";

Improper code block inside a list that needs to be extracted out:

  • A paragraph.

    #include <os>
    +// hello again
+
+
+
+
+ + diff --git a/documentation/test_doxygen/contents_code/warnings.html b/documentation/test_doxygen/contents_code/warnings.html index 92802460..58e0f9e8 100644 --- a/documentation/test_doxygen/contents_code/warnings.html +++ b/documentation/test_doxygen/contents_code/warnings.html @@ -24,7 +24,7 @@
// Code without language
 // description

A paragraph.

multi=line;
-code="that is a part of a paragraph.";

Improper code block inside a list that needs to be extracted out: