Skip to content

Commit

Permalink
add workaround for member -> memberdef thing
Browse files Browse the repository at this point in the history
  • Loading branch information
marzer committed Sep 15, 2024
1 parent 5cc9329 commit 1ddc011
Show file tree
Hide file tree
Showing 41 changed files with 553 additions and 435 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## Unreleased

- added workaround for [this issue](https://github.com/mosra/m.css/issues/239) introduced in Doxygen 1.9.7
- updated m.css

## v0.18.0 - 2024-08-03

- added config option `excluded_symbols` (a.k.a. Doxygen's `EXCLUDE_SYMBOLS`) (#36) (@Guekka)
Expand Down
6 changes: 5 additions & 1 deletion src/poxy/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -1253,7 +1253,11 @@ def __init__(
if config_path is not None:
self.config_path = coerce_path(config_path).resolve()
if self.config_path.is_dir():
self.config_path = Path(self.config_path, r'poxy.toml')
for candidate in (r'poxy.toml', r'docs/poxy.toml', r'doc/poxy.toml', r'doxygen/poxy.toml'):
candidate_path = self.config_path / candidate
if candidate_path and candidate_path.is_file():
self.config_path = candidate_path
break
if not self.config_path.is_file():
raise Error(rf"Config '{self.config_path}' did not exist or was not a file")
if copy_config_to is not None and self.config_path.is_file():
Expand Down
73 changes: 73 additions & 0 deletions src/poxy/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import os
import subprocess
import tempfile
import copy
from distutils.dir_util import copy_tree
from io import StringIO

Expand Down Expand Up @@ -466,6 +467,78 @@ def postprocess_xml(context: Context):
if changed:
xml_utils.write(root, xml_file)

# doxygen >= 1.9.7 needs some special handling to play nice with m.css
# see: https://github.com/mosra/m.css/issues/239
if doxygen.version() >= (1, 9, 7):

This comment has been minimized.

Copy link
@mosra

mosra Sep 15, 2024

Haha yeah, this is exactly what I didn't want to do (and then maintain forever) on my end. I'm sweating just imagining all the ways in which it could break 😅


member_references = dict()

# collect all the unresolved references
for xml_file in xml_files:
root = xml_utils.read(xml_file)
if root.tag != r'doxygen':
continue
compounddef = root.find(r'compounddef')
if compounddef is None:
continue
compound_kind = compounddef.get(r'kind')
if compound_kind is None or not compound_kind or not compound_kind in (r'file', r'namespace'):
continue
for sectiondef in compounddef.findall(r'sectiondef'):
for member in sectiondef.findall(r'member'):
refid = member.get(r'refid')
if refid is not None:
refid = str(refid)
if refid and refid not in member_references:
member_references[refid] = None

if member_references:

# resolve
for xml_file in xml_files:
root = xml_utils.read(xml_file)
if root.tag != r'doxygen':
continue
compounddef = root.find(r'compounddef')
if compounddef is None:
continue
for sectiondef in compounddef.findall(r'sectiondef'):
for memberdef in sectiondef.findall(r'memberdef'):
id = memberdef.get(r'id')
if id is not None:
id = str(id)
if id and id in member_references and member_references[id] is None:
member_references[refid] = memberdef
for id, memberdef in member_references.items():
if memberdef is None:
context.warning(rf"could not resolve <member> reference with id '{id}'!")

# replace
for xml_file in xml_files:
root = xml_utils.read(xml_file)
if root.tag != r'doxygen':
continue
compounddef = root.find(r'compounddef')
if compounddef is None:
continue
compound_kind = compounddef.get(r'kind')
if compound_kind is None or not compound_kind or not compound_kind in (r'file', r'namespace'):
continue
changed = False
for sectiondef in compounddef.findall(r'sectiondef'):
replacements = []
for member in sectiondef.findall(r'member'):
refid = member.get(r'refid')
if refid is not None:
refid = str(refid)
if refid and refid in member_references and member_references[refid] is not None:
replacements.append((member, member_references[refid]))
for member, memberdef in replacements:
sectiondef.replace(member, copy.deepcopy(memberdef))
changed = True
if changed:
xml_utils.write(root, xml_file)

# now do '<doxygen>' files
for xml_file in xml_files:
root = xml_utils.read(xml_file)
Expand Down
2 changes: 1 addition & 1 deletion src/poxy/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.18.0
0.19.0
117 changes: 19 additions & 98 deletions tests/test_project/expected_html/Test!.tagfile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,102 +19,11 @@
<anchor>a867e1e9e6c924393462cf7c1a78c6c3e</anchor>
<arglist></arglist>
</member>
<member kind="typedef">
<type>int</type>
<name>a_shit_typedef</name>
<anchorfile>namespacetest.html</anchorfile>
<anchor>a51ed0e00636746f407a20697efc8518e</anchor>
<arglist></arglist>
</member>
<member kind="typedef">
<type>int</type>
<name>a_typedef</name>
<anchorfile>namespacetest.html</anchorfile>
<anchor>a011ffb640026d2f49f9c73fe09d88cfb</anchor>
<arglist></arglist>
</member>
<member kind="typedef">
<type>T</type>
<name>a_typedef_template</name>
<anchorfile>namespacetest.html</anchorfile>
<anchor>ab80f438f7d1d6d6e3b184b7ce32df687</anchor>
<arglist></arglist>
</member>
<member kind="enumeration">
<type></type>
<name>unscoped_enum</name>
<anchorfile>namespacetest.html</anchorfile>
<anchor>ac1a212ff6fd8b8aa63bd0d5536ae7065</anchor>
<arglist></arglist>
</member>
<member kind="enumvalue">
<name>LEGACY_ENUM_VAL_0</name>
<anchorfile>namespacetest.html</anchorfile>
<anchor>ac1a212ff6fd8b8aa63bd0d5536ae7065a3b6f77dbd09e17c5e8a30dcd3474012f</anchor>
<arglist></arglist>
</member>
<member kind="enumvalue">
<name>LEGACY_ENUM_VAL_1</name>
<anchorfile>namespacetest.html</anchorfile>
<anchor>ac1a212ff6fd8b8aa63bd0d5536ae7065af18ad5a3bf0d316003544836a8734fd4</anchor>
<arglist></arglist>
</member>
<member kind="enumvalue">
<name>LEGACY_ENUM_VAL_2</name>
<anchorfile>namespacetest.html</anchorfile>
<anchor>ac1a212ff6fd8b8aa63bd0d5536ae7065a731c49ced9fc7748acfebc0a4910494d</anchor>
<arglist></arglist>
</member>
<member kind="enumeration">
<type></type>
<name>scoped_enum</name>
<anchorfile>namespacetest.html</anchorfile>
<anchor>a393facd551443a4aaea74c533c2bce6f</anchor>
<arglist></arglist>
<enumvalue file="namespacetest.html" anchor="a393facd551443a4aaea74c533c2bce6fa209e4404bac5df6700a512df9e988ba3">val_0</enumvalue>
<enumvalue file="namespacetest.html" anchor="a393facd551443a4aaea74c533c2bce6fad69dff41cc115965adfeaa0f58fed641">val_1</enumvalue>
<enumvalue file="namespacetest.html" anchor="a393facd551443a4aaea74c533c2bce6fa3745be12e7d2d79a55682a6b1ef5863c">val_2</enumvalue>
</member>
<member kind="function">
<type>void</type>
<name>a_friend_function</name>
<anchorfile>namespacetest.html</anchorfile>
<anchor>a14eee7dd5169cc088aad164c5fcb1800</anchor>
<arglist>()</arglist>
</member>
<member kind="function">
<type>std::uint8_t</type>
<name>do_the_thing</name>
<anchorfile>namespacetest.html</anchorfile>
<anchor>a011c6f27e90f228cd68be9def15bc076</anchor>
<arglist>()</arglist>
</member>
<member kind="function">
<type>constexpr T</type>
<name>do_the_other_thing</name>
<anchorfile>namespacetest.html</anchorfile>
<anchor>ae66b7e2e94f84934cff5de3e512ce0ee</anchor>
<arglist>(U u) noexcept</arglist>
</member>
<member kind="function">
<type>auto</type>
<name>do_the_thing_automatically</name>
<anchorfile>namespacetest.html</anchorfile>
<anchor>af2e6008ff8ee50f6cda80da681d44348</anchor>
<arglist>() -&gt; int</arglist>
</member>
<member kind="function">
<type>auto</type>
<name>a_function_with_a_deduced_return_type</name>
<anchorfile>namespacetest.html</anchorfile>
<anchor>af10bf287d581eb8aae63d450e3f848c5</anchor>
<arglist>()</arglist>
</member>
<member kind="variable">
<type>constexpr bool</type>
<name>inline_variable</name>
<anchorfile>namespacetest.html</anchorfile>
<anchor>af2f5b0612e98ea3ef9de39eb10981879</anchor>
<member kind="define">
<type>#define</type>
<name>KEK_IN_GROUP</name>
<anchorfile>group__group.html</anchorfile>
<anchor>gab8f35b5fe5a9047e142acaef9b5336ca</anchor>
<arglist></arglist>
</member>
</compound>
Expand Down Expand Up @@ -269,14 +178,14 @@
<type>int</type>
<name>a_typedef</name>
<anchorfile>namespacetest.html</anchorfile>
<anchor>a011ffb640026d2f49f9c73fe09d88cfb</anchor>
<anchor>af3b055b49aff8d48bea92e5f226daa5d</anchor>
<arglist></arglist>
</member>
<member kind="typedef">
<type>T</type>
<name>a_typedef_template</name>
<anchorfile>namespacetest.html</anchorfile>
<anchor>ab80f438f7d1d6d6e3b184b7ce32df687</anchor>
<anchor>a58dc421199859607c527ded8e3d87bae</anchor>
<arglist></arglist>
</member>
<member kind="enumeration">
Expand Down Expand Up @@ -366,4 +275,16 @@
<filename>namespacetest_1_1nested.html</filename>
<concept>test::nested::concept_2</concept>
</compound>
<compound kind="group">
<name>group</name>
<title>A group.</title>
<filename>group__group.html</filename>
<member kind="define">
<type>#define</type>
<name>KEK_IN_GROUP</name>
<anchorfile>group__group.html</anchorfile>
<anchor>gab8f35b5fe5a9047e142acaef9b5336ca</anchor>
<arglist></arglist>
</member>
</compound>
</tagfile>
3 changes: 2 additions & 1 deletion tests/test_project/expected_html/annotated.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,11 @@
<div class="m-row">
<ol class="m-col-t-6 m-col-m-none">
<li><a href="files.html">Files</a></li>
<li><a href="modules.html">Modules</a></li>
<li><a href="namespaces.html">Namespaces</a></li>
<li><a href="annotated.html" id="m-navbar-current">Classes</a></li>
</ol>
<ol class="m-col-t-6 m-col-m-none" start="4">
<li><a href="annotated.html" id="m-navbar-current">Classes</a></li>
<li><a href="concepts.html">Concepts</a></li>
<li><a class="poxy-icon theme" href="javascript:void(null);" id="poxy-theme-switch" onclick="toggle_theme(); return false;" role="button" title="Toggle dark and light themes"><svg id="poxy-theme-switch-img" version="1.1" viewBox="0 0 512 512" xmlns="http://www.w3.org/2000/svg"><circle cx="185.6708" cy="183.8122" fill="currentColor" r="65.625"></circle><path d="M185.6708,87.5622a13.1256,13.1256,0,0,0,13.125-13.125V52.5622a13.125,13.125,0,1,0-26.25,0v21.875A13.1257,13.1257,0,0,0,185.6708,87.5622Z" fill="currentColor"></path><path d="M99.051,115.7519a13.1236,13.1236,0,1,0,18.56-18.56L102.1442,81.726a13.1236,13.1236,0,0,0-18.5595,18.56Z" fill="currentColor"></path><path d="M89.4208,183.8122a13.1257,13.1257,0,0,0-13.125-13.125H54.4208a13.125,13.125,0,0,0,0,26.25h21.875A13.1256,13.1256,0,0,0,89.4208,183.8122Z" fill="currentColor"></path><path d="M99.051,251.8725,83.5847,267.3431a13.1236,13.1236,0,1,0,18.56,18.56l15.4663-15.4706a13.1236,13.1236,0,1,0-18.5595-18.56Z" fill="currentColor"></path><path d="M185.6708,280.0622a13.1258,13.1258,0,0,0-13.125,13.125v21.875a13.125,13.125,0,0,0,26.25,0v-21.875A13.1257,13.1257,0,0,0,185.6708,280.0622Z" fill="currentColor"></path><path d="M272.2907,251.8725a13.1236,13.1236,0,1,0-18.56,18.56l15.4663,15.4706a13.1236,13.1236,0,1,0,18.56-18.56Z" fill="currentColor"></path><path d="M330.0458,183.8122a13.1257,13.1257,0,0,0-13.125-13.125h-21.875a13.125,13.125,0,0,0,0,26.25h21.875A13.1256,13.1256,0,0,0,330.0458,183.8122Z" fill="currentColor"></path><path d="M263.0109,119.5971a13.0824,13.0824,0,0,0,9.28-3.8452l15.4663-15.4663a13.1236,13.1236,0,1,0-18.56-18.56L253.7312,97.1923a13.125,13.125,0,0,0,9.28,22.4048Z" fill="currentColor"></path><path d="M456.9379,401.6714a63.97,63.97,0,0,1-14.9963,7.2055c-19.6448,6.5283-41.8787,2.9566-58.1439-9.8523a68.9311,68.9311,0,0,1-10.835-10.8339c-12.8088-16.2663-16.3806-38.5-9.8523-58.1471a63.8444,63.8444,0,0,1,7.2077-14.9931,8.8036,8.8036,0,0,0-10.1172-13.3034,87.5188,87.5188,0,1,0,110.0372,110.04A8.8,8.8,0,0,0,456.9379,401.6714Z" fill="currentColor"></path></svg></a></li>
<li class="m-show-m"><a class="m-doc-search-icon" href="#search" onclick="return showSearch()" title="Search"><svg style="height: 0.9rem;" viewBox="0 0 16 16">
Expand Down
11 changes: 6 additions & 5 deletions tests/test_project/expected_html/classtest_1_1class__1.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,11 @@
<div class="m-row">
<ol class="m-col-t-6 m-col-m-none">
<li><a href="files.html">Files</a></li>
<li><a href="modules.html">Modules</a></li>
<li><a href="namespaces.html">Namespaces</a></li>
<li><a href="annotated.html">Classes</a></li>
</ol>
<ol class="m-col-t-6 m-col-m-none" start="4">
<li><a href="annotated.html">Classes</a></li>
<li><a href="concepts.html">Concepts</a></li>
<li><a class="poxy-icon theme" href="javascript:void(null);" id="poxy-theme-switch" onclick="toggle_theme(); return false;" role="button" title="Toggle dark and light themes"><svg id="poxy-theme-switch-img" version="1.1" viewBox="0 0 512 512" xmlns="http://www.w3.org/2000/svg"><circle cx="185.6708" cy="183.8122" fill="currentColor" r="65.625"></circle><path d="M185.6708,87.5622a13.1256,13.1256,0,0,0,13.125-13.125V52.5622a13.125,13.125,0,1,0-26.25,0v21.875A13.1257,13.1257,0,0,0,185.6708,87.5622Z" fill="currentColor"></path><path d="M99.051,115.7519a13.1236,13.1236,0,1,0,18.56-18.56L102.1442,81.726a13.1236,13.1236,0,0,0-18.5595,18.56Z" fill="currentColor"></path><path d="M89.4208,183.8122a13.1257,13.1257,0,0,0-13.125-13.125H54.4208a13.125,13.125,0,0,0,0,26.25h21.875A13.1256,13.1256,0,0,0,89.4208,183.8122Z" fill="currentColor"></path><path d="M99.051,251.8725,83.5847,267.3431a13.1236,13.1236,0,1,0,18.56,18.56l15.4663-15.4706a13.1236,13.1236,0,1,0-18.5595-18.56Z" fill="currentColor"></path><path d="M185.6708,280.0622a13.1258,13.1258,0,0,0-13.125,13.125v21.875a13.125,13.125,0,0,0,26.25,0v-21.875A13.1257,13.1257,0,0,0,185.6708,280.0622Z" fill="currentColor"></path><path d="M272.2907,251.8725a13.1236,13.1236,0,1,0-18.56,18.56l15.4663,15.4706a13.1236,13.1236,0,1,0,18.56-18.56Z" fill="currentColor"></path><path d="M330.0458,183.8122a13.1257,13.1257,0,0,0-13.125-13.125h-21.875a13.125,13.125,0,0,0,0,26.25h21.875A13.1256,13.1256,0,0,0,330.0458,183.8122Z" fill="currentColor"></path><path d="M263.0109,119.5971a13.0824,13.0824,0,0,0,9.28-3.8452l15.4663-15.4663a13.1236,13.1236,0,1,0-18.56-18.56L253.7312,97.1923a13.125,13.125,0,0,0,9.28,22.4048Z" fill="currentColor"></path><path d="M456.9379,401.6714a63.97,63.97,0,0,1-14.9963,7.2055c-19.6448,6.5283-41.8787,2.9566-58.1439-9.8523a68.9311,68.9311,0,0,1-10.835-10.8339c-12.8088-16.2663-16.3806-38.5-9.8523-58.1471a63.8444,63.8444,0,0,1,7.2077-14.9931,8.8036,8.8036,0,0,0-10.1172-13.3034,87.5188,87.5188,0,1,0,110.0372,110.04A8.8,8.8,0,0,0,456.9379,401.6714Z" fill="currentColor"></path></svg></a></li>
<li class="m-show-m"><a class="m-doc-search-icon" href="#search" onclick="return showSearch()" title="Search"><svg style="height: 0.9rem;" viewBox="0 0 16 16">
Expand Down Expand Up @@ -103,7 +104,7 @@ <h2><a href="#pub-static-attribs">Public static variables</a></h2>
<h2><a href="#pub-static-methods">Public static functions</a></h2>
<dl class="m-doc">
<dt>
<span class="m-doc-wrap-bumper">static auto <a class="m-doc" href="#af2caa02646ff203339faf41a0efc4b20">public_static_function</a>(</span><span class="m-doc-wrap">)&nbsp;&rarr;&nbsp; <a class="m-doc" href="structtest_1_1struct__1.html">struct_<wbr/>1</a> <span class="m-label m-flat m-primary">constexpr</span></span>
<span class="m-doc-wrap-bumper">static auto <a class="m-doc" href="#af2caa02646ff203339faf41a0efc4b20">public_static_function</a>(</span><span class="m-doc-wrap">) →  <a class="m-doc" href="structtest_1_1struct__1.html">struct_<wbr/>1</a> <span class="m-label m-flat m-primary">constexpr</span></span>
</dt>
<dd>A public static function.</dd>
</dl>
Expand All @@ -112,7 +113,7 @@ <h2><a href="#pub-static-methods">Public static functions</a></h2>
<h2><a href="#pub-methods">Public functions</a></h2>
<dl class="m-doc">
<dt>
<span class="m-doc-wrap-bumper">auto <a class="m-doc" href="#a6b372d2af2e8e874869f0ddf50a306fb">public_function</a>(</span><span class="m-doc-wrap">)&nbsp;&rarr;&nbsp; bool</span>
<span class="m-doc-wrap-bumper">auto <a class="m-doc" href="#a6b372d2af2e8e874869f0ddf50a306fb">public_function</a>(</span><span class="m-doc-wrap">) →  bool</span>
</dt>
<dd>A public function.</dd>
</dl>
Expand All @@ -139,7 +140,7 @@ <h2><a href="#pro-types">Protected types</a></h2>
<h2><a href="#pro-static-methods">Protected static functions</a></h2>
<dl class="m-doc">
<dt>
<span class="m-doc-wrap-bumper">static auto <a class="m-doc" href="#ac4b22b5c1e50ba1a06f0319566252bb8">protected_static_function</a>(</span><span class="m-doc-wrap">)&nbsp;&rarr;&nbsp; bool <span class="m-label m-flat m-primary">constexpr</span></span>
<span class="m-doc-wrap-bumper">static auto <a class="m-doc" href="#ac4b22b5c1e50ba1a06f0319566252bb8">protected_static_function</a>(</span><span class="m-doc-wrap">) →  bool <span class="m-label m-flat m-primary">constexpr</span></span>
</dt>
<dd>A protected static function.</dd>
</dl>
Expand All @@ -148,7 +149,7 @@ <h2><a href="#pro-static-methods">Protected static functions</a></h2>
<h2><a href="#pro-methods">Protected functions</a></h2>
<dl class="m-doc">
<dt>
<span class="m-doc-wrap-bumper">auto <a class="m-doc" href="#ab61d354f51a90bb49d38d22e7a7d7f48">protected_function</a>(</span><span class="m-doc-wrap">)&nbsp;&rarr;&nbsp; bool</span>
<span class="m-doc-wrap-bumper">auto <a class="m-doc" href="#ab61d354f51a90bb49d38d22e7a7d7f48">protected_function</a>(</span><span class="m-doc-wrap">) →  bool</span>
</dt>
<dd>A protected function.</dd>
</dl>
Expand Down
Loading

0 comments on commit 1ddc011

Please sign in to comment.