openscad-docsgen 2.0.42__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- openscad_docsgen/__init__.py +159 -0
- openscad_docsgen/blocks.py +953 -0
- openscad_docsgen/errorlog.py +46 -0
- openscad_docsgen/filehashes.py +72 -0
- openscad_docsgen/imagemanager.py +282 -0
- openscad_docsgen/mdimggen.py +192 -0
- openscad_docsgen/parser.py +958 -0
- openscad_docsgen/target.py +14 -0
- openscad_docsgen/target_githubwiki.py +45 -0
- openscad_docsgen/target_wiki.py +221 -0
- openscad_docsgen/utils.py +19 -0
- openscad_docsgen-2.0.42.dist-info/LICENSE +21 -0
- openscad_docsgen-2.0.42.dist-info/METADATA +240 -0
- openscad_docsgen-2.0.42.dist-info/RECORD +17 -0
- openscad_docsgen-2.0.42.dist-info/WHEEL +5 -0
- openscad_docsgen-2.0.42.dist-info/entry_points.txt +3 -0
- openscad_docsgen-2.0.42.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
from __future__ import print_function
|
|
4
|
+
|
|
5
|
+
import os
|
|
6
|
+
import sys
|
|
7
|
+
import glob
|
|
8
|
+
import os.path
|
|
9
|
+
import argparse
|
|
10
|
+
import platform
|
|
11
|
+
|
|
12
|
+
from .errorlog import ErrorLog, errorlog
|
|
13
|
+
from .parser import DocsGenParser, DocsGenException
|
|
14
|
+
from .target import default_target, target_classes
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class Options(object):
|
|
18
|
+
def __init__(self, args):
|
|
19
|
+
self.files = args.srcfiles
|
|
20
|
+
self.target_profile = args.target_profile
|
|
21
|
+
self.project_name = args.project_name
|
|
22
|
+
self.docs_dir = args.docs_dir.rstrip("/")
|
|
23
|
+
self.quiet = args.quiet
|
|
24
|
+
self.force = args.force
|
|
25
|
+
self.strict = args.strict
|
|
26
|
+
self.test_only = args.test_only
|
|
27
|
+
self.gen_imgs = not args.no_images
|
|
28
|
+
self.gen_files = args.gen_files
|
|
29
|
+
self.gen_toc = args.gen_toc
|
|
30
|
+
self.gen_index = args.gen_index
|
|
31
|
+
self.gen_topics = args.gen_topics
|
|
32
|
+
self.gen_cheat = args.gen_cheat
|
|
33
|
+
self.gen_sidebar = args.gen_sidebar
|
|
34
|
+
self.report = args.report
|
|
35
|
+
self.dump_tree = args.dump_tree
|
|
36
|
+
self.png_animation = args.png_animation
|
|
37
|
+
self.update_target()
|
|
38
|
+
|
|
39
|
+
def set_target(self, targ):
|
|
40
|
+
if targ not in target_classes:
|
|
41
|
+
return False
|
|
42
|
+
self.target_profile = targ
|
|
43
|
+
return True
|
|
44
|
+
|
|
45
|
+
def update_target(self):
|
|
46
|
+
self.target = target_classes[self.target_profile](
|
|
47
|
+
project_name=self.project_name,
|
|
48
|
+
docs_dir=self.docs_dir
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
def processFiles(opts):
|
|
52
|
+
docsgen = DocsGenParser(opts)
|
|
53
|
+
# DocsGenParser may change opts settings, based on the _rc file.
|
|
54
|
+
|
|
55
|
+
if not opts.files:
|
|
56
|
+
opts.files = glob.glob("*.scad")
|
|
57
|
+
elif platform.system() == 'Windows':
|
|
58
|
+
opts.files = [file for src_file in opts.files for file in glob.glob(src_file)]
|
|
59
|
+
|
|
60
|
+
fail = False
|
|
61
|
+
for infile in opts.files:
|
|
62
|
+
if not os.path.exists(infile):
|
|
63
|
+
print("{} does not exist.".format(infile))
|
|
64
|
+
fail = True
|
|
65
|
+
elif not os.path.isfile(infile):
|
|
66
|
+
print("{} is not a file.".format(infile))
|
|
67
|
+
fail = True
|
|
68
|
+
elif not os.access(infile, os.R_OK):
|
|
69
|
+
print("{} is not readable.".format(infile))
|
|
70
|
+
fail = True
|
|
71
|
+
if fail:
|
|
72
|
+
sys.exit(-1)
|
|
73
|
+
|
|
74
|
+
docsgen.parse_files(opts.files, False)
|
|
75
|
+
|
|
76
|
+
if opts.dump_tree:
|
|
77
|
+
docsgen.dump_full_tree()
|
|
78
|
+
|
|
79
|
+
if opts.gen_files or opts.test_only:
|
|
80
|
+
docsgen.write_docs_files()
|
|
81
|
+
if opts.gen_toc:
|
|
82
|
+
docsgen.write_toc_file()
|
|
83
|
+
if opts.gen_index:
|
|
84
|
+
docsgen.write_index_file()
|
|
85
|
+
if opts.gen_topics:
|
|
86
|
+
docsgen.write_topics_file()
|
|
87
|
+
if opts.gen_cheat:
|
|
88
|
+
docsgen.write_cheatsheet_file()
|
|
89
|
+
if opts.gen_sidebar:
|
|
90
|
+
docsgen.write_sidebar_file()
|
|
91
|
+
|
|
92
|
+
if opts.report:
|
|
93
|
+
errorlog.write_report()
|
|
94
|
+
if errorlog.has_errors:
|
|
95
|
+
print("WARNING: Errors encountered.", file=sys.stderr)
|
|
96
|
+
sys.exit(-1)
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
def main():
|
|
100
|
+
target_profiles = ["githubwiki", "stdwiki"]
|
|
101
|
+
|
|
102
|
+
parser = argparse.ArgumentParser(prog='openscad-docsgen')
|
|
103
|
+
parser.add_argument('-D', '--docs-dir', default="docs",
|
|
104
|
+
help='The directory to put generated documentation in.')
|
|
105
|
+
parser.add_argument('-T', '--test-only', action="store_true",
|
|
106
|
+
help="If given, don't generate images, but do try executing the scripts.")
|
|
107
|
+
parser.add_argument('-q', '--quiet', action="store_true",
|
|
108
|
+
help="Suppress printing of progress data.")
|
|
109
|
+
parser.add_argument('-S', '--strict', action="store_true",
|
|
110
|
+
help="If given, require File/LibFile and Section headers.")
|
|
111
|
+
parser.add_argument('-f', '--force', action="store_true",
|
|
112
|
+
help='If given, force regeneration of images.')
|
|
113
|
+
parser.add_argument('-n', '--no-images', action="store_true",
|
|
114
|
+
help='If given, skips image generation.')
|
|
115
|
+
parser.add_argument('-m', '--gen-files', action="store_true",
|
|
116
|
+
help='If given, generate documents for each source file.')
|
|
117
|
+
parser.add_argument('-i', '--gen-index', action="store_true",
|
|
118
|
+
help='If given, generate AlphaIndex.md file.')
|
|
119
|
+
parser.add_argument('-I', '--gen-topics', action="store_true",
|
|
120
|
+
help='If given, generate Topics.md topics index file.')
|
|
121
|
+
parser.add_argument('-t', '--gen-toc', action="store_true",
|
|
122
|
+
help='If given, generate TOC.md table of contents file.')
|
|
123
|
+
parser.add_argument('-c', '--gen-cheat', action="store_true",
|
|
124
|
+
help='If given, generate CheatSheet.md file with all Usage lines.')
|
|
125
|
+
parser.add_argument('-s', '--gen_sidebar', action="store_true",
|
|
126
|
+
help="If given, generate _Sidebar.md file index.")
|
|
127
|
+
parser.add_argument('-a', '--png-animation', action="store_true",
|
|
128
|
+
help='If given, animations are created using animated PNGs instead of GIFs.')
|
|
129
|
+
parser.add_argument('-P', '--project-name',
|
|
130
|
+
help='If given, sets the name of the project to be shown in titles.')
|
|
131
|
+
parser.add_argument('-r', '--report', action="store_true",
|
|
132
|
+
help='If given, write all warnings and errors to docsgen_report.json')
|
|
133
|
+
parser.add_argument('-d', '--dump-tree', action="store_true",
|
|
134
|
+
help='If given, dumps the documentation tree for debugging.')
|
|
135
|
+
parser.add_argument('-p', '--target-profile', choices=target_classes.keys(), default=default_target,
|
|
136
|
+
help='Sets the output target profile. Defaults to "{}"'.format(default_target))
|
|
137
|
+
parser.add_argument('srcfiles', nargs='*', help='List of input source files.')
|
|
138
|
+
opts = Options(parser.parse_args())
|
|
139
|
+
|
|
140
|
+
try:
|
|
141
|
+
processFiles(opts)
|
|
142
|
+
except DocsGenException as e:
|
|
143
|
+
print(e)
|
|
144
|
+
sys.exit(-1)
|
|
145
|
+
except OSError as e:
|
|
146
|
+
print(e)
|
|
147
|
+
sys.exit(-1)
|
|
148
|
+
except KeyboardInterrupt as e:
|
|
149
|
+
print(" Aborting.", file=sys.stderr)
|
|
150
|
+
sys.exit(-1)
|
|
151
|
+
|
|
152
|
+
sys.exit(0)
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
if __name__ == "__main__":
|
|
156
|
+
main()
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
# vim: expandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap
|