[gtkmm-documentation] meson.build: Build PDF file with dblatex
- From: Kjell Ahlstedt <kjellahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtkmm-documentation] meson.build: Build PDF file with dblatex
- Date: Mon, 6 May 2019 15:16:59 +0000 (UTC)
commit df698dff6c6bc0520bee1ec1977031f5c4f6b6dc
Author: Kjell Ahlstedt <kjellahlstedt gmail com>
Date: Mon May 6 17:13:08 2019 +0200
meson.build: Build PDF file with dblatex
docs/tutorial/meson.build | 44 ++++++++++---------------------
meson.build | 2 +-
tools/meson_aux/tutorial-custom-cmd.sh | 48 +++++++++++++++++++++++++++++++---
3 files changed, 59 insertions(+), 35 deletions(-)
---
diff --git a/docs/tutorial/meson.build b/docs/tutorial/meson.build
index 7e664fd..169c54d 100644
--- a/docs/tutorial/meson.build
+++ b/docs/tutorial/meson.build
@@ -4,6 +4,7 @@
# output: can_parse_and_validate, build_translations_by_default, can_build_translations,
# build_pdf_by_default, can_build_pdf, tutorial_languages
+# xsltproc is required because it is called by tutorial_custom_cmd_sh html.
xsltproc = find_program('xsltproc', required: true)
perl = find_program('perl', required: true)
xmllint = find_program('xmllint', required: false)
@@ -15,8 +16,9 @@ can_build_translations = find_program('msgfmt', required: false).found() and \
build_translations_by_default = get_option('build-translations')
validate = get_option('validation') ? 'true' : 'false'
-can_build_pdf = find_program('docbook2pdf', required: false).found() and \
- xmllint.found()
+dblatex = find_program('dblatex', required: false)
+can_build_pdf = dblatex.found() or (xmllint.found() and \
+ find_program('docbook2pdf', required: false).found())
build_pdf_by_default = get_option('build-pdf')
tutorial_languages = ['cs', 'de', 'el', 'es', 'fr', 'pt_BR', 'sl', 'zh_CN']
@@ -131,24 +133,6 @@ foreach i : tutorial_iconfiles
tutorial_icons += join_paths('icons', i)
endforeach
-# Set the use.id.as.filename param so that we don't use the chapter / section
-# number as the filename, otherwise the url will change every time anything is
-# re-ordered or inserted in the documentation
-xslt_params = [
- '--param', 'toc.section.depth', '1',
- '--stringparam', 'html.stylesheet', 'style.css',
- '--stringparam', 'admon.graphics', '1',
- '--stringparam', 'admon.graphics.path', 'icons/',
- '--stringparam', 'admon.graphics.extension', '.png',
- '--stringparam', 'chunker.output.indent', 'yes',
- '--stringparam', 'chunker.output.encoding', 'UTF-8',
- '--stringparam', 'navig.graphics', 'yes',
- '--stringparam', 'navig.graphics.extension', '.png',
- '--stringparam', 'navig.graphics.path', 'icons/',
- '--stringparam', 'toc.list.type', 'ul',
- '--stringparam', 'use.id.as.filename', '1',
-]
-
# Create a DocBook C locale XML file with the examples' source code included.
index_docbook = custom_target('index.docbook',
input: join_paths('C', 'index-in.docbook'),
@@ -168,13 +152,11 @@ custom_target('html_index.html',
input: index_docbook,
output: 'html',
command: [
- xsltproc,
- xslt_params,
- '-o', '@OUTPUT@/',
- '--xinclude',
- '--catalogs',
- 'http://docbook.sourceforge.net/release/xsl/current/html/chunk.xsl',
+ tutorial_custom_cmd_sh, 'html',
+ 'html',
+ meson.current_build_dir(),
'@INPUT@',
+ '@OUTPUT@',
],
build_by_default: true,
install: true,
@@ -199,7 +181,7 @@ endif
if can_build_translations
# Create XML files with translations.
foreach lang : tutorial_languages
- # Create .mo files.
+ # Create .mo file.
po2mo = custom_target(lang + '-po2mo',
input: join_paths(lang, lang + '.po'),
output: lang + '_mo.stamp',
@@ -214,12 +196,12 @@ if can_build_translations
build_by_default: build_translations_by_default,
)
- # Create XML files.
+ # Create XML file.
lang_index_docbook = custom_target(lang + '-index.docbook',
input: [po2mo, index_docbook],
output: lang + '_docbook.stamp',
command: [
- tutorial_custom_cmd_sh, 'docbook',
+ tutorial_custom_cmd_sh, 'xmltrans',
join_paths(meson.current_build_dir(), lang, lang + '.mo'),
'@INPUT1@',
join_paths(meson.current_build_dir(), lang),
@@ -247,11 +229,13 @@ endif # can_build_translations
if can_build_pdf
# Create a PDF file of the C locale's version of the DocBook.
+ # Prefer dblatex, if both dblatex and docbook2pdf are available.
custom_target('C-pdf',
input: index_docbook,
output: 'programming-with-gtkmm.pdf',
command: [
- tutorial_custom_cmd_sh, 'pdf',
+ tutorial_custom_cmd_sh,
+ dblatex.found() ? 'dblatex' : 'docbook2pdf',
'@INPUT@',
join_paths(meson.current_source_dir(), 'C', 'figures'),
'@OUTPUT@'
diff --git a/meson.build b/meson.build
index e95b047..f1e70dd 100644
--- a/meson.build
+++ b/meson.build
@@ -74,7 +74,7 @@ endif
build_pdf = build_pdf_by_default and can_build_pdf
explain_pdf = ''
if build_pdf_by_default and not build_pdf
- explain_pdf = ' (requires xmllint and docbook2pdf)'
+ explain_pdf = ' (requires dblatex or (xmllint and docbook2pdf))'
endif
summary = [
diff --git a/tools/meson_aux/tutorial-custom-cmd.sh b/tools/meson_aux/tutorial-custom-cmd.sh
index 878b9df..d134183 100755
--- a/tools/meson_aux/tutorial-custom-cmd.sh
+++ b/tools/meson_aux/tutorial-custom-cmd.sh
@@ -3,13 +3,41 @@
# External command, intended to be called with custom_target() in meson.build
case $1 in
+html)
+ # tutorial-custom-cmd.sh html <relative_dir_name> <build_dir> <input_xml_file> <output_html_dir>
+
+ # Set the use.id.as.filename param so that we don't use the chapter / section
+ # number as the filename, otherwise the url will change every time anything is
+ # re-ordered or inserted in the documentation.
+ # For a list of available parameters, see http://docbook.sourceforge.net/release/xsl/current/doc/html/
+ xslt_params='
+ --param toc.section.depth 1
+ --stringparam html.stylesheet style.css
+ --stringparam admon.graphics 1
+ --stringparam admon.graphics.path icons/
+ --stringparam admon.graphics.extension .png
+ --stringparam chunker.output.indent yes
+ --stringparam chunker.output.encoding UTF-8
+ --stringparam navig.graphics yes
+ --stringparam navig.graphics.extension .png
+ --stringparam navig.graphics.path icons/
+ --stringparam toc.list.type ul
+ --stringparam use.id.as.filename 1'
+ xslt_stylesheet='http://docbook.sourceforge.net/release/xsl/current/html/chunk.xsl'
+
+ ( cd "$3"; rm --force --recursive "$2"; mkdir --parents "$2" )
+ # Don't use grep instead of sed. grep returns a non-zero exit status if no line
+ # is selected, which is the normal case.
+ set -o pipefail # Return the exit status of xsltproc, if sed succeeds.
+ xsltproc $xslt_params -o "$5/" --xinclude $xslt_stylesheet "$4" |& sed '/^Writing /d'
+ ;;
po2mo)
# tutorial-custom-cmd.sh po2mo <relative_dir_name> <build_dir> <input_po_file> <output_mo_file>
<stamp_file_path>
( cd "$3"; mkdir --parents "$2" )
msgfmt -o "$5" "$4"
touch "$6"
;;
-docbook)
+xmltrans)
# tutorial-custom-cmd.sh docbook <input_mo_file> <input_xml_file> <output_xml_dir> <stamp_file_path>
# Create XML file with translation.
itstool -m "$2" -o "$4" "$3"
@@ -24,8 +52,20 @@ xmllint)
xmllint --noout --noent --xinclude $validate "$3"
touch "$4"
;;
-pdf)
- # tutorial-custom-cmd.sh pdf <input_xml_file> <figures_dir> <output_pdf_file>
+dblatex)
+ # tutorial-custom-cmd.sh dblatex <input_xml_file> <figures_dir> <output_pdf_file>
+ # Create a PDF file, using dblatex.
+
+ # For a list of available parameters, see http://dblatex.sourceforge.net/doc/manual/
+ dblatex_params='
+ -P toc.section.depth=2
+ -P paper.type=a4paper'
+ figures_dir_parent="$(dirname "$3")"
+ dblatex $dblatex_params -I "$figures_dir_parent" -o "$4" --pdf "$2"
+ ;;
+docbook2pdf)
+ # tutorial-custom-cmd.sh docbook2pdf <input_xml_file> <figures_dir> <output_pdf_file>
+ # Create a PDF file, using docbook2pdf.
output_dir="$(dirname "$4")"
output_basename="$(basename -s .pdf "$4")"
xml_file="$output_dir/$output_basename.xml"
@@ -34,7 +74,7 @@ pdf)
xmllint --xinclude --postvalid --output "$xml_file" "$2"
# We also need to copy the figures from the source directory, so they
- # can be found from the XML files.
+ # can be found from the XML file.
cp --preserve --recursive "$3" "$output_dir/$(basename "$3")"
docbook2pdf --output "$output_dir" "$xml_file"
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]