-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOzDoc.py
57 lines (47 loc) · 2.19 KB
/
OzDoc.py
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
"""
This script is part of The OzDoc Framework, written for the thesis :
"OzDoc , Development and implementation of a highly automated documentation generator for the Oz programming language"
Authors : ALEXE Simon and FRENYO Péter
Supervisor : VAN ROY Peter
School : Université Catholique de Louvain
Year : 2018-2019
Git : https://github.com/AlexeSimon/OzDoc
Version : 1.0
License: GNU GPL
"""
import os
import errno
from src.OzDocParser import OzDocParser
from src.ArgumentsHandler import parse_args
from src import FileHandler
if __name__ == '__main__':
# Recover program arguments (file, dir, text, out, settings, template, docgen)
args = parse_args()
try:
os.makedirs(args.out)
except FileExistsError:
if not os.access(args.out, os.W_OK):
raise IOError(errno.EIO, "Error writing out folder", args.out)
# Check program mode
settings = FileHandler.import_module("settings", args.settings)
if args.file[0] is not None: # file mode
parser = OzDocParser(context_type="file", description=args.file[0],
priority_context_rules=settings.priority_context_rules,
context_rules=settings.context_rules)
elif args.dir is not None: # directory mode
if args.extension is None:
parser = OzDocParser(context_type="dir", description=args.dir,
priority_context_rules=settings.priority_context_rules,
context_rules=settings.context_rules)
else:
parser = OzDocParser(code=args.extension, context_type="dir", description=args.dir,
priority_context_rules=settings.priority_context_rules,
context_rules=settings.context_rules)
else: # text mode
parser = OzDocParser(code=args.text, context_type="text",
priority_context_rules=settings.priority_context_rules,
context_rules=settings.context_rules)
FileHandler.copy_directory(args.template, args.out)
docgen = FileHandler.import_module("docgen", args.docgen)
docgen.run(parser, settings, args.out)
# Exit successfully