From owner-dev-commits-doc-all@freebsd.org Sat Feb 13 21:22:45 2021 Return-Path: Delivered-To: dev-commits-doc-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A3B5153BD33 for ; Sat, 13 Feb 2021 21:22:45 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4DdNcj4K3hz3LcR; Sat, 13 Feb 2021 21:22:45 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 874B21E45A; Sat, 13 Feb 2021 21:22:45 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 11DLMju5065980; Sat, 13 Feb 2021 21:22:45 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11DLMjKB065979; Sat, 13 Feb 2021 21:22:45 GMT (envelope-from git) Date: Sat, 13 Feb 2021 21:22:45 GMT Message-Id: <202102132122.11DLMjKB065979@gitrepo.freebsd.org> To: doc-committers@FreeBSD.org, dev-commits-doc-all@FreeBSD.org From: Sergio Carlavilla Delgado Subject: git: fb36cfdfb2 - main - Add gitref macro to reference a git hash MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: carlavilla X-Git-Repository: doc X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: fb36cfdfb2dd5e9ebe217d820609d96fb73d8cc8 Auto-Submitted: auto-generated X-BeenThere: dev-commits-doc-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the doc repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 13 Feb 2021 21:22:45 -0000 The branch main has been updated by carlavilla: URL: https://cgit.FreeBSD.org/doc/commit/?id=fb36cfdfb2dd5e9ebe217d820609d96fb73d8cc8 commit fb36cfdfb2dd5e9ebe217d820609d96fb73d8cc8 Author: Sergio Carlavilla Delgado AuthorDate: 2021-02-13 21:16:57 +0000 Commit: Sergio Carlavilla Delgado CommitDate: 2021-02-13 21:22:34 +0000 Add gitref macro to reference a git hash With this extension a git hash can be easily referenced. The porters handbook versions chapter uses this extension as an example in the FreeBSD 14.0 version table. An example of use gitref:hash[repository="src|doc|ports",length=hash-longitude] The repository should be src, doc or ports. And if no length it's specified the macro will use 12 characters of the specified hash. PR: 253050 Submitted by: jhb@ --- documentation/config/_default/config.toml | 2 +- .../books/porters-handbook/versions/chapter.adoc | 8 +++---- shared/lib/GitReferencesMacro/extension.rb | 25 ++++++++++++++++++++++ shared/lib/git-macro.rb | 5 +++++ website/config/_default/config.toml | 2 +- 5 files changed, 36 insertions(+), 6 deletions(-) diff --git a/documentation/config/_default/config.toml b/documentation/config/_default/config.toml index d75e4f5433..316f8bacd8 100644 --- a/documentation/config/_default/config.toml +++ b/documentation/config/_default/config.toml @@ -19,7 +19,7 @@ enableRobotsTXT = true [markup.asciidocExt] preserveTOC = true - extensions = ["../shared/lib/man-macro.rb", "../shared/lib/inter-document-references-macro.rb", "../shared/lib/sectnumoffset-treeprocessor.rb", "../shared/lib/packages-macro.rb"] + extensions = ["../shared/lib/man-macro.rb", "../shared/lib/inter-document-references-macro.rb", "../shared/lib/sectnumoffset-treeprocessor.rb", "../shared/lib/packages-macro.rb", "../shared/lib/git-macro.rb"] [outputs] home = [ "HTML" ] diff --git a/documentation/content/en/books/porters-handbook/versions/chapter.adoc b/documentation/content/en/books/porters-handbook/versions/chapter.adoc index cc3ab873b3..e55201ea51 100644 --- a/documentation/content/en/books/porters-handbook/versions/chapter.adoc +++ b/documentation/content/en/books/porters-handbook/versions/chapter.adoc @@ -43,22 +43,22 @@ Here is a convenient list of `__FreeBSD_version` values as defined in https://cg | Release |1400000 -|link:https://cgit.freebsd.org/src/commit/?id=a53ce3fc4938e37d5ec89304846203d2083c61a2[a53ce3fc4938] +|gitref:a53ce3fc4938e37d5ec89304846203d2083c61a2[repository="src",length=12] |January 22, 2021 |14.0-CURRENT. |1400001 -|link:https://cgit.freebsd.org/src/commit/?id=739ecbcf1c4fd22b5f6ee0bb180a67644046a3e0[739ecbcf1c4f] +|gitref:739ecbcf1c4fd22b5f6ee0bb180a67644046a3e0[repository="src",length=12] |January 23, 2021 |14.0-CURRENT after adding symlink support to lockless lookup. |1400002 -|link:https://cgit.freebsd.org/src/commit/?id=2cf84258922f306a3f84866685d2f5346f67db58[2cf84258922f] +|gitref:2cf84258922f306a3f84866685d2f5346f67db58[repository="src",length=12] |January 26, 2021 |14.0-CURRENT after fixing a clang assertion when building the package:devel/onetbb[] port. |1400003 -|link:https://cgit.freebsd.org/src/commit/?id=d386f3a3c32f0396aa7995349dd65d6c59711393[d386f3a3c32f] +|gitref:d386f3a3c32f0396aa7995349dd65d6c59711393[repository="src",length=12] |January 28, 2021 |14.0-CURRENT after adding various LinuxKPI bits conflicting with drm-kmod. |=== diff --git a/shared/lib/GitReferencesMacro/extension.rb b/shared/lib/GitReferencesMacro/extension.rb new file mode 100644 index 0000000000..40dcbed1fd --- /dev/null +++ b/shared/lib/GitReferencesMacro/extension.rb @@ -0,0 +1,25 @@ +require 'asciidoctor/extensions' unless RUBY_ENGINE == 'opal' + +include ::Asciidoctor + +class GitReferencesMacro < Asciidoctor::Extensions::InlineMacroProcessor + use_dsl + + named :gitref + + def process parent, target, attrs + hash = target + repository = if (repository = attrs['repository']) + "#{repository}" + else + "src" + end + length = if (length = attrs['length']) + length.to_i + else + 12 + end + url = %(https://cgit.freebsd.org/#{repository}/commit/?id=#{hash}) + %(#{hash[0, length]}) + end +end diff --git a/shared/lib/git-macro.rb b/shared/lib/git-macro.rb new file mode 100644 index 0000000000..0ed1526b14 --- /dev/null +++ b/shared/lib/git-macro.rb @@ -0,0 +1,5 @@ +RUBY_ENGINE == 'opal' ? (require 'GitReferencesMacro/extension') : (require_relative 'GitReferencesMacro/extension') + +Asciidoctor::Extensions.register do + inline_macro GitReferencesMacro +end diff --git a/website/config/_default/config.toml b/website/config/_default/config.toml index 656b88787c..a7c4585ebe 100644 --- a/website/config/_default/config.toml +++ b/website/config/_default/config.toml @@ -17,7 +17,7 @@ preserveTOC = true [markup.asciidocExt] preserveTOC = true - extensions = ["../shared/lib/man-macro.rb", "../shared/lib/inter-document-references-macro.rb", "../shared/lib/sectnumoffset-treeprocessor.rb", "../shared/lib/packages-macro.rb"] + extensions = ["../shared/lib/man-macro.rb", "../shared/lib/inter-document-references-macro.rb", "../shared/lib/sectnumoffset-treeprocessor.rb", "../shared/lib/packages-macro.rb", "../shared/lib/git-macro.rb"] staticDir = ["static", "shared"]