Skip to content

Commit 278bc08

Browse files
Merge pull request #4 from lurch/small_tweaks
Make output file an explicit argument.
2 parents 70569f2 + 4bf0bc2 commit 278bc08

File tree

3 files changed

+21
-14
lines changed

3 files changed

+21
-14
lines changed

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ This project converts doxygen XML output to asciidoc.
55
Allowed args:
66

77
`-f`: the full path to the file to be converted
8+
9+
`-o`: the full path the the output file (will print to STDOUT if not specified)
10+
811
`-c`: process a node other than `doxygenindex`
912

10-
The following attributes from the XML will be preserved in the generated asciidoc: role, tag, type.
13+
The following attributes from the XML will be preserved in the generated asciidoc: role, tag, type.

cli.py

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,28 +8,31 @@
88

99

1010
def main():
11-
"""Convert the given Doxygen index.xml to AsciiDoc and print the result."""
11+
"""Convert the given Doxygen index.xml to AsciiDoc and output the result."""
1212
parser = argparse.ArgumentParser()
1313
parser.add_argument("-f", "--file", help="The path of the file to convert", default=None)
14+
parser.add_argument("-o", "--output", help="The path of the output file", default=None)
1415
parser.add_argument("-c", "--child", help="Is NOT the root index file", default=False, action='store_true')
1516
args = parser.parse_args()
1617
filename = args.file
18+
output_filename = args.output
1719
is_child = args.child
1820
if filename:
1921
xmldir = os.path.dirname(filename)
2022
with open(filename, encoding="utf-8") as xml:
2123
if is_child:
22-
print(
23-
Node(
24-
BeautifulSoup(xml, "xml").doxygen, xmldir=xmldir
25-
).to_asciidoc()
26-
)
24+
result = Node(
25+
BeautifulSoup(xml, "xml").doxygen, xmldir=xmldir
26+
).to_asciidoc()
2727
else:
28-
print(
29-
DoxygenindexNode(
30-
BeautifulSoup(xml, "xml").doxygenindex, xmldir=xmldir
31-
).to_asciidoc()
32-
)
33-
28+
result = DoxygenindexNode(
29+
BeautifulSoup(xml, "xml").doxygenindex, xmldir=xmldir
30+
).to_asciidoc()
31+
if output_filename is not None:
32+
with open(output_filename, "w", encoding="utf-8") as output:
33+
output.write(result)
34+
else:
35+
print(result)
36+
3437
else:
3538
sys.exit(1)

requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
PyYAML
2-
beautifulsoup4
2+
beautifulsoup4
3+
lxml

0 commit comments

Comments
 (0)