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