From 72af40b42704b64b2b5219e0c5ae4ea7c74fa84a Mon Sep 17 00:00:00 2001 From: Jehan Date: Fri, 29 Jan 2021 18:04:20 +0100 Subject: [PATCH] devel-docs: generate both gjs (Javascript) and Python API docs. Apparently g-ir-doc-tool does not support other language than C, Python and gjs right now (in particular neither Lua nor Vala bindings). --- devel-docs/g-ir-docs/Makefile.am | 45 ++++--- devel-docs/g-ir-docs/meson.build | 204 ++++++++++++++++--------------- 2 files changed, 126 insertions(+), 123 deletions(-) diff --git a/devel-docs/g-ir-docs/Makefile.am b/devel-docs/g-ir-docs/Makefile.am index 467947e946..1e29a4c65c 100644 --- a/devel-docs/g-ir-docs/Makefile.am +++ b/devel-docs/g-ir-docs/Makefile.am @@ -1,34 +1,33 @@ if ENABLE_G_IR_DOC -Gimp-pythondocs: $(top_builddir)/libgimp/Gimp-@GIMP_API_VERSION@.gir +Gimp-%-docs: $(top_builddir)/libgimp/Gimp-@GIMP_API_VERSION@.gir $(GIR_DOC_TOOL) -I "$(prefix)/share/gir-1.0/" \ - -I "$(top_builddir)/libgimp" --language=Python \ - -o "$(builddir)/pages/Python/Gimp-$(GIMP_API_VERSION)" \ - $^ + -I "$(top_builddir)/libgimp" --language=$* \ + -o "$(builddir)/pages/$*/Gimp-$(GIMP_API_VERSION)" \ + $< $(YELP_BUILD) cache \ - -o "$(builddir)/pages/Python/Gimp-$(GIMP_API_VERSION)/index.cache" \ - "$(builddir)/pages/Python/Gimp-$(GIMP_API_VERSION)/" - mkdir -p "$(builddir)/html/Python/Gimp-$(GIMP_API_VERSION)" + -o "$(builddir)/pages/$*/Gimp-$(GIMP_API_VERSION)/index.cache" \ + "$(builddir)/pages/$*/Gimp-$(GIMP_API_VERSION)/" + mkdir -p "$(builddir)/html/$*/Gimp-$(GIMP_API_VERSION)" $(YELP_BUILD) html \ - -o "$(builddir)/html/Python/Gimp-$(GIMP_API_VERSION)" \ - "$(builddir)/pages/Python/Gimp-$(GIMP_API_VERSION)/" - echo "Python Gimp module documentation: $(builddir)/html/Python/Gimp-$(GIMP_API_VERSION)" + -o "$(builddir)/html/$*/Gimp-$(GIMP_API_VERSION)" \ + "$(builddir)/pages/$*/Gimp-$(GIMP_API_VERSION)/" + echo "$* Gimp module documentation: $(builddir)/html/Python/Gimp-$(GIMP_API_VERSION)" -GimpUi-pythondocs: $(top_builddir)/libgimp/GimpUi-@GIMP_API_VERSION@.gir - $(GIR_DOC_TOOL) -I "$(prefix)/share/gir-1.0/" \ - -I "$(top_builddir)/libgimp" --language=Python \ - -o "$(builddir)/pages/Python/GimpUi-$(GIMP_API_VERSION)" \ - $^ +GimpUi-%-docs: $(top_builddir)/libgimp/GimpUi-@GIMP_API_VERSION@.gir Gimp-%-docs + $(GIR_DOC_TOOL) -I "$(prefix)/share/gir-1.0/" \ + -I "$(top_builddir)/libgimp" --language=$* \ + -o "$(builddir)/pages/$*/GimpUi-$(GIMP_API_VERSION)" \ + $< $(YELP_BUILD) cache \ - -o "$(builddir)/pages/Python/GimpUi-$(GIMP_API_VERSION)/index.cache" \ - "$(builddir)/pages/Python/GimpUi-$(GIMP_API_VERSION)/" - mkdir -p "$(builddir)/html/Python/GimpUi-$(GIMP_API_VERSION)" + -o "$(builddir)/pages/$*/GimpUi-$(GIMP_API_VERSION)/index.cache" \ + "$(builddir)/pages/$*/GimpUi-$(GIMP_API_VERSION)/" + mkdir -p "$(builddir)/html/$*/GimpUi-$(GIMP_API_VERSION)" $(YELP_BUILD) html \ - -o "$(builddir)/html/Python/GimpUi-$(GIMP_API_VERSION)" \ - "$(builddir)/pages/Python/GimpUi-$(GIMP_API_VERSION)/" - echo "Python GimpUi module documentation: $(builddir)/html/Python/Gimp-$(GIMP_API_VERSION)" + -o "$(builddir)/html/$*/GimpUi-$(GIMP_API_VERSION)" \ + "$(builddir)/pages/$*/GimpUi-$(GIMP_API_VERSION)/" + echo "$* GimpUi module documentation: $(builddir)/html/Python/GimpUi-$(GIMP_API_VERSION)" -.PHONY: Gimp-pythondocs GimpUi-pythondocs -all-local: Gimp-pythondocs GimpUi-pythondocs +all-local: GimpUi-gjs-docs GimpUi-python-docs endif diff --git a/devel-docs/g-ir-docs/meson.build b/devel-docs/g-ir-docs/meson.build index b84553b682..3554b66c8b 100644 --- a/devel-docs/g-ir-docs/meson.build +++ b/devel-docs/g-ir-docs/meson.build @@ -1,110 +1,114 @@ -# XXX meson does not allow building into subdir: -# https://github.com/mesonbuild/meson/issues/2320 -# Otherwise I could use '-o', '@OUTDIR@' into following commands if -# the `output` was subdir-able. -gir_docs_dir = custom_target('g-ir-docs-dir', - depends: [ libgimp_gir, libgimpui_gir ], - input: [ ], - output: [ 'html-dirs' ], - command: [ - 'mkdir', '-p', - '@OUTDIR@' + '/pages/Python/GimpUi-' + gimp_api_version, - '@OUTDIR@' + '/pages/Python/Gimp-' + gimp_api_version, - '@OUTDIR@' + '/html/Python/GimpUi-' + gimp_api_version, - '@OUTDIR@' + '/html/Python/Gimp-' + gimp_api_version - ], - build_by_default: true) +foreach lang : [ 'python', 'gjs' ] -# XXX `output` is bogus. g-ir-doc-tool produces a lot of output, -# basically one page per public symbol, which is more than 1000 so -# it's not usable. Since custom_target() requires an 'output', I could -# just set one output such as 'index.page` as a trick, but since we -# have another issue on subdir anyway (cf. above), I use some bogus -# file instead. The fact the bogus file is not even created does not -# even seem to be a problem for meson. -# Moreover I realized that the targets listed by ninja are only the -# output files (not the target name), so I basically ends up using -# this field to create understandable names). -gir_docs_python = custom_target('g-ir-Gimp-python-pages', - depends: [ gir_docs_dir, libgimp_gir ], - input: [ libgimp_gir[0] ], - output: [ 'Gimp-python-pages' ], - command: [ - gir_doc_tool, - '-I', prefix / 'share/gir-1.0/', - '-I', meson.build_root() / 'libgimp', - '--language=Python', - '-o', '@OUTDIR@' + '/pages/Python/Gimp-' + gimp_api_version, - '@INPUT@' - ], - build_by_default: true) + # XXX meson does not allow building into subdir: + # https://github.com/mesonbuild/meson/issues/2320 + # Otherwise I could use '-o', '@OUTDIR@' into following commands if + # the `output` was subdir-able. + gir_docs_dir = custom_target('g-ir-docs-' + lang + '-dir', + depends: [ libgimp_gir, libgimpui_gir ], + input: [ ], + output: [ 'gir-' + lang + '-dirs' ], + command: [ + 'mkdir', '-p', + '@OUTDIR@' + '/pages/' + lang + '/GimpUi-' + gimp_api_version, + '@OUTDIR@' + '/pages/' + lang + '/Gimp-' + gimp_api_version, + '@OUTDIR@' + '/html/' + lang + '/GimpUi-' + gimp_api_version, + '@OUTDIR@' + '/html/' + lang + '/Gimp-' + gimp_api_version + ], + build_by_default: true) -## Gimp Module ## + # XXX `output` is bogus. g-ir-doc-tool produces a lot of output, + # basically one page per public symbol, which is more than 1000 so + # it's not usable. Since custom_target() requires an 'output', I could + # just set one output such as 'index.page` as a trick, but since we + # have another issue on subdir anyway (cf. above), I use some bogus + # file instead. The fact the bogus file is not even created does not + # even seem to be a problem for meson. + # Moreover I realized that the targets listed by ninja are only the + # output files (not the target name), so I basically ends up using + # this field to create understandable names). + gir_docs_pages = custom_target('g-ir-Gimp-' + lang + '-pages', + depends: [ gir_docs_dir, libgimp_gir ], + input: [ libgimp_gir[0] ], + output: [ 'Gimp-' + lang + '-pages' ], + command: [ + gir_doc_tool, + '-I', prefix / 'share/gir-1.0/', + '-I', meson.build_root() / 'libgimp', + '--language=' + lang, + '-o', '@OUTDIR@' + '/pages/' + lang + '/Gimp-' + gimp_api_version, + '@INPUT@' + ], + build_by_default: true) -gir_cache_python = custom_target('g-ir-Gimp-python-cache', - input: [ gir_docs_python ], - output: [ 'Gimp-python-cache' ], - command: [ - yelp_build, 'cache', - '-o', '@OUTDIR@' + '/pages/Python/Gimp-' + gimp_api_version + '/index.cache', - '@OUTDIR@' + '/pages/Python/Gimp-' + gimp_api_version, - ], - build_by_default: true) + ## Gimp Module ## -gir_html_python = custom_target('g-ir-Gimp-python-html', - input: [ gir_cache_python ], - output: [ 'Gimp-python-html' ], - # TODO: `output` needs to be complete for installation to work. So - # we need to figure out how to install the generated files (listing - # all of them is a crazy idea, but maybe we can generate the - # expected list somehow? Maybe even using the .def file which is - # already an exhaustive listing would be a good idea? - # Also where should we install exactly? - #install_dir: prefix / gimpdatadir / 'g-ir-docs/html/Python/Gimp', - #install: true, - command: [ - 'yelp-build', 'html', - '-o', '@OUTDIR@' + '/html/Python/Gimp-' + gimp_api_version, - '@OUTDIR@' + '/pages/Python/Gimp-' + gimp_api_version, - ], - build_by_default: true) + gir_docs_cache = custom_target('g-ir-Gimp-' + lang + '-cache', + input: [ gir_docs_pages ], + output: [ 'Gimp-' + lang + '-cache' ], + command: [ + yelp_build, 'cache', + '-o', '@OUTDIR@' + '/pages/' + lang + '/Gimp-' + gimp_api_version + '/index.cache', + '@OUTDIR@' + '/pages/' + lang + '/Gimp-' + gimp_api_version, + ], + build_by_default: true) -## GimpUi module ## + gir_docs_html = custom_target('g-ir-Gimp-' + lang + '-html', + input: [ gir_docs_cache ], + output: [ 'Gimp-' + lang + '-html' ], + # TODO: `output` needs to be complete for installation to work. So + # we need to figure out how to install the generated files (listing + # all of them is a crazy idea, but maybe we can generate the + # expected list somehow? Maybe even using the .def file which is + # already an exhaustive listing would be a good idea? + # Also where should we install exactly? + #install_dir: prefix / gimpdatadir / 'g-ir-docs/html/' + lang + '/Gimp', + #install: true, + command: [ + 'yelp-build', 'html', + '-o', '@OUTDIR@' + '/html/' + lang + '/Gimp-' + gimp_api_version, + '@OUTDIR@' + '/pages/' + lang + '/Gimp-' + gimp_api_version, + ], + build_by_default: true) -gir_docs_python = custom_target('g-ir-GimpUi-python-pages', - depends: [ gir_docs_dir, libgimpui_gir ], - input: [ libgimpui_gir[0] ], - output: [ 'GimpUi-python-pages' ], - command: [ - gir_doc_tool, - '-I', prefix / 'share/gir-1.0/', - '-I', meson.build_root() / 'libgimp', - '--language=Python', - '-o', '@OUTDIR@' + '/pages/Python/GimpUi-' + gimp_api_version, - '@INPUT@' - ], - build_by_default: true) + ## GimpUi module ## -gir_cache_python = custom_target('g-ir-GimpUi-python-cache', - input: [ gir_docs_python ], - output: [ 'GimpUi-python-cache' ], - command: [ - yelp_build, 'cache', - '-o', '@OUTDIR@' + '/pages/Python/GimpUi-' + gimp_api_version + '/index.cache', - '@OUTDIR@' + '/pages/Python/GimpUi-' + gimp_api_version, - ], - build_by_default: true) + gir_ui_docs_pages = custom_target('g-ir-GimpUi-' + lang + '-pages', + depends: [ gir_docs_dir, libgimpui_gir ], + input: [ libgimpui_gir[0] ], + output: [ 'GimpUi-' + lang + '-pages' ], + command: [ + gir_doc_tool, + '-I', prefix / 'share/gir-1.0/', + '-I', meson.build_root() / 'libgimp', + '--language=' + lang, + '-o', '@OUTDIR@' + '/pages/' + lang + '/GimpUi-' + gimp_api_version, + '@INPUT@' + ], + build_by_default: true) -gir_html_python = custom_target('g-ir-GimpUi-python-html', - input: [ gir_cache_python ], - output: [ 'GimpUi-python-html' ], - #install_dir: prefix / gimpdatadir / 'g-ir-docs/html/Python/GimpUi', - #install: true, - command: [ - 'yelp-build', 'html', - '-o', '@OUTDIR@' + '/html/Python/GimpUi-' + gimp_api_version, - '@OUTDIR@' + '/pages/Python/GimpUi-' + gimp_api_version, - ], - build_by_default: true) + gir_ui_docs_cache = custom_target('g-ir-GimpUi-' + lang + '-cache', + input: [ gir_ui_docs_pages ], + output: [ 'GimpUi-' + lang + '-cache' ], + command: [ + yelp_build, 'cache', + '-o', '@OUTDIR@' + '/pages/' + lang + '/GimpUi-' + gimp_api_version + '/index.cache', + '@OUTDIR@' + '/pages/' + lang + '/GimpUi-' + gimp_api_version, + ], + build_by_default: true) + + gir_ui_docs_html = custom_target('g-ir-GimpUi-' + lang + '-html', + input: [ gir_ui_docs_cache ], + output: [ 'GimpUi-' + lang + '-html' ], + #install_dir: prefix / gimpdatadir / 'g-ir-docs/html/' + lang + '/GimpUi', + #install: true, + command: [ + 'yelp-build', 'html', + '-o', '@OUTDIR@' + '/html/' + lang + '/GimpUi-' + gimp_api_version, + '@OUTDIR@' + '/pages/' + lang + '/GimpUi-' + gimp_api_version, + ], + build_by_default: true) + +endforeach ## TODO: a unit test using yelp-check would be useful.