|
8 | 8 |
|
9 | 9 |
|
10 | 10 | 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.""" |
12 | 12 | parser = argparse.ArgumentParser()
|
13 | 13 | 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) |
14 | 15 | parser.add_argument("-c", "--child", help="Is NOT the root index file", default=False, action='store_true')
|
15 | 16 | args = parser.parse_args()
|
16 | 17 | filename = args.file
|
| 18 | + output_filename = args.output |
17 | 19 | is_child = args.child
|
18 | 20 | if filename:
|
19 | 21 | xmldir = os.path.dirname(filename)
|
20 | 22 | with open(filename, encoding="utf-8") as xml:
|
21 | 23 | 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() |
27 | 27 | 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 | + |
34 | 37 | else:
|
35 | 38 | sys.exit(1)
|
0 commit comments