{"thread":{"id":"55769","subject":"[PATCH v3 00/12] doc: cleanup old cruft and asciidoctor revamp","startedAt":"2021-05-25T10:48:07Z","lastAt":"2021-05-25T10:48:42Z","messageCount":13,"participants":["Felipe Contreras"],"isPatch":true,"patchVersion":3,"patchTotal":12},"messages":[{"id":"425507","messageId":"20210525104802.158336-1-felipe.contreras@gmail.com","threadId":"55769","inReplyTo":null,"subject":"[PATCH v3 00/12] doc: cleanup old cruft and asciidoctor revamp","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2021-05-25T10:47:50Z","receivedAt":"2021-05-25T10:48:07Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"This patch series gets rid of old unnecessary workarounds and convoluted solutions.\n\nAdditionally it cleanups the asciidoctor-specific code so it ends up much more simpler.\n\nThis goes on top of my other cleanup patches [1].\n\nNothing changed since v2 except the patches are now generated without `git format-patch -D`.\n\n[2] https://lore.kernel.org/git/20210521222941.525901-1-felipe.contreras@gmail.com/\n\nFelipe Contreras (12):\n  doc: remove GNU troff workaround\n  doc: use --stringparam in xmlto\n  doc: simplify version passing\n  doc: asciidoc: remove unnecessary attribute\n  doc: asciidoctor: remove unnecessary require\n  doc: asciidoctor: remove cruft\n  doc: asciidoctor: reorganize extensions\n  doc: asciidoctor: use html-prefix only for html\n  doc: asciidoctor: refactor macro registration\n  doc: asciidoctor: improve string handling\n  doc: asciidoctor: split the format from the code\n  doc: asciidoctor: specify name of our group\n\n Documentation/.gitignore                |  1 -\n Documentation/Makefile                  | 19 ++-------\n Documentation/asciidoc.conf             | 20 ---------\n Documentation/asciidoctor-extensions.rb | 56 ++++++++-----------------\n Documentation/manpage-base-url.xsl.in   | 10 -----\n Documentation/manpage-quote-apos.xsl    | 16 -------\n Makefile                                |  4 --\n 7 files changed, 21 insertions(+), 105 deletions(-)\n delete mode 100644 Documentation/manpage-base-url.xsl.in\n delete mode 100644 Documentation/manpage-quote-apos.xsl\n\nRange-diff against v2:\n 1:  f9fe40224d =  1:  f9fe40224d doc: remove GNU troff workaround\n 2:  eed7d77e1e =  2:  eed7d77e1e doc: use --stringparam in xmlto\n 3:  d8bebb37e4 =  3:  d8bebb37e4 doc: simplify version passing\n 4:  2df412bce6 =  4:  2df412bce6 doc: asciidoc: remove unnecessary attribute\n 5:  3abdeada0c =  5:  3abdeada0c doc: asciidoctor: remove unnecessary require\n 6:  685cd824ea =  6:  685cd824ea doc: asciidoctor: remove cruft\n 7:  7f1fb74a04 =  7:  7f1fb74a04 doc: asciidoctor: reorganize extensions\n 8:  bede3d2294 =  8:  bede3d2294 doc: asciidoctor: use html-prefix only for html\n 9:  2ecd19e4e3 =  9:  2ecd19e4e3 doc: asciidoctor: refactor macro registration\n10:  6c5e9142c8 = 10:  6c5e9142c8 doc: asciidoctor: improve string handling\n11:  820bc01e49 = 11:  820bc01e49 doc: asciidoctor: split the format from the code\n12:  69de00c9ee = 12:  69de00c9ee doc: asciidoctor: specify name of our group\n-- \n2.32.0.rc0\n\n"},{"id":"425508","messageId":"20210525104802.158336-2-felipe.contreras@gmail.com","threadId":"55769","inReplyTo":"20210525104802.158336-1-felipe.contreras@gmail.com","subject":"[PATCH v3 01/12] doc: remove GNU troff workaround","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2021-05-25T10:47:51Z","receivedAt":"2021-05-25T10:48:11Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"In 2007 the docbook project made the mistake of converting ' to \\' for\nman pages [1]. It's a problem because groff interprets \\' as acute\naccent which is rendered as ' in ASCII, but as ´ in utf-8.\n\nThis started a cascade of bug reports in git [2], debian [3], Arch Linux\n[4], docbook itself [5], and probably many others.\n\nA solution was to use the correct groff character: \\(aq, which is always\nrendered as ', but the problem is that such character doesn't work in\nother troff programs.\n\nA portable solution required the use of a conditional character that is\n\\(aq in groff, but ' in all others:\n\n  .ie \\n(.g .ds Aq \\(aq\n  .el .ds Aq '\n\nThe proper solution took time to be implemented in docbook, but in 2010\nthey did it [6]. So the docbook man page stylesheets were broken from\n1.73 to 1.76.\n\nUnfortunately by that point many workarounds already existed. In the\ncase of git GNU_ROFF was introduced, and in the case of Arch Linux\na mappig from \\' to ' was added to groff's man.local. Other\ndistributions might have done the same, or similar workarounds.\n\nSince 2010 there is not need for this workaround, which is fixed\nelsewhere not just in docbook, but other layers as well.\n\nLet's remove it.\n\nAlso, it's GNU troff, not GNU roff.\n\n[1] https://github.com/docbook/xslt10-stylesheets/commit/ea2a0bac56c56eec1892ac3d9254dca89f7c5746\n[2] https://lore.kernel.org/git/20091012102926.GA3937@debian.b2j/\n[3] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=507673#65\n[4] https://bugs.archlinux.org/task/9643\n[5] https://sourceforge.net/p/docbook/bugs/1022/\n[6] https://github.com/docbook/xslt10-stylesheets/commit/fb553434265906ed81edc6d5f533d0b08d200046\n\nInspired-by: brian m. carlson <sandals@crustytoothpaste.net>\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n Documentation/Makefile               |  8 --------\n Documentation/manpage-quote-apos.xsl | 16 ----------------\n Makefile                             |  4 ----\n 3 files changed, 28 deletions(-)\n delete mode 100644 Documentation/manpage-quote-apos.xsl\n\ndiff --git a/Documentation/Makefile b/Documentation/Makefile\nindex f5605b7767..bf1f66b3eb 100644\n--- a/Documentation/Makefile\n+++ b/Documentation/Makefile\n@@ -178,14 +178,6 @@ MAN_BASE_URL = file://$(htmldir)/\n endif\n XMLTO_EXTRA += -m manpage-base-url.xsl\n \n-# If your target system uses GNU groff, it may try to render\n-# apostrophes as a \"pretty\" apostrophe using unicode.  This breaks\n-# cut&paste, so you should set GNU_ROFF to force them to be ASCII\n-# apostrophes.  Unfortunately does not work with non-GNU roff.\n-ifdef GNU_ROFF\n-XMLTO_EXTRA += -m manpage-quote-apos.xsl\n-endif\n-\n ifdef USE_ASCIIDOCTOR\n ASCIIDOC = asciidoctor\n ASCIIDOC_CONF =\ndiff --git a/Documentation/manpage-quote-apos.xsl b/Documentation/manpage-quote-apos.xsl\ndeleted file mode 100644\nindex aeb8839f33..0000000000\n--- a/Documentation/manpage-quote-apos.xsl\n+++ /dev/null\n@@ -1,16 +0,0 @@\n-<xsl:stylesheet xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\"\n-\t\tversion=\"1.0\">\n-\n-<!-- work around newer groff/man setups using a prettier apostrophe\n-     that unfortunately does not quote anything when cut&pasting\n-     examples to the shell -->\n-<xsl:template name=\"escape.apostrophe\">\n-  <xsl:param name=\"content\"/>\n-  <xsl:call-template name=\"string.subst\">\n-    <xsl:with-param name=\"string\" select=\"$content\"/>\n-    <xsl:with-param name=\"target\">'</xsl:with-param>\n-    <xsl:with-param name=\"replacement\">\\(aq</xsl:with-param>\n-  </xsl:call-template>\n-</xsl:template>\n-\n-</xsl:stylesheet>\ndiff --git a/Makefile b/Makefile\nindex 3a2d3c80a8..55dbdee98e 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -278,10 +278,6 @@ all::\n # Define NO_ST_BLOCKS_IN_STRUCT_STAT if your platform does not have st_blocks\n # field that counts the on-disk footprint in 512-byte blocks.\n #\n-# Define GNU_ROFF if your target system uses GNU groff.  This forces\n-# apostrophes to be ASCII so that cut&pasting examples to the shell\n-# will work.\n-#\n # Define USE_ASCIIDOCTOR to use Asciidoctor instead of AsciiDoc to build the\n # documentation.\n #\n-- \n2.32.0.rc0\n\n"},{"id":"425509","messageId":"20210525104802.158336-3-felipe.contreras@gmail.com","threadId":"55769","inReplyTo":"20210525104802.158336-1-felipe.contreras@gmail.com","subject":"[PATCH v3 02/12] doc: use --stringparam in xmlto","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2021-05-25T10:47:52Z","receivedAt":"2021-05-25T10:48:14Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"Commit 50d9bbba92 (Documentation: Avoid use of xmlto --stringparam,\n2009-12-04) introduced manpage-base-url.xsl because ancient versions of\nxmlto did not have --stringparam.\n\nHowever, that was more than ten years ago, no need for that complexity\nanymore.\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n Documentation/.gitignore              |  1 -\n Documentation/Makefile                |  8 ++------\n Documentation/manpage-base-url.xsl.in | 10 ----------\n 3 files changed, 2 insertions(+), 17 deletions(-)\n delete mode 100644 Documentation/manpage-base-url.xsl.in\n\ndiff --git a/Documentation/.gitignore b/Documentation/.gitignore\nindex 9022d48355..e9f8d693b1 100644\n--- a/Documentation/.gitignore\n+++ b/Documentation/.gitignore\n@@ -10,7 +10,6 @@ howto-index.txt\n doc.dep\n cmds-*.txt\n mergetools-*.txt\n-manpage-base-url.xsl\n SubmittingPatches.txt\n tmp-doc-diff/\n GIT-ASCIIDOCFLAGS\ndiff --git a/Documentation/Makefile b/Documentation/Makefile\nindex bf1f66b3eb..84643a34e9 100644\n--- a/Documentation/Makefile\n+++ b/Documentation/Makefile\n@@ -176,7 +176,7 @@ endif\n ifndef MAN_BASE_URL\n MAN_BASE_URL = file://$(htmldir)/\n endif\n-XMLTO_EXTRA += -m manpage-base-url.xsl\n+XMLTO_EXTRA += --stringparam man.base.url.for.relative.links='$(MAN_BASE_URL)'\n \n ifdef USE_ASCIIDOCTOR\n ASCIIDOC = asciidoctor\n@@ -342,7 +342,6 @@ clean:\n \t$(RM) technical/*.html technical/api-index.txt\n \t$(RM) SubmittingPatches.txt\n \t$(RM) $(cmds_txt) $(mergetools_txt) *.made\n-\t$(RM) manpage-base-url.xsl\n \t$(RM) GIT-ASCIIDOCFLAGS\n \n $(MAN_HTML): %.html : %.txt $(ASCIIDOC_DEPS)\n@@ -351,10 +350,7 @@ $(MAN_HTML): %.html : %.txt $(ASCIIDOC_DEPS)\n $(OBSOLETE_HTML): %.html : %.txto $(ASCIIDOC_DEPS)\n \t$(QUIET_ASCIIDOC)$(TXT_TO_HTML) -o $@ $<\n \n-manpage-base-url.xsl: manpage-base-url.xsl.in\n-\t$(QUIET_GEN)sed \"s|@@MAN_BASE_URL@@|$(MAN_BASE_URL)|\" $< > $@\n-\n-%.1 %.5 %.7 : %.xml manpage-base-url.xsl $(wildcard manpage*.xsl)\n+%.1 %.5 %.7 : %.xml $(wildcard manpage*.xsl)\n \t$(QUIET_XMLTO)$(XMLTO) -m $(MANPAGE_XSL) $(XMLTO_EXTRA) man $<\n \n %.xml : %.txt $(ASCIIDOC_DEPS)\ndiff --git a/Documentation/manpage-base-url.xsl.in b/Documentation/manpage-base-url.xsl.in\ndeleted file mode 100644\nindex e800904df3..0000000000\n--- a/Documentation/manpage-base-url.xsl.in\n+++ /dev/null\n@@ -1,10 +0,0 @@\n-<!-- manpage-base-url.xsl:\n-     special settings for manpages rendered from newer docbook -->\n-<xsl:stylesheet xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\"\n-\t\tversion=\"1.0\">\n-\n-<!-- set a base URL for relative links -->\n-<xsl:param name=\"man.base.url.for.relative.links\"\n-\t>@@MAN_BASE_URL@@</xsl:param>\n-\n-</xsl:stylesheet>\n-- \n2.32.0.rc0\n\n"},{"id":"425510","messageId":"20210525104802.158336-4-felipe.contreras@gmail.com","threadId":"55769","inReplyTo":"20210525104802.158336-1-felipe.contreras@gmail.com","subject":"[PATCH v3 03/12] doc: simplify version passing","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2021-05-25T10:47:53Z","receivedAt":"2021-05-25T10:48:24Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"The code to pass the version of the man page comes from 2007:\n7ef195ba3e (Documentation: Add version information to man pages,\n2007-03-25). However, both asciidoc and asciidoctor already do this by\ndefault.\n\nAsciidoctor doesn't read manversion, but there's no need since both\ntools just join mansource and manversion.\n\nLet's do that ourselves and get rid of a bunch of code.\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n Documentation/Makefile                  |  3 +--\n Documentation/asciidoc.conf             | 19 -------------------\n Documentation/asciidoctor-extensions.rb | 17 -----------------\n 3 files changed, 1 insertion(+), 38 deletions(-)\n\ndiff --git a/Documentation/Makefile b/Documentation/Makefile\nindex 84643a34e9..47053c78f8 100644\n--- a/Documentation/Makefile\n+++ b/Documentation/Makefile\n@@ -137,8 +137,7 @@ ASCIIDOC_HTML = xhtml11\n ASCIIDOC_DOCBOOK = docbook\n ASCIIDOC_CONF = -f asciidoc.conf\n ASCIIDOC_COMMON = $(ASCIIDOC) $(ASCIIDOC_EXTRA) $(ASCIIDOC_CONF) \\\n-\t\t-amanversion=$(GIT_VERSION) \\\n-\t\t-amanmanual='Git Manual' -amansource='Git'\n+\t\t-amanmanual='Git Manual' -amansource='Git $(GIT_VERSION)'\n ASCIIDOC_DEPS = asciidoc.conf GIT-ASCIIDOCFLAGS\n TXT_TO_HTML = $(ASCIIDOC_COMMON) -b $(ASCIIDOC_HTML)\n TXT_TO_XML = $(ASCIIDOC_COMMON) -b $(ASCIIDOC_DOCBOOK)\ndiff --git a/Documentation/asciidoc.conf b/Documentation/asciidoc.conf\nindex 3e4c13971b..60f76f43ed 100644\n--- a/Documentation/asciidoc.conf\n+++ b/Documentation/asciidoc.conf\n@@ -51,25 +51,6 @@ ifdef::doctype-manpage[]\n endif::doctype-manpage[]\n endif::backend-docbook[]\n \n-ifdef::doctype-manpage[]\n-ifdef::backend-docbook[]\n-[header]\n-template::[header-declarations]\n-<refentry>\n-<refmeta>\n-<refentrytitle>{mantitle}</refentrytitle>\n-<manvolnum>{manvolnum}</manvolnum>\n-<refmiscinfo class=\"source\">{mansource}</refmiscinfo>\n-<refmiscinfo class=\"version\">{manversion}</refmiscinfo>\n-<refmiscinfo class=\"manual\">{manmanual}</refmiscinfo>\n-</refmeta>\n-<refnamediv>\n-  <refname>{manname}</refname>\n-  <refpurpose>{manpurpose}</refpurpose>\n-</refnamediv>\n-endif::backend-docbook[]\n-endif::doctype-manpage[]\n-\n ifdef::backend-xhtml11[]\n [attributes]\n git-relative-html-prefix=\ndiff --git a/Documentation/asciidoctor-extensions.rb b/Documentation/asciidoctor-extensions.rb\nindex d906a00803..70a0956663 100644\n--- a/Documentation/asciidoctor-extensions.rb\n+++ b/Documentation/asciidoctor-extensions.rb\n@@ -23,26 +23,9 @@ module Git\n         end\n       end\n     end\n-\n-    class DocumentPostProcessor < Asciidoctor::Extensions::Postprocessor\n-      def process document, output\n-        if document.basebackend? 'docbook'\n-          mansource = document.attributes['mansource']\n-          manversion = document.attributes['manversion']\n-          manmanual = document.attributes['manmanual']\n-          new_tags = \"\" \\\n-            \"<refmiscinfo class=\\\"source\\\">#{mansource}</refmiscinfo>\\n\" \\\n-            \"<refmiscinfo class=\\\"version\\\">#{manversion}</refmiscinfo>\\n\" \\\n-            \"<refmiscinfo class=\\\"manual\\\">#{manmanual}</refmiscinfo>\\n\"\n-          output = output.sub(/<\\/refmeta>/, new_tags + \"</refmeta>\")\n-        end\n-        output\n-      end\n-    end\n   end\n end\n \n Asciidoctor::Extensions.register do\n   inline_macro Git::Documentation::LinkGitProcessor, :linkgit\n-  postprocessor Git::Documentation::DocumentPostProcessor\n end\n-- \n2.32.0.rc0\n\n"},{"id":"425511","messageId":"20210525104802.158336-5-felipe.contreras@gmail.com","threadId":"55769","inReplyTo":"20210525104802.158336-1-felipe.contreras@gmail.com","subject":"[PATCH v3 04/12] doc: asciidoc: remove unnecessary attribute","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2021-05-25T10:47:54Z","receivedAt":"2021-05-25T10:48:29Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"It's part of asciidoc global configuration since 2012.\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n Documentation/asciidoc.conf | 1 -\n 1 file changed, 1 deletion(-)\n\ndiff --git a/Documentation/asciidoc.conf b/Documentation/asciidoc.conf\nindex 60f76f43ed..f7908f9dea 100644\n--- a/Documentation/asciidoc.conf\n+++ b/Documentation/asciidoc.conf\n@@ -12,7 +12,6 @@\n \n [attributes]\n asterisk=&#42;\n-plus=&#43;\n caret=&#94;\n startsb=&#91;\n endsb=&#93;\n-- \n2.32.0.rc0\n\n"},{"id":"425512","messageId":"20210525104802.158336-6-felipe.contreras@gmail.com","threadId":"55769","inReplyTo":"20210525104802.158336-1-felipe.contreras@gmail.com","subject":"[PATCH v3 05/12] doc: asciidoctor: remove unnecessary require","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2021-05-25T10:47:55Z","receivedAt":"2021-05-25T10:48:32Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"This file is loaded by asciidoctor, the module is already loaded.\n\nIn addition to being less redundant this fixes a problem while trying\nuse a development version of asciidoctor when the gem is available:\n\n  $GEM_HOME/gems/asciidoctor-2.0.15/lib/asciidoctor.rb:51:\n    warning: already initialized constant Asciidoctor::RUBY_ENGINE\n  $HOME/asciidoctor/lib/asciidoctor.rb:52:\n    warning: previous definition of RUBY_ENGINE was here\n  ...\n\nThat's a bug in asciidoctor, but there's no need to trigger it.\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n Documentation/asciidoctor-extensions.rb | 1 -\n 1 file changed, 1 deletion(-)\n\ndiff --git a/Documentation/asciidoctor-extensions.rb b/Documentation/asciidoctor-extensions.rb\nindex 70a0956663..423450392d 100644\n--- a/Documentation/asciidoctor-extensions.rb\n+++ b/Documentation/asciidoctor-extensions.rb\n@@ -1,4 +1,3 @@\n-require 'asciidoctor'\n require 'asciidoctor/extensions'\n \n module Git\n-- \n2.32.0.rc0\n\n"},{"id":"425513","messageId":"20210525104802.158336-7-felipe.contreras@gmail.com","threadId":"55769","inReplyTo":"20210525104802.158336-1-felipe.contreras@gmail.com","subject":"[PATCH v3 06/12] doc: asciidoctor: remove cruft","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2021-05-25T10:47:56Z","receivedAt":"2021-05-25T10:48:32Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"These were probably copy-pasted from other extensions. The name is\nalready defined (:linkgit), and we are not using the DSL mode.\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n Documentation/asciidoctor-extensions.rb | 4 ----\n 1 file changed, 4 deletions(-)\n\ndiff --git a/Documentation/asciidoctor-extensions.rb b/Documentation/asciidoctor-extensions.rb\nindex 423450392d..3dea106d00 100644\n--- a/Documentation/asciidoctor-extensions.rb\n+++ b/Documentation/asciidoctor-extensions.rb\n@@ -3,10 +3,6 @@ require 'asciidoctor/extensions'\n module Git\n   module Documentation\n     class LinkGitProcessor < Asciidoctor::Extensions::InlineMacroProcessor\n-      use_dsl\n-\n-      named :chrome\n-\n       def process(parent, target, attrs)\n         prefix = parent.document.attr('git-relative-html-prefix')\n         if parent.document.doctype == 'book'\n-- \n2.32.0.rc0\n\n"},{"id":"425514","messageId":"20210525104802.158336-9-felipe.contreras@gmail.com","threadId":"55769","inReplyTo":"20210525104802.158336-1-felipe.contreras@gmail.com","subject":"[PATCH v3 08/12] doc: asciidoctor: use html-prefix only for html","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2021-05-25T10:47:58Z","receivedAt":"2021-05-25T10:48:33Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"This is what asciidoc.conf does.\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n Documentation/asciidoctor-extensions.rb | 4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/Documentation/asciidoctor-extensions.rb b/Documentation/asciidoctor-extensions.rb\nindex f998a42249..c77b6de350 100644\n--- a/Documentation/asciidoctor-extensions.rb\n+++ b/Documentation/asciidoctor-extensions.rb\n@@ -4,11 +4,11 @@ Asciidoctor::Extensions.register do\n \n   inline_macro :linkgit do\n     process do |parent, target, attrs|\n-      prefix = parent.document.attr('git-relative-html-prefix')\n       if parent.document.doctype == 'book'\n-        \"<ulink url=\\\"#{prefix}#{target}.html\\\">\" \\\n+        \"<ulink url=\\\"#{target}.html\\\">\" \\\n         \"#{target}(#{attrs[1]})</ulink>\"\n       elsif parent.document.basebackend? 'html'\n+        prefix = parent.document.attr('git-relative-html-prefix')\n         %(<a href=\"#{prefix}#{target}.html\">#{target}(#{attrs[1]})</a>)\n       elsif parent.document.basebackend? 'docbook'\n         \"<citerefentry>\\n\" \\\n-- \n2.32.0.rc0\n\n"},{"id":"425515","messageId":"20210525104802.158336-8-felipe.contreras@gmail.com","threadId":"55769","inReplyTo":"20210525104802.158336-1-felipe.contreras@gmail.com","subject":"[PATCH v3 07/12] doc: asciidoctor: reorganize extensions","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2021-05-25T10:47:57Z","receivedAt":"2021-05-25T10:48:34Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"There's no need to create verbose classes, we can do the same with a\nsimple block.\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n Documentation/asciidoctor-extensions.rb | 34 +++++++++++--------------\n 1 file changed, 15 insertions(+), 19 deletions(-)\n\ndiff --git a/Documentation/asciidoctor-extensions.rb b/Documentation/asciidoctor-extensions.rb\nindex 3dea106d00..f998a42249 100644\n--- a/Documentation/asciidoctor-extensions.rb\n+++ b/Documentation/asciidoctor-extensions.rb\n@@ -1,26 +1,22 @@\n require 'asciidoctor/extensions'\n \n-module Git\n-  module Documentation\n-    class LinkGitProcessor < Asciidoctor::Extensions::InlineMacroProcessor\n-      def process(parent, target, attrs)\n-        prefix = parent.document.attr('git-relative-html-prefix')\n-        if parent.document.doctype == 'book'\n-          \"<ulink url=\\\"#{prefix}#{target}.html\\\">\" \\\n-          \"#{target}(#{attrs[1]})</ulink>\"\n-        elsif parent.document.basebackend? 'html'\n-          %(<a href=\"#{prefix}#{target}.html\">#{target}(#{attrs[1]})</a>)\n-        elsif parent.document.basebackend? 'docbook'\n-          \"<citerefentry>\\n\" \\\n-            \"<refentrytitle>#{target}</refentrytitle>\" \\\n-            \"<manvolnum>#{attrs[1]}</manvolnum>\\n\" \\\n-          \"</citerefentry>\"\n-        end\n+Asciidoctor::Extensions.register do\n+\n+  inline_macro :linkgit do\n+    process do |parent, target, attrs|\n+      prefix = parent.document.attr('git-relative-html-prefix')\n+      if parent.document.doctype == 'book'\n+        \"<ulink url=\\\"#{prefix}#{target}.html\\\">\" \\\n+        \"#{target}(#{attrs[1]})</ulink>\"\n+      elsif parent.document.basebackend? 'html'\n+        %(<a href=\"#{prefix}#{target}.html\">#{target}(#{attrs[1]})</a>)\n+      elsif parent.document.basebackend? 'docbook'\n+        \"<citerefentry>\\n\" \\\n+          \"<refentrytitle>#{target}</refentrytitle>\" \\\n+          \"<manvolnum>#{attrs[1]}</manvolnum>\\n\" \\\n+        \"</citerefentry>\"\n       end\n     end\n   end\n-end\n \n-Asciidoctor::Extensions.register do\n-  inline_macro Git::Documentation::LinkGitProcessor, :linkgit\n end\n-- \n2.32.0.rc0\n\n"},{"id":"425516","messageId":"20210525104802.158336-11-felipe.contreras@gmail.com","threadId":"55769","inReplyTo":"20210525104802.158336-1-felipe.contreras@gmail.com","subject":"[PATCH v3 10/12] doc: asciidoctor: improve string handling","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2021-05-25T10:48:00Z","receivedAt":"2021-05-25T10:48:36Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"Using printf style formatting (more familiar to git developers), and\nalso here document.\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n Documentation/asciidoctor-extensions.rb | 14 +++++++-------\n 1 file changed, 7 insertions(+), 7 deletions(-)\n\ndiff --git a/Documentation/asciidoctor-extensions.rb b/Documentation/asciidoctor-extensions.rb\nindex a678704e17..3282d59a48 100644\n--- a/Documentation/asciidoctor-extensions.rb\n+++ b/Documentation/asciidoctor-extensions.rb\n@@ -7,20 +7,20 @@ Asciidoctor::Extensions.register do\n   inline_macro :linkgit do\n     if doc.doctype == 'book'\n       process do |parent, target, attrs|\n-        \"<ulink url=\\\"#{target}.html\\\">\" \\\n-        \"#{target}(#{attrs[1]})</ulink>\"\n+        '<ulink url=\"%1$s.html\">%1$s(%2$s)</ulink>' % [target, attrs[1]]\n       end\n     elsif doc.basebackend? 'html'\n       prefix = doc.attr('git-relative-html-prefix')\n       process do |parent, target, attrs|\n-        %(<a href=\"#{prefix}#{target}.html\">#{target}(#{attrs[1]})</a>)\n+        %(<a href=\"#{prefix}%1$s.html\">%1$s(%2$s)</a>) % [target, attrs[1]]\n       end\n     elsif doc.basebackend? 'docbook'\n       process do |parent, target, attrs|\n-        \"<citerefentry>\\n\" \\\n-          \"<refentrytitle>#{target}</refentrytitle>\" \\\n-          \"<manvolnum>#{attrs[1]}</manvolnum>\\n\" \\\n-        \"</citerefentry>\"\n+        <<~EOF.chomp % [target, attrs[1]]\n+        <citerefentry>\n+        <refentrytitle>%s</refentrytitle><manvolnum>%s</manvolnum>\n+        </citerefentry>\n+        EOF\n       end\n     end\n   end\n-- \n2.32.0.rc0\n\n"},{"id":"425517","messageId":"20210525104802.158336-12-felipe.contreras@gmail.com","threadId":"55769","inReplyTo":"20210525104802.158336-1-felipe.contreras@gmail.com","subject":"[PATCH v3 11/12] doc: asciidoctor: split the format from the code","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2021-05-25T10:48:01Z","receivedAt":"2021-05-25T10:48:37Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"This way we don't have to specify the block to execute on every\nconditional.\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n Documentation/asciidoctor-extensions.rb | 26 ++++++++++++-------------\n 1 file changed, 13 insertions(+), 13 deletions(-)\n\ndiff --git a/Documentation/asciidoctor-extensions.rb b/Documentation/asciidoctor-extensions.rb\nindex 3282d59a48..51981af13c 100644\n--- a/Documentation/asciidoctor-extensions.rb\n+++ b/Documentation/asciidoctor-extensions.rb\n@@ -6,22 +6,22 @@ Asciidoctor::Extensions.register do\n \n   inline_macro :linkgit do\n     if doc.doctype == 'book'\n-      process do |parent, target, attrs|\n-        '<ulink url=\"%1$s.html\">%1$s(%2$s)</ulink>' % [target, attrs[1]]\n-      end\n+      format = '<ulink url=\"%1$s.html\">%1$s(%2$s)</ulink>'\n     elsif doc.basebackend? 'html'\n       prefix = doc.attr('git-relative-html-prefix')\n-      process do |parent, target, attrs|\n-        %(<a href=\"#{prefix}%1$s.html\">%1$s(%2$s)</a>) % [target, attrs[1]]\n-      end\n+      format = %(<a href=\"#{prefix}%1$s.html\">%1$s(%2$s)</a>)\n     elsif doc.basebackend? 'docbook'\n-      process do |parent, target, attrs|\n-        <<~EOF.chomp % [target, attrs[1]]\n-        <citerefentry>\n-        <refentrytitle>%s</refentrytitle><manvolnum>%s</manvolnum>\n-        </citerefentry>\n-        EOF\n-      end\n+      format = <<~EOF.chomp\n+      <citerefentry>\n+      <refentrytitle>%s</refentrytitle><manvolnum>%s</manvolnum>\n+      </citerefentry>\n+      EOF\n+    else\n+      return\n+    end\n+\n+    process do |_, target, attrs|\n+      format % [target, attrs[1]]\n     end\n   end\n \n-- \n2.32.0.rc0\n\n"},{"id":"425518","messageId":"20210525104802.158336-13-felipe.contreras@gmail.com","threadId":"55769","inReplyTo":"20210525104802.158336-1-felipe.contreras@gmail.com","subject":"[PATCH v3 12/12] doc: asciidoctor: specify name of our group","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2021-05-25T10:48:02Z","receivedAt":"2021-05-25T10:48:38Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"Doesn't do anything, but otherwise we get a random name.\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n Documentation/asciidoctor-extensions.rb | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/Documentation/asciidoctor-extensions.rb b/Documentation/asciidoctor-extensions.rb\nindex 51981af13c..b36317e4d2 100644\n--- a/Documentation/asciidoctor-extensions.rb\n+++ b/Documentation/asciidoctor-extensions.rb\n@@ -1,6 +1,6 @@\n require 'asciidoctor/extensions'\n \n-Asciidoctor::Extensions.register do\n+Asciidoctor::Extensions.register :git do\n \n   doc = document\n \n-- \n2.32.0.rc0\n\n"},{"id":"425519","messageId":"20210525104802.158336-10-felipe.contreras@gmail.com","threadId":"55769","inReplyTo":"20210525104802.158336-1-felipe.contreras@gmail.com","subject":"[PATCH v3 09/12] doc: asciidoctor: refactor macro registration","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2021-05-25T10:47:59Z","receivedAt":"2021-05-25T10:48:42Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"There is no need to execute extra code every time the process block is\ncalled.\n\nIn Ruby the lexical scope is shared, so we can define variables in the\nregister block scope, and all the rest will inherit those variables.\n\nBased on the doctype and basebackend one of three blocks is selected for\nthe inline_macro. However, the conditionals will be run only once.\n\nIn the end Ruby will only run the code between `process do end`, nothing\nelse.\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n Documentation/asciidoctor-extensions.rb | 16 +++++++++++-----\n 1 file changed, 11 insertions(+), 5 deletions(-)\n\ndiff --git a/Documentation/asciidoctor-extensions.rb b/Documentation/asciidoctor-extensions.rb\nindex c77b6de350..a678704e17 100644\n--- a/Documentation/asciidoctor-extensions.rb\n+++ b/Documentation/asciidoctor-extensions.rb\n@@ -2,15 +2,21 @@ require 'asciidoctor/extensions'\n \n Asciidoctor::Extensions.register do\n \n+  doc = document\n+\n   inline_macro :linkgit do\n-    process do |parent, target, attrs|\n-      if parent.document.doctype == 'book'\n+    if doc.doctype == 'book'\n+      process do |parent, target, attrs|\n         \"<ulink url=\\\"#{target}.html\\\">\" \\\n         \"#{target}(#{attrs[1]})</ulink>\"\n-      elsif parent.document.basebackend? 'html'\n-        prefix = parent.document.attr('git-relative-html-prefix')\n+      end\n+    elsif doc.basebackend? 'html'\n+      prefix = doc.attr('git-relative-html-prefix')\n+      process do |parent, target, attrs|\n         %(<a href=\"#{prefix}#{target}.html\">#{target}(#{attrs[1]})</a>)\n-      elsif parent.document.basebackend? 'docbook'\n+      end\n+    elsif doc.basebackend? 'docbook'\n+      process do |parent, target, attrs|\n         \"<citerefentry>\\n\" \\\n           \"<refentrytitle>#{target}</refentrytitle>\" \\\n           \"<manvolnum>#{attrs[1]}</manvolnum>\\n\" \\\n-- \n2.32.0.rc0\n\n"}]}