Giter Site home page Giter Site logo

isnow / marklet Goto Github PK

View Code? Open in Web Editor NEW

This project forked from atlascommunity/marklet

0.0 1.0 0.0 488 KB

Marklet is a custom Java Doclet that generates Javadoc in a markdown format ready to use in GitHub.

License: Apache License 2.0

Java 100.00%
doclet java java-11 java-17 javadoc markdown maven

marklet's Introduction

Marklet

Marklet is a Doclet that plugs into javadoc. The purpose of Marklet is to generate Javadoc in Markdown format instead of the usual HTML that javadoc creates. This version requires Java 14 or higher to run, but can document all lower source code versions.

Currently working on the migration from com.sun.javadoc to the newer jdk.javadoc.doclet API because the older classes are no longer supported on Java 12 and up. Still work in progress.

Examples :

How to use

You can run Marklet on the command line to generate one-shot documentation or add it to your pom.xml so Markdown docs are created on Maven build. You probably can use it from Gradle, but since I am a Maven guy, I don't know the syntax.

The most important caveat is that you have to specify the Java packages (option -subpackage) you want to document and their location in the file system (option -sourcepath) correctly, otherwise no output will be generated (specifying -sourcepath alone is not sufficient).

Command-line use

First run mvn package to build the doclet.

Linux/macOS:

javadoc -docletpath ./target/marklet-2.0.0.jar \
  -doclet io.github.atlascommunity.marklet.Marklet \
  -cp ./target/marklet-2.0.0.jar \
  -sourcepath ./src/main/java \
  -subpackages io.github.atlascommunity.marklet

Windows:

javadoc -docletpath .\target\marklet-2.0.0.jar  -doclet io.github.atlascommunity.marklet.Marklet -cp .\target\marklet-2.0.0.jar -sourcepath .\src\main\java -subpackages io.github.atlascommunity.marklet

On both platforms, be sure to set subpackages toyour project packages qualified name and sourcepath pointing to your sources.

Maven use

In order to use it with Maven, add the following configuration for the maven-javadoc-plugin in your project POM :

<profiles>
    <profile>
        <id>generate-markdown</id>
        <activation>
            <activeByDefault>false</activeByDefault>
        </activation>
        <build>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-javadoc-plugin</artifactId>
                    <version>${maven-javadoc-plugin.version}</version>
                    <configuration>
                        <doclet>io.github.atlascommunity.marklet.Marklet</doclet>
                        <docletArtifact>
                            <groupId>io.github.atlascommunity</groupId>
                            <artifactId>marklet</artifactId>
                            <version>2.0.0</version>
                        </docletArtifact>
                        <reportOutputDirectory>./</reportOutputDirectory>
                        <destDir>./</destDir>
                        <useStandardDocletOptions>false</useStandardDocletOptions>
                        <additionalOptions>
                            <additionalOption>-e markdown</additionalOption>
                        </additionalOptions>
                        <show>private</show>
                        <subpackages>io.github.atlascommunity.marklet</subpackages>
                        <sourcepath>src/main/java/</sourcepath>
                    </configuration>
                </plugin>
            </plugins>
        </build>
    </profile>
</profiles>

This profile is not active by default, so the Markdown documentation would not get re-created with each Maven run, but if you type mvn clean package -P generate-markdown, it gets run. If you want to have it permanently active, set activeByDefault to true:

<activation>
     <activeByDefault>true</activeByDefault>
 </activation>

Running from Maven, you may omit the sourcepath option, but be sure to set subpackages to your project packages qualified name. You may usually omit reportOutputDirectory, but not destDir.

If you set show to public, no internals (protected/private objects) will be documented, and your api-docs will be the public API.

useStandardDocletOptions interferes with the working of Marklet, it must be set to false.

This will generate the javadoc report into the project directory under project subfolder javadoc and use the file extension .markdown ( the -e in the additionalOptions overrides the default extension .md).

The Apache Maven site has more information on how to use alternate doclets like Marklet in addition to the default HTML-generating javadoc-plugin.

Java 8 doclint issues.

If you are using Java 8 you may have some issues with doclint validation especially when using Markdown blockquotes syntax. To deal with it, just add the following directive to your pom.xml file to deactivate doclint :

<additionalOptions>
    <additionalOption>-Xdoclint:none</additionalOption>
</additionalOptions>

Available doclet options

Option LongOpt What it does By default
-e set files extension .md
-i location of the source directory
-d -destDir location of the target output directory .javadoc/

Developing Marklet

To hack on Marklet and improve it, look at Marklet.java and use the main() method to get it to run in any IDE. The provided options allow you to run Marklet on its own source tree.

In order to generate Markdown documentation for Marklet itself via Maven, run

$ mvn -P generate-markdown javadoc:javadoc

Developer docs

License

Marklet is licensed under the Apache License, Version 2.0

Current issues

The current version is still under development with the following issues:

marklet's People

Contributors

johannesjander avatar faylixe avatar isnow avatar trieloff avatar mashintsev avatar pandathegrim avatar dependabot[bot] avatar

Watchers

 avatar

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.