Code Snippets in Java API Doku geplant (JEP 413)
Interessantes Feature, was die Javadoc doch dicker machen könnte. Geplant:
/**
- The following code shows how to use {@code
Optional.isPresent}: - {@snippet :
- if (v.isPresent()) {
- System.out.println("v: " + v.get());
- }
- }
*/
Interessant wird das ganze durch Includes (wie bei Asciidoc):
```java
/**
* The following code shows how to use {@code Optional.isPresent}:
* {@snippet file="ShowOptional.java" region="example"}
*/
Dinge können zum Beispiel fett hervorgehoben werden:
/**
* A simple program.
* {@snippet :
* class HelloWorld {
* public static void main(String... args) {
* System.out.println("Hello World!"); // @highlight substring="println"
* }
* }
* }
*/
Und Texte können ersetzt werden:
/**
* A simple program.
* {@snippet :
* class HelloWorld {
* public static void main(String... args) {
* System.out.println("Hello World!"); // @replace regex='".*"' replacement="..."
* }
* }
* }
*/
Ziemlich wild, würdet ihr so was nutzen für eure Javadoc? Ich nutzte bisher immer Testfälle, um eine API zu zeigen und auch zu lernen.
Zum Weiterlesen: