Skip to content

Commit ffef80e

Browse files
tiwaiacmel
authored andcommitted
perf Documentation: Support for asciidoctor
The asciidoc package seems behind the recent big wave of python3 conversion, and we were advised to switch to asciidoctor instead. It's almost compatible but some extensions used for perf documentation don't work with it. Here is the patch to cover them, and add the proper support for asciidoctor. Pass USE_ASCIIDOCTOR=yes to make for using asciidoctor instead of asciidoc. The man source and manual attributes are passed via command options. The support for these attributes have been fixed in the latest asciidoctor code. Since asciidoctor can covert to a man page and an HTML directly, we can omit the dependency on xmlto when USE_ASCIIDOCTOR is set. Signed-off-by: Takashi Iwai <tiwai@suse.de> Cc: Peter Zijlstra <peterz@infradead.org> Link: http://lkml.kernel.org/r/20180424150456.17353-1-tiwai@suse.de Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent 83cf774 commit ffef80e

2 files changed

Lines changed: 53 additions & 5 deletions

File tree

‎tools/perf/Documentation/Makefile‎

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,23 @@ man5dir=$(mandir)/man5
4747
man7dir=$(mandir)/man7
4848

4949
ASCIIDOC=asciidoc
50-
ASCIIDOC_EXTRA = --unsafe
50+
ASCIIDOC_EXTRA = --unsafe -f asciidoc.conf
51+
ASCIIDOC_HTML = xhtml11
5152
MANPAGE_XSL = manpage-normal.xsl
5253
XMLTO_EXTRA =
5354
INSTALL?=install
5455
RM ?= rm -f
5556
DOC_REF = origin/man
5657
HTML_REF = origin/html
5758

59+
ifdef USE_ASCIIDOCTOR
60+
ASCIIDOC = asciidoctor
61+
ASCIIDOC_EXTRA = -a compat-mode
62+
ASCIIDOC_EXTRA += -I. -rasciidoctor-extensions
63+
ASCIIDOC_EXTRA += -a mansource="perf" -a manmanual="perf Manual"
64+
ASCIIDOC_HTML = xhtml5
65+
endif
66+
5867
infodir?=$(prefix)/share/info
5968
MAKEINFO=makeinfo
6069
INSTALL_INFO=install-info
@@ -73,10 +82,12 @@ ifeq ($(_tmp_tool_path),)
7382
missing_tools = $(ASCIIDOC)
7483
endif
7584

85+
ifndef USE_ASCIIDOCTOR
7686
_tmp_tool_path := $(call get-executable,$(XMLTO))
7787
ifeq ($(_tmp_tool_path),)
7888
missing_tools += $(XMLTO)
7989
endif
90+
endif
8091

8192
#
8293
# For asciidoc ...
@@ -264,17 +275,25 @@ clean:
264275

265276
$(MAN_HTML): $(OUTPUT)%.html : %.txt
266277
$(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
267-
$(ASCIIDOC) -b xhtml11 -d manpage -f asciidoc.conf \
278+
$(ASCIIDOC) -b $(ASCIIDOC_HTML) -d manpage \
279+
$(ASCIIDOC_EXTRA) -aperf_version=$(PERF_VERSION) -o $@+ $< && \
280+
mv $@+ $@
281+
282+
ifdef USE_ASCIIDOCTOR
283+
$(OUTPUT)%.1 $(OUTPUT)%.5 $(OUTPUT)%.7 : $(OUTPUT)%.txt
284+
$(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
285+
$(ASCIIDOC) -b manpage -d manpage \
268286
$(ASCIIDOC_EXTRA) -aperf_version=$(PERF_VERSION) -o $@+ $< && \
269287
mv $@+ $@
288+
endif
270289

271290
$(OUTPUT)%.1 $(OUTPUT)%.5 $(OUTPUT)%.7 : $(OUTPUT)%.xml
272291
$(QUIET_XMLTO)$(RM) $@ && \
273292
$(XMLTO) -o $(OUTPUT). -m $(MANPAGE_XSL) $(XMLTO_EXTRA) man $<
274293

275294
$(OUTPUT)%.xml : %.txt
276295
$(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
277-
$(ASCIIDOC) -b docbook -d manpage -f asciidoc.conf \
296+
$(ASCIIDOC) -b docbook -d manpage \
278297
$(ASCIIDOC_EXTRA) -aperf_version=$(PERF_VERSION) -o $@+ $< && \
279298
mv $@+ $@
280299

@@ -321,13 +340,13 @@ howto-index.txt: howto-index.sh $(wildcard howto/*.txt)
321340
mv $@+ $@
322341

323342
$(patsubst %,%.html,$(ARTICLES)) : %.html : %.txt
324-
$(QUIET_ASCIIDOC)$(ASCIIDOC) -b xhtml11 $*.txt
343+
$(QUIET_ASCIIDOC)$(ASCIIDOC) -b $(ASCIIDOC_HTML) $*.txt
325344

326345
WEBDOC_DEST = /pub/software/tools/perf/docs
327346

328347
$(patsubst %.txt,%.html,$(wildcard howto/*.txt)): %.html : %.txt
329348
$(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
330-
sed -e '1,/^$$/d' $< | $(ASCIIDOC) -b xhtml11 - >$@+ && \
349+
sed -e '1,/^$$/d' $< | $(ASCIIDOC) -b $(ASCIIDOC_HTML) - >$@+ && \
331350
mv $@+ $@
332351

333352
# UNIMPLEMENTED
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
require 'asciidoctor'
2+
require 'asciidoctor/extensions'
3+
4+
module Perf
5+
module Documentation
6+
class LinkPerfProcessor < Asciidoctor::Extensions::InlineMacroProcessor
7+
use_dsl
8+
9+
named :chrome
10+
11+
def process(parent, target, attrs)
12+
if parent.document.basebackend? 'html'
13+
%(<a href="#{target}.html">#{target}(#{attrs[1]})</a>\n)
14+
elsif parent.document.basebackend? 'manpage'
15+
"#{target}(#{attrs[1]})"
16+
elsif parent.document.basebackend? 'docbook'
17+
"<citerefentry>\n" \
18+
"<refentrytitle>#{target}</refentrytitle>" \
19+
"<manvolnum>#{attrs[1]}</manvolnum>\n" \
20+
"</citerefentry>\n"
21+
end
22+
end
23+
end
24+
end
25+
end
26+
27+
Asciidoctor::Extensions.register do
28+
inline_macro Perf::Documentation::LinkPerfProcessor, :linkperf
29+
end

0 commit comments

Comments
 (0)