407 * Returns true if there are elements to be displayed. |
407 * Returns true if there are elements to be displayed. |
408 * |
408 * |
409 * @param section set of elements |
409 * @param section set of elements |
410 * @return true if there are elements to be displayed |
410 * @return true if there are elements to be displayed |
411 */ |
411 */ |
412 public boolean display(SortedSet<? extends Element> section) { |
412 public boolean display(Set<? extends Element> section) { |
413 return section != null && !section.isEmpty(); |
413 return section != null && !section.isEmpty(); |
414 } |
414 } |
415 |
415 |
416 /** |
416 /** |
417 * Returns true if there are elements to be displayed. |
417 * Returns true if there are elements to be displayed. |
419 * @param section map of elements. |
419 * @param section map of elements. |
420 * @return true if there are elements to be displayed |
420 * @return true if there are elements to be displayed |
421 */ |
421 */ |
422 public boolean display(Map<? extends Element, ?> section) { |
422 public boolean display(Map<? extends Element, ?> section) { |
423 return section != null && !section.isEmpty(); |
423 return section != null && !section.isEmpty(); |
|
424 } |
|
425 |
|
426 /* |
|
427 * Returns true, in API mode, if at least one type element in |
|
428 * the typeElements set is referenced by a javadoc tag in tagsMap. |
|
429 */ |
|
430 private boolean displayServices(Set<TypeElement> typeElements, |
|
431 Map<TypeElement, Content> tagsMap) { |
|
432 return typeElements != null && |
|
433 typeElements.stream().anyMatch((v) -> displayServiceDirective(v, tagsMap)); |
|
434 } |
|
435 |
|
436 /* |
|
437 * Returns true, in API mode, if the type element is referenced |
|
438 * from a javadoc tag in tagsMap. |
|
439 */ |
|
440 private boolean displayServiceDirective(TypeElement typeElement, |
|
441 Map<TypeElement, Content> tagsMap) { |
|
442 return moduleMode == ModuleMode.ALL || tagsMap.containsKey(typeElement); |
424 } |
443 } |
425 |
444 |
426 /** |
445 /** |
427 * Add the summary header. |
446 * Add the summary header. |
428 * |
447 * |
766 |
785 |
767 /** |
786 /** |
768 * {@inheritDoc} |
787 * {@inheritDoc} |
769 */ |
788 */ |
770 public void addServicesSummary(Content summaryContentTree) { |
789 public void addServicesSummary(Content summaryContentTree) { |
771 if (display(uses) || display(provides)) { |
790 |
|
791 boolean haveUses = displayServices(uses, usesTrees); |
|
792 boolean haveProvides = displayServices(provides.keySet(), providesTrees); |
|
793 |
|
794 if (haveProvides || haveUses) { |
772 HtmlTree li = new HtmlTree(HtmlTag.LI); |
795 HtmlTree li = new HtmlTree(HtmlTag.LI); |
773 li.addStyle(HtmlStyle.blockList); |
796 li.addStyle(HtmlStyle.blockList); |
774 addSummaryHeader(HtmlConstants.START_OF_SERVICES_SUMMARY, SectionName.SERVICES, |
797 addSummaryHeader(HtmlConstants.START_OF_SERVICES_SUMMARY, SectionName.SERVICES, |
775 contents.navServices, li); |
798 contents.navServices, li); |
776 String text; |
799 String text; |
777 String tableSummary; |
800 String tableSummary; |
778 if (display(provides)) { |
801 if (haveProvides) { |
779 text = configuration.getText("doclet.Provides_Summary"); |
802 text = configuration.getText("doclet.Provides_Summary"); |
780 tableSummary = configuration.getText("doclet.Member_Table_Summary", |
803 tableSummary = configuration.getText("doclet.Member_Table_Summary", |
781 configuration.getText("doclet.Provides_Summary"), |
804 configuration.getText("doclet.Provides_Summary"), |
782 configuration.getText("doclet.types")); |
805 configuration.getText("doclet.types")); |
783 Content table = getTableHeader(text, tableSummary, HtmlStyle.providesSummary, providesTableHeader); |
806 Content table = getTableHeader(text, tableSummary, HtmlStyle.providesSummary, providesTableHeader); |
786 if (!tbody.isEmpty()) { |
809 if (!tbody.isEmpty()) { |
787 table.addContent(tbody); |
810 table.addContent(tbody); |
788 li.addContent(table); |
811 li.addContent(table); |
789 } |
812 } |
790 } |
813 } |
791 if (display(uses)) { |
814 if (haveUses){ |
792 text = configuration.getText("doclet.Uses_Summary"); |
815 text = configuration.getText("doclet.Uses_Summary"); |
793 tableSummary = configuration.getText("doclet.Member_Table_Summary", |
816 tableSummary = configuration.getText("doclet.Member_Table_Summary", |
794 configuration.getText("doclet.Uses_Summary"), |
817 configuration.getText("doclet.Uses_Summary"), |
795 configuration.getText("doclet.types")); |
818 configuration.getText("doclet.types")); |
796 Content table = getTableHeader(text, tableSummary, HtmlStyle.usesSummary, usesTableHeader); |
819 Content table = getTableHeader(text, tableSummary, HtmlStyle.usesSummary, usesTableHeader); |
816 Content typeLinkContent; |
839 Content typeLinkContent; |
817 Content thType; |
840 Content thType; |
818 HtmlTree tdSummary; |
841 HtmlTree tdSummary; |
819 Content description; |
842 Content description; |
820 for (TypeElement t : uses) { |
843 for (TypeElement t : uses) { |
821 // For each uses directive in the module declaration, if we are in the "api" mode and |
844 if (!displayServiceDirective(t, usesTrees)) { |
822 // if there are service types listed using @uses javadoc tag, check if the service type in |
|
823 // the uses directive is specified using the @uses tag. If not, we do not display the |
|
824 // service type in the "api" mode. |
|
825 if (moduleMode == ModuleMode.API && display(usesTrees) && !usesTrees.containsKey(t)) { |
|
826 continue; |
845 continue; |
827 } |
846 } |
828 typeLinkContent = getLink(new LinkInfoImpl(configuration, LinkInfoImpl.Kind.PACKAGE, t)); |
847 typeLinkContent = getLink(new LinkInfoImpl(configuration, LinkInfoImpl.Kind.PACKAGE, t)); |
829 thType = HtmlTree.TH_ROW_SCOPE(HtmlStyle.colFirst, typeLinkContent); |
848 thType = HtmlTree.TH_ROW_SCOPE(HtmlStyle.colFirst, typeLinkContent); |
830 tdSummary = new HtmlTree(HtmlTag.TD); |
849 tdSummary = new HtmlTree(HtmlTag.TD); |
831 tdSummary.addStyle(HtmlStyle.colLast); |
850 tdSummary.addStyle(HtmlStyle.colLast); |
832 if (display(usesTrees)) { |
851 if (display(usesTrees)) { |
833 description = usesTrees.get(t); |
852 description = usesTrees.get(t); |
834 if (description != null) { |
853 if (description != null) { |
835 tdSummary.addContent(description); |
854 tdSummary.addContent(description); |
836 } |
855 } |
837 } |
856 } |
838 addSummaryComment(t, tdSummary); |
857 addSummaryComment(t, tdSummary); |
839 HtmlTree tr = HtmlTree.TR(thType); |
858 HtmlTree tr = HtmlTree.TR(thType); |
840 tr.addContent(tdSummary); |
859 tr.addContent(tdSummary); |
841 tr.addStyle(altColor ? HtmlStyle.altColor : HtmlStyle.rowColor); |
860 tr.addStyle(altColor ? HtmlStyle.altColor : HtmlStyle.rowColor); |
842 tbody.addContent(tr); |
861 tbody.addContent(tr); |
843 altColor = !altColor; |
862 altColor = !altColor; |
844 } |
863 } |
845 } |
864 } |
846 |
865 |
847 /** |
866 /** |
849 * |
868 * |
850 * @param tbody the content tree to which the directive will be added |
869 * @param tbody the content tree to which the directive will be added |
851 */ |
870 */ |
852 public void addProvidesList(Content tbody) { |
871 public void addProvidesList(Content tbody) { |
853 boolean altColor = true; |
872 boolean altColor = true; |
854 TypeElement srv; |
|
855 SortedSet<TypeElement> implSet; |
873 SortedSet<TypeElement> implSet; |
856 Content description; |
874 Content description; |
857 for (Map.Entry<TypeElement, SortedSet<TypeElement>> entry : provides.entrySet()) { |
875 for (Map.Entry<TypeElement, SortedSet<TypeElement>> entry : provides.entrySet()) { |
858 srv = entry.getKey(); |
876 TypeElement srv = entry.getKey(); |
859 // For each provides directive in the module declaration, if we are in the "api" mode and |
877 if (!displayServiceDirective(srv, providesTrees)) { |
860 // if there are service types listed using @provides javadoc tag, check if the service type in |
|
861 // the provides directive is specified using the @provides tag. If not, we do not display the |
|
862 // service type in the "api" mode. |
|
863 if (moduleMode == ModuleMode.API && display(providesTrees) && !providesTrees.containsKey(srv)) { |
|
864 continue; |
878 continue; |
865 } |
879 } |
866 implSet = entry.getValue(); |
880 implSet = entry.getValue(); |
867 Content srvLinkContent = getLink(new LinkInfoImpl(configuration, LinkInfoImpl.Kind.PACKAGE, srv)); |
881 Content srvLinkContent = getLink(new LinkInfoImpl(configuration, LinkInfoImpl.Kind.PACKAGE, srv)); |
868 HtmlTree thType = HtmlTree.TH_ROW_SCOPE(HtmlStyle.colFirst, srvLinkContent); |
882 HtmlTree thType = HtmlTree.TH_ROW_SCOPE(HtmlStyle.colFirst, srvLinkContent); |
869 HtmlTree tdDesc = new HtmlTree(HtmlTag.TD); |
883 HtmlTree tdDesc = new HtmlTree(HtmlTag.TD); |
870 tdDesc.addStyle(HtmlStyle.colLast); |
884 tdDesc.addStyle(HtmlStyle.colLast); |