mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 15:24:43 +02:00
8225321: Repeated use of {@systemProperty} in a file causes duplicate ids
Reviewed-by: hannesw
This commit is contained in:
parent
332d079057
commit
948577bb1f
4 changed files with 63 additions and 3 deletions
|
@ -27,6 +27,7 @@ package jdk.javadoc.internal.doclets.formats.html;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
|
@ -196,6 +197,14 @@ public class HtmlDocletWriter {
|
|||
|
||||
protected Script mainBodyScript;
|
||||
|
||||
/**
|
||||
* A table of the anchors used for at-index and related tags,
|
||||
* so that they can be made unique by appending a suitable suffix.
|
||||
* (Ideally, javadoc should be tracking all id's generated in a file
|
||||
* to avoid generating duplicates.)
|
||||
*/
|
||||
Map<String, Integer> indexAnchorTable = new HashMap<>();
|
||||
|
||||
/**
|
||||
* Constructor to construct the HtmlStandardWriter object.
|
||||
*
|
||||
|
|
|
@ -409,11 +409,16 @@ public class TagletWriterImpl extends TagletWriter {
|
|||
}
|
||||
|
||||
private Content createAnchorAndSearchIndex(Element element, String tagText, String desc){
|
||||
String anchorName = htmlWriter.links.getName(tagText);
|
||||
Content result = null;
|
||||
if (isFirstSentence && inSummary) {
|
||||
result = new StringContent(tagText);
|
||||
} else {
|
||||
String anchorName = htmlWriter.links.getName(tagText);
|
||||
int count = htmlWriter.indexAnchorTable.computeIfAbsent(anchorName, s -> 0);
|
||||
htmlWriter.indexAnchorTable.put(anchorName, count + 1);
|
||||
if (count > 0) {
|
||||
anchorName += "-" + count;
|
||||
}
|
||||
result = HtmlTree.A_ID(HtmlStyle.searchTagResult, anchorName, new StringContent(tagText));
|
||||
if (configuration.createindex && !tagText.isEmpty()) {
|
||||
SearchIndexItem si = new SearchIndexItem();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue