make/Javadoc.gmk
author ihse
Wed, 19 Apr 2017 10:24:42 +0200
changeset 44725 8747b14eb49c
parent 44397 f932d6b9f7fe
child 44726 04aa2c065f5c
permissions -rw-r--r--
8172312: Update docs target and image for new combined docs Reviewed-by: erikj, mchung Contributed-by: Magnus Ihse Bursie <magnus.ihse.bursie@oracle.com>, Mandy Chung <mandy.chung@oracle.com>

# Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation.  Oracle designates this
# particular file as subject to the "Classpath" exception as provided
# by Oracle in the LICENSE file that accompanied this code.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#

default: all

include $(SPEC)
include MakeBase.gmk
include Modules.gmk
include ZipArchive.gmk
include $(JDK_TOPDIR)/make/Tools.gmk
include $(JDK_TOPDIR)/make/ModuleTools.gmk

# This is needed to properly setup DOCS_MODULES.
$(eval $(call ReadImportMetaData))

################################################################################
# Javadoc settings

# All modules to have docs generated by docs-javadoc target
JAVADOC_MODULES := $(sort $(DOCS_MODULES))

# On top of the sources that was used to compile the JDK, we need some
# extra java.rmi sources that are used just for javadoc.
JAVADOC_SOURCE_PATH := $(call PathList, $(call GetModuleSrcPath) \
    $(SUPPORT_OUTPUTDIR)/rmic/* $(JDK_TOPDIR)/src/*/share/doc/stub)

# Should we use -Xdocrootparent? Allow custom to overwrite.
DOCROOTPARENT_FLAG = TRUE

# URLs
JAVADOC_BASE_URL := http://docs.oracle.com/javase/$(VERSION_SPECIFICATION)/docs
BUG_SUBMIT_URL := http://bugreport.java.com/bugreport/
COPYRIGHT_URL := {@docroot}/../legal/cpyr.html

# In order to get a specific ordering it's necessary to specify the total
# ordering of tags as the tags are otherwise ordered in order of definition.
JAVADOC_TAGS := \
    -tag beaninfo:X \
    -tag revised:X \
    -tag since.unbundled:X \
    -tag spec:X \
    -tag specdefault:X \
    -tag Note:X \
    -tag ToDo:X \
    -tag 'apiNote:a:API Note:' \
    -tag 'implSpec:a:Implementation Requirements:' \
    -tag 'implNote:a:Implementation Note:' \
    -tag param \
    -tag return \
    -tag throws \
    -taglet build.tools.taglet.ModuleGraph \
    -tag since \
    -tag version \
    -tag serialData \
    -tag factory \
    -tag see \
    -tag 'jvms:a:See <cite>The Java&trade; Virtual Machine Specification</cite>:' \
    -tag 'jls:a:See <cite>The Java&trade; Language Specification</cite>:' \
    -taglet build.tools.taglet.Incubating \
    -tagletpath $(BUILDTOOLS_OUTPUTDIR)/jdk_tools_classes \
    #

# Which doclint checks to ignore
JAVADOC_DISABLED_DOCLINT := accessibility html missing syntax reference

# The initial set of options for javadoc
JAVADOC_OPTIONS := -XDignore.symbol.file=true -use -keywords -notimestamp \
    -serialwarn -encoding ISO-8859-1 -breakiterator -splitIndex --system none \
    --expand-requires transitive

#
# TODO: this should be set by the configure option.
#
ifndef ENABLE_MODULE_GRAPH
   ENABLE_MODULE_GRAPH=false
endif

# Should we add DRAFT stamps to the generated javadoc?
ifeq ($(VERSION_IS_GA), true)
  IS_DRAFT := false
else
  IS_DRAFT := true
endif

################################################################################
# General text snippets

FULL_COMPANY_NAME := Oracle and/or its affiliates
COMPANY_ADDRESS := 500 Oracle Parkway<br>Redwood Shores, CA 94065 USA

ifeq ($(IS_DRAFT), true)
  DRAFT_MARKER_STR := <br><strong>DRAFT $(VERSION_STRING)</strong>
  ifeq ($(VERSION_BUILD), 0)
    DRAFT_MARKER_TITLE := [ad-hoc build]
  else
    DRAFT_MARKER_TITLE := [build $(VERSION_BUILD)]
  endif
endif


################################################################################
# JDK javadoc titles/text snippets

JAVADOC_WINDOW_TITLE := Java Platform SE $(VERSION_SPECIFICATION) \
    $(DRAFT_MARKER_TITLE)

JAVADOC_DOC_TITLE := Java&trade; Platform, Standard Edition Development Kit \
    (JDK&trade;) $(VERSION_SPECIFICATION)<br>API Specification

JAVADOC_HEADER_TITLE := $(subst $(SPACE),&nbsp;,$(strip \
    <strong>Java&trade; Platform<br>Standard Ed. \
    $(VERSION_SPECIFICATION)</strong>$(DRAFT_MARKER_STR)))

JAVADOC_BOTTOM := \
    <span style="font-size:smaller"> \
    <a href="$(BUG_SUBMIT_URL)">Submit a bug or feature</a><br> \
    For further API reference and developer documentation, see \
    <a href="$(JAVADOC_BASE_URL)/index.html" target="_blank">Java SE \
    Documentation</a>. That documentation contains more detailed, \
    developer-targeted descriptions, with conceptual overviews, definitions \
    of terms, workarounds, and working code examples.<br> \
    Java is a trademark or registered trademark of $(FULL_COMPANY_NAME) in \
    the US and other countries.<br> \
    <a href="$(COPYRIGHT_URL)">Copyright</a> \
    &copy; 1993, $(COPYRIGHT_YEAR), $(FULL_COMPANY_NAME). \
    $(COMPANY_ADDRESS). All rights reserved.$(DRAFT_MARKER_STR)</span>

JAVADOC_TOP := \
    <div style="background-color: $(HASH)EEEEEE"><div style="padding: 6px; \
    margin-top: 2px; margin-bottom: 6px; margin-left: 6px; margin-right: \
    6px; text-align: justify; font-size: 80%; font-family: Helvetica, Arial, \
    sans-serif; font-weight: normal;">Please note that the specifications \
    and other information contained herein are not final and are subject to \
    change. The information is being made available to you solely for \
    purpose of evaluation.</div></div>

################################################################################
# Java SE Reference javadoc titles/text snippets

REFERENCE_DOC_TITLE := Java&trade; Platform, Standard Edition \
    $(VERSION_SPECIFICATION)<br>API Specification

################################################################################
# Setup call to JDK javadoc based on above settings

# Create a string like "-Xdoclint:all,-syntax,-html,..."
JAVADOC_OPTIONS += -Xdoclint:all,$(call CommaList, $(addprefix -, \
    $(JAVADOC_DISABLED_DOCLINT)))

ifneq ($($DOCROOTPARENT_FLAG), )
  JAVADOC_OPTIONS += -Xdocrootparent $(JAVADOC_BASE_URL)
endif

JAVADOC_TITLE_OPTIONS += -doctitle '$(JAVADOC_DOC_TITLE)'
JAVADOC_TITLE_OPTIONS += -windowtitle '$(JAVADOC_WINDOW_TITLE)'
JAVADOC_TITLE_OPTIONS += -header '$(JAVADOC_HEADER_TITLE)'
JAVADOC_TITLE_OPTIONS += -bottom '$(JAVADOC_BOTTOM)'
ifeq ($(IS_DRAFT), true)
  JAVADOC_TITLE_OPTIONS += -top '$(JAVADOC_TOP)'
endif

# Do not store debug level options in VARDEPS.
ifneq ($(LOG_LEVEL), trace)
  JAVADOC_LOG_OPTION += -quiet
else
  JAVADOC_LOG_OPTION += -verbose
endif

JAVADOC_VARDEPS := $(JAVADOC_OPTIONS) $(JAVADOC_TITLE_OPTIONS) $(JAVADOC_TAGS) \
    $(JAVADOC_MODULES) $(JAVADOC_SOURCE_PATH)
JAVADOC_VARDEPS_FILE := $(call DependOnVariable, JAVADOC_VARDEPS, \
    $(SUPPORT_OUTPUTDIR)/docs/javadoc.vardeps)

# Get a list of all files in all the source dirs for all included modules
JAVADOC_SOURCE_DEPS := $(call CacheFind, $(wildcard \
    $(foreach module, $(JAVADOC_MODULES), $(call FindModuleSrcDirs, $(module)))))

JAVADOC_TARGET_DIR := $(JAVADOC_OUTPUTDIR)/api
JAVADOC_OVERVIEW := $(JDK_TOPDIR)/src/java.base/share/classes/overview-core.html

# Javadoc creates a lot of files but use index.html as a marker
$(JAVADOC_TARGET_DIR)/index.html: $(BUILD_TOOLS_JDK) $(JAVADOC_VARDEPS_FILE) \
    $(JAVADOC_SOURCE_DEPS) $(JAVADOC_OVERVIEW)
	$(call LogWarn, Generating Javadoc for $(words $(JAVADOC_MODULES)) modules)
	$(call LogInfo, Javadoc modules: $(JAVADOC_MODULES))
	$(call MakeDir, $(JAVADOC_TARGET_DIR))
	$(call ExecuteWithLog, $(SUPPORT_OUTPUTDIR)/docs/javadoc, \
	    $(JAVA) -Djava.awt.headless=true \
	        -DenableModuleGraph=$(ENABLE_MODULE_GRAPH) \
	        $(NEW_JAVADOC) -d $(JAVADOC_TARGET_DIR) \
	        $(JAVADOC_TAGS) $(JAVADOC_OPTIONS) $(JAVADOC_LOG_OPTION) \
	        $(JAVADOC_TITLE_OPTIONS) -overview $(JAVADOC_OVERVIEW) \
	        --module-source-path $(JAVADOC_SOURCE_PATH) \
	        --module $(call CommaList, $(JAVADOC_MODULES)))

JAVADOC_TARGETS += $(JAVADOC_TARGET_DIR)/index.html

################################################################################
# Setup call to Java SE Reference javadoc based on above settings

REFERENCE_TARGET_DIR := $(IMAGES_OUTPUTDIR)/javase-docs/api
REFERENCE_OVERVIEW := $(JDK_TOPDIR)/src/java.base/share/classes/overview-core.html

REFERENCE_TITLE_OPTIONS += -doctitle '$(REFERENCE_DOC_TITLE)'
REFERENCE_TITLE_OPTIONS += -windowtitle '$(JAVADOC_WINDOW_TITLE)'
REFERENCE_TITLE_OPTIONS += -header '$(JAVADOC_HEADER_TITLE)'
REFERENCE_TITLE_OPTIONS += -bottom '$(JAVADOC_BOTTOM)'
ifeq ($(IS_DRAFT), true)
  REFERENCE_TITLE_OPTIONS += -top '$(JAVADOC_TOP)'
endif

REFERENCE_VARDEPS := $(JAVADOC_OPTIONS) $(REFERENCE_TITLE_OPTIONS) $(JAVADOC_TAGS) \
    $(JAVADOC_MODULES) $(JAVADOC_SOURCE_PATH)
REFERENCE_VARDEPS_FILE := $(call DependOnVariable, REFERENCE_VARDEPS, \
    $(SUPPORT_OUTPUTDIR)/docs/reference.vardeps)

# Javadoc creates a lot of files but use index.html as a marker.
$(REFERENCE_TARGET_DIR)/index.html: $(BUILD_TOOLS_JDK) $(REFERENCE_VARDEPS_FILE) \
    $(JAVADOC_SOURCE_DEPS) $(REFERENCE_OVERVIEW)
	$(call LogWarn, Generating reference Javadoc for Java SE)
	$(call MakeDir, $(REFERENCE_TARGET_DIR))
	$(call ExecuteWithLog, $(SUPPORT_OUTPUTDIR)/docs/reference, \
	    $(JAVA) -Djava.awt.headless=true \
	        -DenableModuleGraph=$(ENABLE_MODULE_GRAPH) \
	        $(NEW_JAVADOC) -d $(REFERENCE_TARGET_DIR) \
	        $(JAVADOC_TAGS) $(JAVADOC_OPTIONS) $(JAVADOC_LOG_OPTION) \
	        $(REFERENCE_TITLE_OPTIONS) -overview $(REFERENCE_OVERVIEW) \
	        --module-source-path $(JAVADOC_SOURCE_PATH) \
	        --module java.se.ee)

REFERENCE_TARGETS += $(REFERENCE_TARGET_DIR)/index.html

################################################################################
# Copy targets

JDWP_HTML := $(SUPPORT_OUTPUTDIR)/gensrc/jdk.jdi/jdwp-protocol.html

$(eval $(call SetupCopyFiles, COPY_JDWP_HTML, \
    FILES := $(JDWP_HTML), \
    DEST := $(JAVADOC_OUTPUTDIR)/platform/jpda/jdwp, \
))

COPY_TARGETS += $(COPY_JDWP_HTML)

# Pick jvmti.html from any jvm variant, they are all the same.
JVMTI_HTML := $(firstword \
    $(wildcard $(HOTSPOT_OUTPUTDIR)/variant-*/gensrc/jvmtifiles/jvmti.html))

$(eval $(call SetupCopyFiles, COPY_JVMTI_HTML, \
    FILES := $(JVMTI_HTML), \
    DEST := $(JAVADOC_OUTPUTDIR)/platform/jvmti, \
))

COPY_TARGETS += $(COPY_JVMTI_HTML)

################################################################################
# Optional target which bundles all generated javadocs into a zip archive.

JAVADOC_ZIP_NAME := jdk-$(VERSION_STRING)-docs.zip
JAVADOC_ZIP_FILE := $(OUTPUT_ROOT)/bundles/$(JAVADOC_ZIP_NAME)

$(eval $(call SetupZipArchive, BUILD_JAVADOC_ZIP, \
  SRC := $(JAVADOC_OUTPUTDIR), \
  ZIP := $(JAVADOC_ZIP_FILE), \
  EXTRA_DEPS := $(JAVADOC_TARGETS) $(COPY_TARGETS), \
))

ZIP_TARGETS += $(BUILD_JAVADOC_ZIP)

################################################################################
# generate .dot files for module graphs

JAVADOC_MODULE_GRAPHS_DIR := $(SUPPORT_OUTPUTDIR)/docs/module-graphs
JAVADOC_MODULE_GRAPHS := $(JAVADOC_MODULE_GRAPHS_DIR)/java.se.dot
JAVADOC_MODULE_GRAPHS_PROPS := $(JDK_TOPDIR)/make/src/classes/build/tools/jigsaw/javadoc-graphs.properties

$(JAVADOC_MODULE_GRAPHS): $(BUILD_JIGSAW_TOOLS) $(JAVADOC_MODULE_GRAPHS_PROPS)
	$(MKDIR) -p $(@D)
	$(TOOL_GENGRAPHS) --spec --output $(JAVADOC_MODULE_GRAPHS_DIR) \
	    --dot-attributes $(JAVADOC_MODULE_GRAPHS_PROPS)

MODULE_GRAPH_TARGETS += $(JAVADOC_MODULE_GRAPHS)

################################################################################

# Hook to include the corresponding custom file, if present.
$(eval $(call IncludeCustomExtension, , Javadoc.gmk))

################################################################################

docs-module-graphs: $(MODULE_GRAPH_TARGETS)

docs-javadoc: $(JAVADOC_TARGETS)

docs-reference: $(REFERENCE_TARGETS)

docs-copy: $(COPY_TARGETS)

docs-zip: $(ZIP_TARGETS)

all: docs-module-graphs docs-javadoc docs-reference docs-copy docs-zip

.PHONY: default all docs-module-graphs docs-javadoc docs-reference docs-copy docs-zip