Add example usage (markdown?) to JavaDocs
Asked Answered
E

1

3

Say I have this:

enter image description here

Is there a way to add markdown or html to each method, with an example of how to use the method? I am thinking an expanding panel - button says view example and it opens a panel.

I tried adding this to the inline docs:

 /**
   * <pre>
   * <code>new BeanTranslator.Builder()
   *   .translate(
   *     new{@code Translator<String, Integer>}(String.class, Integer.class){
   *      {@literal @}Override
   *       public Integer translate(String instance) {
   *         return Integer.valueOf(instance);
   *       }})
   *   .build();
   * </code>
   * </pre>
   */
  @SuppressWarnings("Duplicates")
  public static <I, T, V, E> void Reduce(I initialVal, List<T> tasks, Asyncc.Reducer<V, E> m, Asyncc.IAsyncCallback<V, E> f) {
    NeoReduce.Reduce(initialVal, tasks, m, f);
  }

but I only see this on the right side:

enter image description here

Elater answered 17/2, 2019 at 23:1 Comment(0)
D
3

There is a library that allows to use Markdown and even PlantUML in Javadocs like this:

/**
* Java Example:
*
* ```java
* @Override
* public void myMethod() {
* }
* ```
*/
Depot answered 18/2, 2019 at 6:13 Comment(2)
thanks i tried installing using maven and got an error, filed a ticket with them, i got it working with html instead of markdown, but would be cool to get markdown working too thanksElater
The folllowing guide does an overview about how to use this librar, however, it doesn't seem like it is an standard so I would be wary about using it. mscharhag.com/java/using-markdown-syntax-in-javadocCloakroom

© 2022 - 2024 — McMap. All rights reserved.