Skip to content

Commit 8ef3497

Browse files
committed
Merge branch 'bc/use-asciidoctor-opt' into pu
Asciidoctor, an alternative reimplementation of AsciiDoc, still needs some changes to work with documents meant to be formatted with AsciiDoc. "make USE_ASCIIDOCTOR=YesPlease" to use it out of the box to document our pages is getting closer to reality. * bc/use-asciidoctor-opt: Makefile: add a knob to enable the use of Asciidoctor Documentation: move dblatex arguments into variable Documentation: add XSLT to fix DocBook for Texinfo Documentation: sort sources for gitman.texi Documentation: remove unneeded argument in cat-texi.perl Documentation: modernize cat-texi.perl Documentation: fix warning in cat-texi.perl
2 parents 135daf8 + ec3366e commit 8ef3497

File tree

4 files changed

+62
-13
lines changed

4 files changed

+62
-13
lines changed

Documentation/Makefile

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ INSTALL_INFO = install-info
120120
DOCBOOK2X_TEXI = docbook2x-texi
121121
DBLATEX = dblatex
122122
ASCIIDOC_DBLATEX_DIR = /etc/asciidoc/dblatex
123+
DBLATEX_COMMON = -p $(ASCIIDOC_DBLATEX_DIR)/asciidoc-dblatex.xsl -s $(ASCIIDOC_DBLATEX_DIR)/asciidoc-dblatex.sty
123124
ifndef PERL_PATH
124125
PERL_PATH = /usr/bin/perl
125126
endif
@@ -173,6 +174,18 @@ ifdef GNU_ROFF
173174
XMLTO_EXTRA += -m manpage-quote-apos.xsl
174175
endif
175176

177+
ifdef USE_ASCIIDOCTOR
178+
ASCIIDOC = asciidoctor
179+
ASCIIDOC_CONF =
180+
ASCIIDOC_HTML = xhtml5
181+
ASCIIDOC_DOCBOOK = docbook45
182+
ifdef ASCIIDOCTOR_EXTENSIONS_LAB
183+
ASCIIDOC_EXTRA = -I$(ASCIIDOCTOR_EXTENSIONS_LAB) -rasciidoctor/extensions -rman-inline-macro
184+
endif
185+
ASCIIDOC_EXTRA += -alitdd='&\#x2d;&\#x2d;'
186+
DBLATEX_COMMON =
187+
endif
188+
176189
SHELL_PATH ?= $(SHELL)
177190
# Shell quote;
178191
SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
@@ -368,13 +381,14 @@ user-manual.texi: user-manual.xml
368381

369382
user-manual.pdf: user-manual.xml
370383
$(QUIET_DBLATEX)$(RM) $@+ $@ && \
371-
$(DBLATEX) -o $@+ -p $(ASCIIDOC_DBLATEX_DIR)/asciidoc-dblatex.xsl -s $(ASCIIDOC_DBLATEX_DIR)/asciidoc-dblatex.sty $< && \
384+
$(DBLATEX) -o $@+ $(DBLATEX_COMMON) $< && \
372385
mv $@+ $@
373386

374-
gitman.texi: $(MAN_XML) cat-texi.perl
387+
gitman.texi: $(MAN_XML) cat-texi.perl texi.xsl
375388
$(QUIET_DB2TEXI)$(RM) $@+ $@ && \
376-
($(foreach xml,$(MAN_XML),$(DOCBOOK2X_TEXI) --encoding=UTF-8 \
377-
--to-stdout $(xml) &&) true) > $@++ && \
389+
($(foreach xml,$(sort $(MAN_XML)),xsltproc -o $(xml)+ texi.xsl $(xml) && \
390+
$(DOCBOOK2X_TEXI) --encoding=UTF-8 --to-stdout $(xml)+ && \
391+
rm $(xml)+ &&) true) > $@++ && \
378392
$(PERL_PATH) cat-texi.perl $@ <$@++ >$@+ && \
379393
rm $@++ && \
380394
mv $@+ $@

Documentation/cat-texi.perl

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,26 @@
11
#!/usr/bin/perl -w
22

3+
use strict;
4+
use warnings;
5+
36
my @menu = ();
47
my $output = $ARGV[0];
58

6-
open TMP, '>', "$output.tmp";
9+
open my $tmp, '>', "$output.tmp";
710

811
while (<STDIN>) {
912
next if (/^\\input texinfo/../\@node Top/);
1013
next if (/^\@bye/ || /^\.ft/);
1114
if (s/^\@top (.*)/\@node $1,,,Top/) {
1215
push @menu, $1;
1316
}
14-
s/\(\@pxref{\[(URLS|REMOTES)\]}\)//;
17+
s/\(\@pxref\{\[(URLS|REMOTES)\]}\)//;
1518
s/\@anchor\{[^{}]*\}//g;
16-
print TMP;
19+
print $tmp $_;
1720
}
18-
close TMP;
21+
close $tmp;
1922

20-
printf '\input texinfo
23+
print '\input texinfo
2124
@setfilename gitman.info
2225
@documentencoding UTF-8
2326
@dircategory Development
@@ -28,16 +31,16 @@
2831
@top Git Manual Pages
2932
@documentlanguage en
3033
@menu
31-
', $menu[0];
34+
';
3235

3336
for (@menu) {
3437
print "* ${_}::\n";
3538
}
3639
print "\@end menu\n";
37-
open TMP, '<', "$output.tmp";
38-
while (<TMP>) {
40+
open $tmp, '<', "$output.tmp";
41+
while (<$tmp>) {
3942
print;
4043
}
41-
close TMP;
44+
close $tmp;
4245
print "\@bye\n";
4346
unlink "$output.tmp";

Documentation/texi.xsl

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<!-- texi.xsl:
2+
convert refsection elements into refsect elements that docbook2texi can
3+
understand -->
4+
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
5+
version="1.0">
6+
7+
<xsl:output method="xml"
8+
encoding="UTF-8"
9+
doctype-public="-//OASIS//DTD DocBook XML V4.5//EN"
10+
doctype-system="http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" />
11+
12+
<xsl:template match="//refsection">
13+
<xsl:variable name="element">refsect<xsl:value-of select="count(ancestor-or-self::refsection)" /></xsl:variable>
14+
<xsl:element name="{$element}">
15+
<xsl:apply-templates select="@*|node()" />
16+
</xsl:element>
17+
</xsl:template>
18+
19+
<!-- Copy all other nodes through. -->
20+
<xsl:template match="node()|@*">
21+
<xsl:copy>
22+
<xsl:apply-templates select="@*|node()" />
23+
</xsl:copy>
24+
</xsl:template>
25+
26+
</xsl:stylesheet>

Makefile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,12 @@ all::
250250
# apostrophes to be ASCII so that cut&pasting examples to the shell
251251
# will work.
252252
#
253+
# Define USE_ASCIIDOCTOR to use Asciidoctor instead of AsciiDoc to build the
254+
# documentation.
255+
#
256+
# Define ASCIIDOCTOR_EXTENSIONS_LAB to point to the location of the Asciidoctor
257+
# Extensions Lab if you have it available.
258+
#
253259
# Define PERL_PATH to the path of your Perl binary (usually /usr/bin/perl).
254260
#
255261
# Define NO_PERL_MAKEMAKER if you cannot use Makefiles generated by perl's

0 commit comments

Comments
 (0)