[gtk-doc] mkhtml: split into wrapper and module
- From: Stefan Sauer <stefkost src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk-doc] mkhtml: split into wrapper and module
- Date: Fri, 31 Mar 2017 19:35:41 +0000 (UTC)
commit 106afd389337f424b4985e7d2476f3928a8dd0da
Author: Stefan Sauer <ensonic users sf net>
Date: Fri Mar 31 21:33:36 2017 +0200
mkhtml: split into wrapper and module
Makefile.am | 2 +
gtkdoc-mkhtml.in | 146 +++++++++++++++++-------------------------------------
gtkdoc/mkhtml.py | 95 +++++++++++++++++++++++++++++++++++
3 files changed, 143 insertions(+), 100 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index 4c20b34..8ee64b9 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -39,6 +39,7 @@ pylibdata_DATA = \
gtkdoc/__init__.py \
gtkdoc/check.py \
gtkdoc/config.py \
+ gtkdoc/mkhtml.py \
gtkdoc/mkman.py
pkgconfigdir = $(datadir)/pkgconfig
@@ -80,6 +81,7 @@ CLEANFILES = \
gtkdoc/__init__.pyc \
gtkdoc/check.pyc \
gtkdoc/config.pyc \
+ gtkdoc/mkhtml.pyc \
gtkdoc/mkman.pyc
DISTCLEANFILES = \
diff --git a/gtkdoc-mkhtml.in b/gtkdoc-mkhtml.in
index fc887f1..00c7779 100644
--- a/gtkdoc-mkhtml.in
+++ b/gtkdoc-mkhtml.in
@@ -1,101 +1,47 @@
#!@PYTHON@
-
-# Support both Python 2 and 3
-from __future__ import print_function
-
-import os, sys, argparse, subprocess, shutil
-from glob import glob
-
-version = '@VERSION@'
-xsltproc = '@XSLTPROC@'
-
-parser = argparse.ArgumentParser(description='gtkdoc-mkhtml version %s - generate documentation in html
format' % version)
-
-parser.add_argument('--verbose', default=False, action='store_true',
- help='Print extra output while processing')
-parser.add_argument('--path', default=[], action='append',
- help='Extra source directories')
-parser.add_argument('--version', default=False, action='store_true',
- help='Print the version of this program')
-parser.add_argument('args', nargs='*',
- help='MODULE DRIVER_FILE')
-parser.add_argument('--uninstalled', action='store_true', default=False,
- help='???')
-
-options = parser.parse_args()
-if options.version:
- print(version)
- sys.exit(0)
-
-if len(options.args) < 2:
- sys.exit('Too few arguments')
-
-module=options.args[0]
-document=options.args[1]
-if options.verbose:
- quiet = '0'
-else:
- quiet = '1'
-remaining_args = options.args[2:]
-
-if options.uninstalled:
- # this does not work from buiddir!=srcdir
- gtkdocdir = os.path.split(sys.argv[0])[0]
- if not os.path.exists(gtkdocdir + '/gtk-doc.xsl'):
- # try to src dir (set from makefiles) too
- if os.path.exists(os.path.environ.get("ABS_TOP_SRCDIR", '') + '/gtk-doc.xsl'):
- gtkdocdir=os.path.environ['ABS_TOP_SRCDIR']
- styledir=gtkdocdir + '/style'
- #echo "uninstalled, gtkdocdir=$gtkdocdir, cwd=$PWD"
-else:
- # the first vars are needed to resolve datadir
- prefix='@prefix@'
- datarootdir="@datarootdir@".replace('${prefix}', prefix)
- datadir="@datadir@".replace('${datarootdir}', datarootdir)
- gtkdocdir=os.path.join(datadir, 'gtk-doc/data')
- styledir=gtkdocdir
-
-# We need to use a wrapper because there's no other way to conditionally pass
-# a `--path $searchpath` argument with proper quoting for the path
-def run_xsltproc(args):
- # we could do "$path_option $PWD "
- # to avoid needing rewriting entities that are copied from the header
- # into docs under xml
- if os.environ.get("GTKDOC_PROFILE", '') == '':
- if len(options.path):
- subprocess.check_call([xsltproc] + args)
- else:
- subprocess.check_call([xsltproc, '--path'] + options.path + args)
- else:
- if len(options.path) == 0:
- subprocess.check_call([xsltproc, '--profile'] + args, stderr=open('profile.txt', 'w'))
- else:
- subprocess.check_call([xsltproc ,'--profile', '--path'] + options.path + args,
stderr=open('profile.txt', 'w'))
-
-run_xsltproc(['--nonet',
- '--xinclude',
- '--stringparam',
- 'gtkdoc.bookname',
- module,
- '--stringparam',
- 'gtkdoc.version',
- version,
- '--stringparam',
- 'chunk.quietly',
- quiet,
- '--stringparam',
- 'chunker.output.quiet',
- quiet] + remaining_args + \
- [gtkdocdir + '/gtk-doc.xsl',
- document])
-
-# profiling
-if os.environ.get("GTKDOC_PROFILE", '') != '':
- subprocess.check_call('cat profile.txt | gprof2dot.py -e 0.01 -n 0.01 | dot -Tpng -o profile.png',
shell=True)
-
-# copy navigation images and stylesheets to html directory ...
-for f in glob(styledir + '/*.png') + glob(styledir + '/*.css'):
- shutil.copy(f, '.')
-
-open('../html.stamp', 'w').write('timestamp')
-
+# -*- python; coding: utf-8 -*-
+#
+# gtk-doc - GTK DocBook documentation generator.
+# Copyright (C) 1998 Owen Taylor
+# 2001-2005 Damon Chaplin
+# 2009-2017 Stefan Sauer
+# 2017 Jussi Pakkanen
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+
+import argparse, sys
+sys.path.append('@PYTHON_PACKAGE_DIR@')
+
+from gtkdoc import config, mkhtml
+
+if __name__== '__main__':
+ parser = argparse.ArgumentParser(description='gtkdoc-mkhtml version %s - generate documentation in html
format' % config.version)
+ parser.add_argument('--version', action='version', version=config.version)
+ parser.add_argument('--verbose', default=False, action='store_true',
+ help='Print extra output while processing')
+ parser.add_argument('--path', default=[], action='append',
+ help='Extra source directories')
+ parser.add_argument('args', nargs='*',
+ help='MODULE DRIVER_FILE')
+ # TODO: only for testing, replace with env-var
+ parser.add_argument('--uninstalled', action='store_true', default=False,
+ help='???')
+
+ options = parser.parse_args()
+ if len(options.args) < 2:
+ sys.exit('Too few arguments')
+
+ sys.exit(mkhtml.run(options))
diff --git a/gtkdoc/mkhtml.py b/gtkdoc/mkhtml.py
new file mode 100644
index 0000000..803d16b
--- /dev/null
+++ b/gtkdoc/mkhtml.py
@@ -0,0 +1,95 @@
+#!@PYTHON@
+# -*- python; coding: utf-8 -*-
+#
+# gtk-doc - GTK DocBook documentation generator.
+# Copyright (C) 1998 Owen Taylor
+# 2001-2005 Damon Chaplin
+# 2009-2017 Stefan Sauer
+# 2017 Jussi Pakkanen
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+
+# Support both Python 2 and 3
+from __future__ import print_function
+
+import os, sys, argparse, subprocess, shutil
+from glob import glob
+
+from . import config
+
+
+def run_xsltproc(options, args):
+ command = [config.xsltproc]
+ # we could do "$path_option $PWD " to avoid needing rewriting entities that
+ # are copied from the header into docs under xml
+ if os.environ.get("GTKDOC_PROFILE", '') == '':
+ if len(options.path):
+ command += ['--path'] + options.path
+ return subprocess.call(command + args)
+ else:
+ command += ['--profile']
+ if len(options.path):
+ command += ['--path'] + options.path
+ return subprocess.call(command + args, stderr=open('profile.txt', 'w'))
+
+
+def run(options):
+ module = options.args[0]
+ document = options.args[1]
+ if options.verbose:
+ quiet = '0'
+ else:
+ quiet = '1'
+ remaining_args = options.args[2:]
+
+ if options.uninstalled:
+ # this does not work from buiddir!=srcdir
+ gtkdocdir = os.path.split(sys.argv[0])[0]
+ if not os.path.exists(gtkdocdir + '/gtk-doc.xsl'):
+ # try to src dir (set from makefiles) too
+ if os.path.exists(os.environ.get("ABS_TOP_SRCDIR", '') + '/gtk-doc.xsl'):
+ gtkdocdir = os.environ['ABS_TOP_SRCDIR']
+ styledir = gtkdocdir + '/style'
+ else:
+ gtkdocdir = os.path.join(config.datadir, 'gtk-doc/data')
+ styledir = gtkdocdir
+
+ res = run_xsltproc(options, [
+ '--nonet',
+ '--xinclude',
+ '--stringparam',
+ 'gtkdoc.bookname',
+ module,
+ '--stringparam',
+ 'gtkdoc.version',
+ config.version,
+ '--stringparam',
+ 'chunk.quietly',
+ quiet,
+ '--stringparam',
+ 'chunker.output.quiet',
+ quiet] + remaining_args + [gtkdocdir + '/gtk-doc.xsl', document])
+
+ # profiling
+ if os.environ.get("GTKDOC_PROFILE", '') != '':
+ subprocess.check_call('cat profile.txt | gprof2dot.py -e 0.01 -n 0.01 | dot -Tpng -o profile.png',
shell=True)
+
+ # copy navigation images and stylesheets to html directory ...
+ for f in glob(styledir + '/*.png') + glob(styledir + '/*.css'):
+ shutil.copy(f, '.')
+
+ open('../html.stamp', 'w').write('timestamp')
+ return res
\ No newline at end of file
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]