< prev index next >

src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/TagletWriterImpl.java

Print this page




  55 import jdk.javadoc.internal.doclets.toolkit.util.CommentHelper;
  56 import jdk.javadoc.internal.doclets.toolkit.util.DocLink;
  57 import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
  58 import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
  59 import jdk.javadoc.internal.doclets.toolkit.util.DocletConstants;
  60 import jdk.javadoc.internal.doclets.toolkit.util.Utils;
  61 
  62 /**
  63  * The taglet writer that writes HTML.
  64  *
  65  *  <p><b>This is NOT part of any supported API.
  66  *  If you write code that depends on this, you do so at your own risk.
  67  *  This code and its internal interfaces are subject to change or
  68  *  deletion without notice.</b>
  69  */
  70 
  71 public class TagletWriterImpl extends TagletWriter {
  72 
  73     private final HtmlDocletWriter htmlWriter;
  74     private final HtmlConfiguration configuration;

  75     private final Utils utils;
  76     private final boolean inSummary;
  77     private final Resources resources;
  78 
  79     public TagletWriterImpl(HtmlDocletWriter htmlWriter, boolean isFirstSentence) {
  80         this(htmlWriter, isFirstSentence, false);
  81     }
  82 
  83     public TagletWriterImpl(HtmlDocletWriter htmlWriter, boolean isFirstSentence, boolean inSummary) {
  84         super(isFirstSentence);
  85         this.htmlWriter = htmlWriter;
  86         configuration = htmlWriter.configuration;
  87         this.utils = configuration.utils;
  88         this.inSummary = inSummary;



  89         resources = configuration.getResources();
  90     }
  91 
  92     /**
  93      * {@inheritDoc}
  94      */
  95     public Content getOutputInstance() {
  96         return new ContentBuilder();
  97     }
  98 
  99     /**
 100      * {@inheritDoc}
 101      */
 102     protected Content codeTagOutput(Element element, DocTree tag) {
 103         CommentHelper ch = utils.getCommentHelper(element);
 104         StringContent content = new StringContent(utils.normalizeNewlines(ch.getText(tag)));
 105         Content result = HtmlTree.CODE(content);
 106         return result;
 107     }
 108 


 421     /**
 422      * {@inheritDoc}
 423      */
 424     protected TypeElement getCurrentPageElement() {
 425         return htmlWriter.getCurrentPageElement();
 426     }
 427 
 428     @SuppressWarnings("preview")
 429     private Content createAnchorAndSearchIndex(Element element, String tagText, String desc, boolean isSystemProperty) {
 430         Content result = null;
 431         if (isFirstSentence && inSummary) {
 432             result = new StringContent(tagText);
 433         } else {
 434             String anchorName = htmlWriter.links.getName(tagText);
 435             int count = htmlWriter.indexAnchorTable
 436                     .compute(anchorName, (k, v) -> v == null ? 0 : v + 1);
 437             if (count > 0) {
 438                 anchorName += "-" + count;
 439             }
 440             result = HtmlTree.SPAN(anchorName, HtmlStyle.searchTagResult, new StringContent(tagText));
 441             if (configuration.createindex && !tagText.isEmpty()) {
 442                 SearchIndexItem si = new SearchIndexItem();
 443                 si.setSystemProperty(isSystemProperty);
 444                 si.setLabel(tagText);
 445                 si.setDescription(desc);
 446                 si.setUrl(htmlWriter.path.getPath() + "#" + anchorName);
 447                 new SimpleElementVisitor14<Void, Void>() {
 448 
 449                     @Override
 450                     public Void visitModule(ModuleElement e, Void p) {
 451                         si.setHolder(resources.getText("doclet.module")
 452                                              + " " + utils.getFullyQualifiedName(e));
 453                         return null;
 454                     }
 455 
 456                     @Override
 457                     public Void visitPackage(PackageElement e, Void p) {
 458                         si.setHolder(resources.getText("doclet.package")
 459                                              + " " + utils.getFullyQualifiedName(e));
 460                         return null;
 461                     }




  55 import jdk.javadoc.internal.doclets.toolkit.util.CommentHelper;
  56 import jdk.javadoc.internal.doclets.toolkit.util.DocLink;
  57 import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
  58 import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
  59 import jdk.javadoc.internal.doclets.toolkit.util.DocletConstants;
  60 import jdk.javadoc.internal.doclets.toolkit.util.Utils;
  61 
  62 /**
  63  * The taglet writer that writes HTML.
  64  *
  65  *  <p><b>This is NOT part of any supported API.
  66  *  If you write code that depends on this, you do so at your own risk.
  67  *  This code and its internal interfaces are subject to change or
  68  *  deletion without notice.</b>
  69  */
  70 
  71 public class TagletWriterImpl extends TagletWriter {
  72 
  73     private final HtmlDocletWriter htmlWriter;
  74     private final HtmlConfiguration configuration;
  75     private final HtmlOptions options;
  76     private final Utils utils;
  77     private final boolean inSummary;
  78     private final Resources resources;
  79 
  80     public TagletWriterImpl(HtmlDocletWriter htmlWriter, boolean isFirstSentence) {
  81         this(htmlWriter, isFirstSentence, false);
  82     }
  83 
  84     public TagletWriterImpl(HtmlDocletWriter htmlWriter, boolean isFirstSentence, boolean inSummary) {
  85         super(isFirstSentence);
  86         this.htmlWriter = htmlWriter;


  87         this.inSummary = inSummary;
  88         configuration = htmlWriter.configuration;
  89         options = configuration.getOptions();
  90         utils = configuration.utils;
  91         resources = configuration.getResources();
  92     }
  93 
  94     /**
  95      * {@inheritDoc}
  96      */
  97     public Content getOutputInstance() {
  98         return new ContentBuilder();
  99     }
 100 
 101     /**
 102      * {@inheritDoc}
 103      */
 104     protected Content codeTagOutput(Element element, DocTree tag) {
 105         CommentHelper ch = utils.getCommentHelper(element);
 106         StringContent content = new StringContent(utils.normalizeNewlines(ch.getText(tag)));
 107         Content result = HtmlTree.CODE(content);
 108         return result;
 109     }
 110 


 423     /**
 424      * {@inheritDoc}
 425      */
 426     protected TypeElement getCurrentPageElement() {
 427         return htmlWriter.getCurrentPageElement();
 428     }
 429 
 430     @SuppressWarnings("preview")
 431     private Content createAnchorAndSearchIndex(Element element, String tagText, String desc, boolean isSystemProperty) {
 432         Content result = null;
 433         if (isFirstSentence && inSummary) {
 434             result = new StringContent(tagText);
 435         } else {
 436             String anchorName = htmlWriter.links.getName(tagText);
 437             int count = htmlWriter.indexAnchorTable
 438                     .compute(anchorName, (k, v) -> v == null ? 0 : v + 1);
 439             if (count > 0) {
 440                 anchorName += "-" + count;
 441             }
 442             result = HtmlTree.SPAN(anchorName, HtmlStyle.searchTagResult, new StringContent(tagText));
 443             if (options.createIndex && !tagText.isEmpty()) {
 444                 SearchIndexItem si = new SearchIndexItem();
 445                 si.setSystemProperty(isSystemProperty);
 446                 si.setLabel(tagText);
 447                 si.setDescription(desc);
 448                 si.setUrl(htmlWriter.path.getPath() + "#" + anchorName);
 449                 new SimpleElementVisitor14<Void, Void>() {
 450 
 451                     @Override
 452                     public Void visitModule(ModuleElement e, Void p) {
 453                         si.setHolder(resources.getText("doclet.module")
 454                                              + " " + utils.getFullyQualifiedName(e));
 455                         return null;
 456                     }
 457 
 458                     @Override
 459                     public Void visitPackage(PackageElement e, Void p) {
 460                         si.setHolder(resources.getText("doclet.package")
 461                                              + " " + utils.getFullyQualifiedName(e));
 462                         return null;
 463                     }


< prev index next >