-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdox++html
executable file
·89 lines (78 loc) · 4.44 KB
/
dox++html
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#! /usr/bin/env python3
# dox++
# Copyright 2020, Cris Luengo
#
# 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 os
import shlex
import doxpp
import doxpp.createhtml
import importlib.util
parser = argparse.ArgumentParser(description='dox++, C++ documentation, back-end generator.')
parser.add_argument('config_file', nargs='?', default='dox++config', help='name of the configuration file')
args = parser.parse_args()
# Processing options
config = doxpp.config.read(args.config_file)
doxpp.log.setLevel(doxpp.config.get(config, 'log', 'level'))
spec = importlib.util.spec_from_loader('helper', loader=None) # This section from https://stackoverflow.com/a/60054279/7328782
helper = importlib.util.module_from_spec(spec)
exec(doxpp.config.get(config, 'html', 'modify include statement'), helper.__dict__)
options = {
'show_private_virtual': doxpp.config.get_boolean(config, 'html', 'document private virtual members'),
'show_private_nonvirtual': doxpp.config.get_boolean(config, 'html', 'document private non-virtual members'),
'show_protected': doxpp.config.get_boolean(config, 'html', 'document protected members'),
'show_undocumented': doxpp.config.get_boolean(config, 'html', 'document undocumented members'),
'modify_include_statement': helper.modify_include_statement,
'extra_files': shlex.split(doxpp.config.get(config, 'html', 'extra files'), posix=False),
'templates': doxpp.config.get(config, 'html', 'templates'),
'source_files': shlex.split(doxpp.config.get(config, 'input', 'header files'), posix=False) +
shlex.split(doxpp.config.get(config, 'input', 'markdown files'), posix=False),
'doc_link_class': doxpp.config.get(config, 'html', 'documentation link class'),
'add_snake_case_suffixes': doxpp.config.get_boolean(config, 'search', 'add snake case suffixes'),
'add_camel_case_suffixes': doxpp.config.get_boolean(config, 'search', 'add camel case suffixes'),
'math_cache_file': doxpp.config.get(config, 'math', 'cache file')
}
template_params = {
'PROJECT_NAME': doxpp.config.get(config, 'project', 'name'),
'PROJECT_BRIEF': doxpp.config.get(config, 'project', 'brief'),
'PROJECT_VERSION': doxpp.config.get(config, 'project', 'version'),
'MAIN_PROJECT_URL': doxpp.config.get(config, 'project', 'url'),
'PROJECT_DOWNLOAD_URL': doxpp.config.get(config, 'project', 'download'),
'PROJECT_LOGO': doxpp.config.get(config, 'project', 'logo'),
'THEME_COLOR': doxpp.config.get(config, 'html', 'theme color'),
'FAVICON': doxpp.config.get(config, 'html', 'favicon'),
'STYLESHEETS': shlex.split(doxpp.config.get(config, 'html', 'stylesheets'), posix=False),
'HTML_HEADER': doxpp.config.get(config, 'html', 'html header'),
'PAGE_HEADER': doxpp.config.get(config, 'html', 'page header'),
'FINE_PRINT': doxpp.config.get(config, 'html', 'fine print'),
'LINKS_NAVBAR1': eval(doxpp.config.get(config, 'html', 'navigation bar 1')),
'LINKS_NAVBAR2': eval(doxpp.config.get(config, 'html', 'navigation bar 2')),
'FILE_INDEX_EXPAND_LEVELS': doxpp.config.get_int(config, 'html', 'file index expand levels'),
'CLASS_INDEX_EXPAND_LEVELS': doxpp.config.get_int(config, 'html', 'class index expand levels'),
'CLASS_INDEX_EXPAND_INNER': doxpp.config.get_boolean(config, 'html', 'class index expand inner'),
'SEARCH_DISABLED': not doxpp.config.get_boolean(config, 'search', 'enable'),
'SEARCH_DOWNLOAD_BINARY': doxpp.config.get_boolean(config, 'search', 'download binary'),
'SEARCH_BASE_URL': doxpp.config.get(config, 'search', 'base URL'),
'SEARCH_EXTERNAL_URL': doxpp.config.get(config, 'search', 'external URL')
}
outdir = doxpp.config.get(config, 'html', 'output directory')
os.makedirs(outdir, exist_ok=True)
# Generate HTML
data = doxpp.createhtml.createhtml(
doxpp.config.get(config, 'json', 'filename'),
outdir,
options,
template_params
)