58 import com.sun.source.doctree.IndexTree;
59 import com.sun.source.doctree.InheritDocTree;
60 import com.sun.source.doctree.LinkTree;
61 import com.sun.source.doctree.LiteralTree;
62 import com.sun.source.doctree.SeeTree;
63 import com.sun.source.doctree.StartElementTree;
64 import com.sun.source.doctree.SummaryTree;
65 import com.sun.source.doctree.TextTree;
66 import com.sun.source.util.SimpleDocTreeVisitor;
67
68 import jdk.javadoc.internal.doclets.formats.html.markup.Comment;
69 import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder;
70 import jdk.javadoc.internal.doclets.formats.html.markup.DocType;
71 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlAttr;
72 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants;
73 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlDocWriter;
74 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlDocument;
75 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
76 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
77 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
78 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlVersion;
79 import jdk.javadoc.internal.doclets.formats.html.markup.RawHtml;
80 import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
81 import jdk.javadoc.internal.doclets.toolkit.AnnotationTypeWriter;
82 import jdk.javadoc.internal.doclets.toolkit.ClassWriter;
83 import jdk.javadoc.internal.doclets.toolkit.BaseConfiguration;
84 import jdk.javadoc.internal.doclets.toolkit.Content;
85 import jdk.javadoc.internal.doclets.toolkit.Messages;
86 import jdk.javadoc.internal.doclets.toolkit.PackageSummaryWriter;
87 import jdk.javadoc.internal.doclets.toolkit.Resources;
88 import jdk.javadoc.internal.doclets.toolkit.taglets.DocRootTaglet;
89 import jdk.javadoc.internal.doclets.toolkit.taglets.TagletWriter;
90 import jdk.javadoc.internal.doclets.toolkit.util.CommentHelper;
91 import jdk.javadoc.internal.doclets.toolkit.util.DocFile;
92 import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException;
93 import jdk.javadoc.internal.doclets.toolkit.util.DocLink;
94 import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
95 import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
96 import jdk.javadoc.internal.doclets.toolkit.util.DocletConstants;
97 import jdk.javadoc.internal.doclets.toolkit.util.ImplementedMethods;
98 import jdk.javadoc.internal.doclets.toolkit.util.Utils;
99
100 import static com.sun.source.doctree.DocTree.Kind.*;
101 import static jdk.javadoc.internal.doclets.toolkit.util.CommentHelper.SPACER;
102
103
372 */
373 public Content getTargetModulePackageLink(PackageElement pkg, String target,
374 Content label, ModuleElement mdle) {
375 return getHyperLink(pathString(pkg, DocPaths.PACKAGE_SUMMARY),
376 label, "", target);
377 }
378
379 /**
380 * Get Module link, with target frame.
381 *
382 * @param target name of the target frame
383 * @param label tag for the link
384 * @param mdle the module being documented
385 * @return a content for the target module link
386 */
387 public Content getTargetModuleLink(String target, Content label, ModuleElement mdle) {
388 return getHyperLink(pathToRoot.resolve(
389 DocPaths.moduleSummary(mdle)), label, "", target);
390 }
391
392 public void addClassesSummary(SortedSet<TypeElement> classes, String label,
393 String tableSummary, List<String> tableHeader, Content summaryContentTree) {
394 if (!classes.isEmpty()) {
395 Content caption = getTableCaption(new RawHtml(label));
396 Content table = (configuration.isOutputHtml5())
397 ? HtmlTree.TABLE(HtmlStyle.typeSummary, caption)
398 : HtmlTree.TABLE(HtmlStyle.typeSummary, tableSummary, caption);
399 table.addContent(getSummaryTableHeader(tableHeader, "col"));
400 Content tbody = new HtmlTree(HtmlTag.TBODY);
401 boolean altColor = true;
402 for (TypeElement te : classes) {
403 if (!utils.isCoreClass(te) ||
404 !configuration.isGeneratedDoc(te)) {
405 continue;
406 }
407 Content classContent = getLink(new LinkInfoImpl(
408 configuration, LinkInfoImpl.Kind.PACKAGE, te));
409 Content tdClass = HtmlTree.TH_ROW_SCOPE(HtmlStyle.colFirst, classContent);
410 HtmlTree tr = HtmlTree.TR(tdClass);
411 tr.addStyle(altColor ? HtmlStyle.altColor : HtmlStyle.rowColor);
412 altColor = !altColor;
413 HtmlTree tdClassDescription = new HtmlTree(HtmlTag.TD);
414 tdClassDescription.addStyle(HtmlStyle.colLast);
415 if (utils.isDeprecated(te)) {
416 tdClassDescription.addContent(getDeprecatedPhrase(te));
417 List<? extends DocTree> tags = utils.getDeprecatedTrees(te);
418 if (!tags.isEmpty()) {
419 addSummaryDeprecatedComment(te, tags.get(0), tdClassDescription);
420 }
421 } else {
422 addSummaryComment(te, tdClassDescription);
423 }
424 tr.addContent(tdClassDescription);
425 tbody.addContent(tr);
426 }
427 table.addContent(tbody);
428 summaryContentTree.addContent(table);
429 }
430 }
431
432 /**
433 * Generates the HTML document tree and prints it out.
434 *
435 * @param metakeywords Array of String keywords for META tag. Each element
436 * of the array is assigned to a separate META tag.
437 * Pass in null for no array
438 * @param includeScript true if printing windowtitle script
439 * false for files that appear in the left-hand frames
440 * @param body the body htmltree to be included in the document
441 * @throws DocFileIOException if there is a problem writing the file
442 */
443 public void printHtmlDocument(List<String> metakeywords, boolean includeScript,
444 Content body) throws DocFileIOException {
445 Content htmlDocType = configuration.isOutputHtml5()
446 ? DocType.HTML5
447 : DocType.TRANSITIONAL;
448 Content htmlComment = new Comment(configuration.getText("doclet.New_Page"));
449 Content head = new HtmlTree(HtmlTag.HEAD);
450 head.addContent(getGeneratedBy(!configuration.notimestamp));
451 head.addContent(getTitle());
921 helpfilenm = DocPath.create(file.getName());
922 }
923 Content linkContent = getHyperLink(pathToRoot.resolve(helpfilenm),
924 contents.helpLabel, "", "");
925 Content li = HtmlTree.LI(linkContent);
926 return li;
927 }
928
929 /**
930 * Add gap between navigation bar elements.
931 *
932 * @param liNav the content tree to which the gap will be added
933 */
934 protected void addNavGap(Content liNav) {
935 liNav.addContent(Contents.SPACE);
936 liNav.addContent("|");
937 liNav.addContent(Contents.SPACE);
938 }
939
940 /**
941 * Get summary table header.
942 *
943 * @param header the header for the table
944 * @param scope the scope of the headers
945 * @return a content tree for the header
946 */
947 public Content getSummaryTableHeader(List<String> header, String scope) {
948 Content tr = new HtmlTree(HtmlTag.TR);
949 final int size = header.size();
950 Content tableHeader;
951 if (size == 2) {
952 tableHeader = new StringContent(header.get(0));
953 tr.addContent(HtmlTree.TH(HtmlStyle.colFirst, scope, tableHeader));
954 tableHeader = new StringContent(header.get(1));
955 tr.addContent(HtmlTree.TH(HtmlStyle.colLast, scope, tableHeader));
956 return tr;
957 }
958 for (int i = 0; i < size; i++) {
959 tableHeader = new StringContent(header.get(i));
960 if (i == 0)
961 tr.addContent(HtmlTree.TH(HtmlStyle.colFirst, scope, tableHeader));
962 else if (i == 1)
963 tr.addContent(HtmlTree.TH(HtmlStyle.colSecond, scope, tableHeader));
964 else if (i == (size - 1))
965 tr.addContent(HtmlTree.TH(HtmlStyle.colLast, scope, tableHeader));
966 else
967 tr.addContent(HtmlTree.TH(scope, tableHeader));
968 }
969 return tr;
970 }
971
972 /**
973 * Get table caption.
974 *
975 * @param rawText the caption for the table which could be raw Html
976 * @return a content tree for the caption
977 */
978 public Content getTableCaption(Content title) {
979 Content captionSpan = HtmlTree.SPAN(title);
980 Content space = Contents.SPACE;
981 Content tabSpan = HtmlTree.SPAN(HtmlStyle.tabEnd, space);
982 Content caption = HtmlTree.CAPTION(captionSpan);
983 caption.addContent(tabSpan);
984 return caption;
985 }
986
987 /**
988 * Get the marker anchor which will be added to the documentation tree.
989 *
990 * @param anchorName the anchor name attribute
991 * @return a content tree for the marker anchor
992 */
993 public Content getMarkerAnchor(String anchorName) {
994 return getMarkerAnchor(getName(anchorName), null);
995 }
2587 c, c.getSimpleName(), false);
2588 }
2589 @Override
2590 public Content visitArray(List<? extends AnnotationValue> vals, Void p) {
2591 ContentBuilder buf = new ContentBuilder();
2592 String sep = "";
2593 for (AnnotationValue av : vals) {
2594 buf.addContent(sep);
2595 buf.addContent(visit(av));
2596 sep = " ";
2597 }
2598 return buf;
2599 }
2600 @Override
2601 protected Content defaultAction(Object o, Void p) {
2602 return new StringContent(annotationValue.toString());
2603 }
2604 }.visit(annotationValue);
2605 }
2606
2607 /**
2608 * Return the configuration for this doclet.
2609 *
2610 * @return the configuration for this doclet.
2611 */
2612 @Override
2613 public BaseConfiguration configuration() {
2614 return configuration;
2615 }
2616 }
|
58 import com.sun.source.doctree.IndexTree;
59 import com.sun.source.doctree.InheritDocTree;
60 import com.sun.source.doctree.LinkTree;
61 import com.sun.source.doctree.LiteralTree;
62 import com.sun.source.doctree.SeeTree;
63 import com.sun.source.doctree.StartElementTree;
64 import com.sun.source.doctree.SummaryTree;
65 import com.sun.source.doctree.TextTree;
66 import com.sun.source.util.SimpleDocTreeVisitor;
67
68 import jdk.javadoc.internal.doclets.formats.html.markup.Comment;
69 import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder;
70 import jdk.javadoc.internal.doclets.formats.html.markup.DocType;
71 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlAttr;
72 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants;
73 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlDocWriter;
74 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlDocument;
75 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
76 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
77 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
78 import jdk.javadoc.internal.doclets.formats.html.markup.RawHtml;
79 import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
80 import jdk.javadoc.internal.doclets.toolkit.AnnotationTypeWriter;
81 import jdk.javadoc.internal.doclets.toolkit.ClassWriter;
82 import jdk.javadoc.internal.doclets.toolkit.Content;
83 import jdk.javadoc.internal.doclets.toolkit.Messages;
84 import jdk.javadoc.internal.doclets.toolkit.PackageSummaryWriter;
85 import jdk.javadoc.internal.doclets.toolkit.Resources;
86 import jdk.javadoc.internal.doclets.toolkit.taglets.DocRootTaglet;
87 import jdk.javadoc.internal.doclets.toolkit.taglets.TagletWriter;
88 import jdk.javadoc.internal.doclets.toolkit.util.CommentHelper;
89 import jdk.javadoc.internal.doclets.toolkit.util.DocFile;
90 import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException;
91 import jdk.javadoc.internal.doclets.toolkit.util.DocLink;
92 import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
93 import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
94 import jdk.javadoc.internal.doclets.toolkit.util.DocletConstants;
95 import jdk.javadoc.internal.doclets.toolkit.util.ImplementedMethods;
96 import jdk.javadoc.internal.doclets.toolkit.util.Utils;
97
98 import static com.sun.source.doctree.DocTree.Kind.*;
99 import static jdk.javadoc.internal.doclets.toolkit.util.CommentHelper.SPACER;
100
101
370 */
371 public Content getTargetModulePackageLink(PackageElement pkg, String target,
372 Content label, ModuleElement mdle) {
373 return getHyperLink(pathString(pkg, DocPaths.PACKAGE_SUMMARY),
374 label, "", target);
375 }
376
377 /**
378 * Get Module link, with target frame.
379 *
380 * @param target name of the target frame
381 * @param label tag for the link
382 * @param mdle the module being documented
383 * @return a content for the target module link
384 */
385 public Content getTargetModuleLink(String target, Content label, ModuleElement mdle) {
386 return getHyperLink(pathToRoot.resolve(
387 DocPaths.moduleSummary(mdle)), label, "", target);
388 }
389
390 /**
391 * Generates the HTML document tree and prints it out.
392 *
393 * @param metakeywords Array of String keywords for META tag. Each element
394 * of the array is assigned to a separate META tag.
395 * Pass in null for no array
396 * @param includeScript true if printing windowtitle script
397 * false for files that appear in the left-hand frames
398 * @param body the body htmltree to be included in the document
399 * @throws DocFileIOException if there is a problem writing the file
400 */
401 public void printHtmlDocument(List<String> metakeywords, boolean includeScript,
402 Content body) throws DocFileIOException {
403 Content htmlDocType = configuration.isOutputHtml5()
404 ? DocType.HTML5
405 : DocType.TRANSITIONAL;
406 Content htmlComment = new Comment(configuration.getText("doclet.New_Page"));
407 Content head = new HtmlTree(HtmlTag.HEAD);
408 head.addContent(getGeneratedBy(!configuration.notimestamp));
409 head.addContent(getTitle());
879 helpfilenm = DocPath.create(file.getName());
880 }
881 Content linkContent = getHyperLink(pathToRoot.resolve(helpfilenm),
882 contents.helpLabel, "", "");
883 Content li = HtmlTree.LI(linkContent);
884 return li;
885 }
886
887 /**
888 * Add gap between navigation bar elements.
889 *
890 * @param liNav the content tree to which the gap will be added
891 */
892 protected void addNavGap(Content liNav) {
893 liNav.addContent(Contents.SPACE);
894 liNav.addContent("|");
895 liNav.addContent(Contents.SPACE);
896 }
897
898 /**
899 * Get table caption.
900 *
901 * @param title the content for the caption
902 * @return a content tree for the caption
903 */
904 public Content getTableCaption(Content title) {
905 Content captionSpan = HtmlTree.SPAN(title);
906 Content space = Contents.SPACE;
907 Content tabSpan = HtmlTree.SPAN(HtmlStyle.tabEnd, space);
908 Content caption = HtmlTree.CAPTION(captionSpan);
909 caption.addContent(tabSpan);
910 return caption;
911 }
912
913 /**
914 * Get the marker anchor which will be added to the documentation tree.
915 *
916 * @param anchorName the anchor name attribute
917 * @return a content tree for the marker anchor
918 */
919 public Content getMarkerAnchor(String anchorName) {
920 return getMarkerAnchor(getName(anchorName), null);
921 }
2513 c, c.getSimpleName(), false);
2514 }
2515 @Override
2516 public Content visitArray(List<? extends AnnotationValue> vals, Void p) {
2517 ContentBuilder buf = new ContentBuilder();
2518 String sep = "";
2519 for (AnnotationValue av : vals) {
2520 buf.addContent(sep);
2521 buf.addContent(visit(av));
2522 sep = " ";
2523 }
2524 return buf;
2525 }
2526 @Override
2527 protected Content defaultAction(Object o, Void p) {
2528 return new StringContent(annotationValue.toString());
2529 }
2530 }.visit(annotationValue);
2531 }
2532
2533 protected TableHeader getPackageTableHeader() {
2534 return new TableHeader(contents.packageLabel, contents.descriptionLabel);
2535 }
2536 }
|