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