Code Monkey home page Code Monkey logo

jdrupes-mdoclet's Introduction

MDoclet

Java CI Maven Central

Please note that starting with version 2.0.0 the doclet works with the API introduced in Java 9. It has been tested with Java 11.

A Doclet that allows the use of Markdown in JavaDoc. It uses a configurable Markdown processor (flexmark-java by default). Basically, the doclet intercepts the standard doclet's access to the AST generated by the javadoc tool and converts the texts from the comments from markdown to HTML.

See the javadoc overview for details.

  • Version 4.0.0 supports/requires Java-21.

  • Version 3.0.0 supports/requires Java-17.

  • Version 2.2.0 avoids a warning when using @see tags with quoted strings.

  • Version 2.1.0 fixes a problem that caused a class cast exception with JDK 15+ when javadoc tries to report a warning.

This Doclet is released under the AGPL 3.0.

jdrupes-mdoclet's People

Contributors

javadev avatar mnlipp avatar slovdahl avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

slovdahl

jdrupes-mdoclet's Issues

'@' in code blocks causes crash

Hello,
If I write a comment like:

/**
* ````java
* @Entity
* ````
*/

The '@' inside the blocks is not ignored and so it tries to map it to a know tag, failiing.
It just issues a
warning - @Entity is an unknown tag.
but the document generation stops.

If I use a workaround like:

* ````java
* \@Entity
* ````

Everything works but the the '' is rendered.

PS: Great work!

Issue running with JDK11.0.10 on Windows OS

Hi team, We are still getting issue on running it on Jdk11 though it works on jdk8. Below is our configuration:
Configuration in pom.xml
<configuration> <!-- Exclude classes that shouldn't be exposed to end users, ex, those in 'internal' packages --> <excludePackageNames>*.internal.*</excludePackageNames> <doclet>org.jdrupes.mdoclet.MDoclet</doclet> <docletArtifact> <groupId>org.jdrupes.mdoclet</groupId> <artifactId>doclet</artifactId> <version>1.0.10</version> </docletArtifact> <useStandardDocletOptions>true</useStandardDocletOptions> <aggregate>true</aggregate> <minmemory>256m</minmemory> <maxmemory>2048m</maxmemory> <additionalparam>-Xdoclint:none -disable-highlight</additionalparam> <sourcepath>target/generated-sources-for-docs/delombok</sourcepath> <links> <link>https://jax-rs-spec.java.net/nonav/2.0-rev-a/apidocs</link> <link>https://jersey.java.net/apidocs/${jersey.version}/jersey</link> <link>http://google.github.io/guava/releases/${guava.version}/api/docs</link> </links> </configuration>
Exception:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-javadoc-plugin:2.10.4:jar (aggregate) on project oci-java-sdk-circuitbreaker: MavenReportException: Error while generating Javadoc:
[ERROR] Exit code: 1 - javadoc: warning - The old Doclet and Taglet APIs in the packages
[ERROR] com.sun.javadoc, com.sun.tools.doclets and their implementations
[ERROR] are planned to be removed in a future JDK release. These
[ERROR] components have been superseded by the new APIs in jdk.javadoc.doclet.
[ERROR] Users are strongly recommended to migrate to the new APIs.
[ERROR] javadoc: error - invalid flag: -Xdoclint:none
[ERROR] Command line was: C:\jdk-11.0.10\bin\javadoc.exe -J-Xmx2048m -J-Xms256m @options @argfile

On removing Xdoclint param it gives below error
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-javadoc-plugin:2.10.4:jar (aggregate) on project oc
sdk-circuitbreaker: MavenReportException: Error while generating Javadoc:
[ERROR] Exit code: 1 - javadoc: warning - The old Doclet and Taglet APIs in the packages
[ERROR] com.sun.javadoc, com.sun.tools.doclets and their implementations
[ERROR] are planned to be removed in a future JDK release. These
[ERROR] components have been superseded by the new APIs in jdk.javadoc.doclet.
[ERROR] Users are strongly recommended to migrate to the new APIs.
[ERROR] javadoc: error - invalid flag: -bottom

javadoc generation failed

<=========----> 75% EXECUTING [590ms]
> :app:javadoc
Exception in thread "main" java.lang.NoClassDefFoundError: com/sun/javadoc/DocErrorReporter
        at java.base/java.lang.ClassLoader.defineClass1(Native Method)
        at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1012)
        at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:150)
        at java.base/java.net.URLClassLoader.defineClass(URLClassLoader.java:524)
        at java.base/java.net.URLClassLoader$1.run(URLClassLoader.java:427)
        at java.base/java.net.URLClassLoader$1.run(URLClassLoader.java:421)
        at java.base/java.security.AccessController.doPrivileged(AccessController.java:712)
        at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:420)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:587)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
        at jdk.javadoc/jdk.javadoc.internal.tool.Start.loadDocletClass(Start.java:781)
        at jdk.javadoc/jdk.javadoc.internal.tool.Start.preprocess(Start.java:752)
        at jdk.javadoc/jdk.javadoc.internal.tool.Start.begin(Start.java:371)
        at jdk.javadoc/jdk.javadoc.internal.tool.Start.begin(Start.java:342)
        at jdk.javadoc/jdk.javadoc.internal.tool.Main.execute(Main.java:63)
        at jdk.javadoc/jdk.javadoc.internal.tool.Main.main(Main.java:52)
Caused by: java.lang.ClassNotFoundException: com.sun.javadoc.DocErrorReporter
        at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:445)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:587)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
        ... 16 more

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:javadoc'.
> Javadoc generation failed. Generated Javadoc options file (useful for troubleshooting): '/Users/tkohli/leetcode/ARRAY_AND_STRING/introduction_to_string/app/build/tmp/javadoc/javadoc.options'

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Get more help at https://help.gradle.org

> Task :app:javadoc FAILED

Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

See https://docs.gradle.org/7.3/userguide/command_line_interface.html#sec:command_line_warnings
2 actionable tasks: 1 executed, 1 up-to-date
Could not execute build using connection to Gradle distribution 'https://services.gradle.org/distributions/gradle-7.3-bin.zip'.
 *  The terminal process terminated with exit code: 1. 

Changed maven configuration when using Java 21

First of all, thanks for adding support for Java 21. I can confirm that it works!

However, you need to change the plugin version and the <additionalJOptions> part:

  <plugin>
    <artifactId>maven-javadoc-plugin</artifactId>
    <version>3.6.0</version>
    <configuration>
      <doclet>org.jdrupes.mdoclet.MDoclet</doclet>
      <docletArtifacts>
        <docletArtifact>
          <groupId>org.jdrupes.mdoclet</groupId>
          <artifactId>doclet</artifactId>
          <version>4.0.0</version>
        </docletArtifact>
        <docletArtifact>
          <groupId>com.vladsch.flexmark</groupId>
          <artifactId>flexmark-all</artifactId>
          <version>0.64.0</version>   
        </docletArtifact>   
      </docletArtifacts>      
        <additionalJOptions>
          <additionalJOption>-J--add-exports=jdk.javadoc/jdk.javadoc.internal.tool=ALL-UNNAMED</additionalJOption>
            <additionalJOption>-J--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED</additionalJOption>
            <additionalJOption>-J--add-exports=jdk.compiler/com.sun.tools.doclint=ALL-UNNAMED</additionalJOption>
            <additionalJOption>-J--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED</additionalJOption>
            <additionalJOption>-J--add-exports=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED</additionalJOption>
          </additionalJOptions>
    </configuration>
  </plugin>

Maybe can can add this information to the README file.

Doclet does not work with Java 21 LTS

As explained here #17 (comment), it is "pure luck" if this doclet will work with Java 21.
I can confirm that it has no luck. All generated HTML is escaped (as also reported for Java 20).

It would be great if LTS releases of Java are supported.

@see tags different rendering in 2.0.0

After updating to 2.0.0 @see tags no longer render as @see <a href="http://www.example.com/">LABEL</a>.

This may be due to the fact we split the field with a new line as seen here:
https://github.com/openid/AppAuth-Android/blob/master/library/java/net/openid/appauth/AuthorizationRequest.java

New:
https://javadoc.io/doc/net.openid/appauth/0.11.0/net/openid/appauth/AuthorizationRequest.Prompt.html
Old:
https://javadoc.io/doc/net.openid/appauth/0.10.0/net/openid/appauth/AuthorizationRequest.Prompt.html

After some testing only this format works: @see "[Example](http://www.example.com/)" (singleline)

Our integration: openid/AppAuth-Android@61ca40d?diff=split

This might not be a mdoclet issue but I don't know enough javadoc to say for certain so any feedback would be appreciated.

warning: Error reading resource when using 4.0.0 (java 21)

When using this doclet (4.0.0) with Java 21 a strange warning is shown:

warning: Error reading resource: resources/releases/element-list-21.txt

I assume this warning is generated by javadoc (message doclet.Resource_error, see https://github.com/openjdk/jdk21/blob/master/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/standard.properties)

However, this file is not present in my code base and I suspect it comes from javadoc. I see https://github.com/openjdk/jdk21/tree/master/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/releases
containing these kind of files, copied to your code base. I only cannot find element-list-21.txt. Maybe that is the problem?

Configuration resolution is not safe and is scheduled to be removed in Gradle 7.0

Hi,

It looks like the current jdrupes-mdoclet will be incompatible with Gradle 7.
The related issue is gradle/gradle#11748

The workaround (== workaround "a") seems to be as follows (plugin code, in Kotlin, Apache 2.0): https://github.com/autostyle/autostyle/blob/f201199bc327887225db38ae34261bfb4a861527/buildSrc/src/main/kotlin/mdoclet.gradle.kts

What do you think if https://github.com/mnlipp/jdrupes-mdoclet/blob/50f4adc78570193f134e82c0c1dc6be09f39541b/integrations/gradle-plugin/src/org/jdrupes/mdoclet/integrations/gradle/MDocletPlugin.groovy is rewritten in Kotlin like mdoclet.gradle.kts above?

PS. I can provide a PR provided it is fine to rewrite MDocletPlugin.groovy in Kotlin.

The warnings are as follows:

Configure project :autostyle-lib
The configuration :autostyle-lib-extra:org.jdrupes.mdoclet was resolved without accessing the project in a safe manner. This may happen when a configuration is resolved from a different project. See https://docs.gradle.org/6.0.1/userguide/viewing_debugging_dependencies.html#sub:resolving-unsafe-configuration-resolution-errors for more details. This behaviour has been deprecated and is scheduled to be removed in Gradle 7.0.
The configuration :autostyle-plugin-gradle:org.jdrupes.mdoclet was resolved without accessing the project in a safe manner. This may happen when a configuration is resolved from a different project. See https://docs.gradle.org/6.0.1/userguide/viewing_debugging_dependencies.html#sub:resolving-unsafe-configuration-resolution-errors for more details. This behaviour has been deprecated and is scheduled to be removed in Gradle 7.0.
The configuration :autostyle-testlib:org.jdrupes.mdoclet was resolved without accessing the project in a safe manner. This may happen when a configuration is resolved from a different project. See https://docs.gradle.org/6.0.1/userguide/viewing_debugging_dependencies.html#sub:resolving-unsafe-configuration-resolution-errors for more details. This behaviour has been deprecated and is scheduled to be removed in Gradle 7.0.

Please add a fix for the version 1.0.10, Java 8

Markdown text

 * For some `1 &lt;= k &lt;= 6`, there is exactly one lowercase and one uppercase letter of the first `k` letters of the English alphabet in the grid.

Actual generated html

<p>For some <code>1 &amp;lt;= k &amp;lt;= 6</code>, there is exactly one lowercase and one uppercase letter of the first <code>k</code> letters of the English alphabet in the grid.</p>

Expected generated html

<p>For some <code>1 &lt;= k &lt;= 6</code>, there is exactly one lowercase and one uppercase letter of the first <code>k</code> letters of the English alphabet in the grid.</p>

overview.md

Feature request: process the overview as markdown

favicon

Feature request: allow configuration of a favicon

Javadoc generation error

I tried replacing Abnaxos' doclet with this one but when I run javadoc it generates the following errors:

javadoc: error - Error writing highlight.js: C:\Users\aheredia\cdcl\build\docs\javadoc\internal\highlight.pack.js: The process cannot access the file because it is being used by another process.

javadoc: error - Error writing highlight.js license: C:\Users\aheredia\cdcl\build\docs\javadoc\internal\highlight-LICENSE.txt: The process cannot access the file because it is being used by another process.

javadoc: error - Error writing highlight.js style 'default': C:\Users\aheredia\cdcl\build\docs\javadoc\internal\highlight.css: The process cannot access the file because it is being used by another process.

My build.gradle

plugins {
id "org.jdrupes.mdoclet" version "1.0.5"
}
.
.
.
task internalJavadoc(type: Javadoc) {
classpath = files( project.sourceSets.main.compileClasspath )
destinationDir = new File("${project.buildDir}/docs/javadoc/internal")
maxMemory = '256m'
source project.sourceSets.main.allJava
options.addStringOption('Xdoclint:none', '-quiet')
group = 'documentation'
options.stylesheetFile = rootProject.file('config/javadoc/stylesheet.css')
options.doclet = 'org.jdrupes.mdoclet'

Escaped HTML characters in flexmark output

I'm having a problem with the HTML output of flexmark-java being further processed and escaping characters in the HTML tags. I created a simple example class that shows the problem:

/**
 * This class is an example for using markdown in java doc.
 * ```java
 *  public void foo(bar b) {}
 * ```
 */
public class MDocletExample {
}

The block of HTML generated by javadoc for the comment is:

<div class="block">This class is an example for using markdown in java doc.&lt;pre&gt;&lt;code class="language-java"&gt;  public void foo(bar b) {}
&lt;/code&gt;&lt;/pre&gt;
</div>

It looks like something is taking the output of flexmark and escaping the < and > characters in the HTML. I'm using maven as the build tool. Here is the pom.xml for the example:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>com.example</groupId>
  <artifactId>mdoclet-example</artifactId>
  <version>0.1</version>
  <packaging>jar</packaging>

  <build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.11.0</version>
            <configuration>
              <source>17</source>
              <target>17</target>
              <debug>true</debug>
            </configuration>
          </plugin>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-javadoc-plugin</artifactId>
            <version>3.4.1</version>
            <configuration>
              <doclet>org.jdrupes.mdoclet.MDoclet</doclet>
              <docletArtifacts>
                <docletArtifact>
                  <groupId>org.jdrupes.mdoclet</groupId>
                  <artifactId>doclet</artifactId>
                  <version>3.1.0</version>
                </docletArtifact>
                <docletArtifact>
                  <groupId>com.vladsch.flexmark</groupId>
                  <artifactId>flexmark-all</artifactId>
                  <version>0.64.8</version>
                </docletArtifact>
              </docletArtifacts>
              <additionalJOptions>
                <additionalJOption>-J--add-exports=jdk.javadoc/jdk.javadoc.internal.tool=ALL-UNNAMED</additionalJOption>
                <additionalJOption>-J--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED</additionalJOption>
              </additionalJOptions>
            </configuration>
        </plugin>
    </plugins>
  </build>
</project>

Incompatible with Gradle 6

This line

is triggering this warning in Gradle 5.6:

The configuration :plugin-maven:org.jdrupes.mdoclet was resolved without accessing the project in a safe manner.  This may happen when a configuration is resolved from a thread not managed by Gradle or from a different project.  See https://docs.gradle.org/5.6/userguide/troubleshooting_dependency_resolution.html#sub:configuration_resolution_constraints for more details. This behaviour has been deprecated and is scheduled to be removed in Gradle 6.0.
        at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration.resolveToStateOrLater(DefaultConfiguration.java:566)
        at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration.access$2300(DefaultConfiguration.java:139)
        at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration$ConfigurationFileCollection.getSelectedArtifacts(DefaultConfiguration.java:1241)
        at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration$ConfigurationFileCollection.getFiles(DefaultConfiguration.java:1230)
...

You can reproduce with ./gradlew jar https://github.com/diffplug/spotless @ tag gradle/3.24.2

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.