summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKjell Ahlstedt <kjellahlstedt@gmail.com>2021-09-27 09:36:00 +0200
committerKjell Ahlstedt <kjellahlstedt@gmail.com>2021-09-27 09:36:00 +0200
commit298163aa2328c561e9cfb35768f6a18b5b74b929 (patch)
treefd94e084bd9af1fb765616caf96d94cdd72d79ad
parentf993cc89285662dc9d59b4aa1aa66929fca9f7fa (diff)
downloadsigc++-298163aa2328c561e9cfb35768f6a18b5b74b929.tar.gz
docs/docs/manual, Meson config: Check if xmllint can be used
-rw-r--r--Makefile.am1
-rw-r--r--docs/docs/manual/can_use_xmllint.xml15
-rw-r--r--docs/docs/manual/meson.build18
-rw-r--r--meson.build2
-rwxr-xr-xtools/tutorial-custom-cmd.py12
5 files changed, 46 insertions, 2 deletions
diff --git a/Makefile.am b/Makefile.am
index e10fd1b..5362033 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -50,6 +50,7 @@ EXTRA_DIST = \
meson_options.txt \
sigc++config.h.meson \
MSVC_NMake/meson.build \
+ docs/docs/manual/can_use_xmllint.xml \
docs/docs/manual/meson.build \
docs/docs/reference/meson.build \
examples/meson.build \
diff --git a/docs/docs/manual/can_use_xmllint.xml b/docs/docs/manual/can_use_xmllint.xml
new file mode 100644
index 0000000..8ff1b0d
--- /dev/null
+++ b/docs/docs/manual/can_use_xmllint.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="utf-8"?>
+<book xmlns="http://docbook.org/ns/docbook"
+ version="5.0" xml:id="index" xml:lang="en">
+
+<title>xmllint test</title>
+
+<chapter xml:id="chapter-introduction">
+<title>Introduction</title>
+ <para>
+ This is a short DocBook V5.0 document. It can be used for testing if the installed
+ version of xmllint or a similar program can validate a DocBook V5.0 document.
+ </para>
+</chapter>
+
+</book>
diff --git a/docs/docs/manual/meson.build b/docs/docs/manual/meson.build
index e3e9531..e632131 100644
--- a/docs/docs/manual/meson.build
+++ b/docs/docs/manual/meson.build
@@ -24,6 +24,24 @@ if not build_documentation
subdir_done()
endif
+# Check if xmllint can be used.
+if xmllint.found()
+ can_parse_and_validate = run_command(
+ python3, tutorial_custom_cmd, 'xmllint',
+ validate,
+ meson.current_source_dir() / 'can_use_xmllint.xml',
+ meson.current_build_dir() / 'can_use_xmllint.stamp',
+ ).returncode() == 0
+ if not can_parse_and_validate
+ # The DocBook V5.0 package is called docbook5-xml in Ubuntu,
+ # docbook5-schemas in Fedora. It may have other names in other distros.
+ warning('Can\'t validate XML file.\n' +
+ 'xmllint does not support Relax NG schemas and DocBook V5.0.\n' +
+ 'DocBook V5.0 support may require docbook5-xml, docbook5-schemas or a similar package.'
+ )
+ endif
+endif
+
doc_dist_dir = 'untracked' / 'docs' / 'docs' / 'manual' # Relative to MESON_DIST_ROOT
sigc_manual_xml = 'libsigc_manual.xml'
diff --git a/meson.build b/meson.build
index cf93d48..2e30933 100644
--- a/meson.build
+++ b/meson.build
@@ -288,7 +288,7 @@ endif
validate = get_option('validation') and can_parse_and_validate
explain_val = ''
if get_option('validation') and not validate
- explain_val = ' (requires xmllint)'
+ explain_val = ' (requires xmllint with Relax NG and DocBook V5.0 support)'
endif
build_pdf = build_pdf_by_default and can_build_pdf
diff --git a/tools/tutorial-custom-cmd.py b/tools/tutorial-custom-cmd.py
index 50b6a5b..c102968 100755
--- a/tools/tutorial-custom-cmd.py
+++ b/tools/tutorial-custom-cmd.py
@@ -65,6 +65,13 @@ def xmllint():
stamp_file_path = sys.argv[4]
relax_ng_schema = 'http://docbook.org/xml/5.0/rng/docbook.rng'
+ # schematron_schema = 'http://docbook.org/xml/5.0/sch/docbook.sch'
+
+ # Validation against the Schematron schema does not work on Ubuntu 21.04:
+ # file:///usr/share/xml/docbook/schema/schematron/5.0/docbook.sch:6: element rule:
+ # Schemas parser error : Failed to compile context expression db:firstterm[@linkend]
+ # .....
+ # Schematron schema http://docbook.org/xml/5.0/sch/docbook.sch failed to compile
cmd = [
'xmllint',
@@ -73,7 +80,10 @@ def xmllint():
'--xinclude',
]
if validate == 'true':
- cmd += ['--relaxng', relax_ng_schema]
+ cmd += [
+ '--relaxng', relax_ng_schema,
+ #'--schematron', schematron_schema,
+ ]
cmd += [input_xml_file]
result = subprocess.run(cmd)
if result.returncode: