/
gen_doc.py
60 lines (52 loc) · 1.62 KB
/
gen_doc.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
""" generates a list with the examples """
from __future__ import absolute_import
from __future__ import print_function
import os
import sys
import re
sys.path.insert(1, os.path.abspath("../examples"))
# order the examples sensibly:
ordered_examples = [
"example_mineral.py",
"example_gibbs_modifiers.py",
"example_solid_solution.py",
"example_composite.py",
"example_geotherms.py",
"example_composition.py",
"example_fit_composition.py",
"example_beginner.py",
"example_seismic.py",
"example_anisotropy.py",
"example_anisotropic_mineral.py",
"example_spintransition.py",
"example_spintransition_thermal.py",
"example_user_input_material.py",
"example_averaging.py",
"example_woutput.py",
"example_compare_all_methods.py",
"example_optimize_pv.py",
"example_fit_data.py",
"example_fit_eos.py",
"example_grid.py",
"example_chemical_potentials.py",
"example_perplex.py",
"example_polytopetools.py",
"example_equilibrate.py",
"example_olivine_binary.py",
"example_geodynamic_adiabat.py",
"example_layer.py",
"example_build_planet.py",
]
for ex in ordered_examples:
# print "*",ex
print(__import__(ex.replace(".py", "")).__doc__)
# check we do not forget an example
all = os.listdir("../examples/")
examples = list(filter(lambda k: re.match("^example(.*)\.py$", k), all))
not_listed = list(filter(lambda x: (x not in ordered_examples), examples))
sys.stderr.write(
"The following examples are not included "
"in the automatically generated documentation:\n"
)
for example in not_listed:
sys.stderr.write(f" {example}\n")