-
Notifications
You must be signed in to change notification settings - Fork 15
API docs fixes #431
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
API docs fixes #431
Changes from all commits
d3e8b91
5bbd519
ed489fd
8af7b4e
953b259
d9d6a8a
dc6ceb7
fafe906
c1f164a
cbb3aa8
9640441
8890702
2c7b989
ca9f1e9
9cff95d
466cb49
239ebd7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,6 +3,7 @@ | |
| import re | ||
| import sys | ||
| import warnings | ||
| import xml.etree.ElementTree as ET | ||
| from datetime import date | ||
|
|
||
| from sphinx_scylladb_theme.utils import multiversion_regex_builder | ||
|
|
@@ -112,7 +113,7 @@ | |
| def _generate_structs(outdir, structs, project): | ||
| """Write structs docs in the designated outdir folder""" | ||
| for obj in structs: | ||
| with open(outdir + "/struct." + obj + ".rst", "w") as t_file: | ||
| with open(outdir / f"struct.{obj}.rst", "w") as t_file: | ||
| t_file.write( | ||
| obj | ||
| + "\n" | ||
|
|
@@ -125,25 +126,58 @@ def _generate_structs(outdir, structs, project): | |
| ) | ||
|
|
||
|
|
||
| def _generate_groups(outdir, groups, project): | ||
| """Write structs docs in the designated outdir folder""" | ||
| for obj in groups: | ||
| with open(outdir / f"group.{obj}.rst", "w") as t_file: | ||
| t_file.write( | ||
| obj | ||
| + "\n" | ||
| + "=" * len(obj) | ||
| + "\n\n" | ||
| + ".. doxygengroup:: " | ||
| + obj | ||
| + "\n :project: " | ||
| + breathe_default_project | ||
| + "\n :content-only:" | ||
| ) | ||
|
Comment on lines
+129
to
+143
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ❓ How did you know how to do that?
Please explain this in a comment.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. AI. I ofc read the code to see if it looks reasonable + tested that it works. |
||
|
|
||
|
|
||
| def _generate_doxygen_rst(xmldir, outdir): | ||
| """Autogenerate doxygen docs in the designated outdir folder""" | ||
| structs = [] | ||
| files = os.listdir(os.path.join(os.path.dirname(__file__), xmldir)) | ||
| groups = [] | ||
| group_structs = set() | ||
| xml_path = os.path.join(os.path.dirname(__file__), xmldir) | ||
| files = os.listdir(xml_path) | ||
| for file_name in files: | ||
| if file_name.startswith("group__") and file_name.endswith(".xml"): | ||
| tree = ET.parse(os.path.join(xml_path, file_name)) | ||
| root = tree.getroot() | ||
| compoundname = root.find(".//compoundname") | ||
| if compoundname is not None and compoundname.text: | ||
| group_name = compoundname.text | ||
| groups.append(group_name) | ||
| for inner in root.iter("innerclass"): | ||
| group_structs.add(inner.text) | ||
| for file_name in files: | ||
| if "struct" in file_name and "__" not in file_name: | ||
| structs.append( | ||
| name = ( | ||
| file_name.replace("struct_", "") | ||
| .replace("_", " ") | ||
| .replace(".xml", "") | ||
| .title() | ||
| .replace(" ", "") | ||
| ) | ||
| if name not in group_structs: | ||
| structs.append(name) | ||
| _generate_structs(outdir, structs, breathe_default_project) | ||
| _generate_groups(outdir, groups, breathe_default_project) | ||
|
|
||
|
|
||
| def generate_doxygen(app): | ||
| DOXYGEN_XML_DIR = breathe_projects[breathe_default_project] | ||
| _generate_doxygen_rst(DOXYGEN_XML_DIR, app.builder.srcdir + "/api") | ||
| _generate_doxygen_rst(DOXYGEN_XML_DIR, app.builder.srcdir / "api") | ||
|
|
||
|
|
||
| # -- Options for sitemap extension | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.