Javadoc layout changed with JDK8 - java

Javadoc generated by the JDK8 is completely different compate to that of JDK7.
In new Javadoc, header text is overlapping and layout completely messy. I understand after reading
Oracle documentation that Doclet is reason for creating html view of Javadoc. Is there any way to
use Doclet associated with JDK7 to generate the the Javadoc..?

If you are referring to the doclet, you can turn the doclet off by adding -Xdoclint:none to the command line call to javadoc
http://blog.joda.org/2014/02/turning-off-doclint-in-jdk-8-javadoc.html
If you just want the old CSS used in Java 7 this other Stack overflow question contains the css you can use instead:
JDK8: Getting back the JDK7 look for javadoc

Related

Controlling Package Level Javadoc Generation

When Javadoc processed a package-info.java file in Java 8, the output placed the Javadoc comments (except for the summary sentence) after the generated class and other summary tables. Here is a Java 8 example: https://docs.oracle.com/javase/8/docs/api/java/nio/file/package-summary.html
Sometime between Java 8 and Java 11 this changed, and the Javadoc output in Java 11 now places all Javadoc comments before the generated class and other summary tables. Here is the same example in Java 11: https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/nio/file/package-summary.html
What I'd like, but have been unable to find, is a way to control this behavior in Java 11. I'd prefer to revert to the Java 8 behavior (in Java 11) or, even better, to be able
to control this behavior such that some package comments appear before and some after the summary tables.
Is there a way to control this Javadoc behavior in Java 11? At the moment I am constrained to Java 11 and cannot use features from earlier or later versions.
From Oracle
​You can customize the content and format of the javadoc command output
with doclets. The javadoc command has a default built-in doclet,
called the Standard Doclet, that generates HTML-formatted API
documentation. You can write your own doclet to generate HTML, XML,
MIF, RTF or whatever output format you want.
The StandardDoclet delegates to HtmlDoclet. You might be able to get away with subclassing that and overriding generatePackageFiles.
IMO probably not worth the effort, but hey.

Doxygen style mainpage for Maven

We have an API for OSX that we offer in 3 different languages;
Objective-C, C++, and Java.
For the C++ and The Objective C Languages we use Doxygen for all of the documentation. The same nice looking presentation that is applied to the class pages is also provided for the examples page (mainpage.h). I especially like the syntax coloring.
For the Java Language, we are using Maven. Since apple's dev environment doesn't really offer much for Java, we can use Maven for both documentation and its a decent build system as well. The class pages look as good as Doxygen in my opinion, but the presentation of the main examples page(examples.apt), looks pretty plain and uneventful.
Ive been searching for any reference on how to add some color to the page, but haven't really found anything.
My question:
Can anyone provide an example of how to implement coloring in the appropriate .apt file(examples.apt) or the sites.xml file?
There are two main locations for customizing the Javadocs. The first in in the pom.xml files. The second location is in the src/main/javadoc directory. You will probably have to create the src/main/javadoc directory yourself since it isn't normally in the initial set of directories.
See https://github.com/BradleyRoss/tutorials for how I set up some Javadoc settings. Look at the pom.xml in the parent module and the src/main/javadoc directory in tutorials-common module.
See https://maven.apache.org/plugins/maven-javadoc-plugin/examples/stylesheet-configuration.html for information on how to replace the stylesheet.css file with your own. That is probably where most of the color selection would go. It uses the stylesheetfile and stylesheet tags in the configuration section for the Javadoc plugin.
Maven apparently uses a modified version of the stylesheet.css file that comes with the JDK. You may want to compare the JDK and Maven versions to get some ideas on what you can change.

Add copyright at the end of Java class while writing documentation?

I'm writing documentation for my java file. In that documentation, I want to add some html links at the end of each generated file. For that, what I have to use while writing java documentation?
If you are using Eclipse as IDE, you can use the plugin JAutodoc:
http://jautodoc.sourceforge.net/
To add a default text at the beggining of each text file.
According to the javadoc manual (can't find a newer version right now), you should use -footer when you generate your java API documentation from the CLI, for instance:
javadoc -footer "<b>Copyright 2015 Lakshmi Prasanna</b><br>" com.mypackage
Here's a similar example, but that uses -header instead.
Now, if you use a good IDE, at the very least it should allow you to type that somewhere in the project settings. Back in the day Eclipse wasn't very flexible, so I had to make an Ant script (yuck).
EDIT:
One limitation with this approach is that the CLI -options depend on the tool. This works with the standard javadoc command but might not work with another vendor's doclet. However I'm not sure there's a universal way to achieve what the OP asked.
Anyway, it seems to be: NOT -footer but -bottom.

Javadoc documentation render in place. Can one see pretty-print documentation in IDE?

Is there a plugin to Eclipse (or Visual Studio) which renders javadoc (or doxygen) in place, i.e. there is a pretty print in code instead of displaying javadoc source as comment?
By default it is possible just to fold method body. It could be usefull to have a toggle: full source, source and rendered javadoc, pure rendered javadoc.
Said plugin could generate something looking like this:
Yes there is. In eclipse, just open or select the javadoc view and go to your own method

Looking for good example of Java code that has Javadoc comments

I've been running Checkstyle on some code and looking for a good example to get to grips with how to add comments for specific purposes.
For example Checkstyle says I should add comments for constants/class variables. Yet nowhere in the official docs Oracle host, can I find an example of this.
I was looking in various places, but couldn't find a concise example...
1
2
3
4
5
I figured if I could get my hands on the source code for the Java Calendar class, it would be a good example. You can see all sorts of constants in the API docs of that class.
See here.
How can I either:
1) Get my hands on the source for Calendar?
2) Find an example of how you'd document code like this in Javadoc (Checkstyle flags it needs it):
private static final int NO_OF_RECORDS = 10;
On the Java 6 download page, under the "additional resources" section, you can download the source code for the whole JDK.
Additionally, most IDEs automatically index the source code for Java's library classes so you can open those classes transparently.
Oracle's current java 6 source download links to http://download.java.net/jdk6/source/ which should contain the entire java library source.

Categories