Skip to content
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

[doc] Parse module description as rst. #3008

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 16 additions & 1 deletion sw/tools/modules_doc/modules_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
from docutils import nodes
from lxml import etree as ET
from dataclasses import dataclass
from docutils.frontend import OptionParser
from docutils.utils import new_document


class Define:
Expand Down Expand Up @@ -118,7 +120,8 @@ def parse(self, inputstring: str, document: addnodes.document):
root = self.make_section(m.name)

# description
root.append(nodes.paragraph(text=m.description))
for n in self.parse_rst(m.description):
root.append(n)

if len(m.configures) > 0:
root += self.define_to_table(m.configures, "Configures")
Expand Down Expand Up @@ -151,6 +154,18 @@ def parse(self, inputstring: str, document: addnodes.document):
document.append(root)
self.finish_parse()

def parse_rst(self, text):
parser = RSTParser()
parser.set_application(self.env.app)
settings = OptionParser(
defaults=self.env.settings,
components=(RSTParser,),
read_config_files=True,
).get_default_values()
document = new_document("<rst-doc>", settings=settings)
parser.parse(text, document)
return document.children


def setup(app: "Sphinx") -> Dict[str, Any]:
app.add_source_suffix(".xml", "pprz_module")
Expand Down