From cbc329fc326e437b16b4eb732c6b4fed2c3c7123 Mon Sep 17 00:00:00 2001 From: Jussi Pakkanen Date: Sun, 2 Aug 2015 01:48:24 +0300 Subject: [PATCH] Add sgml main to gtk-doc. --- gtkdochelper.py | 34 ++++++++++------ modules/gnome.py | 4 ++ .../10 gtk-doc/doc/foobar-docs.sgml | 39 +++++++++++++++++++ .../frameworks/10 gtk-doc/doc/meson.build | 8 +++- .../frameworks/10 gtk-doc/doc/version.xml.in | 1 + .../frameworks/10 gtk-doc/installed_files.txt | 4 +- 6 files changed, 75 insertions(+), 15 deletions(-) create mode 100644 test cases/frameworks/10 gtk-doc/doc/foobar-docs.sgml create mode 100644 test cases/frameworks/10 gtk-doc/doc/version.xml.in diff --git a/gtkdochelper.py b/gtkdochelper.py index 5ed979f58..f27b2b5ee 100755 --- a/gtkdochelper.py +++ b/gtkdochelper.py @@ -17,7 +17,7 @@ import sys, os import subprocess import shutil -def build_gtkdoc(source_root, build_root, doc_subdir, src_subdir, module): +def build_gtkdoc(source_root, build_root, doc_subdir, src_subdir, main_sgml, module): abs_src = os.path.join(source_root, src_subdir) abs_out = os.path.join(build_root, doc_subdir) htmldir = os.path.join(abs_out, 'html') @@ -25,18 +25,30 @@ def build_gtkdoc(source_root, build_root, doc_subdir, src_subdir, module): '--module=' + module, '--source-dir=' + abs_src, '--output-dir=.'], cwd=abs_out) - subprocess.check_call(['gtkdoc-mkdb', - '--module=' + module, - '--output-format=xml', - '--source-dir=' + abs_src], cwd=abs_out) + mkdb_cmd = ['gtkdoc-mkdb', + '--module=' + module, + '--output-format=xml', + '--sgml-mode', + '--source-dir=' + abs_src] + sgml_abs = os.path.join(source_root, doc_subdir, main_sgml) + if len(main_sgml) > 0: + mkdb_cmd.append('--main-sgml-file=' + sgml_abs) + subprocess.check_call(mkdb_cmd, cwd=abs_out) shutil.rmtree(htmldir, ignore_errors=True) try: os.mkdir(htmldir) except Exception: pass - subprocess.check_call(['gtkdoc-mkhtml', - module, - '../%s-docs.xml' % module], cwd=htmldir) + mkhtml_cmd = ['gtkdoc-mkhtml', module] + if len(main_sgml) > 0: + # Workaround for + # https://bugzilla.gnome.org/show_bug.cgi?id=753145 + plainfile = os.path.split(sgml_abs)[1] + shutil.copy(sgml_abs, os.path.join(abs_out, plainfile)) + mkhtml_cmd.append('../' + plainfile) + else: + mkhtml_cmd.append('../%s-docs.xml' % module) + subprocess.check_call(mkhtml_cmd, cwd=htmldir, shell=False) subprocess.check_call(['gtkdoc-fixxref', '--module=' + module, '--module-dir=html'], cwd=abs_out) @@ -53,12 +65,12 @@ if __name__ == '__main__': # doc_subdir = 'doc' # src_subdir = 'include' # module = 'foobar' - if len(sys.argv) != 6: + if len(sys.argv) != 7: print(sys.argv) print("Bad arguments.") sys.exit(1) - (source_root, build_root, doc_subdir, src_subdir, module) = sys.argv[1:] - build_gtkdoc(source_root, build_root, doc_subdir, src_subdir, module) + (source_root, build_root, doc_subdir, src_subdir, main_sgml, module) = sys.argv[1:] + build_gtkdoc(source_root, build_root, doc_subdir, src_subdir, main_sgml, module) if 'MESON_INSTALL_PREFIX' in os.environ: if 'DESTDIR' in os.environ: diff --git a/modules/gnome.py b/modules/gnome.py index ed56989a1..43c053766 100644 --- a/modules/gnome.py +++ b/modules/gnome.py @@ -184,6 +184,9 @@ class GnomeModule: raise MesonException('Gtkdoc arg must be string.') if not 'src_dir' in kwargs: raise MesonException('Keyword argument src_dir missing.') + main_sgml = kwargs.get('main_sgml', '') + if not isinstance(main_sgml, str): + raise MesonException('Main sgml keyword argument must be a string.') src_dir = kwargs['src_dir'] targetname = modulename + '-doc' command = os.path.normpath(os.path.join(os.path.split(__file__)[0], "../gtkdochelper.py")) @@ -191,6 +194,7 @@ class GnomeModule: state.environment.get_build_dir(), state.subdir, os.path.normpath(os.path.join(state.subdir, src_dir)), + main_sgml, modulename] res = [build.RunTarget(targetname, command, args, state.subdir)] if kwargs.get('install', True): diff --git a/test cases/frameworks/10 gtk-doc/doc/foobar-docs.sgml b/test cases/frameworks/10 gtk-doc/doc/foobar-docs.sgml new file mode 100644 index 000000000..d23b22fe4 --- /dev/null +++ b/test cases/frameworks/10 gtk-doc/doc/foobar-docs.sgml @@ -0,0 +1,39 @@ + + +]> + + + Foolib Reference Manual + + for Foobar &version; + + + + Jonny + Example + +
+ unknown@example.com +
+
+
+
+ + 2015 + Foobar corporation holdings ltd + +
+ + + Foobar library + + + This part documents Foobar libs. + + + + + +
diff --git a/test cases/frameworks/10 gtk-doc/doc/meson.build b/test cases/frameworks/10 gtk-doc/doc/meson.build index 2940d416a..c9b408923 100644 --- a/test cases/frameworks/10 gtk-doc/doc/meson.build +++ b/test cases/frameworks/10 gtk-doc/doc/meson.build @@ -1,3 +1,9 @@ gnome = import('gnome') -gnome.gtkdoc('foobar', src_dir : '../include', install : true) +cdata = configuration_data() +cdata.set('VERSION', '1.0') +configure_file(input : 'version.xml.in', + output : 'version.xml', + configuration : cdata) + +gnome.gtkdoc('foobar', src_dir : '../include', main_sgml : 'foobar-docs.sgml', install : true) diff --git a/test cases/frameworks/10 gtk-doc/doc/version.xml.in b/test cases/frameworks/10 gtk-doc/doc/version.xml.in new file mode 100644 index 000000000..d78bda934 --- /dev/null +++ b/test cases/frameworks/10 gtk-doc/doc/version.xml.in @@ -0,0 +1 @@ +@VERSION@ diff --git a/test cases/frameworks/10 gtk-doc/installed_files.txt b/test cases/frameworks/10 gtk-doc/installed_files.txt index c8ec9d6c0..9004af21c 100644 --- a/test cases/frameworks/10 gtk-doc/installed_files.txt +++ b/test cases/frameworks/10 gtk-doc/installed_files.txt @@ -1,8 +1,6 @@ -usr/share/gtk-doc/html/foobar/api-index-full.html -usr/share/gtk-doc/html/foobar/ch01.html -usr/share/gtk-doc/html/foobar/deprecated-api-index.html usr/share/gtk-doc/html/foobar/foobar.devhelp2 usr/share/gtk-doc/html/foobar/foobar-foo.html +usr/share/gtk-doc/html/foobar/foobar.html usr/share/gtk-doc/html/foobar/home.png usr/share/gtk-doc/html/foobar/index.html usr/share/gtk-doc/html/foobar/index.sgml