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
JDK-8253735: Cleanup SearchIndexItem API #499
JDK-8253735: Cleanup SearchIndexItem API #499
Conversation
(without changing how items are added to the index collections)
improve comments in IndexItem
Improve comparators used to build index
This is slightly undesirable because it means that Links requires access to Utils, but it is less bad than the alternatives.
…Script index files from AbstractIndexWriter and subtypes to new subtype of IndexBuilder: HtmlIndexBuilder
👋 Welcome back jjg! A progress list of the required criteria for merging this PR into |
@jonathan-gibbons this pull request can not be integrated into git checkout 8253735-searchindexitem
git fetch https://git.openjdk.java.net/jdk master
git merge FETCH_HEAD
# resolve conflicts and follow the instructions given by git merge
git commit -m "Merge master"
git push |
@jonathan-gibbons The following label 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 list. If you would like to change these labels, use the /label pull request command. |
/reviewers 2 |
@jonathan-gibbons |
Webrevs
|
Content dt = HtmlTree.DT(HtmlTree.SPAN(HtmlStyle.searchTagLink, labelLink)); | ||
dt.add(" - "); | ||
dt.add(contents.getContent("doclet.Search_tag_in", sii.getHolder())); | ||
dt.add(contents.getContent("doclet.Search_tag_in", item.getHolder())); |
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.
Possible future RFE: Search tag
is not a great term here, and doesn't really apply to tags like {@systemProperty ...}
that exist for other reasons (e.g. to generate the System Properties page, and for which the entry in the interactive search is something of a secondary side-effect. Given that the IndexItem
contains the original DocTree
, we could vary the description based on the DocTree.Kind
.
That is not done here in this work, because it would likely require corresponding changes to 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.
Also, what is the relationship between this content and the value in IndexItem.getDescription()
?
new IndexBuilder(configuration, nodeprecated, true)); | ||
IndexBuilder allClassesIndex = new IndexBuilder(configuration, nodeprecated, true); | ||
allClassesIndex.addElements(); | ||
AllClassesIndexWriter.generate(configuration, allClassesIndex); | ||
if (!configuration.packages.isEmpty()) { | ||
AllPackagesIndexWriter.generate(configuration); | ||
} | ||
SystemPropertiesWriter.generate(configuration); |
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.
Logically, it would make more sense to write the System Properties page before writing the index files, in case the index files depend in any way on any for the individual pages being written.
src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SplitIndexWriter.java
Outdated
Show resolved
Hide resolved
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.
Excellent work, Jon! It's great to see index generating code going from pretty bad to quite nice in one major effort. I suggested some minor changes in the comments but nothing substantial, so reviewing as "approved".
...jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractIndexWriter.java
Outdated
Show resolved
Hide resolved
src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SplitIndexWriter.java
Outdated
Show resolved
Hide resolved
src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/Links.java
Show resolved
Hide resolved
src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/IndexBuilder.java
Show resolved
Hide resolved
src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/IndexItem.java
Show resolved
Hide resolved
src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/IndexItem.java
Outdated
Show resolved
Hide resolved
Mailing list message from Jonathan Gibbons on javadoc-dev: On 10/6/20 5:30 AM, Hannes Walln?fer wrote:
I'll do Item 1. I think there's a possibility of merging all 3 of -- Jon |
/reviewers 1 |
@jonathan-gibbons |
@jonathan-gibbons 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 more 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 25 new commits pushed to the
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details. ➡️ To integrate this PR with the above commit message to the |
/integrate |
@jonathan-gibbons Since your change was applied there have been 25 commits pushed to the
Your commit was automatically rebased without conflicts. Pushed as commit bd50ccd. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
This pull-request is for a substantial refactoring and cleanup of the code
to build the static index pages and the files for the interactive search
There is no significant change in functionality, and all tests continue to
pass without change.
Improvements
SearchIndexItem
is merged intoIndexItem
SearchIndexItems
(the collection ofSearchIndexItem
s indexed byCategory
) is merged intoIndexBuilder
, which now maintainsboth maps: index items grouped by first character, and grouped by category
Category
, the membersINDEX
andSYSTEM_PROPERTY
are merged intosingle new entry
TAGS
, such that the members ofCategory
now directlycorrespond with the JavaScript files generated for interactive search
IndexItem
now provides access to theDocTree
node for those itemsthat previously were
SearchIndexItem
. This can be used to differentiatebetween items for
{@index...}
and{@systemProperty}
.This specific change was a primary motivation for all this work, in order
to facilitate supporting additional new tags that can contribute items
for the index.
SearchIndexItem
)are now created by static factory methods instead of directly calling
constructors. This allows many values to be precomputed and stored in
final fields or made available by overriding accessor methods in
anonymous subtypes.
of the comparators was "unstable", meaning that it could fall back on
the value of mutable fields, and the
toString
output (which was usedto generate the content for the JavaScript files.)
AbstractIndexBuilder
and its subtypes into a new class,HtmlIndexBuilder
,that subclasses the main
IndexBuilder
.To facilitate that, some methods were moved from
HtmlDocletWriter
toLinks
. This is not ideal, because it introduces a dependence onUtils
in
Links
that was not there before, but the choice was pragmatic and theleast bad of the alternatives. Long term, we might want to move most
of the
formats/html/markup
package into a new more standalone package thatdoes not rely on other javadoc internals, and at that time, the factory
objects like
Links
,TableHead
andTable
would just move up to theformats/html
package.The Changes
The work is done in a series of steps/commits, each with a specific focus
of the work involved. It may be instructive to review the changes in each
commit, to follow the overall evolution of the work. From the Git log,
the changes are as follows (oldest first)
SearchIndexItem
,SearchIndexItems
totoolkit.utils
SearchIndexItem
SearchIndexItems
SearchIndexItems
intoIndexBuilder
IndexItem
prior to merge withSearchIndexItem
SearchIndexItem
prior to merge withIndexItem
SearchIndexItem
intoIndexItem
(without changing how items are added to the index collections)
improve comments in IndexItem
Improve comparators used to build index
getAnchor
methods fromHtmlDocletWriter
toLinks
.This is slightly undesirable because it means that
Links
requires access toUtils
, but it is less bad than the alternatives.AbstractIndexWriter
and subtypes to new subtype ofIndexBuilder
:HtmlIndexBuilder
At each stage, the repo should build and all javadoc tests should pass (and there is no reason to believe that any other tests may fail.)
Future work
Instead of maintaining collections of
SortedSet
s inIndexBuilder
, it mightbe more effective to use
List
instead, and just sort the list as needed.There is little need to eagerly build both maps in
IndexBuilder
. As long asthere is at least one collection, such as the
itemsByFirstCharacter
, we coulddefer generating
itemsByCategory
until we need to write out the JavaScriptfiles. There is one place in the code, in
SystemPropertyWriter
, where welook at
itemsByCategory
to determine whether there were any{@systemProperty...}
tags, but at the time we need that information, itwould not be significantly more expensive to scan
indexByFirstCharacter
,because the items for elements need not have been added at this time.
Progress
Issue
Reviewers
Download
$ git fetch https://git.openjdk.java.net/jdk pull/499/head:pull/499
$ git checkout pull/499