Add tools to automatically extract documentation
This commit is contained in:
parent
a35d462cb7
commit
a37b661c1f
29
tools/extract_doc.py
Executable file
29
tools/extract_doc.py
Executable file
|
@ -0,0 +1,29 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import sys
|
||||
|
||||
filename = sys.argv[1]
|
||||
|
||||
if filename.endswith('__init__.py'):
|
||||
sys.exit(0)
|
||||
|
||||
package_name = filename.replace('/', '.').replace('.py', '')
|
||||
sys.stdout.write('**%s**' % (package_name))
|
||||
sys.stdout.write('\n\n')
|
||||
# sys.stdout.write('-' * len(package_name))
|
||||
# sys.stdout.write('\n\n')
|
||||
|
||||
sys.stderr.write('\tExtract doc from %s\n' % (filename))
|
||||
|
||||
with open(filename) as infile:
|
||||
copy = False
|
||||
for line in infile:
|
||||
if line.strip() in ['"""', "'''"]:
|
||||
if not copy:
|
||||
copy = True
|
||||
else:
|
||||
break
|
||||
elif copy:
|
||||
sys.stdout.write(line)
|
||||
|
||||
sys.stdout.write('\n\n')
|
16
tools/extract_docs.sh
Executable file
16
tools/extract_docs.sh
Executable file
|
@ -0,0 +1,16 @@
|
|||
#!/bin/sh
|
||||
|
||||
MODULES_TARGET="docs/modules.md"
|
||||
MAIN_MD="docs/main.md"
|
||||
TARGET_MD="docs/index.md"
|
||||
|
||||
rm -f "${MODULES_TARGET}"
|
||||
|
||||
echo "Generate doc from iwla.py"
|
||||
python tools/extract_doc.py iwla.py > "${MODULES_TARGET}"
|
||||
|
||||
echo "Generate plugins documentation"
|
||||
find plugins -name '*.py' -exec python tools/extract_doc.py \{\} \; >> "${MODULES_TARGET}"
|
||||
|
||||
echo "Generate ${TARGET_MD}"
|
||||
cat "${MAIN_MD}" "${MODULES_TARGET}" > "${TARGET_MD}"
|
Loading…
Reference in New Issue
Block a user