-
Notifications
You must be signed in to change notification settings - Fork 11
/
gen_doc.sh
executable file
·47 lines (42 loc) · 1.4 KB
/
gen_doc.sh
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
#!/bin/bash
[ -f gen_doc.sh ] || {
echo "Not in top directory" ; exit 1
}
pip install -U mkdocs mkdocs-material mkdocstrings[python]
pip install -U mkdocs-include-markdown-plugin
[ -d doc ] && rm -fr doc
cp -f odfdo.png doc_src/src
cp -f README.md doc_src/src
cp -f CHANGES.md doc_src/src
cd doc_src
rm -fr site
python << END
import os
from importlib import import_module
from pathlib import Path
file = Path('src/recipes.md').open('w', encoding='utf8')
file.write("# Recipes\n\n")
file.write("Recipes source code is in the \`/recipes\` directory of \`odfdo\` sources.\n")
file.write("Most recipes are autonomous scripts doing actual modifications of ODF sample files, you can check the results in the \`recipes/recipes_output\` directory.\n\n")
os.chdir('../recipes')
mods = {}
for path in Path('.').glob('*.py'):
mod = import_module(str(path.stem))
seq = getattr(mod, "_DOC_SEQUENCE", 1000 + len(mods))
while seq in mods:
seq += 1
mods[seq] = (mod, path)
for key in sorted(mods.keys()):
print('recipe:', path.stem)
mod, path = mods[key]
file.write(f'### {path.stem.replace("_", " ").capitalize()}\n\n')
file.write(f'{mod.__doc__}\n\n')
file.write(f'??? code "recipes/{path.name}"\n')
file.write(" \`\`\`python\n")
file.write(f' {{% include "../../recipes/{path.name}" %}}\n')
file.write(" \`\`\`\n\n")
file.close()
END
mkdocs build
mv site ../doc
rm -fr site