Skip to content

Commit

Permalink
Add version information to man pages
Browse files Browse the repository at this point in the history
Inspired and copied from git 7ef195ba3efe0ffa815e12afc4cb1e39a21ddfb4:

    Override the [header] macro of asciidoc's docbook
    backend to add version information to the generated
    man pages.

by Frank Lichtenheld <frank@lichtenheld.de>. Slightly improved to
use asciidoc {version} macro to avoid having to invoke sed.
  • Loading branch information
jonas committed May 31, 2007
1 parent 738cb15 commit bb0ab19
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
11 changes: 6 additions & 5 deletions Makefile
Expand Up @@ -16,9 +16,10 @@ DOCS = $(DOCS_MAN) $(DOCS_HTML) \
manual.toc manual.pdf

ifneq (,$(wildcard .git))
VERSION = $(shell git-describe)
WTDIRTY = $(shell git-diff-index --name-only HEAD 2>/dev/null)
CFLAGS += '-DVERSION="$(VERSION)$(if $(WTDIRTY),-dirty)"'
GITDESC = $(subst tig-,,$(shell git describe))
WTDIRTY = $(if $(shell git-diff-index HEAD 2>/dev/null),-dirty)
VERSION = $(GITDESC)$(WTDIRTY)
CFLAGS += '-DVERSION="tig-$(VERSION)"'
endif

all: $(PROGS)
Expand Down Expand Up @@ -88,7 +89,7 @@ README.html: README
asciidoc -b xhtml11 -d manpage $<

%.1.xml : %.1.txt
asciidoc -b docbook -d manpage $<
asciidoc -b docbook -d manpage -aversion=$(VERSION) $<

%.1 : %.1.xml
xmlto -m manpage.xsl man $<
Expand All @@ -97,7 +98,7 @@ README.html: README
asciidoc -b xhtml11 -d manpage $<

%.5.xml : %.5.txt
asciidoc -b docbook -d manpage $<
asciidoc -b docbook -d manpage -aversion=$(VERSION) $<

%.5 : %.5.xml
xmlto -m manpage.xsl man $<
Expand Down
19 changes: 19 additions & 0 deletions asciidoc.conf
Expand Up @@ -21,6 +21,25 @@ ifdef::backend-xhtml11[]
<a href="{target}{0?.{0}}.html">{target}{0?({0})}</a>
endif::backend-xhtml11[]

ifdef::doctype-manpage[]
ifdef::backend-docbook[]
[header]
template::[header-declarations]
<refentry>
<refmeta>
<refentrytitle>{mantitle}</refentrytitle>
<manvolnum>{manvolnum}</manvolnum>
<refmiscinfo class="source">Tig</refmiscinfo>
<refmiscinfo class="version">{version}</refmiscinfo>
<refmiscinfo class="manual">Tig Manual</refmiscinfo>
</refmeta>
<refnamediv>
<refname>{manname}</refname>
<refpurpose>{manpurpose}</refpurpose>
</refnamediv>
endif::backend-docbook[]
endif::doctype-manpage[]

ifdef::readme[]
# No header or footers for README.html
[header]
Expand Down

0 comments on commit bb0ab19

Please sign in to comment.