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