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-8259283: use new HtmlId and HtmlIds classes #1951
Conversation
|
@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. |
…lve conflicts # Conflicts: # src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/DeprecatedListWriter.java # src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java # src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/Navigation.java
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.
Very nice work, Jon! +1
A few inline comments for an unused field and method and a couple of questions.
*/ | ||
public String getName(String name) { | ||
return name.replaceAll("\\s+", ""); | ||
public Content createExternalLink(DocLink link, Content label) { |
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.
The createLink(DocLink, Content, boolan)
method above (line #221) that is replaced by this new method is not used anymore (and within it, the boolean parameter is not used).
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.
Ah, good catch! Will fix.
@@ -299,16 +298,21 @@ public void addRow(Element element, List<Content> contents) { | |||
int rowIndex = bodyRows.size(); | |||
rowStyle = stripedStyles.get(rowIndex % 2); | |||
} | |||
Set<String> tabClasses = new HashSet<>(); | |||
Set<String> tabClasses = new HashSet<>(); // !! would be better as a List |
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 assume no bug has been filed for this?
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.
Not yet. I have a list of a number of minor cleanups to do.
@@ -71,9 +72,10 @@ | |||
HtmlIndexBuilder(HtmlConfiguration configuration) { | |||
super(configuration, configuration.getOptions().noDeprecated()); | |||
this.configuration = configuration; | |||
links = new Links(DocPath.empty, configuration.utils); | |||
links = new Links(DocPath.empty); |
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.
It looks like links
isn't used anywhere else in HtmlIndexBuilder
and can be removed.
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.
OK, will check.
* | ||
* @see HtmlTree#setId(HtmlId) | ||
*/ | ||
public interface HtmlId { |
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.
Is there a reason for making this an interface instead of a plain class?
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.
At one point, I had in mind using an enum class for the set of fixed ids, and so wanted an interface that I could mix in to the declaration of that class.
Eventually, when we have value types, HtmlId
could be a good candidate for that feature.
@jonathan-gibbons This change now passes all automated pre-integration checks. 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 no new commits pushed to the
|
/integrate |
@jonathan-gibbons Pushed as commit 916ab4e. |
Please review this change to centralize the management of HTML ids used by the standard doclet in a single new factory class,
HtmlIds
, which utilizes a new type-safe wrapper class aroundString
calledHtmlId
.The new classes are used both when declaring ids (e.g.
HtmlTree.setId
) and when referencing them (e.g.Links.createLink
). The enumSectionName
, which declared a set of standard ids, goes away, as do methods inLinks
and other places to create "anchors".This is a simple refactoring: there is no intentional change of functionality, and no tests are affected or need to be updated. However, the changes do highlight the inconsistency of the use of ids: it would be good to rationalize these in separate, targeted follow-up work.
Progress
Issue
Reviewers
Download
$ git fetch https://git.openjdk.java.net/jdk pull/1951/head:pull/1951
$ git checkout pull/1951