From 5892a48a64ce6357ee8fcb6d44d148513296d12a Mon Sep 17 00:00:00 2001 From: Bilal Elmoussaoui Date: Thu, 30 Mar 2023 00:24:06 +0200 Subject: [PATCH] build: Add gi-docgen based docs option --- docs/Mks.toml.in | 52 +++++++++++++++++++++++++++++++++++++++++++++++ docs/meson.build | 42 ++++++++++++++++++++++++++++++++++++++ docs/urlmap.js | 8 ++++++++ meson.build | 4 ++++ meson_options.txt | 4 ++++ 5 files changed, 110 insertions(+) create mode 100644 docs/Mks.toml.in create mode 100644 docs/meson.build create mode 100644 docs/urlmap.js diff --git a/docs/Mks.toml.in b/docs/Mks.toml.in new file mode 100644 index 0000000..fbf67ab --- /dev/null +++ b/docs/Mks.toml.in @@ -0,0 +1,52 @@ +[library] +version = "@version@" +browse_url = "https://gitlab.gnome.org/chergert/libmks" +repository_url = "https://gitlab.gnome.org/chergert/libmks.git" +website_url = "https://gitlab.gnome.org/chergert/libmks" +docs_url = "https://chergert.pages.gitlab.gnome.org/libmks/" +authors = "Christian Hergert" +license = "LGPL-2.1-or-later" +description = "Mouse, Keyboard, and Screen to Qemu" +dependencies = [ "GObject-2.0", "Gdk-4.0", "Gtk-4.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/" + + [dependencies."Gdk-4.0"] + name = "Gdk" + description = "The GTK windowing system abstraction" + docs_url = "https://docs.gtk.org/gdk4/" + + [dependencies."Gtk-4.0"] + name = "Gtk" + description = "The GTK toolkit" + docs_url = "https://docs.gtk.org/gtk4/" + +[theme] +name = "basic" +show_index_summary = true +show_class_hierarchy = true + +[source-location] +base_url = "https://gitlab.gnome.org/chergert/libmks/-/blob/main/" + +[extra] +content_files = [ +] + +urlmap_file = "urlmap.js" + diff --git a/docs/meson.build b/docs/meson.build new file mode 100644 index 0000000..836d2c8 --- /dev/null +++ b/docs/meson.build @@ -0,0 +1,42 @@ +toml_conf = configuration_data() +toml_conf.set('version', meson.project_version()) + +gidocgen = find_program('gi-docgen') + +gidocgen_common_args = [ + '--quiet', + '--no-namespace-dir', +] + +if get_option('werror') + gidocgen_common_args += ['--fatal-warnings'] +endif + +docs_dir = get_option('datadir') / 'doc' + +if get_option('docs') + source_toml = configure_file( + input: 'Mks.toml.in', + output: 'Mks.toml', + configuration: toml_conf, + install: true, + install_dir: docs_dir / 'libmks1', + ) + + custom_target('mks-doc', + input: [ source_toml, libmks_gir[0] ], + output: 'libmks1', + 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/docs/urlmap.js b/docs/urlmap.js new file mode 100644 index 0000000..020fca6 --- /dev/null +++ b/docs/urlmap.js @@ -0,0 +1,8 @@ +baseURLs = [ + [ 'GLib', 'https://docs.gtk.org/glib/' ], + [ 'GObject', 'https://docs.gtk.org/gobject/' ], + [ 'Gio', 'https://docs.gtk.org/gio/' ], + [ 'Gdk', 'https://docs.gtk.org/gdk4/' ], + [ 'Gsk', 'https://docs.gtk.org/gsk4/' ], + [ 'Gtk', 'https://docs.gtk.org/gtk4/' ], +] diff --git a/meson.build b/meson.build index b5c8970..846d632 100644 --- a/meson.build +++ b/meson.build @@ -155,4 +155,8 @@ add_project_link_arguments(project_link_args, language: 'c') subdir('lib') subdir('tools') +if get_option('docs') + subdir('docs') +endif + configure_file(output: 'config.h', configuration: config_h) diff --git a/meson_options.txt b/meson_options.txt index e0fd6da..0500d4c 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -1 +1,5 @@ option('install-tools', type: 'boolean', value: false) + +option('docs', + type: 'boolean', value: false, + description: 'Build reference manual')