From 21ac6ff143cc8bebfbd1818af28e8c6f82cd5265 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Wed, 12 Feb 2014 00:55:38 -0500 Subject: [PATCH] man: use xinclude to de-deduplicate common text I only tested with python-lxml. I'm not sure if xml.etree should be deprecated. --- Makefile.am | 3 ++- man/journalctl.xml | 23 +++-------------------- man/less-variables.xml | 29 +++++++++++++++++++++++++++++ man/localectl.xml | 23 +++-------------------- man/loginctl.xml | 23 +++-------------------- man/machinectl.xml | 23 +++-------------------- man/systemctl.xml | 25 +++---------------------- man/systemd-analyze.xml | 25 +++---------------------- man/timedatectl.xml | 23 +++-------------------- tools/xml_helper.py | 22 +++++++++++++--------- 10 files changed, 65 insertions(+), 154 deletions(-) create mode 100644 man/less-variables.xml diff --git a/Makefile.am b/Makefile.am index 6a3fd4853..09547d32d 100644 --- a/Makefile.am +++ b/Makefile.am @@ -4645,7 +4645,7 @@ if ENABLE_MANPAGES man/custom-entities.ent: $(AM_V_GEN)$(MKDIR_P) $(dir $@) $(AM_V_GEN)(echo '' && \ - echo '$(subst '|,,$(substitutions))))') \ + printf '$(subst '|,\n,$(substitutions))))') \ > $@ # ' DISTCLEANFILES += \ @@ -4653,6 +4653,7 @@ DISTCLEANFILES += \ XSLTPROC_FLAGS = \ --nonet \ + --xinclude \ --stringparam man.output.quietly 1 \ --stringparam funcsynopsis.style ansi \ --stringparam man.authors.section.enabled 0 \ diff --git a/man/journalctl.xml b/man/journalctl.xml index 18a1b9ef2..8890c64a4 100644 --- a/man/journalctl.xml +++ b/man/journalctl.xml @@ -21,7 +21,8 @@ along with systemd; If not, see . --> - + journalctl @@ -875,25 +876,7 @@ failure code is returned. - - Environment - - - - $SYSTEMD_PAGER - Pager to use when - is not given; - overrides $PAGER. Setting - this to an empty string or the value - cat is equivalent to passing - . - $SYSTEMD_LESS - $SYSTEMD_LESS overrides the - default options passed to less - (FRSXMK). - - - + Examples diff --git a/man/less-variables.xml b/man/less-variables.xml new file mode 100644 index 000000000..09cbd42c2 --- /dev/null +++ b/man/less-variables.xml @@ -0,0 +1,29 @@ + + + + + Environment + + + + $SYSTEMD_PAGER + + Pager to use when + is not given; + overrides $PAGER. Setting + this to an empty string or the value + cat is equivalent to passing + . + + + + $SYSTEMD_LESS + + Override the default + options passed to + less + (FRSXMK). + + + diff --git a/man/localectl.xml b/man/localectl.xml index 238757c2e..09e8d41e7 100644 --- a/man/localectl.xml +++ b/man/localectl.xml @@ -21,7 +21,8 @@ along with systemd; If not, see . --> - + localectl @@ -253,25 +254,7 @@ code otherwise. - - Environment - - - - $SYSTEMD_PAGER - Pager to use when - is not given; - overrides $PAGER. Setting - this to an empty string or the value - cat is equivalent to passing - . - $SYSTEMD_LESS - $SYSTEMD_LESS overrides the - default options passed to less - (FRSXMK). - - - + See Also diff --git a/man/loginctl.xml b/man/loginctl.xml index ede869f39..38f099edc 100644 --- a/man/loginctl.xml +++ b/man/loginctl.xml @@ -21,7 +21,8 @@ along with systemd; If not, see . --> - + loginctl @@ -474,25 +475,7 @@ code otherwise. - - Environment - - - - $SYSTEMD_PAGER - Pager to use when - is not given; - overrides $PAGER. Setting - this to an empty string or the value - cat is equivalent to passing - . - $SYSTEMD_LESS - $SYSTEMD_LESS overrides the - default options passed to less - (FRSXMK). - - - + See Also diff --git a/man/machinectl.xml b/man/machinectl.xml index 2e7fa3bf8..5c30c449d 100644 --- a/man/machinectl.xml +++ b/man/machinectl.xml @@ -21,7 +21,8 @@ along with systemd; If not, see . --> - + machinectl @@ -299,25 +300,7 @@ code otherwise. - - Environment - - - - $SYSTEMD_PAGER - Pager to use when - is not given; - overrides $PAGER. Setting - this to an empty string or the value - cat is equivalent to passing - . - $SYSTEMD_LESS - $SYSTEMD_LESS overrides the - default options passed to less - (FRSXMK). - - - + See Also diff --git a/man/systemctl.xml b/man/systemctl.xml index 1b0f8e5e2..906399c3b 100644 --- a/man/systemctl.xml +++ b/man/systemctl.xml @@ -21,7 +21,8 @@ You should have received a copy of the GNU Lesser General Public License along with systemd; If not, see . --> - + systemctl @@ -1465,27 +1466,7 @@ kobject-uevent 1 systemd-udevd-kernel.socket systemd-udevd.service code otherwise. - - Environment - - - - $SYSTEMD_PAGER - - - Pager to use when is not - given; overrides $PAGER. Setting this to - an empty string or the value cat is - equivalent to passing - . - - $SYSTEMD_LESS - $SYSTEMD_LESS overrides the - default options passed to less - (FRSXMK). - - - + See Also diff --git a/man/systemd-analyze.xml b/man/systemd-analyze.xml index 54479e487..de6c2bee2 100644 --- a/man/systemd-analyze.xml +++ b/man/systemd-analyze.xml @@ -21,7 +21,8 @@ along with systemd; If not, see . --> - + systemd-analyze @@ -321,27 +322,7 @@ $ eog targets.svg - - Environment - - - - $SYSTEMD_PAGER - - - Pager to use when is not - given; overrides $PAGER. Setting this to - an empty string or the value cat is - equivalent to passing - . - - $SYSTEMD_LESS - $SYSTEMD_LESS overrides the - default options passed to less - (FRSXMK). - - - + See Also diff --git a/man/timedatectl.xml b/man/timedatectl.xml index be66993e1..6bf277d69 100644 --- a/man/timedatectl.xml +++ b/man/timedatectl.xml @@ -21,7 +21,8 @@ along with systemd; If not, see . --> - + timedatectl @@ -227,25 +228,7 @@ code otherwise. - - Environment - - - - $SYSTEMD_PAGER - Pager to use when - is not given; - overrides $PAGER. Setting - this to an empty string or the value - cat is equivalent to passing - . - $SYSTEMD_LESS - $SYSTEMD_LESS overrides the - default options passed to less - (FRSXMK). - - - + Examples diff --git a/tools/xml_helper.py b/tools/xml_helper.py index 08e226fa2..0d91a17bb 100644 --- a/tools/xml_helper.py +++ b/tools/xml_helper.py @@ -17,19 +17,23 @@ # You should have received a copy of the GNU Lesser General Public License # along with systemd; If not, see . -try: - from lxml import etree as tree +from lxml import etree as tree - class CustomResolver(tree.Resolver): - def resolve(self, url, id, context): - if 'custom-entities.ent' in url: - return self.resolve_filename('man/custom-entities.ent', context) +class CustomResolver(tree.Resolver): + def resolve(self, url, id, context): + if 'custom-entities.ent' in url: + return self.resolve_filename('man/custom-entities.ent', context) +try: _parser = tree.XMLParser() _parser.resolvers.add(CustomResolver()) - xml_parse = lambda page: tree.parse(page, _parser) - xml_print = lambda xml: tree.tostring(xml, pretty_print=True, - encoding='utf-8') + def xml_parse(page): + doc = tree.parse(page, _parser) + doc.xinclude() + return doc + def xml_print(xml): + return tree.tostring(xml, pretty_print=True, encoding='utf-8') + except ImportError: import xml.etree.ElementTree as tree import re as _re -- 2.30.2