From: tiwai@suse.de (Takashi Iwai)
Subject: [PATCH 2/2] Documentation: allow to format with asciidoctor
Date: Thu, 12 Apr 2018 13:02:38 +0200 [thread overview]
Message-ID: <20180412110238.30717-3-tiwai@suse.de> (raw)
In-Reply-To: <20180412110238.30717-1-tiwai@suse.de>
Add asciidoctor support. You need to pass USE_ASCIIDOCTOR=yes to make
for enabling the feature.
Most of the rb extension code was shamelessly borrowed from git.
Signed-off-by: Takashi Iwai <tiwai at suse.de>
---
Documentation/Makefile | 13 +++++++++++++
Documentation/asciidoctor-extensions.rb | 29 +++++++++++++++++++++++++++++
2 files changed, 42 insertions(+)
--- a/Documentation/Makefile
+++ b/Documentation/Makefile
@@ -35,6 +35,19 @@ MAN_REPO = ../../nvme-manpages
ASCIIDOC_HTML = xhtml11
ASCIIDOC_CONF = -f asciidoc.conf
+
+ifdef USE_ASCIIDOCTOR
+ASCIIDOC = asciidoctor
+ASCIIDOC_CONF =
+ASCIIDOC_HTML = xhtml5
+ASCIIDOC_DOCBOOK = docbook45
+ASCIIDOC_EXTRA += -acompat-mode
+ASCIIDOC_EXTRA += -I. -rasciidoctor-extensions
+ASCIIDOC_EXTRA += -alitdd='&\#x2d;&\#x2d;'
+ASCIIDOC_EXTRA += -amansource='NVMe'
+ASCIIDOC_EXTRA += -amanmanual='NVMe Manual'
+endif
+
ASCIIDOC_COMMON = $(ASCIIDOC) $(ASCIIDOC_EXTRA) $(ASCIIDOC_CONF)
TXT_TO_HTML = $(ASCIIDOC_COMMON) -b $(ASCIIDOC_HTML)
--- /dev/null
+++ b/Documentation/asciidoctor-extensions.rb
@@ -0,0 +1,29 @@
+require 'asciidoctor'
+require 'asciidoctor/extensions'
+
+module Nvme
+ module Documentation
+ class LinkNvmeProcessor < Asciidoctor::Extensions::InlineMacroProcessor
+ use_dsl
+
+ named :chrome
+
+ def process(parent, target, attrs)
+ if parent.document.basebackend? 'html'
+ %(<a href="#{target}.html">#{target}(#{attrs[1]})</a>\n)
+ elsif parent.document.basebackend? 'manpage'
+ "#{target}(#{attrs[1]})"
+ elsif parent.document.basebackend? 'docbook'
+ "<citerefentry>\n" \
+ "<refentrytitle>#{target}</refentrytitle>" \
+ "<manvolnum>#{attrs[1]}</manvolnum>\n" \
+ "</citerefentry>\n"
+ end
+ end
+ end
+ end
+end
+
+Asciidoctor::Extensions.register do
+ inline_macro Nvme::Documentation::LinkNvmeProcessor, :linknvme
+end
next prev parent reply other threads:[~2018-04-12 11:02 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-12 11:02 [PATCH 0/2] Documentation: add asciidoctor support Takashi Iwai
2018-04-12 11:02 ` [PATCH 1/2] Documentation: fix title markers Takashi Iwai
2018-04-12 11:02 ` Takashi Iwai [this message]
2018-04-12 15:54 ` [PATCH 0/2] Documentation: add asciidoctor support Sagi Grimberg
2018-06-05 14:41 ` Takashi Iwai
2018-06-05 14:42 ` Johannes Thumshirn
2018-06-05 15:02 ` Keith Busch
2018-06-05 15:12 ` Takashi Iwai
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180412110238.30717-3-tiwai@suse.de \
--to=tiwai@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.