1 # Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
  2 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  3 #
  4 # This code is free software; you can redistribute it and/or modify it
  5 # under the terms of the GNU General Public License version 2 only, as
  6 # published by the Free Software Foundation.  Oracle designates this
  7 # particular file as subject to the "Classpath" exception as provided
  8 # by Oracle in the LICENSE file that accompanied this code.
  9 #
 10 # This code is distributed in the hope that it will be useful, but WITHOUT
 11 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 12 # FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 13 # version 2 for more details (a copy is included in the LICENSE file that
 14 # accompanied this code).
 15 #
 16 # You should have received a copy of the GNU General Public License version
 17 # 2 along with this work; if not, write to the Free Software Foundation,
 18 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 19 #
 20 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 21 # or visit www.oracle.com if you need additional information or have any
 22 # questions.
 23 #
 24 
 25 default: all
 26 
 27 include $(SPEC)
 28 include MakeBase.gmk
 29 include Execute.gmk
 30 include Modules.gmk
 31 include ModuleTools.gmk
 32 include ProcessMarkdown.gmk
 33 include ToolsJdk.gmk
 34 include ZipArchive.gmk
 35 include TextFileProcessing.gmk
 36 
 37 # This is needed to properly setup DOCS_MODULES.
 38 $(eval $(call ReadImportMetaData))
 39 
 40 ################################################################################
 41 # Hook to include the corresponding custom file, if present.
 42 $(eval $(call IncludeCustomExtension, Docs.gmk))
 43 
 44 ################################################################################
 45 # This file generates all documentation for OpenJDK.
 46 #
 47 # We will generate API documentation for two different selections of the source
 48 # code: "Java SE", which contains just the modules covered by the top-level
 49 # module java.se and "JDK", which covers all of Java SE and also all
 50 # other available modules that should be documented, including imported modules,
 51 # if any.
 52 #
 53 # We will also generate separate, free-standing specifications from either
 54 # markdown or existing html files.
 55 #
 56 
 57 ################################################################################
 58 # Javadoc settings
 59 
 60 # Include configuration for URLs in generated javadoc
 61 include $(TOPDIR)/make/conf/javadoc.conf
 62 
 63 MODULES_SOURCE_PATH := $(call PathList, $(call GetModuleSrcPath) )
 64 
 65 
 66 # In order to get a specific ordering it's necessary to specify the total
 67 # ordering of tags as the tags are otherwise ordered in order of definition.
 68 JAVADOC_TAGS := \
 69     -tag beaninfo:X \
 70     -tag revised:X \
 71     -tag since.unbundled:X \
 72     -tag Note:X \
 73     -tag ToDo:X \
 74     -tag 'apiNote:a:API Note:' \
 75     -tag 'implSpec:a:Implementation Requirements:' \
 76     -tag 'implNote:a:Implementation Note:' \
 77     -tag param \
 78     -tag return \
 79     -tag throws \
 80     -taglet build.tools.taglet.JSpec\$$JLS \
 81     -taglet build.tools.taglet.JSpec\$$JVMS \
 82     -taglet build.tools.taglet.ModuleGraph \
 83     -taglet build.tools.taglet.SealedGraph \
 84     -taglet build.tools.taglet.ToolGuide \
 85     -tag since \
 86     -tag serialData \
 87     -tag factory \
 88     -tag spec \
 89     -tag see \
 90     -taglet build.tools.taglet.ExtLink \
 91     -taglet build.tools.taglet.Incubating \
 92     -tagletpath $(BUILDTOOLS_OUTPUTDIR)/jdk_tools_classes \
 93     $(CUSTOM_JAVADOC_TAGS) \
 94     #
 95 
 96 # The reference tags must stay stable to allow for comparisons across the
 97 # development cycle. If JAVADOC_TAGS needs to change, make sure that
 98 # REFERENCE_TAGS remains unchanged, by copying and hardcoding, if necessary.
 99 REFERENCE_TAGS := $(JAVADOC_TAGS)
100 
101 # Which doclint checks to ignore
102 JAVADOC_DISABLED_DOCLINT_WARNINGS := missing
103 JAVADOC_DISABLED_DOCLINT_PACKAGES := org.w3c.* javax.smartcardio
104 
105 # Allow overriding on the command line
106 # (intentionally sharing name with the javac option)
107 JAVA_WARNINGS_ARE_ERRORS ?= -Werror
108 
109 # The initial set of options for javadoc
110 JAVADOC_OPTIONS := -XDignore.symbol.file=true -use -keywords -notimestamp \
111     -encoding ISO-8859-1 -docencoding UTF-8 -breakiterator \
112     -splitIndex --system none -javafx --expand-requires transitive \
113     -XDenableValueTypes \
114     --enable-preview -source $(JDK_SOURCE_TARGET_VERSION) \
115     --override-methods=summary \
116     --no-external-specs-page
117 
118 # The reference options must stay stable to allow for comparisons across the
119 # development cycle.
120 REFERENCE_OPTIONS := -XDignore.symbol.file=true -use -keywords -notimestamp \
121     -encoding ISO-8859-1 -breakiterator -splitIndex --system none \
122     -html5 -javafx --expand-requires transitive \
123     --no-external-specs-page
124 
125 # Should we add DRAFT stamps to the generated javadoc?
126 ifeq ($(VERSION_IS_GA), true)
127   IS_DRAFT := false
128 else
129   IS_DRAFT := true
130 endif
131 
132 ################################################################################
133 # General text snippets
134 
135 FULL_COMPANY_NAME := Oracle and/or its affiliates
136 COMPANY_ADDRESS := 500 Oracle Parkway, Redwood Shores, CA 94065 USA
137 
138 JAVA_PLATFORM := Java Platform
139 
140 ifeq ($(IS_DRAFT), true)
141   DRAFT_MARKER_STR := <br><strong>DRAFT $(VERSION_STRING)</strong>
142   ifeq ($(VERSION_BUILD), )
143     DRAFT_MARKER_TITLE := $(SPACE)[ad-hoc build]
144   else
145     DRAFT_MARKER_TITLE := $(SPACE)[build $(VERSION_BUILD)]
146   endif
147   DRAFT_TEXT := This specification is not final and is subject to change. \
148       Use is subject to <a href="$(LICENSE_URL)">license terms</a>.
149 
150   # Workaround stylesheet bug
151   HEADER_STYLE := style="margin-top: 9px;"
152 else
153   HEADER_STYLE := style="margin-top: 14px;"
154 endif
155 
156 # $1 - Relative prefix to COPYRIGHT_URL
157 COPYRIGHT_BOTTOM = \
158     <a href="$(strip $1)$(COPYRIGHT_URL)">Copyright</a> \
159     &copy; 1993, $(COPYRIGHT_YEAR), $(FULL_COMPANY_NAME), \
160     $(COMPANY_ADDRESS).<br>All rights reserved. \
161     Use is subject to <a href="$(LICENSE_URL)">license terms</a> and the \
162     <a href="$(REDISTRIBUTION_URL)">documentation redistribution policy</a>. \
163     $(DRAFT_MARKER_STR) <!-- Version $(VERSION_STRING) -->
164 
165 # $1 - Optional "Other Versions" link
166 JAVADOC_BOTTOM = \
167     <a href="$(BUG_SUBMIT_URL)">Report a bug or suggest an enhancement</a><br> \
168     For further API reference and developer documentation see the \
169     <a href="$(JAVADOC_BASE_URL)" target="_blank">Java SE \
170     Documentation</a>, which contains more detailed, \
171     developer-targeted descriptions with conceptual overviews, definitions \
172     of terms, workarounds, and working code examples. $1<br> \
173     Java is a trademark or registered trademark of $(FULL_COMPANY_NAME) in \
174     the US and other countries.<br> \
175     $(call COPYRIGHT_BOTTOM, {@docroot}/../)
176 
177 JAVADOC_TOP := \
178     <div style="padding: 6px; text-align: center; font-size: 80%; \
179     font-family: DejaVu Sans, Arial, Helvetica, sans-serif; \
180     font-weight: normal;">$(DRAFT_TEXT)</div>
181 
182 ################################################################################
183 # JDK javadoc titles/text snippets
184 
185 JDK_SHORT_NAME := Java SE $(VERSION_SPECIFICATION) &amp; JDK $(VERSION_SPECIFICATION)
186 JDK_LONG_NAME := Java<sup>&reg;</sup> Platform, Standard Edition \
187     &amp;&nbsp;Java&nbsp;Development&nbsp;Kit
188 
189 ################################################################################
190 # Java SE javadoc titles/text snippets
191 
192 JAVASE_SHORT_NAME := Java SE $(VERSION_SPECIFICATION)
193 JAVASE_LONG_NAME := Java<sup>&reg;</sup> Platform, Standard Edition
194 
195 ################################################################################
196 # Functions
197 
198 # Helper function for creating a svg file from a dot file generated by the
199 # GenGraphs tool for a module.
200 # param 1: SetupJavadocGeneration namespace ($1)
201 # param 2: module name
202 #
203 define setup_module_graph_dot_to_svg
204   $1_$2_DOT_SRC :=  $$($1_MODULE_GRAPHS_DIR)/$2.dot
205   $1_$2_SVG_TARGET := $$($1_TARGET_DIR)/$2/module-graph.svg
206 
207     # For each module needing a graph, create a svg file from the dot file
208     # generated by the GenGraphs tool and store it in the target dir.
209     $$(eval $$(call SetupExecute, module_graphs_svg_$1_$2, \
210         INFO := Running dot for module graphs for $2, \
211         DEPS := $$(module_graphs_dot_$1_TARGET), \
212         OUTPUT_FILE := $$($1_$2_SVG_TARGET), \
213         SUPPORT_DIR := $$($1_MODULE_GRAPHS_DIR), \
214         COMMAND := $$(DOT) -Tsvg -o $$($1_$2_SVG_TARGET) $$($1_$2_DOT_SRC), \
215     ))
216 
217   $1_GRAPHS_TARGETS += $$($1_$2_SVG_TARGET)
218 endef
219 
220 # Helper function for creating a svg file for a class for which the SealedGraph
221 # taglet has generated a dot file. The dot file has a special name which
222 # encodes the module and class the graph belongs to.
223 #
224 # param 1: SetupJavadocGeneration namespace ($1)
225 # param 2: dot file name
226 #
227 define setup_sealed_graph_dot_to_svg
228   $1_$2_DOT_SRC :=  $$($1_SEALED_GRAPHS_DIR)/$2.dot
229   $1_$2_TARGET_CLASS := $$(word 2, $$(subst _, , $2))
230   $1_$2_SLASHED_NAME := $$(subst .,/, $$($1_$2_TARGET_CLASS))
231   $1_$2_TARGET_MODULE := $$(word 1, $$(subst _, , $2))
232   $1_$2_TARGET_PATH := $$($1_TARGET_DIR)/$$($1_$2_TARGET_MODULE)/$$(dir $$($1_$2_SLASHED_NAME))
233   $1_$2_TARGET_NAME := $$(notdir $$($1_$2_SLASHED_NAME))
234   $1_$2_SVG_TARGET := $$($1_$2_TARGET_PATH)/$$($1_$2_TARGET_NAME)-sealed-graph.svg
235   $$(call MakeDir, $$($1_$2_TARGET_PATH))
236 
237     # For each class needing a graph, create a svg file from the dot file
238     # generated by the SealedGraph taglet and store it in the target dir.
239     $$(eval $$(call SetupExecute, sealed_graphs_svg_$1_$2, \
240         INFO := Running dot for sealed graphs for $$($1_$2_TARGET_MODULE)/$$($1_$2_TARGET_CLASS), \
241         DEPS := $$($1_$2_DOT_SRC), \
242         OUTPUT_FILE := $$($1_$2_SVG_TARGET), \
243         SUPPORT_DIR := $$($1_SEALED_GRAPHS_DIR), \
244         COMMAND := $$(DOT) -Tsvg -o $$($1_$2_SVG_TARGET) $$($1_$2_DOT_SRC), \
245     ))
246 
247   $1_GRAPHS_TARGETS += $$($1_$2_SVG_TARGET)
248 endef
249 
250 # Helper function to create the overview.html file to use with the -overview
251 # javadoc option.
252 # Returns the filename as $1_OVERVIEW.
253 #
254 # param 1: SetupJavadocGeneration namespace ($1)
255 define create_overview_file
256   $1_OVERVIEW_TEXT := \
257       <!DOCTYPE html> \
258       <html><head></head><body> \
259       #
260   ifneq ($$($1_GROUPS),)
261     $1_OVERVIEW_TEXT += \
262       <p>This document is divided into \
263       $$(subst 2,two,$$(subst 3,three,$$(words $$($1_GROUPS)))) sections:</p> \
264       <blockquote><dl> \
265       #
266     $1_OVERVIEW_TEXT += $$(foreach g, $$($1_GROUPS), \
267         <dt style="margin-top: 8px;">$$($$g_GROUP_NAME)</dt> \
268         <dd style="margin-top: 8px;">$$($$g_GROUP_DESCRIPTION)</dd> \
269     )
270     $1_OVERVIEW_TEXT += \
271         </dl></blockquote> \
272         #
273   endif
274   $1_OVERVIEW_TEXT += \
275       </body></html> \
276       #
277 
278   $1_OVERVIEW := $$(SUPPORT_OUTPUTDIR)/docs/$1-overview.html
279 
280   $1_OVERVIEW_VARDEPS_FILE := $$(call DependOnVariable, $1_OVERVIEW_TEXT, \
281       $$($1_OVERVIEW).vardeps)
282 
283   $$($1_OVERVIEW): $$($1_OVERVIEW_VARDEPS_FILE)
284 	$$(call LogInfo, Creating overview.html for $1)
285 	$$(call MakeDir, $$(@D))
286 	$$(PRINTF) > $$@ '$$($1_OVERVIEW_TEXT)'
287 endef
288 
289 ################################################################################
290 # Setup make rules to create an API documentation collection, using javadoc and
291 # other tools if needed.
292 #
293 # Parameter 1 is the name of the rule. This name is used as variable prefix.
294 # Targets generated are returned as $1_JAVADOC_TARGETS and
295 # $1_GRAPHS_TARGETS. Note that the index.html file will work as a "touch
296 # file" for all the magnitude of files that are generated by javadoc.
297 #
298 # Remaining parameters are named arguments. These include:
299 #   MODULES - Modules to generate javadoc for
300 #   GROUPS - Name of the groups to divide the modules into, if any
301 #   SHORT_NAME - The short name of this documentation collection
302 #   LONG_NAME - The long name of this documentation collection
303 #   TARGET_DIR - Where to store the output
304 #   OTHER_VERSIONS - URL for other page listing versions
305 #
306 SetupApiDocsGeneration = $(NamedParamsMacroTemplate)
307 define SetupApiDocsGenerationBody
308 
309   # Figure out all modules, both specified and transitive indirect exports, that
310   # will be processed by javadoc.
311   $1_INDIRECT_EXPORTS := $$(call FindTransitiveIndirectDepsForModules, $$($1_MODULES))
312   $1_ALL_MODULES := $$(sort $$($1_MODULES) $$($1_INDIRECT_EXPORTS))
313 
314   $1_JAVA_ARGS := -Dextlink.spec.version=$$(VERSION_SPECIFICATION) \
315 	-Djspec.version=$$(VERSION_SPECIFICATION)
316 
317   ifeq ($$(ENABLE_FULL_DOCS), true)
318     $1_SEALED_GRAPHS_DIR := $$(SUPPORT_OUTPUTDIR)/docs/$1-sealed-graphs
319 
320     # Tell the ModuleGraph and SealedGraph taglets to generate html links to
321     # soon-to-be-created svg files with module/sealed graphs.
322     $1_JAVA_ARGS += -DenableModuleGraph=true -DsealedDotOutputDir=$$($1_SEALED_GRAPHS_DIR)
323     $$(call MakeDir, $$($1_SEALED_GRAPHS_DIR))
324   endif
325 
326   # Start with basic options and tags
327   ifeq ($$($1_OPTIONS), )
328     $1_OPTIONS := $$(JAVADOC_OPTIONS)
329   endif
330   ifeq ($$($1_TAGS), )
331     $1_TAGS := $$(JAVADOC_TAGS)
332   endif
333   $1_OPTIONS += $$($1_TAGS)
334 
335   $1_OPTIONS += --module-source-path $$(MODULES_SOURCE_PATH)
336   $1_OPTIONS += --module $$(call CommaList, $$($1_MODULES))
337 
338   # Create a string like "-Xdoclint:all,-syntax,-html,..."
339   $1_OPTIONS += -Xdoclint:all,$$(call CommaList, $$(addprefix -, \
340       $$(JAVADOC_DISABLED_DOCLINT_WARNINGS)))
341   # Ignore the doclint warnings in certain packages
342   $1_OPTIONS += -Xdoclint/package:$$(call CommaList, $$(addprefix -, \
343       $$(JAVADOC_DISABLED_DOCLINT_PACKAGES)))
344   $1_OPTIONS += $$(JAVA_WARNINGS_ARE_ERRORS)
345 
346   $1_DOC_TITLE := $$($1_LONG_NAME)<br>Version $$(VERSION_SPECIFICATION) API \
347       Specification
348   $1_WINDOW_TITLE := $$(subst &amp;,&,$$($1_SHORT_NAME))$$(DRAFT_MARKER_TITLE)
349   $1_HEADER_TITLE := <div $$(HEADER_STYLE)><strong>$$($1_SHORT_NAME)</strong> \
350       $$(DRAFT_MARKER_STR)</div>
351   ifneq ($$($1_OTHER_VERSIONS), )
352       $1_JAVADOC_BOTTOM := $$(call JAVADOC_BOTTOM, <a href="$$($1_OTHER_VERSIONS)">Other versions.</a>)
353   else
354       $1_JAVADOC_BOTTOM := $$(call JAVADOC_BOTTOM, )
355   endif
356 
357   $1_OPTIONS += -doctitle '$$($1_DOC_TITLE)'
358   $1_OPTIONS += -windowtitle '$$($1_WINDOW_TITLE)'
359   $1_OPTIONS += -header '$$($1_HEADER_TITLE)'
360   $1_OPTIONS += -bottom '$$($1_JAVADOC_BOTTOM)'
361   ifeq ($$(IS_DRAFT), true)
362     $1_OPTIONS += -top '$$(JAVADOC_TOP)'
363   endif
364 
365   # Do not store debug level options in VARDEPS.
366   ifneq ($$(LOG_LEVEL), trace)
367     $1_LOG_OPTION += -quiet
368   else
369     $1_LOG_OPTION += -verbose
370   endif
371 
372   # Generate the overview.html file. This will return the filename in
373   # $1_OVERVIEW.
374   $$(eval $$(call create_overview_file,$1))
375   $1_OPTIONS += -overview $$($1_OVERVIEW)
376 
377   # Add summary pages for new/deprecated APIs in recent releases
378   $1_OPTIONS += --since $(call CommaList, \
379       $(filter-out $(VERSION_DOCS_API_SINCE), \
380           $(call sequence, $(VERSION_DOCS_API_SINCE), $(VERSION_FEATURE))))
381   $1_OPTIONS += --since-label "New API since JDK $(VERSION_DOCS_API_SINCE)"
382 
383   $$(foreach g, $$($1_GROUPS), \
384     $$(eval $1_OPTIONS += -group "$$($$g_GROUP_NAME)" "$$($$g_GROUP_MODULES)") \
385   )
386 
387   ifeq ($$($1_JAVADOC_CMD), )
388     $1_JAVADOC_CMD := $$(JAVA) -Djava.awt.headless=true $$($1_JAVA_ARGS) \
389         $$(NEW_JAVADOC)
390   else
391     $1_OPTIONS += $$(addprefix -J, $$($1_JAVA_ARGS))
392   endif
393 
394   $1_VARDEPS := $$($1_JAVA_ARGS) $$($1_OPTIONS) $$(MODULES_SOURCE_PATH) \
395       $$($1_ALL_MODULES) $$($1_JAVADOC_CMD)
396   $1_VARDEPS_FILE := $$(call DependOnVariable, $1_VARDEPS, \
397       $$(SUPPORT_OUTPUTDIR)/docs/$1.vardeps)
398 
399   # Get a list of all files in all the source dirs for all included modules
400   $1_SOURCE_DEPS := $$(call FindFiles, $$(wildcard $$(foreach module, \
401       $$($1_ALL_MODULES), $$(call FindModuleSrcDirs, $$(module)))))
402 
403   $$(eval $$(call SetupExecute, javadoc_$1, \
404       WARN := Generating $1 javadoc for $$(words $$($1_ALL_MODULES)) modules, \
405       INFO := Javadoc modules: $$($1_ALL_MODULES), \
406       DEPS := $$(BUILD_TOOLS_JDK) $$($1_VARDEPS_FILE) $$($1_SOURCE_DEPS) \
407           $$($1_OVERVIEW), \
408       OUTPUT_DIR := $$($1_TARGET_DIR), \
409       SUPPORT_DIR := $$(SUPPORT_OUTPUTDIR)/docs, \
410       COMMAND := $$($1_JAVADOC_CMD) -d $$($1_TARGET_DIR) $$($1_OPTIONS) \
411           $$($1_LOG_OPTION), \
412   ))
413 
414   $1_JAVADOC_TARGETS := $$(javadoc_$1_TARGET)
415 
416   ifeq ($$(ENABLE_FULL_DOCS), true)
417     # We have asked ModuleGraph to generate links to svg files. Now we must
418     # produce the svg files.
419 
420     # Locate which modules has the @moduleGraph tag in their module-info.java
421     $1_MODULES_NEEDING_GRAPH := $$(strip $$(foreach m, $$($1_ALL_MODULES), \
422       $$(if $$(shell $$(GREP) -e @moduleGraph \
423           $$(wildcard $$(addsuffix /module-info.java, \
424           $$(call FindModuleSrcDirs, $$m)))), \
425         $$m) \
426     ))
427 
428     # First we run the GenGraph tool. It will query the module structure of the
429     # running JVM and output .dot files for all existing modules.
430     MODULE_GRAPHS_PROPS := \
431         $$(TOPDIR)/make/jdk/src/classes/build/tools/jigsaw/javadoc-graphs.properties
432 
433     $1_MODULE_GRAPHS_DIR := $$(SUPPORT_OUTPUTDIR)/docs/$1-module-graphs
434 
435     $$(eval $$(call SetupExecute, module_graphs_dot_$1, \
436         INFO := Generating module graphs for $1 documentation, \
437         DEPS := $$(BUILD_JIGSAW_TOOLS) $$(MODULE_GRAPHS_PROPS), \
438         OUTPUT_DIR := $$($1_MODULE_GRAPHS_DIR), \
439         COMMAND := $$(TOOL_GENGRAPHS) --spec --output $$($1_MODULE_GRAPHS_DIR) \
440             --dot-attributes $$(MODULE_GRAPHS_PROPS), \
441     ))
442 
443     # For each module needing a graph, create a svg file from the dot file
444     # generated by the GenGraphs tool and store it in the target dir.
445     # They will depend on module_graphs_dot_$1_TARGET, and will be added to
446     # $1_GRAPHS_TARGETS.
447     $$(foreach m, $$($1_MODULES_NEEDING_GRAPH), \
448       $$(eval $$(call setup_module_graph_dot_to_svg,$1,$$m)) \
449     )
450 
451     # We have asked SealedGraph to generate dot files and links to svg files.
452     # Now we must produce the svg files from the dot files.
453 
454     # Get a list of classes for which SealedGraph has generated dot files
455     $1_SEALED_CLASSES := $$(patsubst %.dot,%,$$(patsubst \
456         $$($1_SEALED_GRAPHS_DIR)/%,%, \
457         $$(wildcard $$($1_SEALED_GRAPHS_DIR)/*.dot)))
458 
459     # For each class needing a graph, create a svg file from the dot file
460     # generated by the SealedGraph taglet and store it in the target dir.
461     # They will will be added to $1_GRAPHS_TARGETS.
462     $$(foreach c, $$($1_SEALED_CLASSES), \
463       $$(eval $$(call setup_sealed_graph_dot_to_svg,$1,$$c)) \
464     )
465   endif
466 endef
467 
468 ################################################################################
469 # Setup generation of the JDK API documentation (javadoc + graphs)
470 
471 # Define the groups of the JDK API documentation
472 JavaSE_GROUP_NAME := Java SE
473 JavaSE_GROUP_MODULES := $(call ColonList, $(sort java.se \
474     $(call FindTransitiveIndirectDepsForModules, java.se)))
475 JavaSE_GROUP_DESCRIPTION := \
476     The Java Platform, Standard Edition (Java SE) APIs define the core Java \
477     platform for general-purpose computing. These APIs are in modules whose \
478     names start with {@code java}. \
479     #
480 JDK_GROUPS += JavaSE
481 
482 JDK_GROUP_NAME := JDK
483 JDK_GROUP_MODULES := jdk.*
484 JDK_GROUP_DESCRIPTION := \
485     The Java Development Kit (JDK) APIs are specific to the JDK and will not \
486     necessarily be available in all implementations of the Java SE Platform. \
487     These APIs are in modules whose names start with {@code jdk}. \
488     #
489 JDK_GROUPS += JDK
490 
491 # If we are importing JavaFX, we need a JavaFX group. In an ideal world, this
492 # would have been abstracted away to a more proper generic handling of imported
493 # modules.
494 ifneq ($(findstring javafx., $(IMPORTED_MODULES)), )
495   JavaFX_GROUP_NAME := JavaFX
496   JavaFX_GROUP_MODULES := javafx.*
497   JavaFX_GROUP_DESCRIPTION := \
498       The JavaFX APIs define a set of user-interface controls, graphics, \
499       media, and web packages for developing rich client applications. These \
500       APIs are in modules whose names start with {@code javafx}. \
501       #
502   JDK_GROUPS += JavaFX
503 endif
504 
505 # All modules to have docs generated by docs-jdk-api target
506 JDK_MODULES := $(sort $(filter-out $(MODULES_FILTER), $(DOCS_MODULES)))
507 
508 $(eval $(call SetupApiDocsGeneration, JDK_API, \
509     MODULES := $(JDK_MODULES), \
510     GROUPS := $(JDK_GROUPS), \
511     SHORT_NAME := $(JDK_SHORT_NAME), \
512     LONG_NAME := $(JDK_LONG_NAME), \
513     TARGET_DIR := $(DOCS_OUTPUTDIR)/api, \
514     OTHER_VERSIONS := $(OTHER_JDK_VERSIONS_URL), \
515 ))
516 
517 # Targets generated are returned in JDK_API_JAVADOC_TARGETS and
518 # JDK_API_GRAPHS_TARGETS.
519 
520 ################################################################################
521 # Setup generation of the Java SE API documentation (javadoc + graphs)
522 
523 # The Java SE module scope is just java.se and its transitive indirect
524 # exports.
525 JAVASE_MODULES := java.se
526 
527 $(eval $(call SetupApiDocsGeneration, JAVASE_API, \
528     MODULES := $(JAVASE_MODULES), \
529     SHORT_NAME := $(JAVASE_SHORT_NAME), \
530     LONG_NAME := $(JAVASE_LONG_NAME), \
531     TARGET_DIR := $(DOCS_JAVASE_IMAGE_DIR)/api, \
532 ))
533 
534 # Targets generated are returned in JAVASE_API_JAVADOC_TARGETS and
535 # JAVASE_API_GRAPHS_TARGETS.
536 
537 ################################################################################
538 # Setup generation of the reference Java SE API documentation (javadoc + graphs)
539 
540 # The reference javadoc is just the same as javase, but using the BootJDK javadoc
541 # and a stable set of javadoc options.  Typically it is used for generating
542 # diffs between the reference javadoc and a javadoc bundle of a specific build
543 # generated in the same way.
544 
545 $(eval $(call SetupApiDocsGeneration, REFERENCE_API, \
546     MODULES := $(JAVASE_MODULES), \
547     SHORT_NAME := $(JAVASE_SHORT_NAME), \
548     LONG_NAME := $(JAVASE_LONG_NAME), \
549     TARGET_DIR := $(DOCS_REFERENCE_IMAGE_DIR)/api, \
550     JAVADOC_CMD := $(DOCS_REFERENCE_JAVADOC), \
551     OPTIONS := $(REFERENCE_OPTIONS), \
552     TAGS := $(REFERENCE_TAGS), \
553 ))
554 
555 # Targets generated are returned in REFERENCE_API_JAVADOC_TARGETS and
556 # REFERENCE_API_GRAPHS_TARGETS.
557 
558 ################################################################################
559 
560 # Use this variable to control which spec files are included in the output.
561 # Format: space-delimited list of names, including at most one '%' as a
562 # wildcard. Spec source files match if their filename or any enclosing folder
563 # name matches one of the items in SPEC_FILTER.
564 SPEC_FILTER := %
565 
566 ApplySpecFilter = \
567     $(strip $(foreach file, $(1), \
568         $(eval searchkeys := $(subst /, ,$(subst $(WORKSPACE_ROOT),,$(file)))) \
569         $(if $(filter $(SPEC_FILTER), $(searchkeys)), \
570             $(file) \
571         ) \
572     ))
573 
574 # Copy the global resources, including the top-level redirect index.html
575 GLOBAL_SPECS_RESOURCES_DIR := $(TOPDIR)/make/data/docs-resources
576 $(eval $(call SetupCopyFiles, COPY_GLOBAL_RESOURCES, \
577     SRC := $(GLOBAL_SPECS_RESOURCES_DIR), \
578     FILES := $(call ApplySpecFilter, $(call FindFiles, $(GLOBAL_SPECS_RESOURCES_DIR))), \
579     DEST := $(DOCS_OUTPUTDIR), \
580 ))
581 JDK_INDEX_TARGETS += $(COPY_GLOBAL_RESOURCES)
582 
583 # Copy the legal notices distributed with the docs bundle
584 $(eval $(call SetupCopyFiles, COPY_DOCS_LEGAL_NOTICES, \
585     SRC := $(TOPDIR)/src/jdk.javadoc/share/legal, \
586     FILES := $(call ApplySpecFilter, $(wildcard $(TOPDIR)/src/jdk.javadoc/share/legal/*)), \
587     DEST := $(DOCS_OUTPUTDIR)/legal, \
588 ))
589 JDK_INDEX_TARGETS += $(COPY_DOCS_LEGAL_NOTICES)
590 
591 ################################################################################
592 # Copy JDK specs files
593 
594 # For all non html/md files in $module/share/specs directories, copy them
595 # unmodified
596 
597 ALL_MODULES := $(call FindAllModules)
598 COPY_SPEC_FILTER := %.gif %.jpg %.mib %.css
599 
600 $(foreach m, $(ALL_MODULES), \
601   $(eval SPECS_$m := $(call FindModuleSpecsDirs, $m)) \
602   $(foreach d, $(SPECS_$m), \
603     $(if $(call ApplySpecFilter, $(filter $(COPY_SPEC_FILTER), $(call FindFiles, $d))), \
604       $(eval $(call SetupCopyFiles, COPY_$m, \
605           SRC := $d, \
606           FILES := $(call ApplySpecFilter, $(filter $(COPY_SPEC_FILTER), $(call FindFiles, $d))), \
607           DEST := $(DOCS_OUTPUTDIR)/specs/, \
608       )) \
609       $(eval JDK_SPECS_TARGETS += $(COPY_$m)) \
610     ) \
611   ) \
612 )
613 
614 # Create copyright footer variables. We need different variables for different
615 # relative paths to the copyright.html file. The number 0-2 below represent how
616 # many extra directory levels down below the specs dir the specs html file is
617 # located.
618 SPECS_BOTTOM = <footer class="legal-footer"><hr/>$(COPYRIGHT_BOTTOM)</footer>
619 # The legal dir is one ../ below the specs dir, so start with one ../.
620 specs_bottom_rel_path := ../
621 $(foreach n, 0 1 2, \
622   $(eval SPECS_BOTTOM_$n := $(call SPECS_BOTTOM,$(specs_bottom_rel_path))) \
623   $(eval specs_bottom_rel_path := $(specs_bottom_rel_path)../) \
624 )
625 
626 SPECS_TOP := $(if $(filter true, $(IS_DRAFT)), <header class="draft-header" role="banner">$(DRAFT_TEXT)</header>)
627 
628 # For all html files in $module/share/specs directories, copy and add the
629 # copyright footer.
630 
631 $(foreach m, $(ALL_MODULES), \
632   $(eval SPECS_$m := $(call FindModuleSpecsDirs, $m)) \
633   $(foreach d, $(SPECS_$m), \
634     $(foreach f, $(call ApplySpecFilter, $(filter %.html, $(call FindFiles, $d))), \
635       $(eval $m_$f_NOF_SUBDIRS := $(words $(subst /, $(SPACE), $(subst $d, , $(dir $f))))) \
636       $(eval $m_$f_NAME := PROCESS_HTML_$m_$(strip $(call RelativePath, $f, $(TOPDIR)))) \
637       $(eval $(call SetupTextFileProcessing, $($m_$f_NAME), \
638           SOURCE_FILES := $f, \
639           SOURCE_BASE_DIR := $d, \
640           OUTPUT_DIR := $(DOCS_OUTPUTDIR)/specs/, \
641           REPLACEMENTS := \
642               <body> => <body>$(SPECS_TOP) ; \
643               </body> => $(SPECS_BOTTOM_$($m_$f_NOF_SUBDIRS))</body>, \
644       )) \
645       $(eval JDK_SPECS_TARGETS += $($($m_$f_NAME))) \
646     ) \
647   ) \
648 )
649 
650 ifeq ($(ENABLE_PANDOC), true)
651   # For all markdown files in $module/share/specs directories, convert them to
652   # html, if we have pandoc (otherwise we'll just skip this).
653 
654   GLOBAL_SPECS_DEFAULT_CSS_FILE := $(DOCS_OUTPUTDIR)/resources/jdk-default.css
655   # Unset the following to suppress the link to the tool guides
656   NAV_LINK_GUIDES := --nav-link-guides
657   HEADER_RIGHT_SIDE_INFO := <strong>$(subst &amp;,&,$(JDK_SHORT_NAME))$(DRAFT_MARKER_STR)</strong>
658 
659   $(foreach m, $(ALL_MODULES), \
660     $(eval SPECS_$m := $(call FindModuleSpecsDirs, $m)) \
661     $(foreach d, $(SPECS_$m), \
662       $(foreach f, $(call ApplySpecFilter, $(filter %.md, $(call FindFiles, $d))), \
663         $(eval $m_$f_NOF_SUBDIRS := $(words $(subst /, $(SPACE), $(subst $d, , $(dir $f))))) \
664         $(eval $m_$f_NAME := SPECS_TO_HTML_$m_$(strip $(call RelativePath, $f, $(TOPDIR)))) \
665         $(eval $(call SetupProcessMarkdown, $($m_$f_NAME), \
666             SRC := $d, \
667             FILES := $f, \
668             DEST := $(DOCS_OUTPUTDIR)/specs/, \
669             CSS := $(GLOBAL_SPECS_DEFAULT_CSS_FILE), \
670             OPTIONS := -V include-before='$(SPECS_TOP)' -V include-after='$(SPECS_BOTTOM_$($m_$f_NOF_SUBDIRS))', \
671             REPLACEMENTS := \
672 		@@VERSION_SPECIFICATION@@ => $(VERSION_SPECIFICATION) ; \
673 		@@VERSION_STRING@@ => $(VERSION_STRING), \
674             POST_PROCESS := $(TOOL_FIXUPPANDOC) --insert-nav --nav-right-info '$(HEADER_RIGHT_SIDE_INFO)' \
675                 --nav-subdirs $($m_$f_NOF_SUBDIRS) $(NAV_LINK_GUIDES), \
676         )) \
677         $(eval JDK_SPECS_TARGETS += $($($m_$f_NAME))) \
678       ) \
679     ) \
680   )
681 
682   # For all markdown files in $module/share/man directories, convert them to
683   # html.
684 
685   # Create dynamic man pages from markdown using pandoc. We need
686   # PANDOC_HTML_MANPAGE_FILTER, a wrapper around
687   # PANDOC_HTML_MANPAGE_FILTER_JAVASCRIPT. This is created by buildtools-jdk.
688 
689   # We should also depend on the source code for the filter
690   PANDOC_HTML_MANPAGE_FILTER_SOURCE := $(call FindFiles, \
691       $(TOPDIR)/make/jdk/src/classes/build/tools/pandocfilter)
692 
693   $(foreach m, $(ALL_MODULES), \
694     $(eval MAN_$m := $(call FindModuleManDirs, $m)) \
695     $(foreach d, $(MAN_$m), \
696       $(foreach f, $(call ApplySpecFilter, $(filter %.md, $(call FindFiles, $d))), \
697         $(eval $m_$f_NAME := MAN_TO_HTML_$m_$(strip $(call RelativePath, $f, $(TOPDIR)))) \
698         $(eval $(call SetupProcessMarkdown, $($m_$f_NAME), \
699             SRC := $d, \
700             FILES := $f, \
701             DEST := $(DOCS_OUTPUTDIR)/specs/man, \
702             FILTER := $(PANDOC_HTML_MANPAGE_FILTER), \
703             CSS := $(GLOBAL_SPECS_DEFAULT_CSS_FILE), \
704             REPLACEMENTS := \
705 		@@COPYRIGHT_YEAR@@ => $(COPYRIGHT_YEAR) ; \
706 		@@VERSION_SHORT@@ => $(VERSION_SHORT) ; \
707 		@@VERSION_SPECIFICATION@@ => $(VERSION_SPECIFICATION), \
708             OPTIONS := --toc -V include-before='$(SPECS_TOP)' -V include-after='$(SPECS_BOTTOM_1)', \
709             POST_PROCESS := $(TOOL_FIXUPPANDOC) --insert-nav --nav-right-info '$(HEADER_RIGHT_SIDE_INFO)' \
710                 --nav-subdirs 1 --nav-link-guides, \
711             EXTRA_DEPS := $(PANDOC_HTML_MANPAGE_FILTER) \
712                 $(PANDOC_HTML_MANPAGE_FILTER_SOURCE), \
713         )) \
714         $(eval JDK_SPECS_TARGETS += $($($m_$f_NAME))) \
715       ) \
716     ) \
717   )
718 
719   # The html generated from markdown also needs the css file
720   JDK_SPECS_TARGETS += $(COPY_GLOBAL_RESOURCES)
721 endif
722 
723 # Special treatment for generated documentation
724 
725 SPEC_HEADER_BLOCK := \
726 <header id="title-block-header"> \
727     <div class="navbar"> \
728         <div>$(HEADER_RIGHT_SIDE_INFO)</div> \
729         <nav><ul><li><a href="PATH_TO_SPECS/../api/index.html">API</a> \
730         <li><a href="PATH_TO_SPECS/index.html">OTHER SPECIFICATIONS \
731         <li><a href="PATH_TO_SPECS/man/index.html">TOOL GUIDES</a></ul></nav> \
732     </div> \
733 </header>
734 
735 JDWP_PROTOCOL := $(SUPPORT_OUTPUTDIR)/gensrc/jdk.jdi/jdwp-protocol.html
736 ifneq ($(call ApplySpecFilter, $(JDWP_PROTOCOL)), )
737   JDWP_HEADER_BLOCK := $(subst PATH_TO_SPECS,..,$(SPEC_HEADER_BLOCK))
738   $(eval $(call SetupTextFileProcessing, PROCESS_JDWP_PROTOCOL, \
739       SOURCE_FILES := $(JDWP_PROTOCOL), \
740       OUTPUT_DIR := $(DOCS_OUTPUTDIR)/specs/jdwp, \
741       REPLACEMENTS := \
742           <style> => <link rel="stylesheet" href="../../resources/jdk-default.css"/><style> ; \
743           <body> => <body>$(SPECS_TOP)$(JDWP_HEADER_BLOCK) ; \
744           </body> => $(SPECS_BOTTOM_1)</body>, \
745   ))
746   JDK_SPECS_TARGETS += $(PROCESS_JDWP_PROTOCOL)
747 endif
748 
749 # Get jvmti.html from the main jvm variant (all variants' jvmti.html are identical).
750 JVMTI_HTML ?= $(HOTSPOT_OUTPUTDIR)/variant-$(JVM_VARIANT_MAIN)/gensrc/jvmtifiles/jvmti.html
751 ifneq ($(call ApplySpecFilter, $(JVMTI_HTML)), )
752   JVMTI_HEADER_BLOCK := $(subst PATH_TO_SPECS,.,$(SPEC_HEADER_BLOCK))
753   $(eval $(call SetupTextFileProcessing, PROCESS_JVMTI_HTML, \
754       SOURCE_FILES := $(JVMTI_HTML), \
755       OUTPUT_DIR := $(DOCS_OUTPUTDIR)/specs/, \
756       REPLACEMENTS := \
757           <style> => <link rel="stylesheet" href="../resources/jdk-default.css"/><style> ; \
758           <body> => <body>$(SPECS_TOP)$(JVMTI_HEADER_BLOCK) ; \
759           </body> => $(SPECS_BOTTOM_0)</body>, \
760   ))
761   JDK_SPECS_TARGETS += $(PROCESS_JVMTI_HTML)
762 endif
763 
764 ################################################################################
765 # Optional target which bundles all generated javadocs into a zip archive.
766 
767 JAVADOC_ZIP_NAME := jdk-$(VERSION_STRING)-docs.zip
768 JAVADOC_ZIP_FILE := $(OUTPUTDIR)/bundles/$(JAVADOC_ZIP_NAME)
769 
770 $(eval $(call SetupZipArchive, BUILD_JAVADOC_ZIP, \
771     SRC := $(DOCS_OUTPUTDIR), \
772     ZIP := $(JAVADOC_ZIP_FILE), \
773     EXTRA_DEPS := $(JDK_API_JAVADOC_TARGETS) $(JDK_API_GRAPHS_TARGETS) \
774         $(JDK_SPECS_TARGETS), \
775 ))
776 
777 ZIP_TARGETS += $(BUILD_JAVADOC_ZIP)
778 
779 ################################################################################
780 # Hook to include the corresponding custom file, if present.
781 $(eval $(call IncludeCustomExtension, Docs-post.gmk))
782 
783 ################################################################################
784 # Bundles all generated specs into a zip archive, skipping javadocs.
785 
786 SPECS_ZIP_NAME := jdk-$(VERSION_STRING)-specs.zip
787 SPECS_ZIP_FILE := $(OUTPUTDIR)/bundles/$(SPECS_ZIP_NAME)
788 
789 $(eval $(call SetupZipArchive, BUILD_SPECS_ZIP, \
790     SRC := $(DOCS_OUTPUTDIR), \
791     ZIP := $(SPECS_ZIP_FILE), \
792     EXTRA_DEPS := $(JDK_SPECS_TARGETS), \
793 ))
794 
795 SPECS_ZIP_TARGETS += $(BUILD_SPECS_ZIP)
796 
797 ################################################################################
798 
799 docs-jdk-api-javadoc: $(JDK_API_JAVADOC_TARGETS) $(JDK_API_CUSTOM_TARGETS)
800 
801 docs-jdk-api-graphs: $(JDK_API_GRAPHS_TARGETS)
802 
803 docs-javase-api-javadoc: $(JAVASE_API_JAVADOC_TARGETS) $(JAVASE_API_CUSTOM_TARGETS)
804 
805 docs-javase-api-graphs: $(JAVASE_API_GRAPHS_TARGETS)
806 
807 docs-reference-api-javadoc: $(REFERENCE_API_JAVADOC_TARGETS) $(REFERENCE_API_CUSTOM_TARGETS)
808 
809 docs-reference-api-graphs: $(REFERENCE_API_GRAPHS_TARGETS)
810 
811 docs-jdk-specs: $(JDK_SPECS_TARGETS)
812 
813 docs-jdk-index: $(JDK_INDEX_TARGETS)
814 
815 docs-zip: $(ZIP_TARGETS)
816 
817 docs-specs-zip: $(SPECS_ZIP_TARGETS)
818 
819 all: docs-jdk-api-javadoc docs-jdk-api-graphs docs-javase-api-javadoc \
820     docs-javase-api-graphs docs-reference-api-javadoc \
821     docs-reference-api-graphs docs-jdk-specs docs-jdk-index docs-zip \
822     docs-specs-zip
823 
824 .PHONY: default all docs-jdk-api-javadoc docs-jdk-api-graphs \
825     docs-javase-api-javadoc docs-javase-api-graphs \
826     docs-reference-api-javadoc docs-reference-api-graphs docs-jdk-specs \
827     docs-jdk-index docs-zip docs-specs-zip