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