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