AsciiDoc Javadoc Doclet

Asciidoclet is a Javadoc Doclet that allows you to write Javadoc using the AsciiDoc format.

License

License

GroupId

GroupId

org.asciidoctor
ArtifactId

ArtifactId

asciidoclet
Last Version

Last Version

1.5.6
Release Date

Release Date

Type

Type

jar
Description

Description

AsciiDoc Javadoc Doclet
Asciidoclet is a Javadoc Doclet that allows you to write Javadoc using the AsciiDoc format.
Project URL

Project URL

http://asciidoctor.org
Source Code Management

Source Code Management

http://github.com/asciidoctor/asciidoclet

Download asciidoclet

How to add to project

<!-- https://jarcasting.com/artifacts/org.asciidoctor/asciidoclet/ -->
<dependency>
    <groupId>org.asciidoctor</groupId>
    <artifactId>asciidoclet</artifactId>
    <version>1.5.6</version>
</dependency>
// https://jarcasting.com/artifacts/org.asciidoctor/asciidoclet/
implementation 'org.asciidoctor:asciidoclet:1.5.6'
// https://jarcasting.com/artifacts/org.asciidoctor/asciidoclet/
implementation ("org.asciidoctor:asciidoclet:1.5.6")
'org.asciidoctor:asciidoclet:jar:1.5.6'
<dependency org="org.asciidoctor" name="asciidoclet" rev="1.5.6">
  <artifact name="asciidoclet" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.asciidoctor', module='asciidoclet', version='1.5.6')
)
libraryDependencies += "org.asciidoctor" % "asciidoclet" % "1.5.6"
[org.asciidoctor/asciidoclet "1.5.6"]

Dependencies

compile (3)

Group / Artifact Type Version
org.asciidoctor : asciidoctorj jar 1.5.6
org.slf4j : slf4j-simple jar 1.7.25
com.google.guava : guava jar 20.0

test (5)

Group / Artifact Type Version
junit : junit jar 4.12
org.mockito : mockito-all jar 1.10.19
org.powermock : powermock-module-junit4 jar 1.6.4
org.powermock : powermock-api-mockito jar 1.6.4
org.hamcrest : hamcrest-library jar 1.3

system (1)

Group / Artifact Type Version
com.sun.tools » tools jar ${java.version}

Project Modules

There are no modules declared in this project.

Asciidoclet

Build Status Javadoc

Asciidoclet is a Javadoc Doclet based on Asciidoctor that lets you write Javadoc in the AsciiDoc syntax.

Introduction

Traditionally, Javadocs have mixed minor markup with HTML which, if you’re writing for HTML Javadoc output, becomes unreadable and hard to write over time. This is where lightweight markup languages like AsciiDoc thrive. AsciiDoc straddles the line between readable markup and beautifully rendered content.

Asciidoclet incorporates an AsciiDoc renderer (Asciidoctor via the Asciidoctor Java integration library) into a simple Doclet that enables AsciiDoc formatting within Javadoc comments and tags.

Example

Here’s an example of a class with traditional Javadoc.

A Java class with traditional Javadoc
/**
 * <h1>Asciidoclet</h1>
 *
 * <p>Sample comments that include {@code source code}.</p>
 *
 * <pre>{@code
 * public class Asciidoclet extends Doclet {
 *     private final Asciidoctor asciidoctor = Asciidoctor.Factory.create();
 *
 *     {@literal @}SuppressWarnings("UnusedDeclaration")
 *     public static boolean start(RootDoc rootDoc) {
 *         new Asciidoclet().render(rootDoc);
 *         return Standard.start(rootDoc);
 *     }
 * }
 * }</pre>
 *
 * @author <a href="https://github.com/johncarl81">John Ericksen</a>
 */
public class Asciidoclet extends Doclet {
}

This is the same class with Asciidoclet.

A Java class with Asciidoclet Javadoc
/**
 * = Asciidoclet
 *
 * Sample comments that include `source code`.
 *
 * [source,java]
 * --
 * public class Asciidoclet extends Doclet {
 *     private final Asciidoctor asciidoctor = Asciidoctor.Factory.create();
 *
 *     @SuppressWarnings("UnusedDeclaration")
 *     public static boolean start(RootDoc rootDoc) {
 *         new Asciidoclet().render(rootDoc);
 *         return Standard.start(rootDoc);
 *     }
 * }
 * --
 *
 * @author https://github.com/johncarl81[John Ericksen]
 */
public class Asciidoclet extends Doclet {
}

The result is readable source and beautifully rendered Javadocs, the best of both worlds!

Usage

Run Javadoc with the org.asciidoctor.Asciidoclet doclet class. Some examples for common build systems are shown below. See Doclet Options for supported options.

Maven

Asciidoclet may be used via a maven-javadoc-plugin doclet:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-javadoc-plugin</artifactId>
    <version>2.9</version>
    <configuration>
        <source>1.7</source>
        <doclet>org.asciidoctor.Asciidoclet</doclet>
        <docletArtifact>
            <groupId>org.asciidoctor</groupId>
            <artifactId>asciidoclet</artifactId>
            <version>${asciidoclet.version}</version>
        </docletArtifact>
        <overview>src/main/java/overview.adoc</overview>
        <additionalparam>
          --base-dir ${project.basedir}
          --attribute "name=${project.name}"
          --attribute "version=${project.version}"
          --attribute "title-link=https://example.com[${project.name} ${project.version}]"
        </additionalparam>
    </configuration>
</plugin>

Gradle

Asciidoclet may be used via a doclet in the Javadoc task:

configurations {
    asciidoclet
}

dependencies {
    asciidoclet 'org.asciidoctor:asciidoclet:1.+'
}

javadoc {
    options.docletpath = configurations.asciidoclet.files.asType(List)
    options.doclet = 'org.asciidoctor.Asciidoclet'
    options.overview = "src/main/java/overview.adoc"
    options.addStringOption "-base-dir", "${projectDir}" // (1)
    options.addStringOption "-attribute", // (2)
            "name=${project.name}," +
            "version=${project.version}," +
            "title-link=https://example.com[${project.name} ${project.version}]")
}
  1. Option names passed to Gradle’s javadoc task must omit the leading "-", so here "-base-dir" means "--base-dir". See Doclet Options below.

  2. Gradle’s javadoc task does not allow multiple occurrences of the same option. Multiple attributes can be specified in a single string, separated by commas.

Ant

Asciidoclet may be used via a doclet element in Ant’s javadoc task:

<javadoc destdir="target/javadoc"
         sourcepath="src"
         overview="src/overview.adoc">
  <doclet name="org.asciidoctor.Asciidoclet" pathref="asciidoclet.classpath"> <!--(1)-->
    <param name="--base-dir" value="${basedir}"/>
    <param name="--attribute" value="name=${ant.project.name}"/>
    <param name="--attribute" value="version=${version}"/>
    <param name="--attribute" value="title-link=https://example.com[${ant.project.name} ${version}]"/>
  </doclet>
</javadoc>
  1. Assumes a path reference has been defined for Asciidoclet and its dependencies, e.g. using Ivy or similar.

Doclet Options

--base-dir <dir>

Sets the base directory that will be used to resolve relative path names in Asciidoc include:: directives. This should be set to the project’s root directory.

-a, --attribute "name[=value], …​"

Sets document attributes that will be expanded in Javadoc comments. The argument is a string containing a single attribute, or multiple attributes separated by commas.

This option may be used more than once, for example: -a name=foo -a version=1.

Attributes use the same syntax as Asciidoctor command-line attributes:

  • name sets the attribute (with an empty value)

  • name=value assigns value to the attribute. Occurrences of {name} in the Javadoc will be replaced by this value.

  • name=value@ assigns value to the attribute, unless the attribute is defined in the attributes file or Javadoc.

  • name! unsets the attribute.

The document attribute javadoc is set automatically by the doclet. This can be used for conditionally selecting content when using the same Asciidoc file for Javadoc and other documentation.

--attributes-file <file>

Reads document attributes from an Asciidoc file. The attributes will be expanded in Javadoc comments.

If <file> is a relative path name, it is assumed to be relative to the --base-dir directory.

Attributes set by the -a/--attribute option take precedence over those in the attributes file.

-r, --require <library>,…​

Make the specified RubyGems library available to Asciidoctor’s JRuby runtime, for example -r asciidoctor-diagram.

This option may be specified more than once. Alternatively multiple library names may be specified in a single argument, separated by commas.

--gem-path <path>

Sets the GEM_PATH for Asciidoctor’s JRuby runtime. This option is only needed when using the --require option to load additional gems on the GEM_PATH.

-overview <file>

Overview documentation can be generated from an Asciidoc file using the standard -overview option. Files matching *.adoc, *.ad, *.asciidoc or *.txt are processed by Asciidoclet. Other files are assumed to be HTML and will be processed by the standard doclet.

Log Warning

Currently there is a intermittent benign warning message that is emitted during a run of Asciidoclet stating the following:

WARN: tilt autoloading 'tilt/haml' in a non thread-safe way; explicit require 'tilt/haml' suggested.

Unfortunately, until the underlying library removes this warning message, it will be logged during the build.

Additional Features

Make sure to see Asciidoclet 1.5.0 Release Notes for additional features not documented here.

Resources and help

Powered by Asciidoclet

We have a Powered by Asciidoclet page. If you have an example of nifty JavaDoc powered by Asciidoclet, please send us a pull request.

License

Copyright (C) 2013-2015 John Ericksen

Licensed 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

   https://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.
org.asciidoctor

Asciidoctor

An open source publishing toolchain for the AsciiDoc writing format. Provides tools & extensions for converting AsciiDoc to HTML, DocBook, PDF, & other formats.

Versions

Version
1.5.6
1.5.4
1.5.3
1.5.2
1.5.1
1.5.0
0.1.4
0.1.3
0.1.2