aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/scripts/gtkdochelper.py
diff options
context:
space:
mode:
authorThibault Saunier <tsaunier@gnome.org>2016-09-23 20:22:52 -0300
committerThibault Saunier <tsaunier@gnome.org>2016-09-26 15:25:59 -0300
commitf86fbf6ebf68081d2949333ed6bfcda7f768d149 (patch)
tree902b0059ca909e5273c4f8c908f161d82cf17506 /mesonbuild/scripts/gtkdochelper.py
parent68ae8e1ad008236ffb4d85dfa37f4eb2eb6c7cb3 (diff)
downloadmeson-f86fbf6ebf68081d2949333ed6bfcda7f768d149.zip
meson-f86fbf6ebf68081d2949333ed6bfcda7f768d149.tar.gz
meson-f86fbf6ebf68081d2949333ed6bfcda7f768d149.tar.bz2
gnome: Run gtkdoc-scanobjs and add a way to get assets working
Allowing the object tree to be generated. We need to add options to allow copying the ncesseary sources and assets so the HTML generator can work with them (everything is relative so we need to copy them in the build directory). Until now the documentation was not generated from the user provided main sgml file but it was using a generated one, which lead to a broken documentation. Starting using it revealed the other bugs fixed in that commit.
Diffstat (limited to 'mesonbuild/scripts/gtkdochelper.py')
-rw-r--r--mesonbuild/scripts/gtkdochelper.py84
1 files changed, 67 insertions, 17 deletions
diff --git a/mesonbuild/scripts/gtkdochelper.py b/mesonbuild/scripts/gtkdochelper.py
index 0c87717..18a7597 100644
--- a/mesonbuild/scripts/gtkdochelper.py
+++ b/mesonbuild/scripts/gtkdochelper.py
@@ -30,7 +30,15 @@ parser.add_argument('--mainfile', dest='mainfile')
parser.add_argument('--modulename', dest='modulename')
parser.add_argument('--htmlargs', dest='htmlargs', default='')
parser.add_argument('--scanargs', dest='scanargs', default='')
+parser.add_argument('--scanobjsargs', dest='scanobjsargs', default='')
+parser.add_argument('--gobjects-types-file', dest='gobject_typesfile', default='')
parser.add_argument('--fixxrefargs', dest='fixxrefargs', default='')
+parser.add_argument('--ld', dest='ld', default='')
+parser.add_argument('--cc', dest='cc', default='')
+parser.add_argument('--ldflags', dest='ldflags', default='')
+parser.add_argument('--cflags', dest='cflags', default='')
+parser.add_argument('--content-files', dest='content_files', default='')
+parser.add_argument('--html-assets', dest='html_assets', default='')
def gtkdoc_run_check(cmd, cwd):
p = subprocess.Popen(cmd, cwd=cwd,
@@ -45,15 +53,49 @@ def gtkdoc_run_check(cmd, cwd):
raise MesonException('\n'.join(err_msg))
def build_gtkdoc(source_root, build_root, doc_subdir, src_subdir,
- main_file, module, html_args, scan_args, fixxref_args):
+ main_file, module, html_args, scan_args, fixxref_args,
+ gobject_typesfile, scanobjs_args, ld, cc, ldflags, cflags,
+ html_assets, content_files):
+ print("Building documentation for %s" % module)
+
abs_src = os.path.join(source_root, src_subdir)
+ doc_src = os.path.join(source_root, doc_subdir)
abs_out = os.path.join(build_root, doc_subdir)
htmldir = os.path.join(abs_out, 'html')
+
+ content_files += [main_file]
+ sections = os.path.join(doc_src, module + "-sections.txt")
+ if os.path.exists(sections):
+ content_files.append(sections)
+
+ # Copy files to build directory
+ for f in content_files:
+ f_abs = os.path.join(doc_src, f)
+ shutil.copyfile(f_abs, os.path.join(
+ abs_out, os.path.basename(f_abs)))
+
+ shutil.rmtree(htmldir, ignore_errors=True)
+ try:
+ os.mkdir(htmldir)
+ except Exception:
+ pass
+
+ for f in html_assets:
+ f_abs = os.path.join(doc_src, f)
+ shutil.copyfile(f_abs, os.path.join(htmldir, os.path.basename(f_abs)))
+
scan_cmd = ['gtkdoc-scan',
'--module=' + module,
'--source-dir=' + abs_src] + scan_args
gtkdoc_run_check(scan_cmd, abs_out)
+ if gobject_typesfile:
+ scanobjs_cmd = ['gtkdoc-scangobj'] + scanobjs_args + [gobject_typesfile,
+ '--module=' + module, '--cflags=' + cflags, '--ldflags=' + ldflags]
+
+ gtkdoc_run_check(scanobjs_cmd, abs_out)
+
+
# Make docbook files
if main_file.endswith('sgml'):
modeflag = '--sgml-mode'
@@ -62,21 +104,16 @@ def build_gtkdoc(source_root, build_root, doc_subdir, src_subdir,
mkdb_cmd = ['gtkdoc-mkdb',
'--module=' + module,
'--output-format=xml',
+ '--expand-content-files=',
modeflag,
'--source-dir=' + abs_src]
- main_abs = os.path.join(source_root, doc_subdir, main_file)
if len(main_file) > 0:
# Yes, this is the flag even if the file is in xml.
mkdb_cmd.append('--main-sgml-file=' + main_file)
gtkdoc_run_check(mkdb_cmd, abs_out)
# Make HTML documentation
- shutil.rmtree(htmldir, ignore_errors=True)
- try:
- os.mkdir(htmldir)
- except Exception:
- pass
- mkhtml_cmd = ['gtkdoc-mkhtml',
+ mkhtml_cmd = ['gtkdoc-mkhtml',
'--path=' + abs_src,
module,
] + html_args
@@ -109,19 +146,32 @@ def run(args):
scanargs = options.scanargs.split('@@')
else:
scanargs = []
+ if len(options.scanobjsargs) > 0:
+ scanobjsargs = options.scanobjsargs.split('@@')
+ else:
+ scanobjsargs = []
if len(options.fixxrefargs) > 0:
fixxrefargs = options.fixxrefargs.split('@@')
else:
fixxrefargs = []
- build_gtkdoc(options.sourcedir,
- options.builddir,
- options.subdir,
- options.headerdir,
- options.mainfile,
- options.modulename,
- htmlargs,
- scanargs,
- fixxrefargs)
+ build_gtkdoc(
+ options.sourcedir,
+ options.builddir,
+ options.subdir,
+ options.headerdir,
+ options.mainfile,
+ options.modulename,
+ htmlargs,
+ scanargs,
+ fixxrefargs,
+ options.gobject_typesfile,
+ scanobjsargs,
+ options.ld,
+ options.cc,
+ options.ldflags,
+ options.cflags,
+ options.html_assets.split('@@') if options.html_assets else [],
+ options.content_files.split('@@') if options.content_files else [])
if 'MESON_INSTALL_PREFIX' in os.environ:
destdir = os.environ.get('DESTDIR', '')