mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 15:24:43 +02:00
5076751: System properties documentation needed in javadocs
Reviewed-by: jjg
This commit is contained in:
parent
eda5f09014
commit
50dc5ef396
20 changed files with 532 additions and 55 deletions
|
@ -65,6 +65,7 @@ import com.sun.source.doctree.LiteralTree;
|
|||
import com.sun.source.doctree.SeeTree;
|
||||
import com.sun.source.doctree.StartElementTree;
|
||||
import com.sun.source.doctree.SummaryTree;
|
||||
import com.sun.source.doctree.SystemPropertyTree;
|
||||
import com.sun.source.doctree.TextTree;
|
||||
import com.sun.source.util.SimpleDocTreeVisitor;
|
||||
|
||||
|
@ -1531,6 +1532,17 @@ public class HtmlDocletWriter {
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean visitSystemProperty(SystemPropertyTree node, Content p) {
|
||||
Content output = TagletWriter.getInlineTagOutput(element,
|
||||
configuration.tagletManager, holderTag, tag,
|
||||
getTagletWriterInstance(isFirstSentence, inSummary));
|
||||
if (output != null) {
|
||||
result.addContent(output);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private CharSequence textCleanup(String text, boolean isLast) {
|
||||
return textCleanup(text, isLast, false);
|
||||
}
|
||||
|
|
|
@ -37,6 +37,7 @@ import javax.lang.model.util.SimpleElementVisitor9;
|
|||
|
||||
import com.sun.source.doctree.DocTree;
|
||||
import com.sun.source.doctree.IndexTree;
|
||||
import com.sun.source.doctree.SystemPropertyTree;
|
||||
import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder;
|
||||
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
|
||||
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
|
||||
|
@ -45,6 +46,7 @@ import jdk.javadoc.internal.doclets.formats.html.markup.RawHtml;
|
|||
import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
|
||||
import jdk.javadoc.internal.doclets.toolkit.BaseConfiguration;
|
||||
import jdk.javadoc.internal.doclets.toolkit.Content;
|
||||
import jdk.javadoc.internal.doclets.toolkit.Resources;
|
||||
import jdk.javadoc.internal.doclets.toolkit.builders.SerializedFormBuilder;
|
||||
import jdk.javadoc.internal.doclets.toolkit.taglets.TagletWriter;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.CommentHelper;
|
||||
|
@ -72,6 +74,7 @@ public class TagletWriterImpl extends TagletWriter {
|
|||
private final HtmlConfiguration configuration;
|
||||
private final Utils utils;
|
||||
private final boolean inSummary;
|
||||
private final Resources resources;
|
||||
|
||||
public TagletWriterImpl(HtmlDocletWriter htmlWriter, boolean isFirstSentence) {
|
||||
this(htmlWriter, isFirstSentence, false);
|
||||
|
@ -83,6 +86,7 @@ public class TagletWriterImpl extends TagletWriter {
|
|||
configuration = htmlWriter.configuration;
|
||||
this.utils = configuration.utils;
|
||||
this.inSummary = inSummary;
|
||||
resources = configuration.getResources();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -112,61 +116,7 @@ public class TagletWriterImpl extends TagletWriter {
|
|||
}
|
||||
String desc = ch.getText(itt.getDescription());
|
||||
|
||||
String anchorName = htmlWriter.links.getName(tagText);
|
||||
Content result = null;
|
||||
if (isFirstSentence && inSummary) {
|
||||
result = new StringContent(tagText);
|
||||
} else {
|
||||
result = HtmlTree.A_ID(HtmlStyle.searchTagResult, anchorName, new StringContent(tagText));
|
||||
if (configuration.createindex && !tagText.isEmpty()) {
|
||||
SearchIndexItem si = new SearchIndexItem();
|
||||
si.setLabel(tagText);
|
||||
si.setDescription(desc);
|
||||
DocPaths docPaths = configuration.docPaths;
|
||||
new SimpleElementVisitor9<Void, Void>() {
|
||||
@Override
|
||||
public Void visitModule(ModuleElement e, Void p) {
|
||||
si.setUrl(docPaths.moduleSummary(e).getPath() + "#" + anchorName);
|
||||
si.setHolder(utils.getFullyQualifiedName(element));
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitPackage(PackageElement e, Void p) {
|
||||
si.setUrl(docPaths.forPackage(e).getPath()
|
||||
+ "/" + DocPaths.PACKAGE_SUMMARY.getPath() + "#" + anchorName);
|
||||
si.setHolder(utils.getSimpleName(element));
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitType(TypeElement e, Void p) {
|
||||
si.setUrl(docPaths.forClass(e).getPath() + "#" + anchorName);
|
||||
si.setHolder(utils.getFullyQualifiedName(e));
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitVariable(VariableElement e, Void p) {
|
||||
TypeElement te = utils.getEnclosingTypeElement(e);
|
||||
si.setUrl(docPaths.forClass(te).getPath() + "#" + anchorName);
|
||||
si.setHolder(utils.getFullyQualifiedName(e) + "." + utils.getSimpleName(e));
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Void defaultAction(Element e, Void p) {
|
||||
TypeElement te = utils.getEnclosingTypeElement(e);
|
||||
si.setUrl(docPaths.forClass(te).getPath() + "#" + anchorName);
|
||||
si.setHolder(utils.getFullyQualifiedName(e));
|
||||
return null;
|
||||
}
|
||||
}.visit(element);
|
||||
si.setCategory(configuration.getContent("doclet.SearchTags").toString());
|
||||
configuration.tagSearchIndex.add(si);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
return createAnchorAndSearchIndex(element, tagText,desc);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -364,6 +314,16 @@ public class TagletWriterImpl extends TagletWriter {
|
|||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
protected Content systemPropertyTagOutput(Element element, DocTree tag) {
|
||||
SystemPropertyTree itt = (SystemPropertyTree)tag;
|
||||
String tagText = itt.getPropertyName().toString();
|
||||
return HtmlTree.CODE(createAnchorAndSearchIndex(element, tagText,
|
||||
resources.getText("doclet.System_Property")));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
@ -449,4 +409,62 @@ public class TagletWriterImpl extends TagletWriter {
|
|||
public BaseConfiguration configuration() {
|
||||
return configuration;
|
||||
}
|
||||
|
||||
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 {
|
||||
result = HtmlTree.A_ID(HtmlStyle.searchTagResult, anchorName, new StringContent(tagText));
|
||||
if (configuration.createindex && !tagText.isEmpty()) {
|
||||
SearchIndexItem si = new SearchIndexItem();
|
||||
si.setLabel(tagText);
|
||||
si.setDescription(desc);
|
||||
DocPaths docPaths = configuration.docPaths;
|
||||
new SimpleElementVisitor9<Void, Void>() {
|
||||
@Override
|
||||
public Void visitModule(ModuleElement e, Void p) {
|
||||
si.setUrl(docPaths.moduleSummary(e).getPath() + "#" + anchorName);
|
||||
si.setHolder(utils.getFullyQualifiedName(element));
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitPackage(PackageElement e, Void p) {
|
||||
si.setUrl(docPaths.forPackage(e).getPath()
|
||||
+ "/" + DocPaths.PACKAGE_SUMMARY.getPath() + "#" + anchorName);
|
||||
si.setHolder(utils.getSimpleName(element));
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitType(TypeElement e, Void p) {
|
||||
si.setUrl(docPaths.forClass(e).getPath() + "#" + anchorName);
|
||||
si.setHolder(utils.getFullyQualifiedName(e));
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visitVariable(VariableElement e, Void p) {
|
||||
TypeElement te = utils.getEnclosingTypeElement(e);
|
||||
si.setUrl(docPaths.forClass(te).getPath() + "#" + anchorName);
|
||||
si.setHolder(utils.getFullyQualifiedName(e) + "." + utils.getSimpleName(e));
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Void defaultAction(Element e, Void p) {
|
||||
TypeElement te = utils.getEnclosingTypeElement(e);
|
||||
si.setUrl(docPaths.forClass(te).getPath() + "#" + anchorName);
|
||||
si.setHolder(utils.getFullyQualifiedName(e));
|
||||
return null;
|
||||
}
|
||||
}.visit(element);
|
||||
si.setCategory(configuration.getContent("doclet.SearchTags").toString());
|
||||
configuration.tagSearchIndex.add(si);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -95,6 +95,7 @@ doclet.No_Non_Deprecated_Classes_To_Document=No non-deprecated classes found to
|
|||
doclet.Interfaces=Interfaces
|
||||
doclet.Enclosing_Class=Enclosing class:
|
||||
doclet.Enclosing_Interface=Enclosing interface:
|
||||
doclet.System_Property=System Property
|
||||
doclet.Window_Source_title=Source code
|
||||
doclet.Window_Help_title=API Help
|
||||
|
||||
|
|
|
@ -0,0 +1,56 @@
|
|||
/*
|
||||
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package jdk.javadoc.internal.doclets.toolkit.taglets;
|
||||
|
||||
import com.sun.source.doctree.DocTree;
|
||||
import jdk.javadoc.internal.doclets.toolkit.Content;
|
||||
|
||||
import javax.lang.model.element.Element;
|
||||
import java.util.EnumSet;
|
||||
|
||||
import static com.sun.source.doctree.DocTree.Kind.SYSTEM_PROPERTY;
|
||||
|
||||
/**
|
||||
* A taglet that represents the {@code @systemProperty} tag.
|
||||
*
|
||||
* <p><b>This is NOT part of any supported API.
|
||||
* If you write code that depends on this, you do so at your own risk.
|
||||
* This code and its internal interfaces are subject to change or
|
||||
* deletion without notice.</b>
|
||||
*/
|
||||
|
||||
public class SystemPropertyTaglet extends BaseTaglet {
|
||||
|
||||
SystemPropertyTaglet(){
|
||||
super(SYSTEM_PROPERTY.tagName, true, EnumSet.of(Site.CONSTRUCTOR, Site.METHOD, Site.FIELD,
|
||||
Site.PACKAGE, Site.MODULE, Site.TYPE));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Content getTagletOutput(Element element, DocTree tag, TagletWriter writer) {
|
||||
return writer.systemPropertyTagOutput(element, tag);
|
||||
}
|
||||
}
|
|
@ -609,6 +609,7 @@ public class TagletManager {
|
|||
addStandardTaglet(new CodeTaglet());
|
||||
addStandardTaglet(new IndexTaglet());
|
||||
addStandardTaglet(new SummaryTaglet());
|
||||
addStandardTaglet(new SystemPropertyTaglet());
|
||||
|
||||
// Keep track of the names of standard tags for error checking purposes.
|
||||
// The following are not handled above.
|
||||
|
|
|
@ -171,6 +171,15 @@ public abstract class TagletWriter {
|
|||
*/
|
||||
protected abstract Content simpleTagOutput(Element element, DocTree simpleTag, String header);
|
||||
|
||||
/**
|
||||
* Return the system property tag output.
|
||||
*
|
||||
* @param element
|
||||
* @param systemPropertyTag the system property tag
|
||||
* @return the output of system property tag
|
||||
*/
|
||||
protected abstract Content systemPropertyTagOutput(Element element, DocTree systemPropertyTag);
|
||||
|
||||
/**
|
||||
* Return the header for the throws tag.
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue