[jsonrpc-glib/bilelmoussaoui/gi-docgen: 1/7] docs: Initial port to gi-docgen




commit 2ba41cffc59b98dabaa6fa304cb07d9abc3f29ee
Author: Bilal Elmoussaoui <belmouss redhat com>
Date:   Sat Feb 5 15:59:29 2022 +0100

    docs: Initial port to gi-docgen

 doc/Jsonrpc.toml.in | 38 ++++++++++++++++++++++++++++
 doc/meson.build     | 72 +++++++++++++++++++++++++++++------------------------
 doc/urlmap.js       |  6 +++++
 meson.build         |  4 +++
 4 files changed, 88 insertions(+), 32 deletions(-)
---
diff --git a/doc/Jsonrpc.toml.in b/doc/Jsonrpc.toml.in
new file mode 100644
index 0000000..90bed8f
--- /dev/null
+++ b/doc/Jsonrpc.toml.in
@@ -0,0 +1,38 @@
+[library]
+version = "@version@"
+browse_url = "https://gitlab.gnome.org/GNOME/jsonrpc-glib/";
+repository_url = "https://gitlab.gnome.org/GNOME/jsonrpc-glib.git";
+website_url = "https://gitlab.gnome.org/GNOME/jsonrpc-glib/";
+docs_url = "https://gnome.pages.gitlab.gnome.org/jsonrpc-glib/";
+authors = "Christian Hergert"
+license = "LGPL-2.1"
+description = "A GNOME library to communicate with JSON-RPC based peers"
+dependencies = [ "GObject-2.0", "GLib-2.0", "Gio-2.0"]
+devhelp = true
+search_index = true
+
+  [dependencies."GObject-2.0"]
+  name = "GObject"
+  description = "The base type system library"
+  docs_url = "https://docs.gtk.org/gobject/";
+
+  [dependencies."GLib-2.0"]
+  name = "GLib"
+  description = "The base type system library"
+  docs_url = "https://docs.gtk.org/glib/";
+
+  [dependencies."Gio-2.0"]
+  name = "GIO"
+  description = "GObject Interfaces and Objects, Networking, IPC, and I/O"
+  docs_url = "https://docs.gtk.org/gio/";
+
+[theme]
+name = "basic"
+show_index_summary = true
+show_class_hierarchy = true
+
+[source-location]
+base_url = "https://gitlab.gnome.org/GNOME/jsonrpc-glib/-/blob/main/";
+
+[extra]
+urlmap_file = "urlmap.js"
diff --git a/doc/meson.build b/doc/meson.build
index 98b7fb1..db4c377 100644
--- a/doc/meson.build
+++ b/doc/meson.build
@@ -1,38 +1,46 @@
-subdir('xml')
+if get_option('enable_gtk_doc') and not get_option('with_introspection')
+  error('API reference requires introspection.')
+endif
 
-private_headers = [
-  'config.h',
-  'jsonrpc-glib.h',
-  'jsonrpc-version.h',
-]
+toml_conf = configuration_data()
+toml_conf.set('version', meson.project_version())
+
+gidocgen = find_program('gi-docgen', required: get_option('enable_gtk_doc'))
 
-glib_prefix = dependency('glib-2.0').get_pkgconfig_variable('prefix')
-glib_docpath = join_paths(glib_prefix, 'share', 'gtk-doc', 'html')
-json_prefix = dependency('json-glib-1.0').get_pkgconfig_variable('prefix')
-json_docpath = join_paths(json_prefix, 'share', 'gtk-doc', 'html')
-docpath = join_paths(get_option('datadir'), 'gtk-doc', 'html')
+gidocgen_common_args = [
+  '--quiet',
+  '--no-namespace-dir',
+]
 
-gnome.gtkdoc('jsonrpc-glib',
-           main_xml: 'jsonrpc-glib-docs.sgml',
-            src_dir: [
-              join_paths(meson.source_root(), 'src'),
-              join_paths(meson.build_root(), 'src'),
-            ],
+if get_option('werror')
+  gidocgen_common_args += ['--fatal-warnings']
+endif
 
-       dependencies: libjsonrpc_glib_dep,
-  gobject_typesfile: 'jsonrpc-glib.types',
-          scan_args: [
-            '--rebuild-types',
-            '--ignore-decorators=_JSONRPC_EXTERN',
-            '--ignore-headers=' + ' '.join(private_headers),
-          ],
+docs_dir = datadir / 'doc'
 
-       fixxref_args: [
-         '--html-dir=@0@'.format(docpath),
-         '--extra-dir=@0@'.format(join_paths(glib_docpath, 'glib')),
-         '--extra-dir=@0@'.format(join_paths(glib_docpath, 'gobject')),
-         '--extra-dir=@0@'.format(join_paths(glib_docpath, 'gio')),
-         '--extra-dir=@0@'.format(json_docpath),
-       ],
-            install: true)
+if get_option('enable_gtk_doc')
+  source_toml = configure_file(
+    input: 'Jsonrpc.toml.in',
+    output: 'Jsonrpc.toml',
+    configuration: toml_conf,
+    install: true,
+    install_dir: docs_dir / 'jsonrpc-glib',
+  )
 
+  custom_target('jsonrpc-glib-doc',
+    input: [ source_toml, libjsonrpc_glib_gir[0] ],
+    output: 'jsonrpc-glib',
+    command: [
+      gidocgen,
+      'generate',
+      gidocgen_common_args,
+      '--config=@INPUT0@',
+      '--output-dir=@OUTPUT@',
+      '--content-dir=@0@'.format(meson.current_source_dir()),
+      '@INPUT1@',
+    ],
+    build_by_default: true,
+    install: true,
+    install_dir: docs_dir,
+  )
+endif
diff --git a/doc/urlmap.js b/doc/urlmap.js
new file mode 100644
index 0000000..67e8a25
--- /dev/null
+++ b/doc/urlmap.js
@@ -0,0 +1,6 @@
+// A map between namespaces and base URLs for their online documentation
+baseURLs = [
+    [ 'GLib', 'https://docs.gtk.org/glib/' ],
+    [ 'GObject', 'https://docs.gtk.org/gobject/' ],
+    [ 'Gio', 'https://docs.gtk.org/gio/' ],
+]
diff --git a/meson.build b/meson.build
index d1542b9..e212843 100644
--- a/meson.build
+++ b/meson.build
@@ -28,6 +28,10 @@ libversion = '@0@.@1@.@2@'.format(soversion, current, revision)
 
 darwin_versions = [current + 1, '@0@.@1@'.format(current + 1, revision)]
 
+prefix = get_option('prefix')
+
+datadir = join_paths(prefix, get_option('datadir'))
+
 config_h = configuration_data()
 config_h.set_quoted('GETTEXT_PACKAGE', 'libjsonrpc_glib')
 config_h.set_quoted('LOCALEDIR', join_paths(get_option('prefix'), get_option('localedir')))


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