Skip to content

Commit

Permalink
XML v2 work
Browse files Browse the repository at this point in the history
- added support for `<ref>`
- added support for all exposition-only markup
- added additional validation
- started work on the solve for #15
  • Loading branch information
marzer committed Oct 13, 2022
1 parent 2c0235b commit 62346bf
Show file tree
Hide file tree
Showing 31 changed files with 2,631 additions and 486 deletions.
863 changes: 641 additions & 222 deletions poxy/doxygen.py

Large diffs are not rendered by default.

630 changes: 452 additions & 178 deletions poxy/graph.py

Large diffs are not rendered by default.

34 changes: 28 additions & 6 deletions poxy/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from . import doxygen
from . import soup
from . import fixers
from . import graph
from .svg import SVG
from distutils.dir_util import copy_tree

Expand Down Expand Up @@ -134,6 +135,7 @@ def make_temp_file():
(r'SORT_MEMBERS_CTORS_1ST', True),
(r'SOURCE_BROWSER', False),
(r'STRICT_PROTO_MATCHING', False),
(r'STRIP_FROM_INC_PATH', None), # we handle this
(r'SUBGROUPING', True),
(r'TAB_SIZE', 4),
(r'TOC_INCLUDE_HEADINGS', 3),
Expand All @@ -142,6 +144,7 @@ def make_temp_file():
(r'USE_HTAGS', False),
(r'USE_MDFILE_AS_MAINPAGE', None),
(r'VERBATIM_HEADERS', False),
(r'WARN_AS_ERROR', False), # we handle this
(r'WARN_IF_DOC_ERROR', True),
(r'WARN_IF_INCOMPLETE_DOC', True),
(r'WARN_LOGFILE', None),
Expand Down Expand Up @@ -213,7 +216,6 @@ def preprocess_doxyfile(context: Context):
df.append(r'# context.warnings', end='\n\n') # ---------------------------------------------------

df.set_value(r'WARNINGS', context.warnings.enabled)
df.set_value(r'WARN_AS_ERROR', False) # we do this ourself
df.set_value(r'WARN_IF_UNDOCUMENTED', context.warnings.undocumented)

df.append()
Expand Down Expand Up @@ -572,10 +574,15 @@ def postprocess_xml(context: Context):
members = [
m for m in section.findall(r'memberdef') if m.get(r'kind') in (r'friend', r'function')
]
attribute_keywords = ((r'constexpr', r'constexpr',
r'yes'), (r'consteval', r'consteval', r'yes'), (r'explicit', r'explicit', r'yes'),
(r'static', r'static', r'yes'), (r'friend', None, None), (r'inline', r'inline',
r'yes'), (r'virtual', r'virt', r'virtual'))
attribute_keywords = (
(r'constexpr', r'constexpr', r'yes'), #
(r'consteval', r'consteval', r'yes'),
(r'explicit', r'explicit', r'yes'),
(r'static', r'static', r'yes'),
(r'friend', None, None),
(r'inline', r'inline', r'yes'),
(r'virtual', r'virt', r'virtual')
)
for member in members:
type = member.find(r'type')
if type is None or type.text is None:
Expand Down Expand Up @@ -864,7 +871,22 @@ def postprocess_xml_v2(context: Context):
log_func = lambda m: context.verbose(m)

g = doxygen.read_graph_from_xml(context.temp_xml_dir, log_func=log_func)
delete_directory(context.temp_xml_dir, logger=log_func)

# delete 'file' nodes for markdown and dox files
g.remove(filter=lambda n: n.type is graph.File and re.search(r'[.](?:md|dox)$', n.local_name, flags=re.I))

# delete empty 'dir' nodes
g.remove(filter=lambda n: n.type is graph.Directory and not len(list(n(graph.File, graph.Directory))))

# todo:
# - extract namespaces, types and enum values for syntax highlighting
# - enumerate all compound pages and their types for later (e.g. HTML post-process)
# - merge user-defined sections with the same name
# - sort user-defined sections based on their name
# - implementation headers

for f in enumerate_files(context.temp_xml_dir, any=r'*.xml'):
delete_file(f, logger=log_func)
doxygen.write_graph_to_xml(g, context.temp_xml_dir, log_func=log_func)


Expand Down
11 changes: 11 additions & 0 deletions poxy/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,17 @@ def download_binary(uri: str, timeout=10) -> bytes:



def tail(s: str, split: str) -> str:
assert s is not None
assert split is not None
assert split
idx = s.rfind(split)
if idx == -1:
return s
return s[idx + len(split):]



#=======================================================================================================================
# REGEX REPLACER
#=======================================================================================================================
Expand Down
8 changes: 6 additions & 2 deletions tests/regenerate_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,12 @@ def regenerate_expected_outputs():

# delete garbage
garbage = (
r'*.xslt', r'*.xsd', r'favicon*', r'search-v2.js', r'Doxyfile*',
*(coerce_collection([r'garbage']) if r'garbage' in config else [])
r'*.xslt',
r'*.xsd',
r'favicon*',
r'search-v2.js',
r'Doxyfile*',
*(coerce_collection([r'garbage']) if r'garbage' in config else []),
)
garbage = (
*(enumerate_files(html_dir, any=garbage) if output_html else []),
Expand Down
150 changes: 140 additions & 10 deletions tests/test_project/expected_html/Test!.tagfile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,27 @@
<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>
Expand Down Expand Up @@ -48,11 +69,32 @@
<type></type>
<name>scoped_enum</name>
<anchorfile>namespacetest.html</anchorfile>
<anchor>a3a2b94881b2cd4942667975879b992b9</anchor>
<anchor>a393facd551443a4aaea74c533c2bce6f</anchor>
<arglist></arglist>
<enumvalue file="namespacetest.html" anchor="a3a2b94881b2cd4942667975879b992b9a209e4404bac5df6700a512df9e988ba3">val_0</enumvalue>
<enumvalue file="namespacetest.html" anchor="a3a2b94881b2cd4942667975879b992b9ad69dff41cc115965adfeaa0f58fed641">val_1</enumvalue>
<enumvalue file="namespacetest.html" anchor="a3a2b94881b2cd4942667975879b992b9a3745be12e7d2d79a55682a6b1ef5863c">val_2</enumvalue>
<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>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="variable">
<type>constexpr bool</type>
Expand All @@ -62,9 +104,34 @@
<arglist></arglist>
</member>
</compound>
<compound kind="file">
<name>code.h</name>
<filename>subfolder_2code_8h.html</filename>
</compound>
<compound kind="class">
<name>test::class_1</name>
<filename>classtest_1_1class__1.html</filename>
<member kind="typedef">
<type>int</type>
<name>public_typedef</name>
<anchorfile>classtest_1_1class__1.html</anchorfile>
<anchor>a52150fb93a5946c0d2fca381f99f426f</anchor>
<arglist></arglist>
</member>
<member kind="function">
<type>bool</type>
<name>public_function</name>
<anchorfile>classtest_1_1class__1.html</anchorfile>
<anchor>a6b372d2af2e8e874869f0ddf50a306fb</anchor>
<arglist>()</arglist>
</member>
<member kind="function" static="yes">
<type>static constexpr struct_1</type>
<name>public_static_function</name>
<anchorfile>classtest_1_1class__1.html</anchorfile>
<anchor>af2caa02646ff203339faf41a0efc4b20</anchor>
<arglist>()</arglist>
</member>
<member kind="variable">
<type>bool</type>
<name>public_variable</name>
Expand All @@ -73,12 +140,33 @@
<arglist></arglist>
</member>
<member kind="variable" static="yes">
<type>static constexpr bool</type>
<type>static constexpr std::byte</type>
<name>public_static_variable</name>
<anchorfile>classtest_1_1class__1.html</anchorfile>
<anchor>a27966148032ee64e169e8e24ad6c7449</anchor>
<anchor>ae05cfedbf34e9f128e87410c09ad3780</anchor>
<arglist></arglist>
</member>
<member kind="typedef" protection="protected">
<type>int</type>
<name>protected_typedef</name>
<anchorfile>classtest_1_1class__1.html</anchorfile>
<anchor>aa57cecf6a75b7d9a7343b06706f3863c</anchor>
<arglist></arglist>
</member>
<member kind="function" protection="protected">
<type>bool</type>
<name>protected_function</name>
<anchorfile>classtest_1_1class__1.html</anchorfile>
<anchor>ab61d354f51a90bb49d38d22e7a7d7f48</anchor>
<arglist>()</arglist>
</member>
<member kind="function" protection="protected" static="yes">
<type>static constexpr bool</type>
<name>protected_static_function</name>
<anchorfile>classtest_1_1class__1.html</anchorfile>
<anchor>ac4b22b5c1e50ba1a06f0319566252bb8</anchor>
<arglist>()</arglist>
</member>
<member kind="variable" protection="protected">
<type>bool</type>
<name>protected_variable</name>
Expand Down Expand Up @@ -142,6 +230,27 @@
<class kind="struct">test::struct_1</class>
<class kind="class">test::template_class_1</class>
<concept>test::concept_1</concept>
<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>
Expand Down Expand Up @@ -171,11 +280,32 @@
<type></type>
<name>scoped_enum</name>
<anchorfile>namespacetest.html</anchorfile>
<anchor>a3a2b94881b2cd4942667975879b992b9</anchor>
<anchor>a393facd551443a4aaea74c533c2bce6f</anchor>
<arglist></arglist>
<enumvalue file="namespacetest.html" anchor="a3a2b94881b2cd4942667975879b992b9a209e4404bac5df6700a512df9e988ba3">val_0</enumvalue>
<enumvalue file="namespacetest.html" anchor="a3a2b94881b2cd4942667975879b992b9ad69dff41cc115965adfeaa0f58fed641">val_1</enumvalue>
<enumvalue file="namespacetest.html" anchor="a3a2b94881b2cd4942667975879b992b9a3745be12e7d2d79a55682a6b1ef5863c">val_2</enumvalue>
<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>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="variable">
<type>constexpr bool</type>
Expand Down
Loading

0 comments on commit 62346bf

Please sign in to comment.