Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JAVA-2560 : Use jdk.javadoc.doclet package #470

Closed
wants to merge 6 commits into from

Conversation

fhassak
Copy link
Contributor

@fhassak fhassak commented Apr 27, 2018

Migration guide :

Generated API documention on my machine :

image

URLs are correctly generated.

Javadoc Search

JEP 225 added a search box :

image

Javadoc and HTML

Javadoc tools currently generates pages in HTML 4.01 :
image

JEP 224 added an option to generate HTML5.
I have tried this option and it's not working. I need to convert documentation comments written using HTML 4 to HTML5. And there are others rendering issue (with frame).
There is a lot of issue about javadoc tools : JIRA

Build with :

------------------------------------------------------------
Gradle 4.5.1
------------------------------------------------------------

Build time:   2018-02-05 13:22:49 UTC
Revision:     37007e1c012001ff09973e0bd095139239ecd3b3

Groovy:       2.4.12
Ant:          Apache Ant(TM) version 1.9.9 compiled on February 2 2017
JVM:          9.0.4 (Oracle Corporation 9.0.4+11)
OS:           Linux 3.13.0-137-generic amd64

Gradle docs task is not working on Windows : GRADLE-3099

Farès

@@ -185,7 +185,6 @@ public static Bson fields(final Bson... projections) {
*
* @param projections the list of projections to combine
* @return the combined projection
* @mongodb.driver.manual
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Text (url path) is mandatory when generating javadoc. see DocTaglet.java

Set<Location> allowedLocations = new HashSet<Location>();
allowedLocations.addAll(Arrays.asList(Location.CONSTRUCTOR, Location.METHOD, Location.FIELD, Location.OVERVIEW, Location.PACKAGE,
Location.TYPE));
return allowedLocations;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can't use Java 9 style :

return Set.of(Location.CONSTRUCTOR, Location.METHOD, Location.FIELD, Location.OVERVIEW, Location.PACKAGE, Location.TYPE);

because of source compatibility to java 6.

/mongo-java-driver/util/src/main/DocTaglet.java:30: error: static interface method invocations are not supported in -source 1.6               
  (use -source 8 or higher to enable static interface method invocations)

At compile time :

warning: [options] source value 1.6 is obsolete and will be removed in a future release
warning: [options] target value 1.6 is obsolete and will be removed in a future release
warning: [options] To suppress warnings about obsolete options, use -Xlint:-options.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Understood.

IntelliJ does however suggest this small change:

    return new HashSet<Location>(
            asList(Location.CONSTRUCTOR, Location.METHOD, Location.FIELD, Location.OVERVIEW, Location.PACKAGE, Location.TYPE));

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, i made this change but not yet committed. We can also import statically Location.* :

return new HashSet<Location>(asList(CONSTRUCTOR, METHOD, FIELD, OVERVIEW, PACKAGE, TYPE));

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or maybe:

return new HashSet(asList(Location.values()));

for (Tag t : tags) {
buf.append(" <dd>").append(genLink(t.text())).append("</dd>%n");
for (DocTree t : tags) {
String text = ((UnknownBlockTagTree) t).getContent().get(0).toString();
Copy link
Contributor Author

@fhassak fhassak Apr 27, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if there is an empty tag @mongodb.driver.manual without text (like in Projections.fields), getContent().get(0) throw an exception.
I think text is mandatory in tag. So it's good to failed and not necessarry to add control ?

 if (getContent().size() > 0 ) {
text = getContent().get(0).toString();
} 

Or, we can add default value (default path + default display (see genLink method) ?

javadoc: error - An internal exception has occurred.
        (java.lang.IndexOutOfBoundsException: Index: 0, Size: 0)
Please file a bug against the javadoc tool via the Java bug reporting page
(http://bugreport.java.com) after checking the Bug Database (http://bugs.java.com)
for duplicates. Include error messages and the following diagnostic in your report. Thank you.
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
        at jdk.compiler/com.sun.tools.javac.util.List.get(List.java:490)
        at DocTaglet.toString(DocTaglet.java:48)
        at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.taglets.UserTaglet.getTagletOutput(UserTaglet.java:147)
        at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.taglets.TagletWriter.genTagOutput(TagletWriter.java:238)
        at jdk.javadoc/jdk.javadoc.internal.doclets.formats.html.HtmlDocletWriter.addTagsInfo(HtmlDocletWriter.java:333)
        at jdk.javadoc/jdk.javadoc.internal.doclets.formats.html.MethodWriterImpl.addTags(MethodWriterImpl.java:207)
        at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.builders.MethodBuilder.buildTagInfo(MethodBuilder.java:206)
        at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.builders.MethodBuilder.buildMethodDoc(MethodBuilder.java:153)
        at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.builders.MethodBuilder.build(MethodBuilder.java:128)
        at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.builders.ClassBuilder.buildMethodDetails(ClassBuilder.java:393)
        at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.builders.ClassBuilder.buildMemberDetails(ClassBuilder.java:341)
        at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.builders.ClassBuilder.buildClassDoc(ClassBuilder.java:145)
        at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.builders.ClassBuilder.build(ClassBuilder.java:120)
        at jdk.javadoc/jdk.javadoc.internal.doclets.formats.html.HtmlDoclet.generateClassFiles(HtmlDoclet.java:267)
        at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.AbstractDoclet.generateClassFiles(AbstractDoclet.java:290)
        at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.AbstractDoclet.generateClassFiles(AbstractDoclet.java:272)
        at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.AbstractDoclet.startGeneration(AbstractDoclet.java:211)
        at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.AbstractDoclet.run(AbstractDoclet.java:117)
        at jdk.javadoc/jdk.javadoc.doclet.StandardDoclet.run(StandardDoclet.java:72)
        at jdk.javadoc/jdk.javadoc.internal.tool.Start.parseAndExecute(Start.java:581)
        at jdk.javadoc/jdk.javadoc.internal.tool.Start.begin(Start.java:430)
        at jdk.javadoc/jdk.javadoc.internal.tool.Start.begin(Start.java:343)
        at jdk.javadoc/jdk.javadoc.internal.tool.Main.execute(Main.java:63)
        at jdk.javadoc/jdk.javadoc.internal.tool.Main.main(Main.java:52)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's fine to fail fast here.

buf.append(" <dd>").append(genLink(t.text())).append("</dd>%n");
for (DocTree t : tags) {
String text = ((UnknownBlockTagTree) t).getContent().get(0).toString();
buf.append(" <dd>").append(genLink(text)).append("</dd><br/>");
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<br/> must be removed by #468

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this what's creating the extra white below the MongoDB Documentation and Since Server Release paragraphs, as seen in the first screen shot? And #468 will fix it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes ! I suggest to merge #468 on master. I will rebase and fix conflict on this line

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merged!

@@ -2,7 +2,7 @@ dist: trusty
sudo: true
language: java
jdk:
- oraclejdk8
- oraclejdk9
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now, we need JDK 9 to build project. If you merge on master, all next commits must be compiled with jdk 9.

@@ -285,6 +285,7 @@ def setJavaDocOptions(MinimalJavadocOptions options) {
options.encoding = 'UTF-8'
options.charSet 'UTF-8'
options.docEncoding 'UTF-8'
options.addBooleanOption("html4", true)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Building with JDK 10, show me this warning :

javadoc: warning - You have not specified the version of HTML to use.
The default is currently HTML 4.01, but this will change to HTML5
in a future release. To suppress this warning, please specify the
version of HTML used in your documentation comments and to be
generated by this doclet, using the -html4 or -html5 options.

HTML 5 is not working...

@@ -277,14 +277,16 @@ task docs(type: Javadoc) {
def setJavaDocOptions(MinimalJavadocOptions options) {
options.author = true
options.version = true
options.links 'http://docs.oracle.com/javase/7/docs/api/'
options.links 'https://docs.oracle.com/javase/9/docs/api/'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now, we have link to java package :

image

Not working without https :

image

@jyemin
Copy link
Contributor

jyemin commented Apr 30, 2018

Thanks for the contribution @fhassak.

Have you had any luck getting IntelliJ to compile this? When I Rebuild Project I get:

Information:java: Errors occurred while compiling module 'util_main'
Information:javac 9 was used to compile java sources
Information:4/30/18, 12:16 PM - Compilation completed with 21 errors and 3 warnings in 3s 514ms
Warning:java: source value 1.6 is obsolete and will be removed in a future release
Warning:java: target value 1.6 is obsolete and will be removed in a future release
Warning:java: To suppress warnings about obsolete options, use -Xlint:-options.
    /Users/jeff/mongo-java-driver/util/src/main/DocTaglet.java
        Error:(17, 30) java: package com.sun.source.doctree does not exist
        Error:(19, 26) java: package jdk.javadoc.doclet does not exist

even though they clearly do exist.

@jyemin
Copy link
Contributor

jyemin commented Apr 30, 2018

I figured out the IntelliJ issue. You have to uncheck the "Use '--release' option for cross-compilation (Java 9 and later)" on the "Build, Execution, Deployment > Compiler > Java Compiler" preference page. Otherwise when it builds it sets the "--release" command line argument for javac to "--release 6" based on the "targetCompatibility = JavaVersion.VERSION_1_6" in build.gradle.

@jyemin
Copy link
Contributor

jyemin commented Apr 30, 2018

Squashed, rebased, and merged to master at 74b9ff6.

Thanks so much for this contribution. The javadoc looks so much better now.

@jyemin jyemin closed this Apr 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants