-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathsummary-ex.py
More file actions
31 lines (23 loc) · 837 Bytes
/
summary-ex.py
File metadata and controls
31 lines (23 loc) · 837 Bytes
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
"""
Generates a README.md file for the examples folder.
"""
import glob
import importlib
import sys
examples = [file for file in glob.glob("./examples/*.py")]
examples.sort()
sys.path.append("./examples")
with open("./examples/README.md", mode="wt", encoding="utf8 ") as examples_readme:
examples_readme.write(
"<!-- generated file, to update use: python examples-summary.py -->\n\n"
)
examples_readme.write("""# Examples""")
for file_path in examples:
if "__init__" in file_path:
continue
module_name = file_path.replace("./examples/", "").replace(".py", "")
module = importlib.import_module(module_name)
if not module.__doc__:
continue
examples_readme.write(f"\n\n## {module_name}.py\n")
examples_readme.write(str(module.__doc__))