< prev index next >

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

Print this page




  36 import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder;
  37 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
  38 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
  39 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
  40 import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
  41 import jdk.javadoc.internal.doclets.toolkit.Content;
  42 import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException;
  43 import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
  44 import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
  45 
  46 /**
  47  * Generate the module index page "index.html".
  48  *
  49  *  <p><b>This is NOT part of any supported API.
  50  *  If you write code that depends on this, you do so at your own risk.
  51  *  This code and its internal interfaces are subject to change or
  52  *  deletion without notice.</b>
  53  *
  54  * @author Bhavesh Patel
  55  */
  56 public class ModuleIndexWriter extends AbstractOverviewIndexWriter {
  57 
  58     /**
  59      * Modules to be documented.
  60      */
  61     protected SortedSet<ModuleElement> modules;
  62 
  63     /**
  64      * Construct the ModuleIndexWriter.
  65      *
  66      * @param configuration the configuration object
  67      * @param filename the name of the generated file
  68      */
  69     public ModuleIndexWriter(HtmlConfiguration configuration, DocPath filename) {
  70         super(configuration, filename);
  71         modules = configuration.modules;
  72     }
  73 
  74     /**
  75      * Generate the module index page.
  76      *
  77      * @param configuration the current configuration of the doclet.
  78      * @throws DocFileIOException if there is a problem generating the module index page
  79      */
  80     public static void generate(HtmlConfiguration configuration) throws DocFileIOException {
  81         DocPath filename = DocPaths.INDEX;
  82         ModuleIndexWriter mdlgen = new ModuleIndexWriter(configuration, filename);
  83         mdlgen.buildOverviewIndexFile("doclet.Window_Overview_Summary", "module index");
  84     }
  85 
  86     /**
  87      * Adds the list of modules.
  88      *

  89      * @param main the documentation tree to which the modules list will be added
  90      */
  91     @Override
  92     protected void addIndex(Content main) {




















  93         Map<String, SortedSet<ModuleElement>> groupModuleMap
  94                 = configuration.group.groupModules(modules);
  95 
  96         if (!groupModuleMap.keySet().isEmpty()) {
  97             TableHeader tableHeader = new TableHeader(contents.moduleLabel, contents.descriptionLabel);


  98             Table table =  new Table(HtmlStyle.overviewSummary)
  99                     .setHeader(tableHeader)
 100                     .setColumnStyles(HtmlStyle.colFirst, HtmlStyle.colLast)
 101                     .setDefaultTab(resources.getText("doclet.All_Modules"))
 102                     .setTabScript(i -> "show(" + i + ");")
 103                     .setTabId(i -> (i == 0) ? "t0" : ("t" + (1 << (i - 1))));
 104 
 105             // add the tabs in command-line order
 106             for (String groupName : configuration.group.getGroupList()) {
 107                 Set<ModuleElement> groupModules = groupModuleMap.get(groupName);
 108                 if (groupModules != null) {
 109                     table.addTab(groupName, groupModules::contains);
 110                 }
 111             }
 112 
 113             for (ModuleElement mdle : modules) {
 114                 if (!mdle.isUnnamed()) {
 115                     if (!(configuration.nodeprecated && utils.isDeprecated(mdle))) {
 116                         Content moduleLinkContent = getModuleLink(mdle, new StringContent(mdle.getQualifiedName().toString()));
 117                         Content summaryContent = new ContentBuilder();
 118                         addSummaryComment(mdle, summaryContent);
 119                         table.addRow(mdle, moduleLinkContent, summaryContent);
 120                     }
 121                 }
 122             }
 123 
 124             Content div = HtmlTree.DIV(HtmlStyle.contentContainer, table.toContent());
 125             main.add(div);
 126 
 127             if (table.needsScript()) {
 128                 mainBodyScript.append(table.getScript());
 129             }
 130         }































































 131     }
 132 }


  36 import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder;
  37 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
  38 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
  39 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
  40 import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
  41 import jdk.javadoc.internal.doclets.toolkit.Content;
  42 import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException;
  43 import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
  44 import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
  45 
  46 /**
  47  * Generate the module index page "index.html".
  48  *
  49  *  <p><b>This is NOT part of any supported API.
  50  *  If you write code that depends on this, you do so at your own risk.
  51  *  This code and its internal interfaces are subject to change or
  52  *  deletion without notice.</b>
  53  *
  54  * @author Bhavesh Patel
  55  */
  56 public class ModuleIndexWriter extends AbstractModuleIndexWriter {





  57 
  58     /**
  59      * Construct the ModuleIndexWriter.

  60      * @param configuration the configuration object
  61      * @param filename the name of the generated file
  62      */
  63     public ModuleIndexWriter(HtmlConfiguration configuration, DocPath filename) {
  64         super(configuration, filename);

  65     }
  66 
  67     /**
  68      * Generate the module index page.
  69      *
  70      * @param configuration the current configuration of the doclet.
  71      * @throws DocFileIOException if there is a problem generating the module index page
  72      */
  73     public static void generate(HtmlConfiguration configuration) throws DocFileIOException {
  74         DocPath filename = DocPaths.INDEX;
  75         ModuleIndexWriter mdlgen = new ModuleIndexWriter(configuration, filename);
  76         mdlgen.buildModuleIndexFile("doclet.Window_Overview_Summary", "module index");
  77     }
  78 
  79     /**
  80      * Add the module index.
  81      *
  82      * @param header the documentation tree to which the navigational links will be added
  83      * @param main the documentation tree to which the modules list will be added
  84      */
  85     @Override
  86     protected void addIndex(Content header, Content main) {
  87         addIndexContents(header, main);
  88     }
  89 
  90     /**
  91      * Adds module index contents.
  92      *
  93      * @param header the document tree to which the navigational links will be added
  94      * @param main the document tree to which the modules list will be added
  95      */
  96     protected void addIndexContents(Content header, Content main) {
  97         addModulesList(main);
  98     }
  99 
 100     /**
 101      * Add the list of modules.
 102      *
 103      * @param main the content tree to which the module list will be added
 104      */
 105     @Override
 106     protected void addModulesList(Content main) {
 107         Map<String, SortedSet<ModuleElement>> groupModuleMap
 108                 = configuration.group.groupModules(configuration.modules);
 109 
 110         if (!groupModuleMap.keySet().isEmpty()) {
 111             String tableSummary = resources.getText("doclet.Member_Table_Summary",
 112                     resources.getText("doclet.Module_Summary"), resources.getText("doclet.modules"));
 113             TableHeader header = new TableHeader(contents.moduleLabel, contents.descriptionLabel);
 114             Table table =  new Table(HtmlStyle.overviewSummary)
 115                     .setHeader(header)
 116                     .setColumnStyles(HtmlStyle.colFirst, HtmlStyle.colLast)
 117                     .setDefaultTab(resources.getText("doclet.All_Modules"))
 118                     .setTabScript(i -> "show(" + i + ");")
 119                     .setTabId(i -> (i == 0) ? "t0" : ("t" + (1 << (i - 1))));
 120 
 121             // add the tabs in command-line order
 122             for (String groupName : configuration.group.getGroupList()) {
 123                 Set<ModuleElement> groupModules = groupModuleMap.get(groupName);
 124                 if (groupModules != null) {
 125                     table.addTab(groupName, groupModules::contains);
 126                 }
 127             }
 128 
 129             for (ModuleElement mdle : configuration.modules) {
 130                 if (!mdle.isUnnamed()) {
 131                     if (!(configuration.nodeprecated && utils.isDeprecated(mdle))) {
 132                         Content moduleLinkContent = getModuleLink(mdle, new StringContent(mdle.getQualifiedName().toString()));
 133                         Content summaryContent = new ContentBuilder();
 134                         addSummaryComment(mdle, summaryContent);
 135                         table.addRow(mdle, moduleLinkContent, summaryContent);
 136                     }
 137                 }
 138             }
 139 
 140             Content div = HtmlTree.DIV(HtmlStyle.contentContainer, table.toContent());
 141             main.add(div);
 142 
 143             if (table.needsScript()) {
 144                 mainBodyScript.append(table.getScript());
 145             }
 146         }
 147     }
 148 
 149     /**
 150      * Adds the overview summary comment for this documentation. Add one line
 151      * summary at the top of the page and generate a link to the description,
 152      * which is added at the end of this page.
 153      *
 154      * @param main the documentation tree to which the overview header will be added
 155      */
 156     @Override
 157     protected void addOverviewHeader(Content main) {
 158         addConfigurationTitle(main);
 159         if (!utils.getFullBody(configuration.overviewElement).isEmpty()) {
 160             HtmlTree div = new HtmlTree(HtmlTag.DIV);
 161             div.setStyle(HtmlStyle.contentContainer);
 162             addOverviewComment(div);
 163             main.add(div);
 164         }
 165     }
 166 
 167     /**
 168      * Adds the overview comment as provided in the file specified by the
 169      * "-overview" option on the command line.
 170      *
 171      * @param htmltree the documentation tree to which the overview comment will
 172      *                 be added
 173      */
 174     protected void addOverviewComment(Content htmltree) {
 175         if (!utils.getFullBody(configuration.overviewElement).isEmpty()) {
 176             addInlineComment(configuration.overviewElement, htmltree);
 177         }
 178     }
 179 
 180     /**
 181      * Adds the top text (from the -top option), the upper
 182      * navigation bar, and then the title (from the"-title"
 183      * option), at the top of page.
 184      *
 185      * @param header the documentation tree to which the navigation bar header will be added
 186      */
 187     @Override
 188     protected void addNavigationBarHeader(Content header) {
 189         addTop(header);
 190         navBar.setUserHeader(getUserHeaderFooter(true));
 191         header.add(navBar.getContent(true));
 192     }
 193 
 194     /**
 195      * Adds the lower navigation bar and the bottom text
 196      * (from the -bottom option) at the bottom of page.
 197      *
 198      * @param footer the documentation tree to which the navigation bar footer will be added
 199      */
 200     @Override
 201     protected void addNavigationBarFooter(Content footer) {
 202         navBar.setUserFooter(getUserHeaderFooter(false));
 203         footer.add(navBar.getContent(false));
 204         addBottom(footer);
 205     }
 206 
 207     @Override
 208     protected void addModulePackagesList(Map<ModuleElement, Set<PackageElement>> modules, String text,
 209             String tableSummary, Content main, ModuleElement mdle) {
 210     }
 211 }
< prev index next >