git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v3 07/12] doc: asciidoctor: reorganize extensions

From
Felipe Contreras <felipe.contreras@gmail.com>
Date
May 25, 2021, 10:47 UTC
Message-ID
<20210525104802.158336-8-felipe.contreras@gmail.com>
In-Reply-To
<20210525104802.158336-1-felipe.contreras@gmail.com>

There's no need to create verbose classes, we can do the same with a simple block.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 Documentation/asciidoctor-extensions.rb | 34 +++++++++++--------------
 1 file changed, 15 insertions(+), 19 deletions(-)
diff --git a/Documentation/asciidoctor-extensions.rb b/Documentation/asciidoctor-extensions.rb
index 3dea106d00..f998a42249 100644
--- a/Documentation/asciidoctor-extensions.rb
+++ b/Documentation/asciidoctor-extensions.rb
@@ -1,26 +1,22 @@
 require 'asciidoctor/extensions'
 
-module Git
-  module Documentation
-    class LinkGitProcessor < Asciidoctor::Extensions::InlineMacroProcessor
-      def process(parent, target, attrs)
-        prefix = parent.document.attr('git-relative-html-prefix')
-        if parent.document.doctype == 'book'
-          "<ulink url=\"#{prefix}#{target}.html\">" \
-          "#{target}(#{attrs[1]})</ulink>"
-        elsif parent.document.basebackend? 'html'
-          %(<a href="#{prefix}#{target}.html">#{target}(#{attrs[1]})</a>)
-        elsif parent.document.basebackend? 'docbook'
-          "<citerefentry>\n" \
-            "<refentrytitle>#{target}</refentrytitle>" \
-            "<manvolnum>#{attrs[1]}</manvolnum>\n" \
-          "</citerefentry>"
-        end
+Asciidoctor::Extensions.register do
+
+  inline_macro :linkgit do
+    process do |parent, target, attrs|
+      prefix = parent.document.attr('git-relative-html-prefix')
+      if parent.document.doctype == 'book'
+        "<ulink url=\"#{prefix}#{target}.html\">" \
+        "#{target}(#{attrs[1]})</ulink>"
+      elsif parent.document.basebackend? 'html'
+        %(<a href="#{prefix}#{target}.html">#{target}(#{attrs[1]})</a>)
+      elsif parent.document.basebackend? 'docbook'
+        "<citerefentry>\n" \
+          "<refentrytitle>#{target}</refentrytitle>" \
+          "<manvolnum>#{attrs[1]}</manvolnum>\n" \
+        "</citerefentry>"
       end
     end
   end
-end
 
-Asciidoctor::Extensions.register do
-  inline_macro Git::Documentation::LinkGitProcessor, :linkgit
 end
-- 
2.32.0.rc0
Previous: Felipe ContrerasNext: Felipe Contreras
Message 9 of 13 in “doc: cleanup old cruft and asciidoctor revamp”
  1. 00/12 doc: cleanup old cruft and asciidoctor revampFelipe Contreras, May 25, 2021
  2. 01/12 doc: remove GNU troff workaroundFelipe Contreras, May 25, 2021
  3. 02/12 doc: use --stringparam in xmltoFelipe Contreras, May 25, 2021
  4. 03/12 doc: simplify version passingFelipe Contreras, May 25, 2021
  5. 04/12 doc: asciidoc: remove unnecessary attributeFelipe Contreras, May 25, 2021
  6. 05/12 doc: asciidoctor: remove unnecessary requireFelipe Contreras, May 25, 2021
  7. 06/12 doc: asciidoctor: remove cruftFelipe Contreras, May 25, 2021
  8. 08/12 doc: asciidoctor: use html-prefix only for htmlFelipe Contreras, May 25, 2021
  9. 07/12 doc: asciidoctor: reorganize extensionsFelipe Contreras, May 25, 2021
  10. 10/12 doc: asciidoctor: improve string handlingFelipe Contreras, May 25, 2021
  11. 11/12 doc: asciidoctor: split the format from the codeFelipe Contreras, May 25, 2021
  12. 12/12 doc: asciidoctor: specify name of our groupFelipe Contreras, May 25, 2021
  13. 09/12 doc: asciidoctor: refactor macro registrationFelipe Contreras, May 25, 2021

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.