Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Takashi Iwai and committed by
Arnaldo Carvalho de Melo
ffef80ec 83cf774b

+53 -5
+24 -5
tools/perf/Documentation/Makefile
··· 47 47 man7dir=$(mandir)/man7 48 48 49 49 ASCIIDOC=asciidoc 50 - ASCIIDOC_EXTRA = --unsafe 50 + ASCIIDOC_EXTRA = --unsafe -f asciidoc.conf 51 + ASCIIDOC_HTML = xhtml11 51 52 MANPAGE_XSL = manpage-normal.xsl 52 53 XMLTO_EXTRA = 53 54 INSTALL?=install 54 55 RM ?= rm -f 55 56 DOC_REF = origin/man 56 57 HTML_REF = origin/html 58 + 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 57 66 58 67 infodir?=$(prefix)/share/info 59 68 MAKEINFO=makeinfo ··· 82 73 missing_tools = $(ASCIIDOC) 83 74 endif 84 75 76 + ifndef USE_ASCIIDOCTOR 85 77 _tmp_tool_path := $(call get-executable,$(XMLTO)) 86 78 ifeq ($(_tmp_tool_path),) 87 79 missing_tools += $(XMLTO) 80 + endif 88 81 endif 89 82 90 83 # ··· 275 264 276 265 $(MAN_HTML): $(OUTPUT)%.html : %.txt 277 266 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \ 278 - $(ASCIIDOC) -b xhtml11 -d manpage -f asciidoc.conf \ 267 + $(ASCIIDOC) -b $(ASCIIDOC_HTML) -d manpage \ 279 268 $(ASCIIDOC_EXTRA) -aperf_version=$(PERF_VERSION) -o $@+ $< && \ 280 269 mv $@+ $@ 270 + 271 + ifdef USE_ASCIIDOCTOR 272 + $(OUTPUT)%.1 $(OUTPUT)%.5 $(OUTPUT)%.7 : $(OUTPUT)%.txt 273 + $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \ 274 + $(ASCIIDOC) -b manpage -d manpage \ 275 + $(ASCIIDOC_EXTRA) -aperf_version=$(PERF_VERSION) -o $@+ $< && \ 276 + mv $@+ $@ 277 + endif 281 278 282 279 $(OUTPUT)%.1 $(OUTPUT)%.5 $(OUTPUT)%.7 : $(OUTPUT)%.xml 283 280 $(QUIET_XMLTO)$(RM) $@ && \ ··· 293 274 294 275 $(OUTPUT)%.xml : %.txt 295 276 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \ 296 - $(ASCIIDOC) -b docbook -d manpage -f asciidoc.conf \ 277 + $(ASCIIDOC) -b docbook -d manpage \ 297 278 $(ASCIIDOC_EXTRA) -aperf_version=$(PERF_VERSION) -o $@+ $< && \ 298 279 mv $@+ $@ 299 280 ··· 340 321 mv $@+ $@ 341 322 342 323 $(patsubst %,%.html,$(ARTICLES)) : %.html : %.txt 343 - $(QUIET_ASCIIDOC)$(ASCIIDOC) -b xhtml11 $*.txt 324 + $(QUIET_ASCIIDOC)$(ASCIIDOC) -b $(ASCIIDOC_HTML) $*.txt 344 325 345 326 WEBDOC_DEST = /pub/software/tools/perf/docs 346 327 347 328 $(patsubst %.txt,%.html,$(wildcard howto/*.txt)): %.html : %.txt 348 329 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \ 349 - sed -e '1,/^$$/d' $< | $(ASCIIDOC) -b xhtml11 - >$@+ && \ 330 + sed -e '1,/^$$/d' $< | $(ASCIIDOC) -b $(ASCIIDOC_HTML) - >$@+ && \ 350 331 mv $@+ $@ 351 332 352 333 # UNIMPLEMENTED
+29
tools/perf/Documentation/asciidoctor-extensions.rb
··· 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