From 5892a48a64ce6357ee8fcb6d44d148513296d12a Mon Sep 17 00:00:00 2001 From: Bilal Elmoussaoui Date: Thu, 30 Mar 2023 00:24:06 +0200 Subject: [PATCH 1/4] 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') From b3acf4d14399b288f08456b2a8346a0c6aa92021 Mon Sep 17 00:00:00 2001 From: Bilal Elmoussaoui Date: Thu, 30 Mar 2023 00:28:59 +0200 Subject: [PATCH 2/4] ci: Add a flatpak test job --- .gitlab-ci.yml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 .gitlab-ci.yml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..b63cbfc --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,15 @@ +include: + - project: "gnome/citemplates" + file: "flatpak/flatpak_ci_initiative.yml" + +stages: + - test + +flatpak: + variables: + BUNDLE: "mks-test-widget-dev.flatpak" + MANIFEST_PATH: "org.gnome.libmks.mks.json" + FLATPAK_MODULE: "mks" + RUNTIME_REPO: "https://nightly.gnome.org/gnome-nightly.flatpakrepo" + APP_ID: "org.gnome.libmks.mks" + extends: ".flatpak" From d342adf3ab8cbe897b68be954c893084a430c7ff Mon Sep 17 00:00:00 2001 From: Bilal Elmoussaoui Date: Thu, 30 Mar 2023 00:32:43 +0200 Subject: [PATCH 3/4] ci: Add a docs job --- .gitlab-ci.yml | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b63cbfc..fa18f66 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -4,6 +4,8 @@ include: stages: - test + - docs + - deploy flatpak: variables: @@ -13,3 +15,32 @@ flatpak: RUNTIME_REPO: "https://nightly.gnome.org/gnome-nightly.flatpakrepo" APP_ID: "org.gnome.libmks.mks" extends: ".flatpak" + +reference: + image: fedora:38 + stage: docs + needs: [] + variables: + MESON_FLAGS: "-Dwerror=true --buildtype=release" + before_script: + - sudo dnf install -y gtk4-devel meson gcc gi-docgen gobject-introspection-devel + script: + - mkdir -p pfx/ + - meson ${MESON_FLAGS} --prefix=${PWD}/pfx -Ddocs=true _build + - ninja -C _build install + - mkdir -p _reference/ + - mv pfx/share/doc/libmks1/ _reference/ + artifacts: + paths: + - _reference + +pages: + stage: deploy + needs: ["reference"] + script: + - mv _reference public/ + artifacts: + paths: + - public + only: + - main From c7ba1c0104a07df33f267e4a0a3f11b995c6d6d6 Mon Sep 17 00:00:00 2001 From: Bilal Elmoussaoui Date: Thu, 30 Mar 2023 13:14:41 +0200 Subject: [PATCH 4/4] build: Add an option to disable introspection --- lib/meson.build | 20 +++++++++++--------- meson.build | 2 +- meson_options.txt | 4 ++++ 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/lib/meson.build b/lib/meson.build index 6b05eac..1402c32 100644 --- a/lib/meson.build +++ b/lib/meson.build @@ -121,12 +121,14 @@ pkg.generate( install_dir: join_paths(get_option('libdir'), 'pkgconfig') ) -libmks_gir = gnome.generate_gir(libmks, - sources: libmks_sources + libmks_headers, - nsversion: api_version, - namespace: 'Mks', - symbol_prefix: 'mks', - identifier_prefix: 'Mks', - includes: ['Gio-2.0', 'Gtk-4.0'], - install: true, -) +if get_option('introspection').allowed() + libmks_gir = gnome.generate_gir(libmks, + sources: libmks_sources + libmks_headers, + nsversion: api_version, + namespace: 'Mks', + symbol_prefix: 'mks', + identifier_prefix: 'Mks', + includes: ['Gio-2.0', 'Gtk-4.0'], + install: true, + ) +endif \ No newline at end of file diff --git a/meson.build b/meson.build index 846d632..16e8362 100644 --- a/meson.build +++ b/meson.build @@ -155,7 +155,7 @@ add_project_link_arguments(project_link_args, language: 'c') subdir('lib') subdir('tools') -if get_option('docs') +if get_option('docs') and get_option('introspection').allowed() subdir('docs') endif diff --git a/meson_options.txt b/meson_options.txt index 0500d4c..2662a8d 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -3,3 +3,7 @@ option('install-tools', type: 'boolean', value: false) option('docs', type: 'boolean', value: false, description: 'Build reference manual') + +option('introspection', + type: 'feature', value: 'auto', + description: 'Generate gir data')