diff options
Diffstat (limited to 'tools/defs_gen/docextract_to_xml.py')
-rwxr-xr-x | tools/defs_gen/docextract_to_xml.py | 38 |
1 files changed, 28 insertions, 10 deletions
diff --git a/tools/defs_gen/docextract_to_xml.py b/tools/defs_gen/docextract_to_xml.py index 4222250a..a3221350 100755 --- a/tools/defs_gen/docextract_to_xml.py +++ b/tools/defs_gen/docextract_to_xml.py @@ -14,8 +14,8 @@ 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] ' + + '[-s /src/dir | --source-dir=/src/dir] [-a | --with-annotations] ' + + '[-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:apnie", + opts, args = getopt.getopt(sys.argv[1:], "d:s:o:apcrnie", ["source-dir=", "with-annotations", - "with-properties", "no-since", - "no-signals", "no-enums"]) + "with-properties", "with-sections", + "no-recursion", "no-since", + "no-signals", "no-enums"]) except getopt.error as e: sys.stderr.write('docextract_to_xml.py: %s\n' % e) usage() @@ -72,6 +73,7 @@ if __name__ == '__main__': with_annotations = False with_signals = True with_properties = False + with_sections = False with_enums = True for opt, arg in opts: if opt in ('-s', '--source-dir'): @@ -80,6 +82,10 @@ if __name__ == '__main__': with_annotations = True if opt in ('-p', '--with-properties'): 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'): @@ -99,8 +105,8 @@ if __name__ == '__main__': print("<root>") for name, value in sorted(docs.items()): - # Get the type of comment block ('function', 'signal' or - # 'property') (the value is a GtkDoc). + # Get the type of comment block ('function', 'signal', + # 'property', 'section' or 'enum') (the value is a GtkDoc). block_type = value.get_type() # Skip signals if the option was not specified. @@ -109,6 +115,18 @@ if __name__ == '__main__': # Likewise for properties. elif block_type == 'property' and not with_properties: continue + # Likewise for sections. + elif block_type == 'section': + if not with_sections: + continue + # Delete 'SECTION:' from the name. + # (It could easily be deleted by docextract.extract(), but then + # there would be a theoretical risk that a section name would + # be identical to a function name, when all kinds of elements + # are stored in the docs dictionary with their names as key.) + last_colon_pos = name.rfind(':') + if last_colon_pos >= 0: + name = name[last_colon_pos+1:] # Likewise for enums. elif block_type == 'enum' and not with_enums: continue @@ -133,9 +151,9 @@ if __name__ == '__main__': print("</parameters>") - if block_type != 'property' and block_type != 'enum': - # Show the return-type (also if not dealing with a property or - # enum): + if block_type not in ('property', 'section', 'enum'): + # Show the return-type if not dealing with a property, section + # or enum: if with_annotations: print("<return>") print("<return_description>" + escape_text(value.ret[0]) + \ |