33
33
import javax .lang .model .element .ModuleElement ;
34
34
import javax .lang .model .element .PackageElement ;
35
35
36
+ import jdk .javadoc .internal .doclets .formats .html .markup .ContentBuilder ;
36
37
import jdk .javadoc .internal .doclets .formats .html .markup .HtmlConstants ;
37
38
import jdk .javadoc .internal .doclets .formats .html .markup .HtmlStyle ;
38
39
import jdk .javadoc .internal .doclets .formats .html .markup .HtmlTag ;
@@ -81,42 +82,42 @@ public AbstractModuleIndexWriter(HtmlConfiguration configuration,
81
82
/**
82
83
* Adds the navigation bar header to the documentation tree.
83
84
*
84
- * @param body the document tree to which the navigation bar header will be added
85
+ * @param header the document tree to which the navigation bar header will be added
85
86
*/
86
- protected abstract void addNavigationBarHeader (Content body );
87
+ protected abstract void addNavigationBarHeader (Content header );
87
88
88
89
/**
89
90
* Adds the navigation bar footer to the documentation tree.
90
91
*
91
- * @param body the document tree to which the navigation bar footer will be added
92
+ * @param footer the document tree to which the navigation bar footer will be added
92
93
*/
93
- protected abstract void addNavigationBarFooter (Content body );
94
+ protected abstract void addNavigationBarFooter (Content footer );
94
95
95
96
/**
96
97
* Adds the overview header to the documentation tree.
97
98
*
98
- * @param body the document tree to which the overview header will be added
99
+ * @param main the document tree to which the overview header will be added
99
100
*/
100
- protected abstract void addOverviewHeader (Content body );
101
+ protected abstract void addOverviewHeader (Content main );
101
102
102
103
/**
103
104
* Adds the modules list to the documentation tree.
104
105
*
105
- * @param body the document tree to which the modules list will be added
106
+ * @param main the document tree to which the modules list will be added
106
107
*/
107
- protected abstract void addModulesList (Content body );
108
+ protected abstract void addModulesList (Content main );
108
109
109
110
/**
110
111
* Adds the module packages list to the documentation tree.
111
112
*
112
113
* @param modules the set of modules
113
114
* @param text caption for the table
114
115
* @param tableSummary summary for the table
115
- * @param body the document tree to which the modules list will be added
116
+ * @param main the document tree to which the modules list will be added
116
117
* @param mdle the module being documented
117
118
*/
118
119
protected abstract void addModulePackagesList (Map <ModuleElement , Set <PackageElement >> modules , String text ,
119
- String tableSummary , Content body , ModuleElement mdle );
120
+ String tableSummary , Content main , ModuleElement mdle );
120
121
121
122
/**
122
123
* Generate and prints the contents in the module index file. Call appropriate
@@ -130,11 +131,17 @@ protected abstract void addModulePackagesList(Map<ModuleElement, Set<PackageElem
130
131
protected void buildModuleIndexFile (String title , boolean includeScript ) throws DocFileIOException {
131
132
String windowOverview = configuration .getText (title );
132
133
Content body = getBody (includeScript , getWindowTitle (windowOverview ));
133
- addNavigationBarHeader (body );
134
- addOverviewHeader (body );
135
- addIndex (body );
136
- addOverview (body );
137
- addNavigationBarFooter (body );
134
+ Content header = createTagIfAllowed (HtmlTag .HEADER , HtmlTree ::HEADER , ContentBuilder ::new );
135
+ addNavigationBarHeader (header );
136
+ Content main = createTagIfAllowed (HtmlTag .MAIN , HtmlTree ::MAIN , ContentBuilder ::new );
137
+ addOverviewHeader (main );
138
+ addIndex (header , main );
139
+ addOverview (main );
140
+ Content footer = createTagIfAllowed (HtmlTag .FOOTER , HtmlTree ::FOOTER , ContentBuilder ::new );
141
+ addNavigationBarFooter (footer );
142
+ body .addContent (header );
143
+ body .addContent (main );
144
+ body .addContent (footer );
138
145
printHtmlDocument (configuration .metakeywords .getOverviewMetaKeywords (title ,
139
146
configuration .doctitle ), includeScript , body );
140
147
}
@@ -153,45 +160,53 @@ protected void buildModulePackagesIndexFile(String title,
153
160
boolean includeScript , ModuleElement mdle ) throws DocFileIOException {
154
161
String windowOverview = configuration .getText (title );
155
162
Content body = getBody (includeScript , getWindowTitle (windowOverview ));
156
- addNavigationBarHeader (body );
157
- addOverviewHeader (body );
158
- addModulePackagesIndex (body , mdle );
159
- addOverview (body );
160
- addNavigationBarFooter (body );
163
+ Content header = createTagIfAllowed (HtmlTag .HEADER , HtmlTree ::HEADER , ContentBuilder ::new );
164
+ addNavigationBarHeader (header );
165
+ Content main = createTagIfAllowed (HtmlTag .MAIN , HtmlTree ::MAIN , ContentBuilder ::new );
166
+ addOverviewHeader (main );
167
+ addModulePackagesIndex (header , main , mdle );
168
+ addOverview (main );
169
+ Content footer = createTagIfAllowed (HtmlTag .FOOTER , HtmlTree ::FOOTER , ContentBuilder ::new );
170
+ addNavigationBarFooter (footer );
171
+ body .addContent (header );
172
+ body .addContent (main );
173
+ body .addContent (footer );
161
174
printHtmlDocument (configuration .metakeywords .getOverviewMetaKeywords (title ,
162
175
configuration .doctitle ), includeScript , body );
163
176
}
164
177
165
178
/**
166
179
* Default to no overview, override to add overview.
167
180
*
168
- * @param body the document tree to which the overview will be added
181
+ * @param main the document tree to which the overview will be added
169
182
*/
170
- protected void addOverview (Content body ) { }
183
+ protected void addOverview (Content main ) { }
171
184
172
185
/**
173
186
* Adds the frame or non-frame module index to the documentation tree.
174
187
*
175
- * @param body the document tree to which the index will be added
188
+ * @param header the document tree to which the navigational links will be added
189
+ * @param main the document tree to which the modules list will be added
176
190
*/
177
- protected void addIndex (Content body ) {
191
+ protected void addIndex (Content header , Content main ) {
178
192
addIndexContents (configuration .modules , "doclet.Module_Summary" ,
179
193
configuration .getText ("doclet.Member_Table_Summary" ,
180
194
configuration .getText ("doclet.Module_Summary" ),
181
- configuration .getText ("doclet.modules" )), body );
195
+ configuration .getText ("doclet.modules" )), header , main );
182
196
}
183
197
184
198
/**
185
199
* Adds the frame or non-frame module packages index to the documentation tree.
186
200
*
187
- * @param body the document tree to which the index will be added
201
+ * @param header the document tree to which the navigational links will be added
202
+ * @param main the document tree to which the module packages list will be added
188
203
* @param mdle the module being documented
189
204
*/
190
- protected void addModulePackagesIndex (Content body , ModuleElement mdle ) {
205
+ protected void addModulePackagesIndex (Content header , Content main , ModuleElement mdle ) {
191
206
addModulePackagesIndexContents ("doclet.Module_Summary" ,
192
207
configuration .getText ("doclet.Member_Table_Summary" ,
193
208
configuration .getText ("doclet.Module_Summary" ),
194
- configuration .getText ("doclet.modules" )), body , mdle );
209
+ configuration .getText ("doclet.modules" )), header , main , mdle );
195
210
}
196
211
197
212
/**
@@ -201,20 +216,19 @@ protected void addModulePackagesIndex(Content body, ModuleElement mdle) {
201
216
* @param modules the modules to be documented
202
217
* @param text string which will be used as the heading
203
218
* @param tableSummary summary for the table
204
- * @param body the document tree to which the index contents will be added
219
+ * @param header the document tree to which the navgational links will be added
220
+ * @param main the document tree to which the modules list will be added
205
221
*/
206
222
protected void addIndexContents (Collection <ModuleElement > modules , String text ,
207
- String tableSummary , Content body ) {
208
- HtmlTree htmlTree = (configuration .allowTag (HtmlTag .NAV ))
209
- ? HtmlTree .NAV ()
210
- : new HtmlTree (HtmlTag .DIV );
223
+ String tableSummary , Content header , Content main ) {
224
+ HtmlTree htmlTree = (HtmlTree )createTagIfAllowed (HtmlTag .NAV , HtmlTree ::NAV , () -> new HtmlTree (HtmlTag .DIV ));
211
225
htmlTree .setStyle (HtmlStyle .indexNav );
212
226
HtmlTree ul = new HtmlTree (HtmlTag .UL );
213
227
addAllClassesLink (ul );
214
228
addAllPackagesLink (ul );
215
229
htmlTree .addContent (ul );
216
- body .addContent (htmlTree );
217
- addModulesList (body );
230
+ header .addContent (htmlTree );
231
+ addModulesList (main );
218
232
}
219
233
220
234
/**
@@ -223,22 +237,21 @@ protected void addIndexContents(Collection<ModuleElement> modules, String text,
223
237
*
224
238
* @param text string which will be used as the heading
225
239
* @param tableSummary summary for the table
226
- * @param body the document tree to which the index contents will be added
240
+ * @param header the document tree to which the navigational links will be added
241
+ * @param main the document tree to which the module packages list will be added
227
242
* @param mdle the module being documented
228
243
*/
229
244
protected void addModulePackagesIndexContents (String text ,
230
- String tableSummary , Content body , ModuleElement mdle ) {
231
- HtmlTree htmlTree = (configuration .allowTag (HtmlTag .NAV ))
232
- ? HtmlTree .NAV ()
233
- : new HtmlTree (HtmlTag .DIV );
245
+ String tableSummary , Content header , Content main , ModuleElement mdle ) {
246
+ HtmlTree htmlTree = (HtmlTree )createTagIfAllowed (HtmlTag .NAV , HtmlTree ::NAV , () -> new HtmlTree (HtmlTag .DIV ));
234
247
htmlTree .setStyle (HtmlStyle .indexNav );
235
248
HtmlTree ul = new HtmlTree (HtmlTag .UL );
236
249
addAllClassesLink (ul );
237
250
addAllPackagesLink (ul );
238
251
addAllModulesLink (ul );
239
252
htmlTree .addContent (ul );
240
- body .addContent (htmlTree );
241
- addModulePackagesList (modules , text , tableSummary , body , mdle );
253
+ header .addContent (htmlTree );
254
+ addModulePackagesList (modules , text , tableSummary , main , mdle );
242
255
}
243
256
244
257
/**
0 commit comments