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