-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathgenerate.py
125 lines (94 loc) · 4.02 KB
/
generate.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
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
import neuromllite
if __name__ == "__main__":
net = neuromllite.Network(id="net")
doc = net.generate_documentation(format="markdown")
print(doc)
comment = "**Note: the NeuroMLlite specification is still in development! Subject to change...**"
with open("README.md", "w") as d:
d.write("# Specification of NeuroMLlite v%s\n" % neuromllite.__version__)
d.write("%s\n\n" % comment)
d.write(doc)
import json
import yaml
doc = net.generate_documentation(format="dict")
doc = {"version": "NeuroMLlite v%s" % neuromllite.__version__, "specification": doc}
with open("NeuroMLlite_specification.json", "w") as d:
d.write(json.dumps(doc, indent=4))
with open("NeuroMLlite_specification.yaml", "w") as d:
d.write(yaml.dump(doc, indent=4, sort_keys=False))
'''
mod = Model(id="Simple")
doc = mod.generate_documentation(format="markdown")
comment = "**Note: the ModECI MDF specification is still in development! Subject to change without (much) notice.** See [here](https://github.com/ModECI/MDF/issues?q=is%3Aissue+is%3Aopen+label%3Aspecification) for ongoing discussions."
comment_rst = "**Note: the ModECI MDF specification is still in development! Subject to change without (much) notice.** See `here <https://github.com/ModECI/MDF/issues?q=is%3Aissue+is%3Aopen+label%3Aspecification>`_ for ongoing discussions."
with open("README.md", "w") as d:
d.write("# Specification of ModECI v%s\n" % MODECI_MDF_VERSION)
d.write("%s\n" % comment)
d.write(doc)
"""
with open("sphinx/source/api/Specification.md", "w") as d:
d.write("# Specification of ModECI v%s\n" % MODECI_MDF_VERSION)
d.write("%s\n" % comment)
d.write(doc)"""
doc = mod.generate_documentation(format="rst")
with open("sphinx/source/api/Specification.rst", "w") as d:
ver = "Specification of ModECI v%s RST" % MODECI_MDF_VERSION
d.write("%s\n" % ("=" * len(ver)))
d.write("%s\n" % ver)
d.write("%s\n\n" % ("=" * len(ver)))
d.write("%s\n\n" % comment_rst)
d.write(doc)
doc = mod.generate_documentation(format="dict")
doc = {
"version": "ModECI MDF v%s" % MODECI_MDF_VERSION,
"comment": comment,
"specification": doc,
}
with open("MDF_specification.json", "w") as d:
d.write(json.dumps(doc, indent=4))
with open("MDF_specification.yaml", "w") as d:
d.write(yaml.dump(doc, indent=4, sort_keys=False))
print("Written main documentation")
# Generate standard function generate_documentation
from modeci_mdf.functions.standard import mdf_functions, create_python_expression
mdf_dumpable = {
name: {
k: v
for k, v in mdf_functions[name].items()
if not isinstance(v, types.FunctionType)
}
for name in mdf_functions
}
with open("MDF_function_specifications.json", "w") as d:
d.write(json.dumps(mdf_dumpable, indent=4))
with open("MDF_function_specifications.yaml", "w") as d:
d.write(yaml.dump(mdf_dumpable, indent=4, sort_keys=False))
func_doc = ""
with open("sphinx/source/api/MDF_function_specifications.md", "w") as d:
d.write(
"# Specification of standard functions in ModECI v%s\n" % MODECI_MDF_VERSION
)
d.write("%s\n" % comment)
d.write(
"These functions are defined in https://github.com/ModECI/MDF/blob/main/src/modeci_mdf/standard_functions.py\n"
)
d.write("## All functions:\n | ")
all_f = sorted(mdf_functions.keys())
for f in all_f:
c = ":"
n = ""
d.write(f'<a href="#{f.lower().replace(c,n)}">{f}</a> | ')
for f in mdf_functions:
d.write("\n## %s\n " % f)
func = mdf_functions[f]
d.write("<p><i>%s</i></p> \n" % (func["description"]))
# d.write('<p>Arguments: %s</p> \n'%(func['arguments']))
d.write(
"<p><b>%s(%s)</b> = %s</p> \n"
% (f, ", ".join([a for a in func["arguments"]]), func["expression_string"])
)
d.write(
"<p>Python version: %s</p> \n"
% (create_python_expression(func["expression_string"]))
)
print("Written documentation")'''