-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
executable file
·66 lines (46 loc) · 1.63 KB
/
Copy pathmain.py
File metadata and controls
executable file
·66 lines (46 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/env python3
# -*- encoding: utf-8 -*-
import argparse
import logging
import os
from doxy2cppref.cppobjects import CppClass
from doxy2cppref.doxyxml import DoxyIndex
from doxy2cppref.output import output
logger = logging.getLogger("doxy2cppref")
class MyError(Exception):
pass
def render_class(class_details: CppClass, outdir: str):
filename = os.path.join(outdir, class_details.short_name)
logging.info("Generating class file {}".format(filename))
output(class_details, "class", filename)
def main():
# -- setup
parser = argparse.ArgumentParser(description='Process data storage definition files.')
parser.add_argument('-d', '--debug', action='store_true', help='activate more output')
parser.add_argument('indexfile', type=str, help="Doxygen index.xml")
parser.add_argument('outdir', type=str, help="output directory")
args = parser.parse_args()
if args.debug:
level = logging.DEBUG
else:
level = logging.INFO
logging.basicConfig(level=level, format="%(message)s")
indexfile = args.indexfile
if not os.path.isfile(indexfile):
raise MyError("Could not find index file {}!".format(indexfile))
outdir = args.outdir
if os.path.isdir(outdir):
logger.warn("Will re-generate {} directory now".format(outdir))
if not os.path.isdir(outdir):
logger.info("Creating {}".format(outdir))
os.makedirs(outdir)
# -- operation
index = DoxyIndex(indexfile)
for cls in index.classes():
render_class(cls, outdir)
try:
main()
except MyError as ex:
logger.error(ex)
except Exception as ex:
logging.exception(ex)