[glibmm] docextract_to_xml.py: Add support for the --no-recursion option
- From: Kjell Ahlstedt <kjellahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glibmm] docextract_to_xml.py: Add support for the --no-recursion option
- Date: Tue, 2 Jun 2015 16:54:39 +0000 (UTC)
commit 920cf7938bc98bcf9ef5e0dc446117b881fc6655
Author: Kjell Ahlstedt <kjell ahlstedt bredband net>
Date: Tue Jun 2 18:48:05 2015 +0200
docextract_to_xml.py: Add support for the --no-recursion option
* tools/defs_gen/docextract.py:
* tools/defs_gen/docextract_to_xml.py: Add support for the --no-recursion
command-line option, meaning that only the specified directories shall be
traversed, but not their subdirectories.
tools/defs_gen/docextract.py | 14 ++++++++++----
tools/defs_gen/docextract_to_xml.py | 9 ++++++---
2 files changed, 16 insertions(+), 7 deletions(-)
---
diff --git a/tools/defs_gen/docextract.py b/tools/defs_gen/docextract.py
index f794ef8..7ee2ef5 100644
--- a/tools/defs_gen/docextract.py
+++ b/tools/defs_gen/docextract.py
@@ -12,12 +12,17 @@ import sys, os, re
# option being specified.
no_since = False
+# Used to tell if extract() shall collect information from subdirectories.
+# This variable is modified from docextract_to_xml based on the --no-recursion
+# option being specified.
+no_recursion = False
+
__all__ = ['extract']
class GtkDoc:
def __init__(self):
self.name = None
- # The block type ('function', 'signal', property', 'enum')
+ # The block type ('function', 'signal', property', 'section', 'enum')
self.block_type = ''
self.params = []
self.annotations = []
@@ -457,8 +462,9 @@ def parse_dir(dir, doc_dict):
if file in ('.', '..'): continue
path = os.path.join(dir, file)
if os.path.isdir(path):
- parse_dir(path, doc_dict)
- if len(file) > 2 and (file[-2:] == '.c' or file[-2:] == '.h'):
+ if not no_recursion:
+ parse_dir(path, doc_dict)
+ elif len(file) > 2 and file[-2:] in ('.c', '.h'):
sys.stderr.write("Processing " + path + '\n')
parse_file(open(path, 'r'), doc_dict)
@@ -511,6 +517,6 @@ def extract_tmpl(dirs, doc_dict=None):
path = os.path.join(dir, file)
if os.path.isdir(path):
continue
- if len(file) > 2 and file[-2:] == '.sgml':
+ if len(file) > 5 and file[-5:] == '.sgml':
parse_tmpl(open(path, 'r'), doc_dict)
return doc_dict
diff --git a/tools/defs_gen/docextract_to_xml.py b/tools/defs_gen/docextract_to_xml.py
index 00c4f8c..3bf75c6 100755
--- a/tools/defs_gen/docextract_to_xml.py
+++ b/tools/defs_gen/docextract_to_xml.py
@@ -15,7 +15,7 @@ import docextract
def usage():
sys.stderr.write('usage: docextract_to_xml.py ' +
'[-s /src/dir | --source-dir=/src/dir] [-a | --with-annotations] ' +
- '[-p | --with-properties] [-c | --with-sections] ' +
+ '[-p | --with-properties] [-c | --with-sections] [-r | --no-recursion] ' +
'[-n | --no-since] [-i | --no-signals ] [-e | --no-enums ]\n')
sys.exit(1)
@@ -61,10 +61,11 @@ def print_annotations(annotations):
if __name__ == '__main__':
try:
- opts, args = getopt.getopt(sys.argv[1:], "d:s:o:apcnie",
+ opts, args = getopt.getopt(sys.argv[1:], "d:s:o:apcrnie",
["source-dir=", "with-annotations",
"with-properties", "with-sections",
- "no-since", "no-signals", "no-enums"])
+ "no-recursion", "no-since",
+ "no-signals", "no-enums"])
except getopt.error as e:
sys.stderr.write('docextract_to_xml.py: %s\n' % e)
usage()
@@ -83,6 +84,8 @@ if __name__ == '__main__':
with_properties = True
if opt in ('-c', '--with-sections'):
with_sections = True
+ if opt in ('-r', '--no-recursion'):
+ docextract.no_recursion = True
if opt in ('-n', '--no-since'):
docextract.no_since = True
if opt in ('-i', '--no-signals'):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]