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