diff options
author | James Westman <flyingpimonster@gmail.com> | 2020-09-07 13:54:42 +0000 |
---|---|---|
committer | Mathieu Duponchelle <mduponchelle1@gmail.com> | 2020-09-07 13:54:42 +0000 |
commit | de6512b31b614567bf1800406303d1ccfb6d9455 (patch) | |
tree | e64f4ffd064fe31dad8d3934add58aa1a5e1b6a3 /giscanner/annotationparser.py | |
parent | 25dcd89afabd57f199e33cb253aa7fd7fb91ec01 (diff) | |
download | gobject-introspection-de6512b31b614567bf1800406303d1ccfb6d9455.tar.gz |
giscanner: Fix section matching for documentation
When writing documentation to the GIR files, GIR tries to match
classes with their matching SECTION: comment in the source code. Some codebases
use kebab-case or CamelCase for their section names, but GIR always expects
them to be flatcase or the matching will fail.
This commit converts all section names to flatcase (by removing "-" and
converting to lowercase) while they are being parsed, so that they are matched
properly later on.
Fixes #350.
Diffstat (limited to 'giscanner/annotationparser.py')
-rw-r--r-- | giscanner/annotationparser.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/giscanner/annotationparser.py b/giscanner/annotationparser.py index f8257206..c9ff5c2b 100644 --- a/giscanner/annotationparser.py +++ b/giscanner/annotationparser.py @@ -1357,7 +1357,12 @@ class GtkDocCommentBlockParser(object): result = SECTION_RE.match(line) if result: - identifier_name = 'SECTION:%s' % (result.group('section_name'), ) + # Some projects use kebab-case or CamelCase for section + # names. Convert them all to flat case so we can match + # them easily later on. + identifier_name = 'SECTION:%s' % (result.group('section_name') + .replace("-", "") + .lower(), ) identifier_delimiter = None identifier_fields = None identifier_fields_start = None |