16

I found already a possible solution, described at https://dzone.com/articles/using-markdown-syntax-javadoc, which is based upon https://github.com/Abnaxos/pegdown-doclet. This enables markdown support as a replacement for writing the ugly HTML tags in Javadoc.

On the GitHub page, there is also a "markdown-compatible-tooltip" solution as plugin for using the CTRL+Q tooltip in IntelliJ, which is 50% good.

Just to give an example, how the Javadoc is currently looking:

/**
 * This enum gives you insight for various person characteristics.
 * <p>
 * This could be the following:
 * <ul>
 * <li>introvert</li>
 * <li>extrovert</li>
 * </ul>
 */
public enum PersonTypes {
...
}

So, it's ok, if you tooltipping/mouse-hovering over the class in an IDE. Nevertheless, it's hard to read if you are directly in the concerned class, caused by the HTML tags and other macros. And this is only a very simple example without any Javadoc specific macros.

So, as described on the website above, I'd like to replace the Javadoc stuff with the Markdown syntax in the source code directly. Applied to the example, this would look like:

/**
 * This enum gives you insight for various person characteristics.
 * 
 * This could be the following:
 *
 * - introvert
 * - extrovert
 * 
 */
public enum PersonTypes {
...
}

When hovering over PersonTypes enum in Eclipse, the Markdown syntax is getting lost, because Eclipse interprets it as Javadoc and not as Markdown by default.

Unfortunately I currently have no solution found for enable that Markdown tooltip parsing for Eclipse. Does anyone else have a solution or other ideas?

frido
  • 13,065
  • 5
  • 42
  • 56
mchlfchr
  • 3,998
  • 4
  • 26
  • 35
  • I am not pretty much clear what you question is? Are you asking an md option for eclipse?? – Supun Wijerathne Sep 18 '16 at 14:29
  • I updated the description of the question – mchlfchr Sep 18 '16 at 14:51
  • Javadoc is really HTML by specification, and most IDEs stick to specification rather than to the myriad of alternatives. What you're asking for is very likely to not be available, so I would recommend that rather than introducing complexity by using alternatives that aren't well supported by most standard tools, you consider sticking to good old Javadoc which works like a charm. – Mickael Sep 19 '16 at 09:33
  • 6
    "Javadoc is really HTML by specification" - then it is a very poor and outdated specification. MD is the way most and any same programmer would prefer writing javadoc. And your recommendation is ill-advised, rather than pushing and pressing for the needed change. Javadoc as you like it IRREFUTABLY is an annoyance to vast majority and CERTAINLY does not "work like a charm". – Blessed Geek Mar 31 '19 at 11:25
  • @BlessedGeek At the risk of igniting a flamewar here: What you are reading here is (rendered) HTML. Even Markdown is converted into HTML to be displayed. And JavaDoc *does* work like a charm, and I never heard of it to be an "annoyance". (But maybe I'm just hadened by using Doxygen...) – Marco13 Jul 29 '19 at 12:50
  • 2
    @Marco13 Reading **rendered** HTML is great, but **writing** HTML with a text editor is pita. – haui May 22 '20 at 16:11
  • Linking to https://stackoverflow.com/questions/54738479/add-example-usage-markdown-to-javadocs and https://stackoverflow.com/questions/28954774/how-to-enable-markdown-in-intellij – Paul Verest Mar 17 '21 at 03:43
  • 1
    To add to @haui's point, reading **unrendered** HTML is also a PITA. It can be a pain to read through the HTML tag noise. And for me at least, given my IDE's auto-completion of HTML, it's almost more annoying to read unrendered HTML than to edit it in a Javadoc. – M. Justin Sep 10 '21 at 19:58
  • 1
    "Javadoc works like a charm"? If I'd have been drinking coffee when I read that it would probably have shot out of my nose. Next you'll be telling us that type-erased generics "work like a charm"... or that Spring and Hibernate "work like a charm". – barneypitt Jul 28 '22 at 11:55
  • JavaDoc is *not* HTML by specification. HTML is part of the [StandardDoclet "specification";](https://docs.oracle.com/en/java/javase/20/docs/specs/javadoc/doc-comment-spec.html) it's a convention or de facto standard, but not a requirement. JavaDoc from the get-go provided support for alternative doclets to generate different formats *or* interpret different inputs. – erickson Aug 01 '23 at 18:57

2 Answers2

1

IntelliJ has a plugin to support markdow javadoc https://plugins.jetbrains.com/plugin/9840-markdown-doclet-for-idea

Note that the plugin has not been updated since 2017 and the maven plugin has not been updated since 2016, see https://mvnrepository.com/artifact/ch.raffael.pegdown-doclet/pegdown-doclet

Paul Verest
  • 60,022
  • 51
  • 208
  • 332
Sebastien
  • 5,506
  • 4
  • 27
  • 37
1

In Java 13 the legacy doclet API (com.sun.javadoc) is removed and only the new doclet API (jdk.javadoc.doclet), introduced in Java 9 can be used.

jdrupes-mdoclet is an alternative for the abnaxos/pegdown-doclet and support the new doclet API and modern JVM's (Java 17 for version 3).

Also note that there exists a JEP draft, for adding this functionality to the standard javadoc tool. However, this JEP is withdrawn for now, "pending additional design discussions".

UPDATE: For using jdrupes-mdoclet with maven, see https://github.com/mnlipp/jdrupes-mdoclet/issues/11

rmuller
  • 12,062
  • 4
  • 64
  • 92
  • 1
    I was curious and checked the [javadoc-dev archives](https://mail.openjdk.org/pipermail/javadoc-dev/) as well as the [GH pull request](https://github.com/openjdk/jdk/pull/11701). The original author notes in the PR: "FYI, the PR has been withdrawn for now, pending additional design discussions." Unfortunately I don't see that discussion in the mailing list archives. I hope it doesn't just happen "offline", as I'd be curious to take a look into that. – Joachim Sauer Feb 27 '23 at 12:00
  • @JoachimSauer :) AFAIK these kind of discussions are mostly offline, until there is a well thought out draft. This can take a while .. For sure it will not land in the next LTS (21) – rmuller Feb 27 '23 at 12:19
  • 1
    Yeah, I know. I just think it's unfortunate, because having a written record of these discussions can sometimes be very useful. Or at the very least insightful for future decisions. – Joachim Sauer Feb 27 '23 at 12:21