diff options
author | Thibault Saunier <tsaunier@igalia.com> | 2018-11-19 21:49:13 -0300 |
---|---|---|
committer | Thibault Saunier <tsaunier@igalia.com> | 2018-11-28 09:29:07 -0300 |
commit | 925c3b875861e83d3d6808439b61e80fe5ee8b48 (patch) | |
tree | e3e40f76f07d429c8fbec25949d5ccb55a2e210c /giscanner/girparser.py | |
parent | e194cf780fb13932be2e158d5eb23db737a6e0db (diff) | |
download | gobject-introspection-925c3b875861e83d3d6808439b61e80fe5ee8b48.tar.gz |
writer: Include documentation and symbol position in source files
Some documentation tool (as hotdoc[0]) need to have information about
symbol declaration and documentation positions in the source files
to be able to do smart indexing (automatically build the documenation
index).
[0] https://hotdoc.github.io/
Fixes #175
Diffstat (limited to 'giscanner/girparser.py')
-rw-r--r-- | giscanner/girparser.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/giscanner/girparser.py b/giscanner/girparser.py index 6841b6c5..45246307 100644 --- a/giscanner/girparser.py +++ b/giscanner/girparser.py @@ -30,6 +30,7 @@ from xml.etree.cElementTree import parse from . import ast from .girwriter import COMPATIBLE_GIR_VERSION +from .message import Position CORE_NS = "http://www.gtk.org/introspection/core/1.0" C_NS = "http://www.gtk.org/introspection/c/1.0" @@ -189,6 +190,9 @@ class GIRParser(object): if doc is not None: if doc.text: obj.doc = doc.text + obj.doc_position = Position(doc.attrib['filename'], + doc.attrib['line'], + doc.attrib.get('column', None)) version = node.attrib.get('version') if version: obj.version = version @@ -219,6 +223,20 @@ class GIRParser(object): attributes_[name] = value obj.attributes = attributes_ + if hasattr(obj, 'add_file_position'): + positions = sorted(node.findall(_corens('source-position')), + key=lambda x: (x.attrib['filename'], + int(x.attrib['line']))) + for position in positions: + if 'column' in position.attrib: + column = int(position.attrib['column']) + else: + column = None + + obj.add_file_position(Position(position.attrib['filename'], + int(position.attrib['line']), + column)) + def _parse_object_interface(self, node): parent = node.attrib.get('parent') if parent: |