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
8216497: javadoc should auto-link to platform classes #171
Conversation
👋 Welcome back hannesw! A progress list of the required criteria for merging this PR into |
@hns The following labels will be automatically applied to this pull request: When this pull request is ready to be reviewed, an RFR email will be sent to the corresponding mailing lists. If you would like to change these labels, use the |
Webrevs
|
….sym historical data.
I think it would be awesome if we could generate (most of) the {element,package}-list-VERSION.txt from the ct.sym historical data at build time. This would (hopefully) help with long-term maintenance. I've started to sketch that here: Some comments on the attempt: |
Thanks for the suggestions and help, Jan!
I agree files should be generated dynamically. I knew about the sym files but wasn't sure how to go about it. Thanks a lot for stepping in and helping out, it's very much appreciated!
Javadoc in 9 still uses the old package-centric layout (package-list and no module names in URL paths). It only became fully module-aware in 10.
I definitely agree. I'll work on a new version that generates as much of the lists as possible. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Build changes look good.
@hns This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. After integration, the commit message for the final commit will be:
You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 2 new commits pushed to the
Please see this link for an up-to-date comparison between the source branch of this pull request and the ➡️ To integrate this PR with the above commit message to the |
Converted to draft as @lahodaj has offered to enhance the feature as described in the comments above. |
/csr |
@jonathan-gibbons this pull request will not be integrated until the CSR request JDK-8251181 for issue JDK-8216497 has been approved. |
Automatically generate the elements-list data from the ct.sym for releases 11+, including the current release under development
|
@hns Could not parse
|
/contributor add @lahodaj |
@hns |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally excellent. Some feedback inline.
<url> | ||
doclet.usage.link-platform-properties.description=\ | ||
Link to platform documentation URLs declared in properties file at <url> | ||
|
||
doclet.usage.excludedocfilessubdir.parameters=\ | ||
<name>:.. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
3 dots for ellipsis? 2 dots is "parent directory"
...avadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/standard.properties
Outdated
Show resolved
Hide resolved
@@ -185,6 +190,13 @@ | |||
*/ | |||
private boolean noDeprecated = false; | |||
|
|||
/** | |||
* Argument for command-line option {@code --no-platform-link}. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor: would "--no-platform-links" (plural) be a better name for the option?
@@ -411,6 +432,14 @@ public boolean process(String opt, List<String> args) { | |||
} | |||
}, | |||
|
|||
new Option(resources, "--no-platform-link") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Repeating preceding comment: would --no-platform-links
(plural) be a better name?
* | ||
* @param linkPlatformProperties path or URL to properties file containing | ||
* platform documentation URLs, or null | ||
* @param reporter The {@code DocErrorReporter} used to report errors. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(pedantic) param descriptions are typically phrases (no initial capital, no trailing period)
In this case, your two @param
descriptions are inconsistent
if (isUrl(linkPlatformProperties)) { | ||
inputStream = toURL(linkPlatformProperties).openStream(); | ||
} else { | ||
inputStream = DocFile.createFileForInput(configuration, linkPlatformProperties).openInputStream(); | ||
} | ||
try (inputStream) { | ||
props.load(inputStream); | ||
} | ||
url = props.getProperty("doclet.platform.docs." + version); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar to other file-or-url arguments: good!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As a possibly-later cleanup, should we have a single utility method somewhere (in this class) to open a stream on a file-or-url?
*/ | ||
private int getSourceVersionNumber() { | ||
SourceVersion sourceVersion = configuration.docEnv.getSourceVersion(); | ||
// TODO it would be nice if this was provided by SourceVersion |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
File an RFE for SourceVersion
@@ -46,6 +46,7 @@ public static void main(String... args) throws Exception { | |||
public void test() { | |||
javadoc("-d", "out-1", | |||
"-sourcepath", testSrc, | |||
"--no-platform-link", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see lots of instances of no-platform-link
in this and subsequent tests. JavadocTester
does have the concept of default options, although that may be more for the behavior after executing javadoc and not for the options given to javadoc itself. Is it worth supporting default javadoc options, since that the default can be disabled for specific tests?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't really find how JavadocTester
uses or supports default options. My concern with this would be that it would make JavadocTester less transparent and intuitive to use, as you'd have to be aware what the default options are.
Mailing list message from Hannes Wallnoefer on javadoc-dev: Switching to reply by email to javadoc-dev only in order to not spam all the other mailing lists with each comment/reply.
That is outside the scope of this changeset. Should I include the fix regardless?
Changed in next commit.
Yes, I think `--no-platform-links` is a better name, although it will require some changes in tests and CSR.
Fixed.
Will do.
I answered that one in a separate comment on github already, to recap: I couldn?t find the default options mechanism Hannes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with the judgement call to not introduce default javadoc options. It was just a suggestion to consider, and I agree it would make the calls less intuitively obvious, for the short term gain of editing fewer tests here. It also helped to realize that the support default platform links does not involve any network access.
FWIW, the precedent in JavadocTester that I was referrng to is setAutomaticCheckLinks
, setAutomaticCheckAccessibility
, but those are about default actions after javadoc has been run, and not about default methods.
/integrate |
@hns Since your change was applied there have been 2 commits pushed to the
Your commit was automatically rebased without conflicts. Pushed as commit 1e8e543. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
This pull request is identical with the RFR previously sent for the Mercurial repository:
https://mail.openjdk.java.net/pipermail/javadoc-dev/2020-August/001796.html
I'm copy-pasting the comments from the original RFR below.
Most of the new code is added to the Extern class where it fits in quite nicely and can use the existing supporting code for setting up external links.
The default behaviour is to generate links to docs.oracle.com for released versions and download.java.net for prereleases. Platform documentation URLs can be configured using the new --link-platform-properties option to provide a properties file with URLs pointing to to alternative locations. See the CSR linked above for more details on the new options.
The feature can be disabled using the --no-platform-link option, generating the same output as previously.
One problem I had to solve was how to handle the transition from prerelease versions to final releases, since the location of the documentation changes in this transition. For obvious reasons we don’t want to make that switch via code change at a time shortly before release.
The way it is done is that we determine if the current javadoc instance is a prerelease version as indicated by the Version returned by BaseConfiguration#getDocletVersion(), and then check whether the release/source version of the current javadoc execution uses the same (latest) version. This means that that only the latest version will ever generate prerelease links (e.g. running current javadoc 16 with source version 15 will generate links to the final release documentation) but I think this is acceptable.
Another issue I spent some time getting right was tests. New releases require a new element-list resource*), so tests have to pick up new releases. On the other hand, we don’t want hundreds of tests to fail when a new release is added, ideally there should be one test with a clear message. Because of this, when a release is encountered for which no element-list is available a warning is generated instead of an error, and the documentation is generated without platform links as if running with --no-platform-link option. This allows most existing tests to pass and just the new test to fail with a relatively clear message of what is wrong.
*) I also thought about generating the element-list for the current release at build time. It’s quite involved, and we still need to maintain element-lists for older versions, so I’m not sure it’s worth it.
For existing tests that check output affected by the new option I added the --no-platform-link option to disable the feature. Otherwise we’d have to update those tests with each new release (or else freeze the tests to use some static release or source version, which we don’t want either).
I updated the CSR to the new code. It also needs to be reviewed:
https://bugs.openjdk.java.net/browse/JDK-8251181
Thanks,
Hannes
Progress
Testing
Issue
Reviewers
Contributors
<jlahoda@openjdk.org>
Download
$ git fetch https://git.openjdk.java.net/jdk pull/171/head:pull/171
$ git checkout pull/171