[libgit2-glib] doc: migrate to gi-docgen



commit 225297f1e24e67946daf2ab082934be3fe84f138
Author: Iñigo Martínez <inigomartinez gmail com>
Date:   Fri Feb 4 12:22:15 2022 +0100

    doc: migrate to gi-docgen
    
    gi-docgen is a new tool that tries to avoid some of the issues of
    gtk-doc and is also faster.
    
    gtk-doc has been replaced by gi-docgen in CI.

 .gitlab-ci.yml                               |    2 +-
 docs/reference/libgit2-glib-1.0-docs.sgml    |   74 --
 docs/reference/libgit2-glib-1.0-sections.txt | 1043 --------------------------
 docs/reference/libgit2-glib.toml.in          |   43 ++
 docs/reference/meson.build                   |   55 +-
 docs/reference/urlmap.js                     |   10 +
 docs/reference/version.xml.in                |    1 -
 meson.build                                  |    3 +
 8 files changed, 86 insertions(+), 1145 deletions(-)
---
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index f8bf32b..9353884 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -2,7 +2,7 @@ image: fedora:34
 stages:
   - build
 before_script:
-  - dnf install -y gcc meson ninja-build gettext gtk-doc glib2-devel libgit2-devel 
gobject-introspection-devel vala libssh2-devel
+  - dnf install -y gcc meson ninja-build gettext gi-docgen glib2-devel libgit2-devel 
gobject-introspection-devel vala libssh2-devel
 build-libgit2-glib:
   stage: build
   script:
diff --git a/docs/reference/libgit2-glib.toml.in b/docs/reference/libgit2-glib.toml.in
new file mode 100644
index 0000000..2677cbf
--- /dev/null
+++ b/docs/reference/libgit2-glib.toml.in
@@ -0,0 +1,43 @@
+[library]
+version = "@version@"
+browse_url = "https://gitlab.gnome.org/GNOME/libgit2-glib";
+repository_url = "https://gitlab.gnome.org/GNOME/libgit2-glib.git";
+website_url = "https://wiki.gnome.org/Projects/Libgit2-glib";
+# docs_url = "https://www.freedesktop.org/software/libmbim/libmbim-glib/latest/";
+authors = "The libgit2-glib authors"
+license = "@license@"
+description = "libgit2-glib is a glib wrapper library around the libgit2 git access library."
+dependencies = [ "Gio-2.0", "GLib-2.0", "GObject-2.0" ]
+devhelp = true
+search_index = true
+
+  [dependencies."Gio-2.0"]
+  name = "Gio"
+  description = "GObject interfaces and objects"
+  docs_url = "https://docs.gtk.org/gio/";
+
+  [dependencies."GLib-2.0"]
+  name = "GLib"
+  description = "The base type system library"
+  docs_url = "https://docs.gtk.org/glib/";
+
+  [dependencies."GObject-2.0"]
+  name = "GObject"
+  description = "The base type system library"
+  docs_url = "https://docs.gtk.org/gobject/";
+
+
+[theme]
+name = "basic"
+show_index_summary = true
+show_class_hierarchy = true
+
+[source-location]
+base_url = "https://gitlab.gnome.org/GNOME/libgit2-glib/-/blob/master/";
+
+[extra]
+# The same order will be used when generating the index
+content_files = []
+content_images = []
+
+urlmap_file = "urlmap.js"
diff --git a/docs/reference/meson.build b/docs/reference/meson.build
index ea6b0af..58e8161 100644
--- a/docs/reference/meson.build
+++ b/docs/reference/meson.build
@@ -1,32 +1,35 @@
-glib_prefix = glib_dep.get_pkgconfig_variable('prefix')
+doc_module = meson.project_name()
 
-fixxref_args = [
-  '--extra-dir=' + join_paths(glib_prefix, gnome.gtkdoc_html_dir('glib')),
-  '--extra-dir=' + join_paths(glib_prefix, gnome.gtkdoc_html_dir('gobject')),
-  '--extra-dir=' + join_paths(glib_prefix, gnome.gtkdoc_html_dir('gio')),
-  '--html-dir=' + join_paths(libgit2_glib_prefix, gnome.gtkdoc_html_dir(libgit2_glib_api_name)),
-]
+toml_conf = {
+  'version': libgit2_glib_version,
+  'license': ','.join(meson.project_license()),
+}
 
-docs_conf = configuration_data()
-docs_conf.set('PACKAGE_VERSION', libgit2_glib_version)
-
-name = 'version.xml'
-
-content_files = configure_file(
-  input: name + '.in',
-  output: name,
-  configuration: docs_conf,
+libgit2_glib_toml = configure_file(
+  input: doc_module + '.toml.in',
+  output: '@BASENAME@',
+  configuration: toml_conf,
 )
 
-gnome.gtkdoc(
-  libgit2_glib_api_name,
-  main_sgml: libgit2_glib_api_name + '-docs.sgml',
-  src_dir: join_paths(meson.source_root(), 'libgit2-glib'),
-  dependencies: libgit2_glib_dep,
-  ignore_headers: private_headers,
-  gobject_typesfile: libgit2_glib_api_name + '.types',
-  scan_args: '--rebuild-types',
-  fixxref_args: fixxref_args,
-  content_files: content_files,
+custom_target(
+  doc_module + '-doc',
+  input: [
+    libgit2_glib_toml,
+    libgit2_glib_gir,
+  ],
+  output: libgit2_glib_api_name,
+  command: [
+    find_program('gi-docgen'),
+    'generate',
+    '--quiet',
+    '--no-namespace-dir',
+    '--add-include-path=@0@'.format(join_paths(source_root, 'libgit2-glib')),
+    '--config=@INPUT0@',
+    '--output-dir=@OUTPUT@',
+    '--content-dir=@0@'.format(meson.current_source_dir()),
+    '@INPUT1@',
+  ],
+  build_by_default: true,
   install: true,
+  install_dir: gnome.gtkdoc_html_dir(''),
 )
diff --git a/docs/reference/urlmap.js b/docs/reference/urlmap.js
new file mode 100644
index 0000000..e0e0928
--- /dev/null
+++ b/docs/reference/urlmap.js
@@ -0,0 +1,10 @@
+// SPDX-FileCopyrightText: 2022 Iñigo Martinez <inigomartinez gmail com>
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+// A map between namespaces and base URLs for their online documentation
+baseURLs = [
+    [ 'Gio', 'https://docs.gtk.org/gio/' ],
+    [ 'GLib', 'https://docs.gtk.org/glib/' ],
+    [ 'GObject', 'https://docs.gtk.org/gobject/' ],
+    [ 'libgit2', 'https://libgit2.org/libgit2/' ],
+]
diff --git a/meson.build b/meson.build
index ddac357..7a473cb 100644
--- a/meson.build
+++ b/meson.build
@@ -46,6 +46,8 @@ libgit2_glib_pkgincludedir = join_paths(get_option('includedir'), libgit2_glib_a
 gnome = import('gnome')
 pkg = import('pkgconfig')
 
+source_root = meson.current_source_dir()
+
 top_inc = include_directories('.')
 
 cc = meson.get_compiler('c')
@@ -169,5 +171,6 @@ subdir('examples')
 subdir('tests')
 
 if get_option('gtk_doc')
+  assert(enable_gir, 'documentation generation support requested but introspection is disabled. Please use 
-Dgtk_doc=false.')
   subdir('docs/reference')
 endif


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]