Skip to content
Snippets Groups Projects
Commit a26d455f authored by Jean-Noël Avila's avatar Jean-Noël Avila
Browse files

Add asciidoctor extension to better format the manpage

parent 63b48cf0
No related branches found
No related tags found
No related merge requests found
require 'asciidoctor'
require 'asciidoctor/extensions'
module Git
module Documentation
class LinkGitProcessor < Asciidoctor::Extensions::InlineMacroProcessor
use_dsl
named :chrome
def process(parent, target, attrs)
prefix = parent.document.attr('git-relative-html-prefix')
if parent.document.doctype == 'book'
"<ulink url=\"#{prefix}#{target}.html\">" \
"#{target}(#{attrs[1]})</ulink>"
elsif parent.document.basebackend? 'html'
%(<a href="#{prefix}#{target}.html">#{target}(#{attrs[1]})</a>)
elsif parent.document.basebackend? 'manpage'
"#{target}(#{attrs[1]})"
end
end
end
end
end
Asciidoctor::Extensions.register do
inline_macro Git::Documentation::LinkGitProcessor, :linkgit
end
......@@ -22,7 +22,7 @@ include ../../Makefile
XMLTO_EXTRA += --searchpath ../..
ifdef USE_ASCIIDOCTOR
ASCIIDOC_EXTRA += -I../..
ASCIIDOC_EXTRA += -I../.. -I. -rasciidoctor-extensions
else
ASCIIDOC_CONF = -f ../../asciidoc.conf
endif
......@@ -43,12 +43,17 @@ ifndef V
QUIET_ASCIIDOC = @echo ' ' ASCIIDOC $(lang) $@;
endif
-include ../GIT-VERSION-FILE
$(HTML_FILTER): %.html: %.txt
$(QUIET_ASCIIDOC)asciidoctor -b xhtml5 -d manpage $<
$(QUIET_ASCIIDOC)asciidoctor -b xhtml5 -d manpage -d manpage -I.. -I. -rasciidoctor-extensions \
-amanversion=$(GIT_VERSION) -amanmanual='Git Manual' -amansource='Git $(GIT_VERSION)' $<
MANPAGES=$(patsubst %.txt,%.1,$(MAN_FILTER))
$(MANPAGES): %.1: %.txt
$(QUIET_ASCIIDOC)asciidoctor -b manpage -d manpage -o $@ $<
$(QUIET_ASCIIDOC)asciidoctor -b manpage -d manpage -o $@ \
-I. -I.. -rasciidoctor-extensions \
-amanmanual='Git Manual' -amansource='Git $(GIT_VERSION)' $<
man: $(MANPAGES)
html: $(HTML_FILTER)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment