如何使用AsciiDoclet从.java文件中的javadoc注释生成asciidoc文件

Piy*_*ush 5 java javadoc asciidoc maven maven-javadoc-plugin

我是asciidoc的新手。我想从java文件中带注释的javadoc(asciidoc格式)生成HTML文档。

例如java文件

/**
 * = 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 {
}
Run Code Online (Sandbox Code Playgroud)

我可以从.ad文件生成html文件,但是我不知道如何从javadoc生成.ad(或任何asciidoc格式的文件)。
所以我想生成.ad(asciidoc文件),我正在使用asciidoctor-maven-plugin生成html文档。asciidoctor-maven-plugin将在sourceDirectory中检查.ad文件,并在outputDirectory中生成html文件。

</plugin>
<plugin>
    <groupId>org.asciidoctor</groupId>
    <artifactId>asciidoctor-maven-plugin</artifactId>
    <version>${asciidoctor.version}</version>
    <executions>
        <execution>
            <id>output-html</id>
            <phase>generate-resources</phase>
            <goals>
                <goal>process-asciidoc</goal>
            </goals>
        </execution>
    </executions>
    <configuration>
        <sourceDirectory>asciidocs</sourceDirectory>
        <outputDirectory>asciidocs-output</outputDirectory>
        <backend>html</backend>
        <doctype>book</doctype>
    </configuration>
</plugin>
<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=http://example.com[${project.name} ${project.version}]"
        </additionalparam>
    </configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)

相依性

<asciidoclet.version>1.5.0</asciidoclet.version>
<asciidoctor.version>1.5.0</asciidoctor.version>

<dependency>
    <groupId>org.asciidoctor</groupId>
    <artifactId>asciidoctorj</artifactId>
    <version>1.5.2</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)

推荐使用asciidoclet,但无法获取任何有用的信息。所有示例项目也都用于生成html,pdf,epub等。
谢谢...

更新
我按如下方式更改了我的maven-javadoc-plugin配置并执行了,mvn org.apache.maven.plugins:maven-javadoc-plugin:2.9:jar但是它生成的是普通的html java文档,它应该生成.adoc文件。谁能帮我我在做什么错?
谢谢...

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-javadoc-plugin</artifactId>
    <version>2.9</version>
    <executions>
        <execution>
            <id>javadoc-jar</id>
            <phase>package</phase>
            <goals>
                <goal>jar</goal>
            </goals>
            <configuration>
                <includeDependencySources>true</includeDependencySources>
                <dependencySourceExcludes>
                    <dependencySourceExclude>commons-cli:*</dependencySourceExclude>
                </dependencySourceExcludes>
                <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=http://example.com[${project.name} ${project.version}]"
                </additionalparam>
            </configuration>
        </execution>
    </executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)

我正在使用以下依赖项。

Lig*_*ard 2

看来你对 Asciidoclet 正在做的事情的想法有点不对劲。它并不是为了创建 Asciidoc 而设计的,而是为了能够在 Asciidoc 中编写 javadoc,然后将其转换为 javadoc 命令的 html 输出。

您可能想要研究的是为 asciidoctor 构建一个自定义包含模块,它将获取您的 asciidoctor javadoc 源,删除 java 注释并将其包含到您正在创建的其他输出中。