all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
blob 12b9d42ef21132a2cd351b3578beb02862657414 9397 bytes (raw)
name: gnu/packages/patches/git-filter-repo-generate-doc.patch 	 # note: path name is non-authoritative(*)

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
 
From 7c66e1d4a8076f5b0cc29e5c05637ba1363a6bd7 Mon Sep 17 00:00:00 2001
Message-Id: <7c66e1d4a8076f5b0cc29e5c05637ba1363a6bd7.1685797909.git.dev@jpoiret.xyz>
From: Josselin Poiret <dev@jpoiret.xyz>
Date: Sat, 3 Jun 2023 13:07:07 +0200
Subject: [PATCH] Add documentation generation.

From: Josselin Poiret <dev@jpoiret.xyz>

This uses the manpage XSL and asciidoc config files from git 2.40.1.
---
 .gitignore                             |  1 +
 Documentation/Makefile                 | 38 +++++++++++++
 Documentation/asciidoc.conf            | 78 ++++++++++++++++++++++++++
 Documentation/manpage-base-url.xsl.in  | 10 ++++
 Documentation/manpage-bold-literal.xsl | 16 ++++++
 Documentation/manpage-normal.xsl       | 26 +++++++++
 Documentation/manpage-quote-apos.xsl   | 16 ++++++
 Makefile                               | 17 +-----
 8 files changed, 188 insertions(+), 14 deletions(-)
 create mode 100644 Documentation/Makefile
 create mode 100644 Documentation/asciidoc.conf
 create mode 100644 Documentation/manpage-base-url.xsl.in
 create mode 100644 Documentation/manpage-bold-literal.xsl
 create mode 100644 Documentation/manpage-normal.xsl
 create mode 100644 Documentation/manpage-quote-apos.xsl

diff --git a/.gitignore b/.gitignore
index cd5ded4..e167ef7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,6 @@
 /Documentation/html/
 /Documentation/man1/
+/Documentation/manpage-base-url.xsl
 /t/test-results
 /t/trash directory*
 /__pycache__/
diff --git a/Documentation/Makefile b/Documentation/Makefile
new file mode 100644
index 0000000..d4cd939
--- /dev/null
+++ b/Documentation/Makefile
@@ -0,0 +1,38 @@
+MAN_BASE_URL := /usr/share/doc/git-doc/
+VERSION := $(git log --pretty="%H" -n 1)
+
+ASCIIDOC := asciidoc
+ASCIIDOC_EXTRA :=
+ASCIIDOC_HTML := xhtml11
+ASCIIDOC_DOCBOOK := docbook
+ASCIIDOC_CONF := -f asciidoc.conf
+ASCIIDOC_COMMON := $(ASCIIDOC) $(ASCIIDOC_EXTRA) $(ASCIIDOC_CONF) \
+		-amanversion='$(VERSION)' \
+		-amanmanual='git-filter-repo Manual' -amansource='git-filter-repo'
+ASCIIDOC_DEPS := asciidoc.conf
+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 := -m manpage-bold-literal.xsl -m manpage-base-url.xsl -m manpage-quote-apos.xsl
+XMLTO_DEPS := manpage-bold-literal.xsl manpage-base-url.xsl manpage-quote-apos.xsl
+
+manpage-deps := $(XMLTO_DEPS)
+manpage-cmd := $(XMLTO) -m $(MANPAGE_XSL) $(XMLTO_EXTRA) man
+
+manpage-base-url.xsl: manpage-base-url.xsl.in
+	sed "s|@@MAN_BASE_URL@@|$(MAN_BASE_URL)|" $< > $@
+
+%.xml : %.txt $(ASCIIDOC_DEPS)
+	$(QUIET_ASCIIDOC)$(TXT_TO_XML) -d manpage -o $@ $<
+
+man1/%.1 : %.xml $(manpage-deps)
+	mkdir -p man1
+	$(manpage-cmd) -o man1 $<
+
+html/%.html : %.txt $(ASCIIDOC_DEPS)
+	mkdir -p html
+	$(TXT_TO_HTML) -d manpage -o $@ $<
+
+man: man1/git-filter-repo.1
+html: html/git-filter-repo.html
diff --git a/Documentation/asciidoc.conf b/Documentation/asciidoc.conf
new file mode 100644
index 0000000..3e4c139
--- /dev/null
+++ b/Documentation/asciidoc.conf
@@ -0,0 +1,78 @@
+## linkgit: macro
+#
+# Usage: linkgit:command[manpage-section]
+#
+# Note, {0} is the manpage section, while {target} is the command.
+#
+# Show Git link as: <command>(<section>); if section is defined, else just show
+# the command.
+
+[macros]
+(?su)[\\]?(?P<name>linkgit):(?P<target>\S*?)\[(?P<attrlist>.*?)\]=
+
+[attributes]
+asterisk=&#42;
+plus=&#43;
+caret=&#94;
+startsb=&#91;
+endsb=&#93;
+backslash=&#92;
+tilde=&#126;
+apostrophe=&#39;
+backtick=&#96;
+litdd=&#45;&#45;
+
+ifdef::backend-docbook[]
+[linkgit-inlinemacro]
+{0%{target}}
+{0#<citerefentry>}
+{0#<refentrytitle>{target}</refentrytitle><manvolnum>{0}</manvolnum>}
+{0#</citerefentry>}
+endif::backend-docbook[]
+
+ifdef::backend-docbook[]
+ifdef::doctype-manpage[]
+# The following two small workarounds insert a simple paragraph after screen
+[listingblock]
+<example><title>{title}</title>
+<literallayout class="monospaced">
+|
+</literallayout><simpara></simpara>
+{title#}</example>
+
+[verseblock]
+<formalpara{id? id="{id}"}><title>{title}</title><para>
+{title%}<literallayout{id? id="{id}"}>
+{title#}<literallayout>
+|
+</literallayout>
+{title#}</para></formalpara>
+{title%}<simpara></simpara>
+endif::doctype-manpage[]
+endif::backend-docbook[]
+
+ifdef::doctype-manpage[]
+ifdef::backend-docbook[]
+[header]
+template::[header-declarations]
+<refentry>
+<refmeta>
+<refentrytitle>{mantitle}</refentrytitle>
+<manvolnum>{manvolnum}</manvolnum>
+<refmiscinfo class="source">{mansource}</refmiscinfo>
+<refmiscinfo class="version">{manversion}</refmiscinfo>
+<refmiscinfo class="manual">{manmanual}</refmiscinfo>
+</refmeta>
+<refnamediv>
+  <refname>{manname}</refname>
+  <refpurpose>{manpurpose}</refpurpose>
+</refnamediv>
+endif::backend-docbook[]
+endif::doctype-manpage[]
+
+ifdef::backend-xhtml11[]
+[attributes]
+git-relative-html-prefix=
+[linkgit-inlinemacro]
+<a href="{git-relative-html-prefix}{target}.html">{target}{0?({0})}</a>
+endif::backend-xhtml11[]
diff --git a/Documentation/manpage-base-url.xsl.in b/Documentation/manpage-base-url.xsl.in
new file mode 100644
index 0000000..e800904
--- /dev/null
+++ b/Documentation/manpage-base-url.xsl.in
@@ -0,0 +1,10 @@
+<!-- manpage-base-url.xsl:
+     special settings for manpages rendered from newer docbook -->
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+		version="1.0">
+
+<!-- set a base URL for relative links -->
+<xsl:param name="man.base.url.for.relative.links"
+	>@@MAN_BASE_URL@@</xsl:param>
+
+</xsl:stylesheet>
diff --git a/Documentation/manpage-bold-literal.xsl b/Documentation/manpage-bold-literal.xsl
new file mode 100644
index 0000000..e13db85
--- /dev/null
+++ b/Documentation/manpage-bold-literal.xsl
@@ -0,0 +1,16 @@
+<!-- manpage-bold-literal.xsl:
+     special formatting for manpages rendered from asciidoc+docbook -->
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+		xmlns:d="http://docbook.org/ns/docbook"
+		version="1.0">
+
+<!-- render literal text as bold (instead of plain or monospace);
+     this makes literal text easier to distinguish in manpages
+     viewed on a tty -->
+<xsl:template match="literal|d:literal">
+	<xsl:text>\fB</xsl:text>
+	<xsl:apply-templates/>
+	<xsl:text>\fR</xsl:text>
+</xsl:template>
+
+</xsl:stylesheet>
diff --git a/Documentation/manpage-normal.xsl b/Documentation/manpage-normal.xsl
new file mode 100644
index 0000000..a9c7ec6
--- /dev/null
+++ b/Documentation/manpage-normal.xsl
@@ -0,0 +1,26 @@
+<!-- manpage-normal.xsl:
+     special settings for manpages rendered from asciidoc+docbook -->
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+		version="1.0">
+
+
+<!-- these params silence some output from xmlto -->
+<xsl:param name="man.output.quietly" select="1"/>
+<xsl:param name="refentry.meta.get.quietly" select="1"/>
+
+<!-- convert asciidoc callouts to man page format -->
+<xsl:template match="co">
+	<xsl:value-of select="concat('\fB(',substring-after(@id,'-'),')\fR')"/>
+</xsl:template>
+<xsl:template match="calloutlist">
+	<xsl:text>.sp&#10;</xsl:text>
+	<xsl:apply-templates/>
+	<xsl:text>&#10;</xsl:text>
+</xsl:template>
+<xsl:template match="callout">
+	<xsl:value-of select="concat('\fB',substring-after(@arearefs,'-'),'. \fR')"/>
+	<xsl:apply-templates/>
+	<xsl:text>.br&#10;</xsl:text>
+</xsl:template>
+
+</xsl:stylesheet>
diff --git a/Documentation/manpage-quote-apos.xsl b/Documentation/manpage-quote-apos.xsl
new file mode 100644
index 0000000..aeb8839
--- /dev/null
+++ b/Documentation/manpage-quote-apos.xsl
@@ -0,0 +1,16 @@
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+		version="1.0">
+
+<!-- work around newer groff/man setups using a prettier apostrophe
+     that unfortunately does not quote anything when cut&pasting
+     examples to the shell -->
+<xsl:template name="escape.apostrophe">
+  <xsl:param name="content"/>
+  <xsl:call-template name="string.subst">
+    <xsl:with-param name="string" select="$content"/>
+    <xsl:with-param name="target">'</xsl:with-param>
+    <xsl:with-param name="replacement">\(aq</xsl:with-param>
+  </xsl:call-template>
+</xsl:template>
+
+</xsl:stylesheet>
diff --git a/Makefile b/Makefile
index a443450..d965ae5 100644
--- a/Makefile
+++ b/Makefile
@@ -20,21 +20,10 @@ test:
 fixup_locale:
 	sed -ie s%@@LOCALEDIR@@%$(localedir)% git-filter-repo
 
-# People installing from tarball will already have man1/git-filter-repo.1 and
-# html/git-filter-repo.html.  But let's support people installing from a git
-# clone too; for them, just cheat and snag a copy of the built docs that I
-# record in a different branch.
-snag_docs: Documentation/man1/git-filter-repo.1 Documentation/html/git-filter-repo.html
+doc:
+	$(MAKE) -C Documentation man html
 
-Documentation/man1/git-filter-repo.1:
-	mkdir -p Documentation/man1
-	git show origin/docs:man1/git-filter-repo.1 >Documentation/man1/git-filter-repo.1
-
-Documentation/html/git-filter-repo.html:
-	mkdir -p Documentation/html
-	git show origin/docs:html/git-filter-repo.html >Documentation/html/git-filter-repo.html
-
-install: snag_docs #fixup_locale
+install: doc #fixup_locale
 	install -Dm0755 git-filter-repo "$(DESTDIR)/$(bindir)/git-filter-repo"
 	install -dm0755 "$(DESTDIR)/$(pythondir)"
 	ln -sf "$(bindir)/git-filter-repo" "$(DESTDIR)/$(pythondir)/git_filter_repo.py"
-- 
2.40.1


debug log:

solving 12b9d42ef2 ...
found 12b9d42ef2 in https://yhetil.org/guix/c99aef38ef5d4fa8bf8f7f2bda3afe1a11168c0c.1685800921.git.dev@jpoiret.xyz/

applying [1/1] https://yhetil.org/guix/c99aef38ef5d4fa8bf8f7f2bda3afe1a11168c0c.1685800921.git.dev@jpoiret.xyz/
diff --git a/gnu/packages/patches/git-filter-repo-generate-doc.patch b/gnu/packages/patches/git-filter-repo-generate-doc.patch
new file mode 100644
index 0000000000..12b9d42ef2

1:270: space before tab in indent.
 	sed -ie s%@@LOCALEDIR@@%$(localedir)% git-filter-repo
1:271: trailing whitespace.
 
1:279: trailing whitespace.
 
1:290: space before tab in indent.
 	install -Dm0755 git-filter-repo "$(DESTDIR)/$(bindir)/git-filter-repo"
1:291: space before tab in indent.
 	install -dm0755 "$(DESTDIR)/$(pythondir)"
Checking patch gnu/packages/patches/git-filter-repo-generate-doc.patch...
Applied patch gnu/packages/patches/git-filter-repo-generate-doc.patch cleanly.
warning: squelched 3 whitespace errors
warning: 8 lines add whitespace errors.

index at:
100644 12b9d42ef21132a2cd351b3578beb02862657414	gnu/packages/patches/git-filter-repo-generate-doc.patch

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.