Skip to content

Commit 70c1cbf

Browse files
committed
Merge branch 'ma/asciidoctor-refmiscinfo'
Update support for Asciidoctor documentation toolchain. * ma/asciidoctor-refmiscinfo: doc-diff: replace --cut-header-footer with --cut-footer asciidoctor-extensions: provide `<refmiscinfo/>` Doc/Makefile: give mansource/-version/-manual attributes
2 parents 8476507 + 83b0b89 commit 70c1cbf

File tree

4 files changed

+30
-13
lines changed

4 files changed

+30
-13
lines changed

Documentation/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,8 @@ ASCIIDOC_HTML = xhtml11
123123
ASCIIDOC_DOCBOOK = docbook
124124
ASCIIDOC_CONF = -f asciidoc.conf
125125
ASCIIDOC_COMMON = $(ASCIIDOC) $(ASCIIDOC_EXTRA) $(ASCIIDOC_CONF) \
126-
-agit_version=$(GIT_VERSION)
126+
-amanversion=$(GIT_VERSION) \
127+
-amanmanual='Git Manual' -amansource='Git'
127128
TXT_TO_HTML = $(ASCIIDOC_COMMON) -b $(ASCIIDOC_HTML)
128129
TXT_TO_XML = $(ASCIIDOC_COMMON) -b $(ASCIIDOC_DOCBOOK)
129130
MANPAGE_XSL = manpage-normal.xsl

Documentation/asciidoc.conf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,9 @@ template::[header-declarations]
7878
<refmeta>
7979
<refentrytitle>{mantitle}</refentrytitle>
8080
<manvolnum>{manvolnum}</manvolnum>
81-
<refmiscinfo class="source">Git</refmiscinfo>
82-
<refmiscinfo class="version">{git_version}</refmiscinfo>
83-
<refmiscinfo class="manual">Git Manual</refmiscinfo>
81+
<refmiscinfo class="source">{mansource}</refmiscinfo>
82+
<refmiscinfo class="version">{manversion}</refmiscinfo>
83+
<refmiscinfo class="manual">{manmanual}</refmiscinfo>
8484
</refmeta>
8585
<refnamediv>
8686
<refname>{manname}</refname>

Documentation/asciidoctor-extensions.rb

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,26 @@ def process(parent, target, attrs)
2020
end
2121
end
2222
end
23+
24+
class DocumentPostProcessor < Asciidoctor::Extensions::Postprocessor
25+
def process document, output
26+
if document.basebackend? 'docbook'
27+
mansource = document.attributes['mansource']
28+
manversion = document.attributes['manversion']
29+
manmanual = document.attributes['manmanual']
30+
new_tags = "" \
31+
"<refmiscinfo class=\"source\">#{mansource}</refmiscinfo>\n" \
32+
"<refmiscinfo class=\"version\">#{manversion}</refmiscinfo>\n" \
33+
"<refmiscinfo class=\"manual\">#{manmanual}</refmiscinfo>\n"
34+
output = output.sub(/<\/refmeta>/, new_tags + "</refmeta>")
35+
end
36+
output
37+
end
38+
end
2339
end
2440
end
2541

2642
Asciidoctor::Extensions.register do
2743
inline_macro Git::Documentation::LinkGitProcessor, :linkgit
44+
postprocessor Git::Documentation::DocumentPostProcessor
2845
end

Documentation/doc-diff

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ asciidoc use asciidoc with both commits
2121
to-asciidoc use asciidoc with the 'to'-commit
2222
to-asciidoctor use asciidoctor with the 'to'-commit
2323
asciidoctor use asciidoctor with both commits
24-
cut-header-footer cut away header and footer
24+
cut-footer cut away footer
2525
"
2626
SUBDIRECTORY_OK=1
2727
. "$(git --exec-path)/git-sh-setup"
@@ -31,7 +31,7 @@ force=
3131
clean=
3232
from_program=
3333
to_program=
34-
cut_header_footer=
34+
cut_footer=
3535
while test $# -gt 0
3636
do
3737
case "$1" in
@@ -55,8 +55,8 @@ do
5555
--asciidoc)
5656
from_program=-asciidoc
5757
to_program=-asciidoc ;;
58-
--cut-header-footer)
59-
cut_header_footer=-cut-header-footer ;;
58+
--cut-footer)
59+
cut_footer=-cut-footer ;;
6060
--)
6161
shift; break ;;
6262
*)
@@ -118,8 +118,8 @@ construct_makemanflags () {
118118
from_makemanflags=$(construct_makemanflags "$from_program") &&
119119
to_makemanflags=$(construct_makemanflags "$to_program") &&
120120

121-
from_dir=$from_oid$from_program$cut_header_footer &&
122-
to_dir=$to_oid$to_program$cut_header_footer &&
121+
from_dir=$from_oid$from_program$cut_footer &&
122+
to_dir=$to_oid$to_program$cut_footer &&
123123

124124
# generate_render_makefile <srcdir> <dstdir>
125125
generate_render_makefile () {
@@ -169,12 +169,11 @@ render_tree () {
169169
make -j$parallel -f - &&
170170
mv "$tmp/rendered/$dname+" "$tmp/rendered/$dname"
171171

172-
if test "$cut_header_footer" = "-cut-header-footer"
172+
if test "$cut_footer" = "-cut-footer"
173173
then
174174
for f in $(find "$tmp/rendered/$dname" -type f)
175175
do
176-
tail -n +3 "$f" | head -n -2 |
177-
sed -e '1{/^$/d}' -e '${/^$/d}' >"$f+" &&
176+
head -n -2 "$f" | sed -e '${/^$/d}' >"$f+" &&
178177
mv "$f+" "$f" ||
179178
return 1
180179
done

0 commit comments

Comments
 (0)