git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[RFC PATCH 06/12] doc: add gen-stylesheet helper

From
Felipe Contreras <felipe.contreras@gmail.com>
Date
Apr 13, 2023, 11:57 UTC
Message-ID
<20230413115745.116063-7-felipe.contreras@gmail.com>
In-Reply-To
<20230413115745.116063-1-felipe.contreras@gmail.com>

Move most of the logic of xmlto into a simple script that generates a single stylesheet.

There should be no functional changes.
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 Documentation/.gitignore     |  1 +
 Documentation/Makefile       | 12 +++++-------
 Documentation/gen-stylesheet | 17 +++++++++++++++++
 t/t0600-doc-tools.sh         |  4 +++-
 4 files changed, 26 insertions(+), 8 deletions(-)
 create mode 100755 Documentation/gen-stylesheet
diff --git a/Documentation/.gitignore b/Documentation/.gitignore
index a48448de32..afec7e7f19 100644
--- a/Documentation/.gitignore
+++ b/Documentation/.gitignore
@@ -15,3 +15,4 @@ tmp-doc-diff/
 GIT-ASCIIDOCFLAGS
 /.build/
 /GIT-EXCLUDED-PROGRAMS
+/manpage.xsl
diff --git a/Documentation/Makefile b/Documentation/Makefile
index 3fab7ce9cd..96d3f52c60 100644
--- a/Documentation/Makefile
+++ b/Documentation/Makefile
@@ -155,7 +155,6 @@ ASCIIDOC_COMMON = $(ASCIIDOC) $(ASCIIDOC_EXTRA) $(ASCIIDOC_CONF) \
 ASCIIDOC_DEPS = asciidoc.conf GIT-ASCIIDOCFLAGS
 TXT_TO_HTML = $(ASCIIDOC_COMMON) -b $(ASCIIDOC_HTML)
 TXT_TO_XML = $(ASCIIDOC_COMMON) -b $(ASCIIDOC_DOCBOOK)
-MANPAGE_XSL = manpage-normal.xsl
 XMLTO = xmlto
 XMLTO_EXTRA =
 INSTALL ?= install
@@ -176,10 +175,6 @@ endif
 -include ../config.mak.autogen
 -include ../config.mak
 
-ifndef NO_MAN_BOLD_LITERAL
-XMLTO_EXTRA += -m manpage-bold-literal.xsl
-endif
-
 # Newer DocBook stylesheet emits warning cruft in the output when
 # this is not set, and if set it shows an absolute link.  Older
 # stylesheets simply ignore this parameter.
@@ -338,8 +333,11 @@ $(MAN_HTML): %.html : %.txt $(ASCIIDOC_DEPS)
 $(OBSOLETE_HTML): %.html : %.txto $(ASCIIDOC_DEPS)
 	$(QUIET_ASCIIDOC)$(TXT_TO_HTML) -o $@ $<
 
-manpage-prereqs := $(wildcard manpage*.xsl)
-manpage-cmd = $(QUIET_XMLTO)$(XMLTO) -m $(MANPAGE_XSL) $(XMLTO_EXTRA) man $<
+manpage-prereqs := manpage.xsl $(wildcard manpage*.xsl)
+manpage-cmd = $(QUIET_XMLTO)$(XMLTO) -x manpage.xsl $(XMLTO_EXTRA) man $<
+
+manpage.xsl: gen-stylesheet
+	./gen-stylesheet >"$@"
 
 %.1 : %.xml $(manpage-prereqs)
 	$(manpage-cmd)
diff --git a/Documentation/gen-stylesheet b/Documentation/gen-stylesheet
new file mode 100755
index 0000000000..c006a85c39
--- /dev/null
+++ b/Documentation/gen-stylesheet
@@ -0,0 +1,17 @@
+#!/bin/sh
+
+includes='manpage-normal.xsl'
+test -z "$NO_MAN_BOLD_LITERAL" && includes="$includes manpage-bold-literal.xsl"
+
+cat <<EOF
+<?xml version="1.0"?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
+<xsl:import href="http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl"/>
+EOF
+
+for x in $includes
+do
+	printf '<xsl:include href="%s"/>\n' "$x"
+done
+
+echo "</xsl:stylesheet>"
diff --git a/t/t0600-doc-tools.sh b/t/t0600-doc-tools.sh
index 2552b0d376..a003686c2f 100755
--- a/t/t0600-doc-tools.sh
+++ b/t/t0600-doc-tools.sh
@@ -54,10 +54,12 @@ description
 Part of the \fBgit\fR(1) suite
 EOF
 
+"$doc_dir"/gen-stylesheet >"$doc_dir"/manpage.xsl
+
 xmltoman() {
 	base="$1"
 	shift
-	xmlto --skip-validation -m "$doc_dir/manpage-normal.xsl" -m "$doc_dir/manpage-bold-literal.xsl" "$@" man "$base.xml"
+	xmlto --skip-validation -x "$doc_dir"/manpage.xsl man "$base.xml"
 }
 
 build_asciidoc_py() {
-- 
2.40.0+fc1
Previous: Felipe ContrerasNext: Felipe Contreras
Message 7 of 13 in “doc: add tests and reimplement xmlto”
  1. 00/12 doc: add tests and reimplement xmltoFelipe Contreras, Apr 13, 2023
  2. 01/12 doc: add test for doc tools outputFelipe Contreras, Apr 13, 2023
  3. 02/12 doc: add missing manpage docinfoFelipe Contreras, Apr 13, 2023
  4. 03/12 doc: remove unnecessary hack for asciidoctorFelipe Contreras, Apr 13, 2023
  5. 04/12 test: doc: add test for docbook5Felipe Contreras, Apr 13, 2023
  6. 05/12 doc: fix support for multiple docbook backendsFelipe Contreras, Apr 13, 2023
  7. 06/12 doc: add gen-stylesheet helperFelipe Contreras, Apr 13, 2023
  8. 07/12 doc: get rid of xmlto dependencyFelipe Contreras, Apr 13, 2023
  9. 08/12 test: doc: use temporary stylesheetFelipe Contreras, Apr 13, 2023
  10. 09/12 doc: remove references to xmltoFelipe Contreras, Apr 13, 2023
  11. 10/12 doc: stylesheet: move all the xslt templatesFelipe Contreras, Apr 13, 2023
  12. 11/12 test: doc: add check for calloutsFelipe Contreras, Apr 13, 2023
  13. 12/12 doc: manpage: remove callout hackFelipe Contreras, Apr 13, 2023

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.