2013-10-11 13:21:46 -05:00
|
|
|
# Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
|
2012-12-10 19:32:48 -06:00
|
|
|
# file at the top-level directory of this distribution and at
|
|
|
|
# http://rust-lang.org/COPYRIGHT.
|
|
|
|
#
|
|
|
|
# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
|
|
# <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
|
|
# option. This file may not be copied, modified, or distributed
|
|
|
|
# except according to those terms.
|
|
|
|
|
2011-05-01 15:18:52 -05:00
|
|
|
######################################################################
|
2014-12-02 08:20:48 -06:00
|
|
|
# The various pieces of standalone documentation.
|
2014-03-08 08:41:31 -06:00
|
|
|
#
|
|
|
|
# The DOCS variable is their names (with no file extension).
|
|
|
|
#
|
2014-03-08 22:54:16 -06:00
|
|
|
# PDF_DOCS lists the targets for which PDF documentation should be
|
|
|
|
# build.
|
|
|
|
#
|
2014-03-08 08:41:31 -06:00
|
|
|
# RUSTDOC_FLAGS_xyz variables are extra arguments to pass to the
|
|
|
|
# rustdoc invocation for xyz.
|
|
|
|
#
|
|
|
|
# RUSTDOC_DEPS_xyz are extra dependencies for the rustdoc invocation
|
|
|
|
# on xyz.
|
|
|
|
#
|
|
|
|
# L10N_LANGS are the languages for which the docs have been
|
|
|
|
# translated.
|
2011-05-01 15:18:52 -05:00
|
|
|
######################################################################
|
2014-12-02 08:20:48 -06:00
|
|
|
DOCS := index intro tutorial complement-bugreport \
|
|
|
|
complement-lang-faq complement-design-faq complement-project-faq \
|
|
|
|
rustdoc reference
|
2014-03-08 08:41:31 -06:00
|
|
|
|
2015-01-09 02:47:09 -06:00
|
|
|
# Legacy guides, preserved for a while to reduce the number of 404s
|
|
|
|
DOCS += guide-crates guide-error-handling guide-ffi guide-macros guide \
|
|
|
|
guide-ownership guide-plugins guide-pointers guide-strings guide-tasks \
|
|
|
|
guide-testing
|
|
|
|
|
|
|
|
|
2014-12-02 08:20:48 -06:00
|
|
|
PDF_DOCS := reference
|
2014-03-08 22:54:16 -06:00
|
|
|
|
2014-11-06 17:01:45 -06:00
|
|
|
RUSTDOC_DEPS_reference := doc/full-toc.inc
|
|
|
|
RUSTDOC_FLAGS_reference := --html-in-header=doc/full-toc.inc
|
2014-03-08 08:41:31 -06:00
|
|
|
|
|
|
|
L10N_LANGS := ja
|
|
|
|
|
|
|
|
# Generally no need to edit below here.
|
2011-05-01 15:18:52 -05:00
|
|
|
|
2014-03-08 08:41:31 -06:00
|
|
|
# The options are passed to the documentation generators.
|
2014-06-28 05:35:25 -05:00
|
|
|
RUSTDOC_HTML_OPTS_NO_CSS = --html-before-content=doc/version_info.html \
|
|
|
|
--html-in-header=doc/favicon.inc \
|
|
|
|
--html-after-content=doc/footer.inc \
|
2014-06-06 11:12:18 -05:00
|
|
|
--markdown-playground-url='http://play.rust-lang.org/'
|
2011-05-01 15:18:52 -05:00
|
|
|
|
2014-05-14 12:45:51 -05:00
|
|
|
RUSTDOC_HTML_OPTS = $(RUSTDOC_HTML_OPTS_NO_CSS) --markdown-css rust.css
|
|
|
|
|
2014-03-08 08:41:31 -06:00
|
|
|
PANDOC_BASE_OPTS := --standalone --toc --number-sections
|
2014-12-18 17:27:50 -06:00
|
|
|
PANDOC_TEX_OPTS = $(PANDOC_BASE_OPTS) --from=markdown --to=latex \
|
|
|
|
--include-before-body=doc/version.tex \
|
|
|
|
--include-before-body=doc/footer.tex \
|
|
|
|
--include-in-header=doc/uptack.tex
|
2014-03-08 08:41:31 -06:00
|
|
|
PANDOC_EPUB_OPTS = $(PANDOC_BASE_OPTS) --to=epub
|
|
|
|
|
|
|
|
# The rustdoc executable...
|
|
|
|
RUSTDOC_EXE = $(HBIN2_H_$(CFG_BUILD))/rustdoc$(X_$(CFG_BUILD))
|
|
|
|
# ...with rpath included in case --disable-rpath was provided to
|
|
|
|
# ./configure
|
|
|
|
RUSTDOC = $(RPATH_VAR2_T_$(CFG_BUILD)_H_$(CFG_BUILD)) $(RUSTDOC_EXE)
|
2012-01-12 21:10:30 -06:00
|
|
|
|
2014-12-02 08:20:48 -06:00
|
|
|
# The rustbook executable...
|
|
|
|
RUSTBOOK_EXE = $(HBIN2_H_$(CFG_BUILD))/rustbook$(X_$(CFG_BUILD))
|
|
|
|
# ...with rpath included in case --disable-rpath was provided to
|
|
|
|
# ./configure
|
|
|
|
RUSTBOOK = $(RPATH_VAR2_T_$(CFG_BUILD)_H_$(CFG_BUILD)) $(RUSTBOOK_EXE)
|
|
|
|
|
2014-01-28 16:15:29 -06:00
|
|
|
D := $(S)src/doc
|
|
|
|
|
2014-12-02 08:20:48 -06:00
|
|
|
DOC_TARGETS := trpl
|
2014-03-08 08:41:31 -06:00
|
|
|
COMPILER_DOC_TARGETS :=
|
|
|
|
DOC_L10N_TARGETS :=
|
|
|
|
|
|
|
|
# If NO_REBUILD is set then break the dependencies on rustdoc so we
|
|
|
|
# build the documentation without having to rebuild rustdoc.
|
|
|
|
ifeq ($(NO_REBUILD),)
|
|
|
|
HTML_DEPS := $(RUSTDOC_EXE)
|
|
|
|
else
|
|
|
|
HTML_DEPS :=
|
|
|
|
endif
|
|
|
|
|
2015-02-05 21:14:12 -06:00
|
|
|
# Check for xelatex
|
|
|
|
|
2015-02-11 00:16:37 -06:00
|
|
|
ifneq ($(CFG_XELATEX),)
|
2014-03-09 05:21:05 -05:00
|
|
|
CFG_LATEX := $(CFG_XELATEX)
|
2014-09-09 17:47:47 -05:00
|
|
|
XELATEX = 1
|
2015-02-05 21:14:12 -06:00
|
|
|
else
|
|
|
|
$(info cfg: no xelatex found, disabling LaTeX docs)
|
|
|
|
NO_PDF_DOCS = 1
|
2014-03-08 08:41:31 -06:00
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($(CFG_PANDOC),)
|
|
|
|
$(info cfg: no pandoc found, omitting PDF and EPUB docs)
|
|
|
|
ONLY_HTML_DOCS = 1
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
2014-01-06 15:38:20 -06:00
|
|
|
######################################################################
|
|
|
|
# Rust version
|
|
|
|
######################################################################
|
2014-01-17 12:38:48 -06:00
|
|
|
|
2014-03-09 06:41:27 -05:00
|
|
|
doc/version.tex: $(MKFILE_DEPS) $(wildcard $(D)/*.*) | doc/
|
2014-01-06 15:38:20 -06:00
|
|
|
@$(call E, version-stamp: $@)
|
|
|
|
$(Q)echo "$(CFG_VERSION)" >$@
|
|
|
|
|
|
|
|
HTML_DEPS += doc/version_info.html
|
2014-01-28 16:15:29 -06:00
|
|
|
doc/version_info.html: $(D)/version_info.html.template $(MKFILE_DEPS) \
|
|
|
|
$(wildcard $(D)/*.*) | doc/
|
2014-01-06 15:38:20 -06:00
|
|
|
@$(call E, version-info: $@)
|
2014-10-04 13:41:37 -05:00
|
|
|
$(Q)sed -e "s/VERSION/$(CFG_RELEASE)/; \
|
|
|
|
s/SHORT_HASH/$(CFG_SHORT_VER_HASH)/; \
|
2014-01-06 15:38:20 -06:00
|
|
|
s/STAMP/$(CFG_VER_HASH)/;" $< >$@
|
|
|
|
|
2014-03-09 06:41:27 -05:00
|
|
|
GENERATED += doc/version.tex doc/version_info.html
|
2014-01-06 15:38:20 -06:00
|
|
|
|
2012-01-18 16:14:28 -06:00
|
|
|
######################################################################
|
2014-03-09 05:06:03 -05:00
|
|
|
# Docs, from rustdoc and sometimes pandoc
|
2012-01-18 16:14:28 -06:00
|
|
|
######################################################################
|
2012-03-20 19:50:32 -05:00
|
|
|
|
2014-01-28 16:15:29 -06:00
|
|
|
doc/:
|
|
|
|
@mkdir -p $@
|
|
|
|
|
2013-12-22 20:21:45 -06:00
|
|
|
HTML_DEPS += doc/rust.css
|
2014-01-28 16:15:29 -06:00
|
|
|
doc/rust.css: $(D)/rust.css | doc/
|
2012-03-26 19:59:09 -05:00
|
|
|
@$(call E, cp: $@)
|
|
|
|
$(Q)cp -a $< $@ 2> /dev/null
|
|
|
|
|
2014-02-07 13:46:39 -06:00
|
|
|
HTML_DEPS += doc/favicon.inc
|
|
|
|
doc/favicon.inc: $(D)/favicon.inc | doc/
|
|
|
|
@$(call E, cp: $@)
|
|
|
|
$(Q)cp -a $< $@ 2> /dev/null
|
|
|
|
|
2014-01-28 16:15:29 -06:00
|
|
|
doc/full-toc.inc: $(D)/full-toc.inc | doc/
|
2012-12-14 20:06:11 -06:00
|
|
|
@$(call E, cp: $@)
|
|
|
|
$(Q)cp -a $< $@ 2> /dev/null
|
|
|
|
|
2014-02-07 13:46:39 -06:00
|
|
|
HTML_DEPS += doc/footer.inc
|
|
|
|
doc/footer.inc: $(D)/footer.inc | doc/
|
|
|
|
@$(call E, cp: $@)
|
|
|
|
$(Q)cp -a $< $@ 2> /dev/null
|
|
|
|
|
2014-03-08 08:41:31 -06:00
|
|
|
# The (english) documentation for each doc item.
|
2013-04-24 00:51:48 -05:00
|
|
|
|
2014-03-08 22:54:16 -06:00
|
|
|
define DEF_SHOULD_BUILD_PDF_DOC
|
|
|
|
SHOULD_BUILD_PDF_DOC_$(1) = 1
|
|
|
|
endef
|
|
|
|
$(foreach docname,$(PDF_DOCS),$(eval $(call DEF_SHOULD_BUILD_PDF_DOC,$(docname))))
|
|
|
|
|
2014-03-12 12:35:17 -05:00
|
|
|
doc/footer.tex: $(D)/footer.inc | doc/
|
2014-03-12 12:31:52 -05:00
|
|
|
@$(call E, pandoc: $@)
|
|
|
|
$(CFG_PANDOC) --from=html --to=latex $< --output=$@
|
2014-03-12 12:35:17 -05:00
|
|
|
|
2014-12-18 17:27:50 -06:00
|
|
|
doc/uptack.tex: $(D)/uptack.tex | doc/
|
|
|
|
$(Q)cp $< $@
|
|
|
|
|
2014-05-14 12:45:51 -05:00
|
|
|
# HTML (rustdoc)
|
|
|
|
DOC_TARGETS += doc/not_found.html
|
|
|
|
doc/not_found.html: $(D)/not_found.md $(HTML_DEPS) | doc/
|
2014-06-01 13:09:30 -05:00
|
|
|
@$(call E, rustdoc: $@)
|
|
|
|
$(Q)$(RUSTDOC) $(RUSTDOC_HTML_OPTS_NO_CSS) \
|
|
|
|
--markdown-css http://doc.rust-lang.org/rust.css $<
|
2014-05-14 12:45:51 -05:00
|
|
|
|
2014-03-08 08:41:31 -06:00
|
|
|
define DEF_DOC
|
|
|
|
|
|
|
|
# HTML (rustdoc)
|
|
|
|
DOC_TARGETS += doc/$(1).html
|
|
|
|
doc/$(1).html: $$(D)/$(1).md $$(HTML_DEPS) $$(RUSTDOC_DEPS_$(1)) | doc/
|
|
|
|
@$$(call E, rustdoc: $$@)
|
2014-06-01 13:09:30 -05:00
|
|
|
$$(Q)$$(RUSTDOC) $$(RUSTDOC_HTML_OPTS) $$(RUSTDOC_FLAGS_$(1)) $$<
|
2014-03-08 08:41:31 -06:00
|
|
|
|
|
|
|
ifneq ($(ONLY_HTML_DOCS),1)
|
|
|
|
|
|
|
|
# EPUB (pandoc directly)
|
|
|
|
DOC_TARGETS += doc/$(1).epub
|
|
|
|
doc/$(1).epub: $$(D)/$(1).md | doc/
|
|
|
|
@$$(call E, pandoc: $$@)
|
2014-03-09 05:06:03 -05:00
|
|
|
$$(CFG_PANDOC) $$(PANDOC_EPUB_OPTS) $$< --output=$$@
|
2014-03-08 08:41:31 -06:00
|
|
|
|
|
|
|
# PDF (md =(pandoc)=> tex =(pdflatex)=> pdf)
|
|
|
|
DOC_TARGETS += doc/$(1).tex
|
2014-12-18 17:27:50 -06:00
|
|
|
doc/$(1).tex: $$(D)/$(1).md doc/uptack.tex doc/footer.tex doc/version.tex | doc/
|
2014-03-08 08:41:31 -06:00
|
|
|
@$$(call E, pandoc: $$@)
|
2014-03-09 05:06:03 -05:00
|
|
|
$$(CFG_PANDOC) $$(PANDOC_TEX_OPTS) $$< --output=$$@
|
2014-03-08 08:41:31 -06:00
|
|
|
|
|
|
|
ifneq ($(NO_PDF_DOCS),1)
|
2014-03-08 22:54:16 -06:00
|
|
|
ifeq ($$(SHOULD_BUILD_PDF_DOC_$(1)),1)
|
2014-03-08 08:41:31 -06:00
|
|
|
DOC_TARGETS += doc/$(1).pdf
|
2014-09-09 17:47:47 -05:00
|
|
|
ifneq ($(XELATEX),1)
|
2014-03-08 08:41:31 -06:00
|
|
|
doc/$(1).pdf: doc/$(1).tex
|
2014-03-09 05:21:05 -05:00
|
|
|
@$$(call E, latex compiler: $$@)
|
|
|
|
$$(Q)$$(CFG_LATEX) \
|
2014-03-08 08:41:31 -06:00
|
|
|
-interaction=batchmode \
|
|
|
|
-output-directory=doc \
|
|
|
|
$$<
|
2014-09-09 17:47:47 -05:00
|
|
|
else
|
|
|
|
# The version of xelatex on the snap bots seemingly ingores -output-directory
|
|
|
|
# So we'll output to . and move to the doc directory manually.
|
|
|
|
# This will leave some intermediate files in the build directory.
|
|
|
|
doc/$(1).pdf: doc/$(1).tex
|
|
|
|
@$$(call E, latex compiler: $$@)
|
|
|
|
$$(Q)$$(CFG_LATEX) \
|
|
|
|
-interaction=batchmode \
|
|
|
|
-output-directory=. \
|
|
|
|
$$<
|
|
|
|
$$(Q)mv ./$(1).pdf $$@
|
|
|
|
endif # XELATEX
|
2014-03-08 22:54:16 -06:00
|
|
|
endif # SHOULD_BUILD_PDF_DOCS_$(1)
|
2014-03-08 08:41:31 -06:00
|
|
|
endif # NO_PDF_DOCS
|
|
|
|
|
|
|
|
endif # ONLY_HTML_DOCS
|
|
|
|
|
|
|
|
endef
|
|
|
|
|
|
|
|
$(foreach docname,$(DOCS),$(eval $(call DEF_DOC,$(docname))))
|
2013-04-24 00:51:48 -05:00
|
|
|
|
2014-03-08 08:41:31 -06:00
|
|
|
|
2012-01-18 16:14:28 -06:00
|
|
|
######################################################################
|
2013-05-17 12:45:09 -05:00
|
|
|
# Rustdoc (libstd/extra)
|
2012-01-18 16:14:28 -06:00
|
|
|
######################################################################
|
2011-05-01 15:18:52 -05:00
|
|
|
|
2011-12-05 18:46:37 -06:00
|
|
|
|
2012-03-10 00:53:46 -06:00
|
|
|
# The library documenting macro
|
2014-01-24 21:27:22 -06:00
|
|
|
#
|
2013-09-22 01:25:48 -05:00
|
|
|
# $(1) - The crate name (std/extra)
|
2013-11-24 22:31:21 -06:00
|
|
|
#
|
|
|
|
# Passes --cfg stage2 to rustdoc because it uses the stage2 librustc.
|
2014-03-08 08:41:31 -06:00
|
|
|
define DEF_LIB_DOC
|
|
|
|
|
|
|
|
# If NO_REBUILD is set then break the dependencies on rustdoc so we
|
|
|
|
# build crate documentation without having to rebuild rustdoc.
|
|
|
|
ifeq ($(NO_REBUILD),)
|
|
|
|
LIB_DOC_DEP_$(1) = \
|
|
|
|
$$(CRATEFILE_$(1)) \
|
|
|
|
$$(RSINPUTS_$(1)) \
|
|
|
|
$$(RUSTDOC_EXE) \
|
|
|
|
$$(foreach dep,$$(RUST_DEPS_$(1)), \
|
2014-12-21 01:29:59 -06:00
|
|
|
$$(TLIB2_T_$(CFG_BUILD)_H_$(CFG_BUILD))/stamp.$$(dep)) \
|
|
|
|
$$(foreach dep,$$(filter $$(DOC_CRATES), $$(RUST_DEPS_$(1))), \
|
2014-06-09 15:00:18 -05:00
|
|
|
doc/$$(dep)/)
|
2014-03-08 08:41:31 -06:00
|
|
|
else
|
|
|
|
LIB_DOC_DEP_$(1) = $$(CRATEFILE_$(1)) $$(RSINPUTS_$(1))
|
|
|
|
endif
|
2014-02-06 17:43:27 -06:00
|
|
|
|
2014-06-09 15:00:18 -05:00
|
|
|
doc/$(1)/:
|
|
|
|
$$(Q)mkdir -p $$@
|
|
|
|
|
2014-03-08 08:41:31 -06:00
|
|
|
$(2) += doc/$(1)/index.html
|
2014-04-08 12:45:53 -05:00
|
|
|
doc/$(1)/index.html: CFG_COMPILER_HOST_TRIPLE = $(CFG_TARGET)
|
2014-06-09 15:00:18 -05:00
|
|
|
doc/$(1)/index.html: $$(LIB_DOC_DEP_$(1)) doc/$(1)/
|
2014-08-01 18:48:41 -05:00
|
|
|
@$$(call E, rustdoc: $$@)
|
2014-11-25 17:28:49 -06:00
|
|
|
$$(Q)CFG_LLVM_LINKAGE_FILE=$$(LLVM_LINKAGE_PATH_$(CFG_BUILD)) \
|
|
|
|
$$(RUSTDOC) --cfg dox --cfg stage2 $$<
|
2013-12-28 23:13:19 -06:00
|
|
|
endef
|
|
|
|
|
2014-03-08 08:41:31 -06:00
|
|
|
$(foreach crate,$(DOC_CRATES),$(eval $(call DEF_LIB_DOC,$(crate),DOC_TARGETS)))
|
|
|
|
$(foreach crate,$(COMPILER_DOC_CRATES),$(eval $(call DEF_LIB_DOC,$(crate),COMPILER_DOC_TARGETS)))
|
2012-01-18 16:14:28 -06:00
|
|
|
|
|
|
|
ifdef CFG_DISABLE_DOCS
|
|
|
|
$(info cfg: disabling doc build (CFG_DISABLE_DOCS))
|
2014-03-08 08:41:31 -06:00
|
|
|
DOC_TARGETS :=
|
2014-05-27 19:17:17 -05:00
|
|
|
COMPILER_DOC_TARGETS :=
|
2012-01-18 16:14:28 -06:00
|
|
|
endif
|
|
|
|
|
2014-03-08 08:41:31 -06:00
|
|
|
docs: $(DOC_TARGETS)
|
|
|
|
compiler-docs: $(COMPILER_DOC_TARGETS)
|
2014-12-02 08:20:48 -06:00
|
|
|
|
2015-01-08 12:27:03 -06:00
|
|
|
trpl: doc/book/index.html
|
2014-12-02 08:20:48 -06:00
|
|
|
|
2015-01-09 03:26:31 -06:00
|
|
|
doc/book/index.html: $(RUSTBOOK_EXE) $(wildcard $(S)/src/doc/trpl/*.md) | doc/
|
2014-12-02 08:20:48 -06:00
|
|
|
$(Q)rm -rf doc/book
|
|
|
|
$(Q)$(RUSTBOOK) build $(S)src/doc/trpl doc/book
|