I look deeper into asciidoctor and asciidoctor-ant, and I have managed to 
create a simple macro. It creates links to jira just by declaring the name of 
the issue.

The Ant tasks only supports macro implemented in Java, not Ruby, even if it 
seems that asciidoctor itself might support them in Ruby. So the build is a 
little more complex. I hope it is ok. At least the setup is in place in case 
somebody wants to add more macros.

Nicolas

> Le 12 juil. 2017 à 22:55, hi...@apache.org a écrit :
> 
> Repository: ant-ivy
> Updated Branches:
>  refs/heads/master 1a36ae09d -> 6f22f4b49
> 
> 
> An asciidoctor macro to create links to Jira
> 
> 
> Project: http://git-wip-us.apache.org/repos/asf/ant-ivy/repo
> Commit: http://git-wip-us.apache.org/repos/asf/ant-ivy/commit/6f22f4b4
> Tree: http://git-wip-us.apache.org/repos/asf/ant-ivy/tree/6f22f4b4
> Diff: http://git-wip-us.apache.org/repos/asf/ant-ivy/diff/6f22f4b4
> 
> Branch: refs/heads/master
> Commit: 6f22f4b49c2a3a59840d28e6cbe0c37a56ab1f90
> Parents: 1a36ae0
> Author: Nicolas Lalevée <nicolas.lale...@hibnet.org>
> Authored: Wed Jul 12 22:54:25 2017 +0200
> Committer: Nicolas Lalevée <nicolas.lale...@hibnet.org>
> Committed: Wed Jul 12 22:54:25 2017 +0200
> 
> ----------------------------------------------------------------------
> asciidoc/release-notes.adoc                     | 54 ++++++++++----------
> .../src/org/apache/ivy/asciidoc/JiraMacro.java  | 40 +++++++++++++++
> build-release.xml                               | 23 ++++++++-
> 3 files changed, 88 insertions(+), 29 deletions(-)
> ----------------------------------------------------------------------
> 
> 
> http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/6f22f4b4/asciidoc/release-notes.adoc
> ----------------------------------------------------------------------
> diff --git a/asciidoc/release-notes.adoc b/asciidoc/release-notes.adoc
> index c2b7962..3b691b6 100644
> --- a/asciidoc/release-notes.adoc
> +++ b/asciidoc/release-notes.adoc
> @@ -50,40 +50,40 @@ http://issues.apache.org/jira/browse/ivy
> 
> List of changes since Ivy 2.4.0:
> 
> -- FIX: Local conflict manager didn't handle deeper conflicts in transitive 
> dependencies (link:https://issues.apache.org/jira/browse/IVY-1404[IVY-1404])
> -- FIX: Made the maven 'test' configuration public so we can use the test-jar 
> as dependency (link:https://issues.apache.org/jira/browse/IVY-1444[IVY-1444])
> -- FIX: NullPointerException in dependencytree with no dependencies 
> (link:https://issues.apache.org/jira/browse/IVY-1539[IVY-1539])
> -- FIX: checkIfChanged is not settable attribute for checkdepsupdate ant task 
> (link:https://issues.apache.org/jira/browse/IVY-1549[IVY-1549])
> -- FIX: ArrayIndexOutOfBoundsException when using a p2 repository for 
> dependencies (link:https://issues.apache.org/jira/browse/IVY-1504[IVY-1504])
> +- FIX: Local conflict manager didn't handle deeper conflicts in transitive 
> dependencies (jira:IVY-1404[])
> +- FIX: Made the maven 'test' configuration public so we can use the test-jar 
> as dependency (jira:IVY-1444[])
> +- FIX: NullPointerException in dependencytree with no dependencies 
> (jira:IVY-1539[])
> +- FIX: checkIfChanged is not settable attribute for checkdepsupdate ant task 
> (jira:IVY-1549[])
> +- FIX: ArrayIndexOutOfBoundsException when using a p2 repository for 
> dependencies (jira:IVY-1504[])
> - FIX: fixdeps remove transitive 'kept' dependencies
> -- FIX: PomModuleDescriptorParser should parse licenses from parent POM 
> (link:https://issues.apache.org/jira/browse/IVY-1526[IVY-1526]) (Thanks to 
> Jaikiran Pai)
> -- FIX: dynamic revisions are not cached per resolver 
> (link:https://issues.apache.org/jira/browse/IVY-1430[IVY-1430]) (Thanks to 
> Stephen Haberman)
> -- FIX: Dependencies failed using branch attribute (and extra attributes) 
> (link:https://issues.apache.org/jira/browse/IVY-1141[IVY-1141]) (Thanks to 
> Stephen Haberman)
> -- FIX: useCacheOnly should allow lookup of changing dependencies in cache 
> (link:https://issues.apache.org/jira/browse/IVY-1515[IVY-1515]) (Thanks to 
> Ilya)
> -- FIX: Translation of POM to Ivy XML with * exclusion is removing main 
> artifact (link:https://issues.apache.org/jira/browse/IVY-1531[IVY-1531]) 
> (Thanks to Jaikiran Pai)
> -- FIX: Have makepom task take description from ivy-module > info > 
> description element 
> (link:https://issues.apache.org/jira/browse/IVY-1520[IVY-1520])
> -- FIX: Fix RetrieveEngine to take into account the correct extension while 
> dealing with unpacked artifacts 
> (link:https://issues.apache.org/jira/browse/IVY-1478[IVY-1478]) (Thanks to 
> Jaikiran Pai)
> -- FIX: ParseException "Unsupported repository, resources names are not uris" 
> for ivy.xml with parent on Windows 
> (link:https://issues.apache.org/jira/browse/IVY-1448[IVY-1448]) (Thanks to 
> Riccardo Foschia and Jaikiran Pai)
> -- FIX: Ivy 2.4.0 improperly handles modules with colon (:) in version 
> (link:https://issues.apache.org/jira/browse/IVY-1522[IVY-1522]) (Thanks to 
> Jaikiran Pai)
> -- FIX: Delay the processing of configured cache ttls, until the IvySettings 
> object is usable 
> (link:https://issues.apache.org/jira/browse/IVY-1495[IVY-1495]) (Thanks to 
> Jaikiran Pai)
> -- FIX: Including optional ivysettings of type 'file' doesn't work when file 
> doesn't exist (link:https://issues.apache.org/jira/browse/IVY-1555[IVY-1555]) 
> (Thanks to Jaikiran Pai)
> -- FIX: Makepom ignores dependency classifiers 
> (link:https://issues.apache.org/jira/browse/IVY-1528[IVY-1528]) (Thanks to 
> Jaikiran Pai)
> -- FIX: Infinite loop in dependencytree 
> (link:https://issues.apache.org/jira/browse/IVY-1540[IVY-1540]) (Thanks to 
> Jaikiran Pai)
> -
> -- IMPROVEMENT: Throw an IllegalStateException when retrieving the 
> resolutionCacheRoot on the DefaultResolutionCacheManager if the basedir (or 
> IvySettings) is not set 
> (link:https://issues.apache.org/jira/browse/IVY-1482[IVY-1482])
> +- FIX: PomModuleDescriptorParser should parse licenses from parent POM 
> (jira:IVY-1526[]) (Thanks to Jaikiran Pai)
> +- FIX: dynamic revisions are not cached per resolver (jira:IVY-1430[]) 
> (Thanks to Stephen Haberman)
> +- FIX: Dependencies failed using branch attribute (and extra attributes) 
> (jira:IVY-1141[]) (Thanks to Stephen Haberman)
> +- FIX: useCacheOnly should allow lookup of changing dependencies in cache 
> (jira:IVY-1515[]) (Thanks to Ilya)
> +- FIX: Translation of POM to Ivy XML with * exclusion is removing main 
> artifact (jira:IVY-1531[]) (Thanks to Jaikiran Pai)
> +- FIX: Have makepom task take description from ivy-module > info > 
> description element (jira:IVY-1520[])
> +- FIX: Fix RetrieveEngine to take into account the correct extension while 
> dealing with unpacked artifacts (jira:IVY-1478[]) (Thanks to Jaikiran Pai)
> +- FIX: ParseException "Unsupported repository, resources names are not uris" 
> for ivy.xml with parent on Windows (jira:IVY-1448[]) (Thanks to Riccardo 
> Foschia and Jaikiran Pai)
> +- FIX: Ivy 2.4.0 improperly handles modules with colon (:) in version 
> (jira:IVY-1522[]) (Thanks to Jaikiran Pai)
> +- FIX: Delay the processing of configured cache ttls, until the IvySettings 
> object is usable (jira:IVY-1495[]) (Thanks to Jaikiran Pai)
> +- FIX: Including optional ivysettings of type 'file' doesn't work when file 
> doesn't exist (jira:IVY-1555[]) (Thanks to Jaikiran Pai)
> +- FIX: Makepom ignores dependency classifiers (jira:IVY-1528[]) (Thanks to 
> Jaikiran Pai)
> +- FIX: Infinite loop in dependencytree (jira:IVY-1540[]) (Thanks to Jaikiran 
> Pai)
> +
> +- IMPROVEMENT: Throw an IllegalStateException when retrieving the 
> resolutionCacheRoot on the DefaultResolutionCacheManager if the basedir (or 
> IvySettings) is not set (jira:IVY-1482[])
> - IMPROVEMENT: Optimization: limit the revision numbers scanned if revision 
> prefix is specified (Thanks to Ernestas Vaiciukevi&#269;ius)
> -- IMPROVEMENT: Update bouncycastle to 1.52 
> (link:https://issues.apache.org/jira/browse/IVY-1521[IVY-1521]) (Thanks to 
> Michal Srb)
> +- IMPROVEMENT: Update bouncycastle to 1.52 (jira:IVY-1521[]) (Thanks to 
> Michal Srb)
> 
> - NEW: Lets ssh-based resolvers use an ~/.ssh/config file to find 
> username/hostname/keyfile options (Thanks to Colin Stanfill)
> -- NEW: Add ivy.maven.lookup.sources and ivy.maven.lookup.javadoc variables 
> to control the lookup of the additional artifacts. Defaults to true, for 
> backward compatibility 
> (link:https://issues.apache.org/jira/browse/IVY-1529[IVY-1529])
> -- NEW: Add (conditional) support for SHA-256 SHA-512 and SHA-384 checksum 
> algorithms (link:https://issues.apache.org/jira/browse/IVY-1554[IVY-1554]) 
> (Thanks to Jaikiran Pai)
> +- NEW: Add ivy.maven.lookup.sources and ivy.maven.lookup.javadoc variables 
> to control the lookup of the additional artifacts. Defaults to true, for 
> backward compatibility (jira:IVY-1529[])
> +- NEW: Add (conditional) support for SHA-256 SHA-512 and SHA-384 checksum 
> algorithms (jira:IVY-1554[]) (Thanks to Jaikiran Pai)
> 
> ////
>  Samples :
> -- NEW: bla bla bla 
> (link:https://issues.apache.org/jira/browse/IVY-1234[IVY-1234]) (Thanks to 
> Jane Doe)
> -- IMPROVEMENT: bla bla bla 
> (link:https://issues.apache.org/jira/browse/IVY-1234[IVY-1234]) (Thanks to 
> Jane Doe)
> -- FIX: bla bla bla 
> (link:https://issues.apache.org/jira/browse/IVY-1234[IVY-1234]) (Thanks to 
> Jane Doe)
> -- DOCUMENTATION: bla bla bla 
> (link:https://issues.apache.org/jira/browse/IVY-1234[IVY-1234]) (Thanks to 
> Jane Doe)
> +- NEW: bla bla bla (jira:IVY-1234[]) (Thanks to Jane Doe)
> +- IMPROVEMENT: bla bla bla (jira:IVY-1234[]) (Thanks to Jane Doe)
> +- FIX: bla bla bla (jira:IVY-1234[]) (Thanks to Jane Doe)
> +- DOCUMENTATION: bla bla bla (jira:IVY-1234[]) (Thanks to Jane Doe)
> ////
> 
> === Committers and Contributors
> 
> http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/6f22f4b4/asciidoc/templates/extensions/src/org/apache/ivy/asciidoc/JiraMacro.java
> ----------------------------------------------------------------------
> diff --git 
> a/asciidoc/templates/extensions/src/org/apache/ivy/asciidoc/JiraMacro.java 
> b/asciidoc/templates/extensions/src/org/apache/ivy/asciidoc/JiraMacro.java
> new file mode 100644
> index 0000000..113520a
> --- /dev/null
> +++ b/asciidoc/templates/extensions/src/org/apache/ivy/asciidoc/JiraMacro.java
> @@ -0,0 +1,40 @@
> +/*
> + *  Licensed to the Apache Software Foundation (ASF) under one or more
> + *  contributor license agreements.  See the NOTICE file distributed with
> + *  this work for additional information regarding copyright ownership.
> + *  The ASF licenses this file to You under the Apache License, Version 2.0
> + *  (the "License"); you may not use this file except in compliance with
> + *  the License.  You may obtain a copy of the License at
> + *
> + *      http://www.apache.org/licenses/LICENSE-2.0
> + *
> + *  Unless required by applicable law or agreed to in writing, software
> + *  distributed under the License is distributed on an "AS IS" BASIS,
> + *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
> + *  See the License for the specific language governing permissions and
> + *  limitations under the License.
> + *
> + */
> +package org.apache.ivy.asciidoc;
> +
> +import java.util.Map;
> +import java.util.HashMap;
> +
> +import org.asciidoctor.ast.AbstractBlock;
> +import org.asciidoctor.extension.InlineMacroProcessor;
> +
> +public class JiraMacro extends InlineMacroProcessor {
> +
> +    public JiraMacro(String macroName, Map<String, Object> config) {
> +        super(macroName, config);
> +    }
> +
> +    @Override
> +    protected String process(AbstractBlock parent, String target, 
> Map<String, Object> attributes) {
> +        Map<String, Object> options = new HashMap<String, Object>();
> +        options.put("type", ":link");
> +        options.put("target", "https://issues.apache.org/jira/browse/"; + 
> target);
> +        return createInline(parent, "anchor", target, attributes, 
> options).convert();
> +    }
> +
> +}
> 
> http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/6f22f4b4/build-release.xml
> ----------------------------------------------------------------------
> diff --git a/build-release.xml b/build-release.xml
> index 4d5e15b..0a6fcb6 100644
> --- a/build-release.xml
> +++ b/build-release.xml
> @@ -166,9 +166,26 @@
>         <replace dir="${output.dir}" token="${ivy.revision}" 
> value="working@apache"/>
>     </target>
> 
> -    <target name="init-asciidoctor" depends="init-ivy" unless="skip.doc">
> +    <target name="init-asciidoctor-extensions" depends="init-ivy" 
> unless="skip.doc">
> +        <ivy:cachepath pathid="asciidoctorj.path" 
> organisation="org.asciidoctor" module="asciidoctorj" revision="1.5.5" 
> conf="runtime" inline="true"/>
> +        <mkdir dir="${build.dir}/asciidoc-extensions/classes"/>
> +        <javac srcdir="${doc.src.dir}/templates/extensions/src" 
> destdir="${build.dir}/asciidoc-extensions/classes"
> +               debug="true" includeantruntime="no" 
> classpathref="asciidoctorj.path"/>
> +        <copy todir="${build.dir}/asciidoc-extensions">
> +            <fileset dir="${doc.src.dir}/templates/extensions/src">
> +                <exclude name="**/*.java"/>
> +            </fileset>
> +        </copy>
> +    </target>
> +
> +    <target name="init-asciidoctor" depends="init-asciidoctor-extensions" 
> unless="skip.doc">
>         <ivy:cachepath pathid="asciidoctor.path" 
> organisation="org.asciidoctor" module="asciidoctor-ant" revision="1.5.4" 
> inline="true"/>
> -        <taskdef uri="antlib:org.asciidoctor.ant" 
> resource="org/asciidoctor/ant/antlib.xml" classpathref="asciidoctor.path"/>
> +        <taskdef uri="antlib:org.asciidoctor.ant" 
> resource="org/asciidoctor/ant/antlib.xml" classpathref="asciidoctor.path">
> +            <classpath>
> +                <pathelement 
> location="${build.dir}/asciidoc-extensions/classes" />
> +                <path refid="asciidoctor.path" />
> +            </classpath>
> +        </taskdef>
>     </target>
> 
>     <target name="copy-doc-files" unless="skip.doc">
> @@ -185,6 +202,7 @@
>             <attribute key="basedir" value="${doc.src.dir}"/>
>             <attribute key="imagesdir" value=""/>
>             <attribute key="version" value="${build.version}"/>
> +            <inlineMacroProcessor blockName="jira" 
> className="org.apache.ivy.asciidoc.JiraMacro" />
>         </asciidoctor:convert>
>     </target>
> 
> @@ -237,6 +255,7 @@
>         <asciidoctor:convert sourceDirectory="${build.dir}/book" 
> outputDirectory="${doc.build.dir}" backend="xhtml5"
>                              templateDir="${doc.src.dir}/templates/book" 
> sourceHighlighter="highlightjs" doctype="book">
>             <attribute key="version" value="${build.version}" />
> +            <inlineMacroProcessor blockName="jira" 
> className="org.apache.ivy.asciidoc.JiraMacro" />
>         </asciidoctor:convert>
>     </target>
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@ant.apache.org
For additional commands, e-mail: dev-h...@ant.apache.org

Reply via email to