[json-glib] Build API reference with Meson



commit f33d681c51aa2fd9754e8282889fb86dd30291e4
Author: Emmanuele Bassi <ebassi gnome org>
Date:   Mon Mar 13 12:10:10 2017 +0000

    Build API reference with Meson
    
    We can use the gnome module to generate the JSON-GLib API reference.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=773603

 doc/reference/json-glib-docs.xml        |   11 ++++++---
 doc/reference/meson.build               |   34 +++++++++++++++++++++++++++++++
 doc/reference/xml/gtkdocentities.ent.in |    8 +++++++
 doc/reference/xml/meson.build           |   11 ++++++++++
 json-glib/meson.build                   |    2 +-
 meson.build                             |    8 +++++++
 meson_options.txt                       |    8 ++++--
 7 files changed, 74 insertions(+), 8 deletions(-)
---
diff --git a/doc/reference/json-glib-docs.xml b/doc/reference/json-glib-docs.xml
index ed5ce65..5a07fd2 100644
--- a/doc/reference/json-glib-docs.xml
+++ b/doc/reference/json-glib-docs.xml
@@ -1,13 +1,16 @@
 <?xml version="1.0"?>
-<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN" 
-               "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd"; [
-<!ENTITY version SYSTEM "version.xml">
+<!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'">
+  <!ENTITY % gtkdocentities SYSTEM "xml/gtkdocentities.ent">
+  %gtkdocentities;
 ]>
 
 <book id="index" xmlns:xi="http://www.w3.org/2003/XInclude";>
   <bookinfo>
     <title>JSON-GLib Reference Manual</title>
-    <releaseinfo>for JSON-GLib &version;</releaseinfo>
+    <releaseinfo>for JSON-GLib &package_api_version;</releaseinfo>
 
     <copyright>
       <year>2007, 2008</year>
diff --git a/doc/reference/meson.build b/doc/reference/meson.build
new file mode 100644
index 0000000..95a7860
--- /dev/null
+++ b/doc/reference/meson.build
@@ -0,0 +1,34 @@
+subdir('xml')
+
+private_headers = [
+  'json-debug.h',
+  'json-enum-types.h',
+  'json-glib.h',
+  'json-gobject-private.h',
+  'json-marshal.h',
+  'json-private.h',
+  'json-scanner.h',
+  'json-types-private.h',
+]
+
+glib_prefix = dependency('glib-2.0').get_pkgconfig_variable('prefix')
+glib_docpath = join_paths(glib_prefix, 'share', 'gtk-doc', 'html')
+docpath = join_paths(json_datadir, 'gtk-doc', 'html')
+
+gnome.gtkdoc('json-glib',
+             main_xml: 'json-glib-docs.xml',
+             src_dir: [ join_paths(meson.source_root(), 'json-glib'), join_paths(meson.build_root(), 
'json-glib'), ],
+             dependencies: json_glib_dep,
+             gobject_typesfile: 'json-glib.types',
+             scan_args: [
+               '--rebuild-types',
+               '--ignore-decorators=_JSON_EXTERN',
+               '--ignore-headers=' + ' '.join(private_headers),
+             ],
+             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')),
+             ],
+             install: true)
diff --git a/doc/reference/xml/gtkdocentities.ent.in b/doc/reference/xml/gtkdocentities.ent.in
new file mode 100644
index 0000000..f12c9ff
--- /dev/null
+++ b/doc/reference/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/reference/xml/meson.build b/doc/reference/xml/meson.build
new file mode 100644
index 0000000..668435a
--- /dev/null
+++ b/doc/reference/xml/meson.build
@@ -0,0 +1,11 @@
+ent_conf = configuration_data()
+ent_conf.set('PACKAGE', 'JSON-GLib')
+ent_conf.set('PACKAGE_BUGREPORT', 'https://bugzilla.gnome.org/enter_bug.cgi?product=json-glib')
+ent_conf.set('PACKAGE_NAME', 'JSON-GLib')
+ent_conf.set('PACKAGE_STRING', 'json-glib')
+ent_conf.set('PACKAGE_TARNAME', 'json-glib-' + meson.project_version())
+ent_conf.set('PACKAGE_URL', 'http://wiki.gnome.org/Project/JsonGlib')
+ent_conf.set('PACKAGE_VERSION', meson.project_version())
+ent_conf.set('PACKAGE_API_VERSION', apiversion)
+configure_file(input: 'gtkdocentities.ent.in', output: 'gtkdocentities.ent', configuration: ent_conf)
+
diff --git a/json-glib/meson.build b/json-glib/meson.build
index 87a40c8..41bbb74 100644
--- a/json-glib/meson.build
+++ b/json-glib/meson.build
@@ -1,5 +1,5 @@
 install_header_subdir = 'json-glib-1.0/json-glib'
-install_header_dir = join_paths(get_option('includedir'), install_header_subdir)
+install_header_dir = join_paths(json_includedir, install_header_subdir)
 
 configure_file(output: 'config.h', configuration: cdata)
 
diff --git a/meson.build b/meson.build
index a2cdcb2..4ae49d3 100644
--- a/meson.build
+++ b/meson.build
@@ -31,6 +31,10 @@ current = json_version_minor.to_int() * 100 + json_version_micro.to_int() - json
 revision = json_interface_age
 libversion = '@0@.@1@.@2@'.format(soversion, current, revision)
 
+# Paths
+json_includedir = join_paths(get_option('prefix'), get_option('includedir'))
+json_datadir = join_paths(get_option('prefix'), get_option('datadir'))
+
 # Dependencies
 glib_req_version = '>= 2.37.6'
 gobject_dep = dependency('gobject-2.0', version: glib_req_version)
@@ -73,3 +77,7 @@ gir = find_program('g-ir-scanner', required: false)
 build_gir = gir.found() and not meson.is_cross_build() and not get_option('disable_introspection')
 
 subdir('json-glib')
+
+if get_option('enable-gtk-doc')
+  subdir('doc/reference')
+endif
diff --git a/meson_options.txt b/meson_options.txt
index dc0aab7..7b04911 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -1,4 +1,6 @@
 option('disable_introspection',
-        type : 'boolean', value : false,
-        description : 'Whether to disable the introspection generation')
-
+        type: 'boolean', value: false,
+        description: 'Whether to disable the introspection generation')
+option('enable-gtk-doc',
+       type: 'boolean', value: false,
+       description: 'Whether to generate the API reference for JSON-GLib')


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