Add reStructuredText generator to gdbus-codegen

The gdbus-codegen tool generates documentation from the XML introspection
description of a D-Bus interface. Currently, only DocBook is supported at
the moment, but not every modern documentation generator can handle that
format. The reStructuredText format is a bit more well-supported,
especially in documentation generators for non-C languages.

Unlike DocBook, we get to make our own structure and conventions for how
we structure the documentation when using reStructuredText.
This commit is contained in:
Emmanuele Bassi
2022-01-19 13:55:29 +00:00
parent 5013d08315
commit 66e4ba806a
3 changed files with 348 additions and 2 deletions

View File

@@ -30,6 +30,7 @@ from . import dbustypes
from . import parser
from . import codegen
from . import codegen_docbook
from . import codegen_rst
from .utils import print_error, print_warning
@@ -211,6 +212,11 @@ def codegen_main():
metavar="OUTFILES",
help="Generate Docbook in OUTFILES-org.Project.IFace.xml",
)
arg_parser.add_argument(
"--generate-rst",
metavar="OUTFILES",
help="Generate reStructuredText in OUTFILES-org.Project.IFace.rst",
)
arg_parser.add_argument(
"--pragma-once",
action="store_true",
@@ -287,10 +293,12 @@ def codegen_main():
)
if (
args.generate_c_code is not None or args.generate_docbook is not None
args.generate_c_code is not None
or args.generate_docbook is not None
or args.generate_rst is not None
) and args.output is not None:
print_error(
"Using --generate-c-code or --generate-docbook and "
"Using --generate-c-code or --generate-docbook or --generate-rst and "
"--output at the same time is not allowed"
)
@@ -420,6 +428,11 @@ def codegen_main():
if docbook:
docbook_gen.generate(docbook, args.output_directory)
rst = args.generate_rst
rst_gen = codegen_rst.RstCodeGenerator(all_ifaces)
if rst:
rst_gen.generate(rst, args.output_directory)
if args.header:
with open(h_file, "w") as outfile:
gen = codegen.HeaderCodeGenerator(