Open gebezs opened 2 years ago
JDK 18 delivered the @snippet tag for javadoc: https://openjdk.java.net/jeps/413
@snippet
Java 18 Snippet documentation: https://docs.oracle.com/en/java/javase/18/code-snippet/index.html
The JEP 413 supports a wide range of options adding code snippets to the javadoc. Supporting everything would be overkill:
local.zip=94123 # @highlight regex="[0-9]+" System.out.println("Hello World!"); // @link substring="System.out" target="System#out" System.out.println("Hello World!"); // @replace regex='".*"' replacement="..." {@snippet file="ShowOptional.java" region="example"}
I think even a basic support would be a great addition.
{@snippet : if (v.isPresent()) { System.out.println("v: " + v.get()); } }
region
file
class
{@snippet file=HelloWorld.java} {@snippet class=HelloWorld} {@snippet file=config.properties}
class — a class containing the content for the snippet file — a file containing the content for the snippet id — an identifier for the snippet, to identify the snippet in the generated documentation lang — the language or format for the snippet
No support for region
The content of an inline snippet is the text between the newline after the initial colon (:) and the final right curly bracket (}). Incidental white space is removed from the content in the same way as with [String.stripIndent](https://docs.oracle.com/en/java/javase/18/docs/api/java.base/java/lang/String.html#stripIndent()). This means you can control the amount of indentation in the generated output by adjusting the indentation of the final right bracket.
JDK 18 delivered the
@snippet
tag for javadoc: https://openjdk.java.net/jeps/413Java 18 Snippet documentation: https://docs.oracle.com/en/java/javase/18/code-snippet/index.html
The JEP 413 supports a wide range of options adding code snippets to the javadoc. Supporting everything would be overkill:
I think even a basic support would be a great addition.
a, support for inline
@snippet
b, support for external
@snippet
(as-is, withoutregion
; bothfile
andclass
)c, attributes
No support for
region
d, indentations