Skip to content

Commit

Permalink
Merge pull request #4 from lurch/small_tweaks
Browse files Browse the repository at this point in the history
Make output file an explicit argument.
  • Loading branch information
nathan-contino authored Aug 13, 2024
2 parents 70569f2 + 4bf0bc2 commit 278bc08
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 14 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ This project converts doxygen XML output to asciidoc.
Allowed args:

`-f`: the full path to the file to be converted

`-o`: the full path the the output file (will print to STDOUT if not specified)

`-c`: process a node other than `doxygenindex`

The following attributes from the XML will be preserved in the generated asciidoc: role, tag, type.
The following attributes from the XML will be preserved in the generated asciidoc: role, tag, type.
27 changes: 15 additions & 12 deletions cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,31 @@


def main():
"""Convert the given Doxygen index.xml to AsciiDoc and print the result."""
"""Convert the given Doxygen index.xml to AsciiDoc and output the result."""
parser = argparse.ArgumentParser()
parser.add_argument("-f", "--file", help="The path of the file to convert", default=None)
parser.add_argument("-o", "--output", help="The path of the output file", default=None)
parser.add_argument("-c", "--child", help="Is NOT the root index file", default=False, action='store_true')
args = parser.parse_args()
filename = args.file
output_filename = args.output
is_child = args.child
if filename:
xmldir = os.path.dirname(filename)
with open(filename, encoding="utf-8") as xml:
if is_child:
print(
Node(
BeautifulSoup(xml, "xml").doxygen, xmldir=xmldir
).to_asciidoc()
)
result = Node(
BeautifulSoup(xml, "xml").doxygen, xmldir=xmldir
).to_asciidoc()
else:
print(
DoxygenindexNode(
BeautifulSoup(xml, "xml").doxygenindex, xmldir=xmldir
).to_asciidoc()
)

result = DoxygenindexNode(
BeautifulSoup(xml, "xml").doxygenindex, xmldir=xmldir
).to_asciidoc()
if output_filename is not None:
with open(output_filename, "w", encoding="utf-8") as output:
output.write(result)
else:
print(result)

else:
sys.exit(1)
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
PyYAML
beautifulsoup4
beautifulsoup4
lxml

0 comments on commit 278bc08

Please sign in to comment.