-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdox++parse
executable file
·63 lines (53 loc) · 2.19 KB
/
dox++parse
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
#! /usr/bin/env python3
# dox++
# Copyright 2020, Cris Luengo
# Based on cldoc: Copyright 2013-2018, Jesse van den Kieboom
#
# This file is part of dox++. dox++ is free software: you can
# redistribute it and/or modify it under the terms of the GNU General Public
# License as published by the Free Software Foundation, version 2.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, write to the Free Software Foundation, Inc., 51
# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
import argparse
import json
import doxpp
import doxpp.buildtree
parser = argparse.ArgumentParser(description='dox++, C++ documentation, front-end parser.')
parser.add_argument('-g', action='store_true', help='generate a default configuration file')
parser.add_argument('config_file', nargs='?', default='dox++config', help='name of the configuration file')
args = parser.parse_args()
# Generate configuration file if requested, then quit
if args.g:
doxpp.config.generate(args.config_file)
exit(0)
# Processing options
config = doxpp.config.read(args.config_file)
doxpp.log.setLevel(doxpp.config.get(config, 'log', 'level'))
options = {
'code_formatting': doxpp.config.get(config, 'json', 'use typewriter font'),
'tab_size': doxpp.config.get_int(config, 'input', 'tab size')
}
# Process files
data = doxpp.buildtree.buildtree(
doxpp.config.get(config, 'input', 'root directory'),
doxpp.config.get(config, 'input', 'header files'),
doxpp.config.get(config, 'input', 'markdown files'),
doxpp.config.get(config, 'clang', 'compiler flags'),
doxpp.config.get(config, 'clang', 'include directories'),
options
)
# Write JSON file
filename = doxpp.config.get(config, 'json', 'filename')
if doxpp.config.get(config, 'json', 'formatting') == 'readable':
format = {'indent': 2}
else:
format = {'separators': (',', ':')}
with open(filename, 'w') as output_file:
output_file.write(json.dumps(data, **format))