0001 require 'asciidoctor'
0002 require 'asciidoctor/extensions'
0003
0004 module Perf
0005 module Documentation
0006 class LinkPerfProcessor < Asciidoctor::Extensions::InlineMacroProcessor
0007 use_dsl
0008
0009 named :chrome
0010
0011 def process(parent, target, attrs)
0012 if parent.document.basebackend? 'html'
0013 %(<a href="#{target}.html">#{target}(#{attrs[1]})</a>\n)
0014 elsif parent.document.basebackend? 'manpage'
0015 "#{target}(#{attrs[1]})"
0016 elsif parent.document.basebackend? 'docbook'
0017 "<citerefentry>\n" \
0018 "<refentrytitle>#{target}</refentrytitle>" \
0019 "<manvolnum>#{attrs[1]}</manvolnum>\n" \
0020 "</citerefentry>\n"
0021 end
0022 end
0023 end
0024 end
0025 end
0026
0027 Asciidoctor::Extensions.register do
0028 inline_macro Perf::Documentation::LinkPerfProcessor, :linkperf
0029 end