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