extract rst also from modules hidden in subdirectories; fixes #122
This commit is contained in:
parent
d5e429222d
commit
492cbaccab
@ -1,4 +1,3 @@
|
||||
import glob
|
||||
import os
|
||||
import ntpath
|
||||
|
||||
@ -54,18 +53,25 @@ def main():
|
||||
output.append("================")
|
||||
output.append("\n")
|
||||
|
||||
files = glob.glob('%s/*.cmake' % os.path.join(THIS_DIR, '..', 'modules'))
|
||||
module_path = os.path.join(THIS_DIR, '..', 'modules')
|
||||
|
||||
for f in sorted(files):
|
||||
modules = []
|
||||
for root, dirs, files in os.walk(module_path):
|
||||
relative_path = os.path.relpath(root, module_path)
|
||||
for f in files:
|
||||
modules.append((os.path.join(root, f), relative_path))
|
||||
modules = sorted(set(modules))
|
||||
|
||||
for f, relative_path in modules:
|
||||
file_name = ntpath.basename(f)
|
||||
output.append('\n\n%s' % file_name)
|
||||
output.append('-'*len(file_name))
|
||||
output.append('`[Source code] <https://github.com/scisoft/autocmake/blob/master/modules/%s>`__' % file_name)
|
||||
if relative_path != '.':
|
||||
full_file_name = '%s/%s' % (relative_path, file_name)
|
||||
with open(f, 'r') as s:
|
||||
s_out = extract_rst_blobs(s.read())
|
||||
if s_out == '':
|
||||
output.append('\nNo documentation\n')
|
||||
else:
|
||||
if s_out != '':
|
||||
output.append('\n\n%s' % file_name)
|
||||
output.append('-'*len(file_name))
|
||||
output.append('`[Source code] <https://github.com/scisoft/autocmake/blob/master/modules/%s>`__' % full_file_name)
|
||||
output.append(s_out)
|
||||
|
||||
with open(os.path.join(THIS_DIR, 'module-reference.rst'), 'w') as f:
|
||||
|
Loading…
x
Reference in New Issue
Block a user