From 1f9fa64ea3cc3e307283ccf8bd277561804051cb Mon Sep 17 00:00:00 2001
From: Christoph Haag <christoph.haag@collabora.com>
Date: Tue, 13 Aug 2019 04:36:31 +0200
Subject: [PATCH] doc: Add documentation build

---
 doc/libinputsynth-docs.xml     | 40 +++++++++++++++++++++++
 doc/libinputsynth-sections.txt | 60 ++++++++++++++++++++++++++++++++++
 doc/meson.build                | 43 ++++++++++++++++++++++++
 doc/xml/gtkdocentities.ent.in  |  8 +++++
 doc/xml/meson.build            | 10 ++++++
 meson.build                    | 12 +++++++
 meson_options.txt              |  7 ++++
 src/inputsynth.c               |  6 ++--
 src/inputsynth.h               |  3 --
 src/meson.build                | 22 +++++++++++++
 10 files changed, 205 insertions(+), 6 deletions(-)
 create mode 100644 doc/libinputsynth-docs.xml
 create mode 100644 doc/libinputsynth-sections.txt
 create mode 100644 doc/meson.build
 create mode 100644 doc/xml/gtkdocentities.ent.in
 create mode 100644 doc/xml/meson.build
 create mode 100644 meson_options.txt

diff --git a/doc/libinputsynth-docs.xml b/doc/libinputsynth-docs.xml
new file mode 100644
index 0000000..38d9c24
--- /dev/null
+++ b/doc/libinputsynth-docs.xml
@@ -0,0 +1,40 @@
+<?xml version="1.0"?>
+<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
+               "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd"
+[
+  <!ENTITY % local.common.attrib "xmlns:xi  CDATA  #FIXED 'http://www.w3.org/2003/XInclude'">
+]>
+<book id="index">
+  <bookinfo>
+    <title>Libinputsynth Reference Manual</title>
+    <releaseinfo>
+      <para>This document is the API reference for the Libinputsynth library.</para>
+      <para>
+        The latest version of Libinputsynth, as well as the latest version of
+        this API reference, is <ulink role="online-location" url="https://gitlab.freedesktop.org/xrdesktop/libinputsynth">available online</ulink>.
+      </para>
+    </releaseinfo>
+  </bookinfo>
+
+  <chapter>
+    <title>libinputsynth</title>
+
+    <refsect2 id="overview">
+      <para>
+        libinputsynth is a library for synthesizing mouse and keyboard events
+        on X11 and wayland.
+      </para>
+    </refsect2>
+
+  <xi:include href="xml/inputsynth.xml"/>
+
+  </chapter>
+  <index id="api-index">
+    <title>API Index</title>
+    <xi:include href="xml/api-index-full.xml"><xi:fallback /></xi:include>
+  </index>
+
+  <!--
+  <xi:include href="xml/annotation-glossary.xml"><xi:fallback /></xi:include>
+  -->
+</book>
diff --git a/doc/libinputsynth-sections.txt b/doc/libinputsynth-sections.txt
new file mode 100644
index 0000000..fb3fcbd
--- /dev/null
+++ b/doc/libinputsynth-sections.txt
@@ -0,0 +1,60 @@
+<SECTION>
+<FILE>inputsynth</FILE>
+<TITLE>InputSynth</TITLE>
+INPUT_TYPE_SYNTH
+InputSynthClass
+InputsynthBackend
+input_synth_new
+input_synth_move_cursor
+input_synth_click
+input_synth_character
+input_synth_get_backend_name
+InputSynth
+</SECTION>
+
+<SECTION>
+<FILE>inputsynth-version</FILE>
+DESKTOP_INPUT_SYNTHESIZER_MAJOR_VERSION
+DESKTOP_INPUT_SYNTHESIZER_MINOR_VERSION
+DESKTOP_INPUT_SYNTHESIZER_MICRO_VERSION
+DESKTOP_INPUT_SYNTHESIZER_VERSION
+DESKTOP_INPUT_SYNTHESIZER_VERSION_S
+DESKTOP_INPUT_SYNTHESIZER_ENCODE_VERSION
+DESKTOP_INPUT_SYNTHESIZER_VERSION_HEX
+DESKTOP_INPUT_SYNTHESIZER_CHECK_VERSION
+</SECTION>
+
+<SECTION>
+<FILE>inputsynth-wayland-clutter</FILE>
+<TITLE>InputSynthWaylandClutter</TITLE>
+INPUT_TYPE_SYNTH_WAYLAND_CLUTTER
+InputSynthWaylandClutterClass
+input_synth_wayland_clutter_new
+InputSynthWaylandClutter
+</SECTION>
+
+<SECTION>
+<FILE>inputsynth-x11-helper</FILE>
+init_helper_x11
+</SECTION>
+
+<SECTION>
+<FILE>inputsynth-xdo</FILE>
+<TITLE>InputSynthXdo</TITLE>
+INPUT_TYPE_SYNTH_XDO
+InputSynthXdoClass
+InputSynthXdo
+</SECTION>
+
+<SECTION>
+<FILE>inputsynth-xi2</FILE>
+<TITLE>InputSynthXi2</TITLE>
+INPUT_SYNTH_MASTER_CREATE_NAME
+INPUT_SYNTH_MASTER_NAME
+INPUT_SYNTH_SLAVE_NAME
+INPUT_SYNTH_KEYBOARD_SLAVE_NAME
+INPUT_TYPE_SYNTH_XI2
+InputSynthXi2Class
+InputSynthXi2
+</SECTION>
+
diff --git a/doc/meson.build b/doc/meson.build
new file mode 100644
index 0000000..6bbdd8a
--- /dev/null
+++ b/doc/meson.build
@@ -0,0 +1,43 @@
+subdir('xml')
+
+private_headers = [
+  'config.h',
+  'inputsynth-version.h',
+  'inputsynth-wayland-clutter.h',
+  'inputsynth-xdo.h',
+  'inputsynth-xi2.h'
+]
+
+modules = [
+  'inputsynth-wayland-clutter.c',
+  'inputsynth-xdo.c',
+  'inputsynth-xi2.c'
+]
+
+glib_prefix = dependency('glib-2.0').get_pkgconfig_variable('prefix')
+glib_docpath = join_paths(glib_prefix, 'share', 'gtk-doc', 'html')
+docpath = join_paths(inputsynth_datadir, 'gtk-doc', 'html')
+
+gnome.gtkdoc('libinputsynth',
+  main_xml: 'libinputsynth-docs.xml',
+  src_dir: [
+    src_inc,
+  ],
+  dependencies: inputsynth_dep,
+
+  scan_args: [
+    '--rebuild-types',
+    '--ignore-headers=' + ' '.join(private_headers)
+  ],
+  mkdb_args: [
+    '--default-include=inputsynth.h',
+  ],
+  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, 'graphene')),
+  ],
+  # html_assets: html_images,
+  install: true,
+)
diff --git a/doc/xml/gtkdocentities.ent.in b/doc/xml/gtkdocentities.ent.in
new file mode 100644
index 0000000..f12c9ff
--- /dev/null
+++ b/doc/xml/gtkdocentities.ent.in
@@ -0,0 +1,8 @@
+<!ENTITY package "@PACKAGE@">
+<!ENTITY package_bugreport "@PACKAGE_BUGREPORT@">
+<!ENTITY package_name "@PACKAGE_NAME@">
+<!ENTITY package_string "@PACKAGE_STRING@">
+<!ENTITY package_tarname "@PACKAGE_TARNAME@">
+<!ENTITY package_url "@PACKAGE_URL@">
+<!ENTITY package_version "@PACKAGE_VERSION@">
+<!ENTITY package_api_version "@PACKAGE_API_VERSION@">
diff --git a/doc/xml/meson.build b/doc/xml/meson.build
new file mode 100644
index 0000000..a176f7a
--- /dev/null
+++ b/doc/xml/meson.build
@@ -0,0 +1,10 @@
+ent_conf = configuration_data()
+ent_conf.set('PACKAGE', 'libinputsynth')
+ent_conf.set('PACKAGE_BUGREPORT', 'https://gitlab.freedesktop.org/xrdesktop/libinputsynth')
+ent_conf.set('PACKAGE_NAME', 'libinputsynth')
+ent_conf.set('PACKAGE_STRING', 'libinputsynth')
+ent_conf.set('PACKAGE_TARNAME', 'libinputsynth-' + meson.project_version())
+ent_conf.set('PACKAGE_URL', 'https://gitlab.freedesktop.org/xrdesktop/libinputsynth')
+ent_conf.set('PACKAGE_VERSION', meson.project_version())
+ent_conf.set('PACKAGE_API_VERSION', api_version)
+configure_file(input: 'gtkdocentities.ent.in', output: 'gtkdocentities.ent', configuration: ent_conf)
diff --git a/meson.build b/meson.build
index 543ed37..82a99e6 100644
--- a/meson.build
+++ b/meson.build
@@ -2,6 +2,7 @@ project('libinputsynth', 'c', version: '0.12.1',
   meson_version: '>= 0.45.1',
 )
 
+gnome = import('gnome')
 
 config_h = configuration_data()
 config_h.set_quoted('PACKAGE_VERSION', meson.project_version())
@@ -38,6 +39,13 @@ endif
 
 add_project_arguments([project_args], language: ['c'])
 
+# Paths
+inputsynth_prefix = get_option('prefix')
+inputsynth_libdir = join_paths(inputsynth_prefix, get_option('libdir'))
+inputsynth_includedir = join_paths(inputsynth_prefix, get_option('includedir'))
+inputsynth_datadir = join_paths(inputsynth_prefix, get_option('datadir'))
+src_inc = include_directories('src')
+
 gio_dep = dependency('gio-2.0', version: '>= 2.50')
 glib_dep = dependency('glib-2.0')
 gmodule_dep = dependency('gmodule-2.0')
@@ -58,3 +66,7 @@ endif
 subdir('src')
 subdir('examples')
 subdir('tests')
+
+if get_option('api_doc')
+    subdir('doc')
+endif
diff --git a/meson_options.txt b/meson_options.txt
new file mode 100644
index 0000000..752cc26
--- /dev/null
+++ b/meson_options.txt
@@ -0,0 +1,7 @@
+option('api_doc',
+  type: 'boolean',
+  value: false,
+  description: 'Build API documentation using GTK-Doc'
+)
+
+option('introspection', type : 'boolean', value : false)
diff --git a/src/inputsynth.c b/src/inputsynth.c
index 145612a..b5f03ab 100644
--- a/src/inputsynth.c
+++ b/src/inputsynth.c
@@ -143,7 +143,7 @@ input_synth_move_cursor (InputSynth *self, int x, int y)
  * @x: The x coordinate to click at (may have no effect depending on backend)
  * @y: The y coordinate to click at (may have no effect depending on backend)
  * @button: The button to click.
- * Usual Bindings:
+ * The usual bindings are:
  *  * Button 1: Left Click
  *  * Button 2: Right Click
  *  * Button 3: Middle (Mouse Wheel) Click
@@ -165,7 +165,7 @@ input_synth_click (InputSynth *self, int x, int y,
 /**
  * input_synth_character:
  * @self: The #InputSynth
- * @c: The ASCII character to input.
+ * @c: The ASCII character to synthesize.
  */
 void
 input_synth_character (InputSynth *self, char c)
@@ -179,7 +179,7 @@ input_synth_character (InputSynth *self, char c)
  * input_synth_get_backend_name:
  * @self: The #InputSynth
  * Returns: A purely informational descriptive name for the backend
- * currently in use. Can be used to test if loading of backend succeeds.
+ * currently in use. Useful when testing backend loading.
  */
 GString *
 input_synth_get_backend_name (InputSynth *self)
diff --git a/src/inputsynth.h b/src/inputsynth.h
index ff0189c..6495e7e 100644
--- a/src/inputsynth.h
+++ b/src/inputsynth.h
@@ -20,11 +20,8 @@ struct _InputSynthClass
 {
   GObjectClass parent_class;
   void (*move_cursor) (InputSynth *self, int x, int y);
-
   void (*click) (InputSynth *self, int x, int y, int button, gboolean press);
-
   void (*character) (InputSynth *self, char c);
-
   GString * (*get_backend_name) (InputSynth *self);
 };
 
diff --git a/src/meson.build b/src/meson.build
index d15492d..cbe22cd 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -135,3 +135,25 @@ if mutter_clutter_dep.found()
   )
 endif
 
+inputsynth_dep = declare_dependency(
+  sources: [],
+  link_with: inputsynth_lib,
+  include_directories: [ inputsynth_inc ],
+  dependencies: inputsynth_deps,
+)
+
+if get_option('introspection')
+  inputsynth_gir = gnome.generate_gir(
+    inputsynth_lib,
+    sources: inputsynth_sources + inputsynth_headers,
+    namespace: 'libinputsynth',
+    nsversion: api_version,
+    identifier_prefix: 'libinputsynth',
+    symbol_prefix: 'libinputsynth',
+    export_packages: api_path,
+    includes: [ ],
+    header: 'libinputsynth/inputsynth.h',
+    install: true,
+  )
+endif
+
-- 
GitLab