From 492cbaccaba097958daaa7adeb2ad62226e02d23 Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Tue, 8 Sep 2015 20:19:02 +0200 Subject: [PATCH] extract rst also from modules hidden in subdirectories; fixes #122 --- doc/extract_rst.py | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/doc/extract_rst.py b/doc/extract_rst.py index 19f4421..2af0750 100644 --- a/doc/extract_rst.py +++ b/doc/extract_rst.py @@ -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] `__' % 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] `__' % full_file_name) output.append(s_out) with open(os.path.join(THIS_DIR, 'module-reference.rst'), 'w') as f: