summaryrefslogtreecommitdiff
path: root/giscanner/scannermain.py
diff options
context:
space:
mode:
authorThibault Saunier <tsaunier@igalia.com>2018-11-19 21:49:13 -0300
committerThibault Saunier <tsaunier@igalia.com>2018-11-28 09:29:07 -0300
commit925c3b875861e83d3d6808439b61e80fe5ee8b48 (patch)
treee3e40f76f07d429c8fbec25949d5ccb55a2e210c /giscanner/scannermain.py
parente194cf780fb13932be2e158d5eb23db737a6e0db (diff)
downloadgobject-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/scannermain.py')
-rw-r--r--giscanner/scannermain.py13
1 files changed, 10 insertions, 3 deletions
diff --git a/giscanner/scannermain.py b/giscanner/scannermain.py
index ccb14e91..ceca66f4 100644
--- a/giscanner/scannermain.py
+++ b/giscanner/scannermain.py
@@ -248,6 +248,11 @@ match the namespace prefix.""")
parser.add_option("", "--include-last-in-src",
action="append", dest="include_last_src", default=[],
help="Header to include after the other headers in generated sources")
+ parser.add_option("", "--sources-top-dirs", default=[], action='append',
+ help="Paths to the sources directories used to determine"
+ " relative files locations to be used in the gir file."
+ " This is especially useful when build dir and source dir are different"
+ " and mirrored.")
return parser
@@ -441,7 +446,7 @@ def create_source_scanner(options, args):
cflags=options.cflags)
ss.parse_files(filenames)
ss.parse_macros(filenames)
- return ss
+ return ss, filenames
def write_output(data, options):
@@ -535,7 +540,7 @@ def scanner_main(args):
except pkgconfig.PkgConfigError as e:
_error(str(e))
- ss = create_source_scanner(options, args)
+ ss, filenames = create_source_scanner(options, args)
cbp = GtkDocCommentBlockParser()
blocks = cbp.parse_comment_blocks(ss.get_comments())
@@ -575,7 +580,9 @@ def scanner_main(args):
transformer.namespace.c_includes = options.c_includes
transformer.namespace.exported_packages = exported_packages
- writer = Writer(transformer.namespace)
+ if not options.sources_top_dirs:
+ options.sources_top_dirs = [os.path.commonprefix(filenames).rpartition(os.path.sep)[0]]
+ writer = Writer(transformer.namespace, options.sources_top_dirs)
data = writer.get_encoded_xml()
write_output(data, options)