1 require 'asciidoctor' 1 require 'asciidoctor' 2 require 'asciidoctor/extensions' 2 require 'asciidoctor/extensions' 3 3 4 module Perf 4 module Perf 5 module Documentation 5 module Documentation 6 class LinkPerfProcessor < Asciidoctor::Ext 6 class LinkPerfProcessor < Asciidoctor::Extensions::InlineMacroProcessor 7 use_dsl 7 use_dsl 8 8 9 named :chrome 9 named :chrome 10 10 11 def process(parent, target, attrs) 11 def process(parent, target, attrs) 12 if parent.document.basebackend? 'html' 12 if parent.document.basebackend? 'html' 13 %(<a href="#{target}.html">#{target} 13 %(<a href="#{target}.html">#{target}(#{attrs[1]})</a>\n) 14 elsif parent.document.basebackend? 'ma 14 elsif parent.document.basebackend? 'manpage' 15 "#{target}(#{attrs[1]})" 15 "#{target}(#{attrs[1]})" 16 elsif parent.document.basebackend? 'do 16 elsif parent.document.basebackend? 'docbook' 17 "<citerefentry>\n" \ 17 "<citerefentry>\n" \ 18 "<refentrytitle>#{target}</refentr 18 "<refentrytitle>#{target}</refentrytitle>" \ 19 "<manvolnum>#{attrs[1]}</manvolnum 19 "<manvolnum>#{attrs[1]}</manvolnum>\n" \ 20 "</citerefentry>\n" 20 "</citerefentry>\n" 21 end 21 end 22 end 22 end 23 end 23 end 24 end 24 end 25 end 25 end 26 26 27 Asciidoctor::Extensions.register do 27 Asciidoctor::Extensions.register do 28 inline_macro Perf::Documentation::LinkPerfPr 28 inline_macro Perf::Documentation::LinkPerfProcessor, :linkperf 29 end 29 end
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.