2013-10-11 20:21:46 +02:00
|
|
|
# Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
|
2012-12-11 02:32:48 +01: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 22:18:52 +02:00
|
|
|
######################################################################
|
2014-03-08 15:41:31 +01:00
|
|
|
# The various pieces of standalone documentation: guides, tutorial,
|
|
|
|
# manual etc.
|
|
|
|
#
|
|
|
|
# The DOCS variable is their names (with no file extension).
|
|
|
|
#
|
2014-03-09 05:54:16 +01:00
|
|
|
# PDF_DOCS lists the targets for which PDF documentation should be
|
|
|
|
# build.
|
|
|
|
#
|
2014-03-08 15:41:31 +01: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 22:18:52 +02:00
|
|
|
######################################################################
|
2014-04-09 01:13:33 +02:00
|
|
|
DOCS := index intro tutorial guide-ffi guide-macros guide-lifetimes \
|
2014-03-09 13:52:16 +01:00
|
|
|
guide-tasks guide-container guide-pointers guide-testing \
|
|
|
|
guide-runtime complement-bugreport complement-cheatsheet \
|
2014-05-23 07:01:44 +02:00
|
|
|
complement-lang-faq complement-design-faq complement-project-faq rust \
|
|
|
|
rustdoc guide-unsafe
|
2014-03-08 15:41:31 +01:00
|
|
|
|
2014-03-09 05:54:16 +01:00
|
|
|
PDF_DOCS := tutorial rust
|
|
|
|
|
2014-03-08 15:41:31 +01:00
|
|
|
RUSTDOC_DEPS_rust := doc/full-toc.inc
|
|
|
|
RUSTDOC_FLAGS_rust := --markdown-in-header=doc/full-toc.inc
|
|
|
|
|
|
|
|
L10N_LANGS := ja
|
|
|
|
|
|
|
|
# Generally no need to edit below here.
|
2011-05-01 22:18:52 +02:00
|
|
|
|
2014-03-08 15:41:31 +01:00
|
|
|
# The options are passed to the documentation generators.
|
2014-05-14 19:45:51 +02:00
|
|
|
RUSTDOC_HTML_OPTS_NO_CSS = --markdown-before-content=doc/version_info.html \
|
2014-03-08 15:41:31 +01:00
|
|
|
--markdown-in-header=doc/favicon.inc --markdown-after-content=doc/footer.inc
|
2011-05-01 22:18:52 +02:00
|
|
|
|
2014-05-14 19:45:51 +02:00
|
|
|
RUSTDOC_HTML_OPTS = $(RUSTDOC_HTML_OPTS_NO_CSS) --markdown-css rust.css
|
|
|
|
|
2014-03-08 15:41:31 +01:00
|
|
|
PANDOC_BASE_OPTS := --standalone --toc --number-sections
|
2014-03-09 12:41:27 +01:00
|
|
|
PANDOC_TEX_OPTS = $(PANDOC_BASE_OPTS) --include-before-body=doc/version.tex \
|
2014-03-08 15:41:31 +01:00
|
|
|
--from=markdown --include-before-body=doc/footer.tex --to=latex
|
|
|
|
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-13 04:10:30 +01:00
|
|
|
|
2014-01-28 23:15:29 +01:00
|
|
|
D := $(S)src/doc
|
|
|
|
|
2014-03-08 15:41:31 +01:00
|
|
|
DOC_TARGETS :=
|
|
|
|
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
|
|
|
|
|
|
|
|
# Check for the various external utilities for the EPUB/PDF docs:
|
|
|
|
|
|
|
|
ifeq ($(CFG_PDFLATEX),)
|
2014-03-09 11:21:05 +01:00
|
|
|
$(info cfg: no pdflatex found, deferring to xelatex)
|
|
|
|
ifeq ($(CFG_XELATEX),)
|
|
|
|
$(info cfg: no xelatex found, deferring to lualatex)
|
|
|
|
ifeq ($(CFG_LUALATEX),)
|
|
|
|
$(info cfg: no lualatex found, disabling LaTeX docs)
|
|
|
|
NO_PDF_DOCS = 1
|
|
|
|
else
|
|
|
|
CFG_LATEX := $(CFG_LUALATEX)
|
|
|
|
endif
|
2014-03-08 15:41:31 +01:00
|
|
|
else
|
2014-03-09 11:21:05 +01:00
|
|
|
CFG_LATEX := $(CFG_XELATEX)
|
2014-03-08 15:41:31 +01:00
|
|
|
endif
|
2014-03-09 11:21:05 +01:00
|
|
|
else
|
|
|
|
CFG_LATEX := $(CFG_PDFLATEX)
|
2014-03-08 15:41:31 +01:00
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
|
|
ifeq ($(CFG_PANDOC),)
|
|
|
|
$(info cfg: no pandoc found, omitting PDF and EPUB docs)
|
|
|
|
ONLY_HTML_DOCS = 1
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
2014-01-06 22:38:20 +01:00
|
|
|
######################################################################
|
|
|
|
# Rust version
|
|
|
|
######################################################################
|
2014-01-17 19:38:48 +01:00
|
|
|
|
2014-03-09 12:41:27 +01:00
|
|
|
doc/version.tex: $(MKFILE_DEPS) $(wildcard $(D)/*.*) | doc/
|
2014-01-06 22:38:20 +01:00
|
|
|
@$(call E, version-stamp: $@)
|
|
|
|
$(Q)echo "$(CFG_VERSION)" >$@
|
|
|
|
|
|
|
|
HTML_DEPS += doc/version_info.html
|
2014-01-28 23:15:29 +01:00
|
|
|
doc/version_info.html: $(D)/version_info.html.template $(MKFILE_DEPS) \
|
|
|
|
$(wildcard $(D)/*.*) | doc/
|
2014-01-06 22:38:20 +01:00
|
|
|
@$(call E, version-info: $@)
|
2014-06-01 20:09:30 +02:00
|
|
|
$(Q)sed -e "s/VERSION/$(CFG_RELEASE)/; s/SHORT_HASH/$(shell echo \
|
2014-01-06 22:38:20 +01:00
|
|
|
$(CFG_VER_HASH) | head -c 8)/;\
|
|
|
|
s/STAMP/$(CFG_VER_HASH)/;" $< >$@
|
|
|
|
|
2014-03-09 12:41:27 +01:00
|
|
|
GENERATED += doc/version.tex doc/version_info.html
|
2014-01-06 22:38:20 +01:00
|
|
|
|
2012-01-18 23:14:28 +01:00
|
|
|
######################################################################
|
2014-03-09 11:06:03 +01:00
|
|
|
# Docs, from rustdoc and sometimes pandoc
|
2012-01-18 23:14:28 +01:00
|
|
|
######################################################################
|
2012-03-21 01:50:32 +01:00
|
|
|
|
2014-01-28 23:15:29 +01:00
|
|
|
doc/:
|
|
|
|
@mkdir -p $@
|
|
|
|
|
2013-12-23 03:21:45 +01:00
|
|
|
HTML_DEPS += doc/rust.css
|
2014-01-28 23:15:29 +01:00
|
|
|
doc/rust.css: $(D)/rust.css | doc/
|
2012-03-27 02:59:09 +02:00
|
|
|
@$(call E, cp: $@)
|
|
|
|
$(Q)cp -a $< $@ 2> /dev/null
|
|
|
|
|
2014-02-07 20:46:39 +01: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 23:15:29 +01:00
|
|
|
doc/full-toc.inc: $(D)/full-toc.inc | doc/
|
2012-12-15 03:06:11 +01:00
|
|
|
@$(call E, cp: $@)
|
|
|
|
$(Q)cp -a $< $@ 2> /dev/null
|
|
|
|
|
2014-02-07 20:46:39 +01: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 15:41:31 +01:00
|
|
|
# The (english) documentation for each doc item.
|
2013-04-24 07:51:48 +02:00
|
|
|
|
2014-03-09 05:54:16 +01: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 18:35:17 +01:00
|
|
|
doc/footer.tex: $(D)/footer.inc | doc/
|
2014-03-12 18:31:52 +01:00
|
|
|
@$(call E, pandoc: $@)
|
|
|
|
$(CFG_PANDOC) --from=html --to=latex $< --output=$@
|
2014-03-12 18:35:17 +01:00
|
|
|
|
2014-05-14 19:45:51 +02:00
|
|
|
# HTML (rustdoc)
|
|
|
|
DOC_TARGETS += doc/not_found.html
|
|
|
|
doc/not_found.html: $(D)/not_found.md $(HTML_DEPS) | doc/
|
2014-06-01 20:09:30 +02:00
|
|
|
@$(call E, rustdoc: $@)
|
|
|
|
$(Q)$(RUSTDOC) $(RUSTDOC_HTML_OPTS_NO_CSS) \
|
|
|
|
--markdown-css http://doc.rust-lang.org/rust.css $<
|
2014-05-14 19:45:51 +02:00
|
|
|
|
2014-03-08 15:41:31 +01: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 20:09:30 +02:00
|
|
|
$$(Q)$$(RUSTDOC) $$(RUSTDOC_HTML_OPTS) $$(RUSTDOC_FLAGS_$(1)) $$<
|
2014-03-08 15:41:31 +01: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 11:06:03 +01:00
|
|
|
$$(CFG_PANDOC) $$(PANDOC_EPUB_OPTS) $$< --output=$$@
|
2014-03-08 15:41:31 +01:00
|
|
|
|
|
|
|
# PDF (md =(pandoc)=> tex =(pdflatex)=> pdf)
|
|
|
|
DOC_TARGETS += doc/$(1).tex
|
2014-03-09 12:41:27 +01:00
|
|
|
doc/$(1).tex: $$(D)/$(1).md doc/footer.tex doc/version.tex | doc/
|
2014-03-08 15:41:31 +01:00
|
|
|
@$$(call E, pandoc: $$@)
|
2014-03-09 11:06:03 +01:00
|
|
|
$$(CFG_PANDOC) $$(PANDOC_TEX_OPTS) $$< --output=$$@
|
2014-03-08 15:41:31 +01:00
|
|
|
|
|
|
|
ifneq ($(NO_PDF_DOCS),1)
|
2014-03-09 05:54:16 +01:00
|
|
|
ifeq ($$(SHOULD_BUILD_PDF_DOC_$(1)),1)
|
2014-03-08 15:41:31 +01:00
|
|
|
DOC_TARGETS += doc/$(1).pdf
|
|
|
|
doc/$(1).pdf: doc/$(1).tex
|
2014-03-09 11:21:05 +01:00
|
|
|
@$$(call E, latex compiler: $$@)
|
|
|
|
$$(Q)$$(CFG_LATEX) \
|
2014-03-08 15:41:31 +01:00
|
|
|
-interaction=batchmode \
|
|
|
|
-output-directory=doc \
|
|
|
|
$$<
|
2014-03-09 05:54:16 +01:00
|
|
|
endif # SHOULD_BUILD_PDF_DOCS_$(1)
|
2014-03-08 15:41:31 +01:00
|
|
|
endif # NO_PDF_DOCS
|
|
|
|
|
|
|
|
endif # ONLY_HTML_DOCS
|
|
|
|
|
|
|
|
endef
|
|
|
|
|
|
|
|
$(foreach docname,$(DOCS),$(eval $(call DEF_DOC,$(docname))))
|
2013-04-24 07:51:48 +02:00
|
|
|
|
2014-03-08 15:41:31 +01:00
|
|
|
|
|
|
|
# Localized documentation
|
|
|
|
|
|
|
|
# FIXME: I (huonw) haven't actually been able to test properly, since
|
|
|
|
# e.g. (by default) I'm doing an out-of-tree build (#12763), but even
|
|
|
|
# adjusting for that, the files are too old(?) and are rejected by
|
|
|
|
# po4a.
|
2013-12-23 03:21:45 +01:00
|
|
|
#
|
2014-03-08 15:41:31 +01:00
|
|
|
# As such, I've attempted to get it working as much as possible (and
|
|
|
|
# switching from pandoc to rustdoc), but preserving the old behaviour
|
|
|
|
# (e.g. only running on the tutorial)
|
|
|
|
.PHONY: l10n-mds
|
|
|
|
l10n-mds: $(D)/po4a.conf \
|
|
|
|
$(foreach lang,$(L10N_LANG),$(D)/po/$(lang)/*.md.po)
|
|
|
|
$(warning WARNING: localized documentation is experimental)
|
|
|
|
po4a --copyright-holder="The Rust Project Developers" \
|
|
|
|
--package-name="Rust" \
|
|
|
|
--package-version="$(CFG_RELEASE)" \
|
|
|
|
-M UTF-8 -L UTF-8 \
|
|
|
|
$(D)/po4a.conf
|
|
|
|
|
|
|
|
define DEF_L10N_DOC
|
|
|
|
DOC_L10N_TARGETS += doc/l10n/$(1)/$(2).html
|
|
|
|
doc/l10n/$(1)/$(2).html: l10n-mds $$(HTML_DEPS) $$(RUSTDOC_DEPS_$(2))
|
|
|
|
@$$(call E, rustdoc: $$@)
|
|
|
|
$$(RUSTDOC) $$(RUSTDOC_HTML_OPTS) $$(RUSTDOC_FLAGS_$(1)) doc/l10n/$(1)/$(2).md
|
|
|
|
endef
|
|
|
|
|
|
|
|
$(foreach lang,$(L10N_LANGS),$(eval $(call DEF_L10N_DOC,$(lang),tutorial)))
|
2012-01-13 04:10:30 +01:00
|
|
|
|
2012-01-18 23:14:28 +01:00
|
|
|
|
|
|
|
######################################################################
|
|
|
|
# LLnextgen (grammar analysis from refman)
|
|
|
|
######################################################################
|
2014-01-17 19:38:48 +01:00
|
|
|
|
2012-01-18 23:14:28 +01:00
|
|
|
ifeq ($(CFG_LLNEXTGEN),)
|
|
|
|
$(info cfg: no llnextgen found, omitting grammar-verification)
|
|
|
|
else
|
|
|
|
.PHONY: verify-grammar
|
|
|
|
|
2014-03-26 23:20:59 +01:00
|
|
|
doc/rust.g: $(D)/rust.md $(S)src/etc/extract_grammar.py
|
2012-01-18 23:14:28 +01:00
|
|
|
@$(call E, extract_grammar: $@)
|
2013-01-03 08:53:05 +01:00
|
|
|
$(Q)$(CFG_PYTHON) $(S)src/etc/extract_grammar.py $< >$@
|
2012-01-18 23:14:28 +01:00
|
|
|
|
|
|
|
verify-grammar: doc/rust.g
|
|
|
|
@$(call E, LLnextgen: $<)
|
|
|
|
$(Q)$(CFG_LLNEXTGEN) --generate-lexer-wrapper=no $< >$@
|
|
|
|
$(Q)rm -f doc/rust.c doc/rust.h
|
2012-01-18 01:49:57 +01:00
|
|
|
endif
|
|
|
|
|
|
|
|
|
2012-01-18 23:14:28 +01:00
|
|
|
######################################################################
|
2013-05-17 19:45:09 +02:00
|
|
|
# Rustdoc (libstd/extra)
|
2012-01-18 23:14:28 +01:00
|
|
|
######################################################################
|
2011-05-01 22:18:52 +02:00
|
|
|
|
2011-12-06 01:46:37 +01:00
|
|
|
|
2012-03-10 07:53:46 +01:00
|
|
|
# The library documenting macro
|
2014-01-25 04:27:22 +01:00
|
|
|
#
|
2013-09-22 08:25:48 +02:00
|
|
|
# $(1) - The crate name (std/extra)
|
2013-11-25 05:31:21 +01:00
|
|
|
#
|
|
|
|
# Passes --cfg stage2 to rustdoc because it uses the stage2 librustc.
|
2014-03-08 15:41:31 +01: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-01-25 04:27:22 +01:00
|
|
|
$$(TLIB2_T_$(CFG_BUILD)_H_$(CFG_BUILD))/stamp.$$(dep))
|
2014-03-08 15:41:31 +01:00
|
|
|
else
|
|
|
|
LIB_DOC_DEP_$(1) = $$(CRATEFILE_$(1)) $$(RSINPUTS_$(1))
|
|
|
|
endif
|
2014-02-07 00:43:27 +01:00
|
|
|
|
2014-03-08 15:41:31 +01:00
|
|
|
$(2) += doc/$(1)/index.html
|
2014-04-08 19:45:53 +02:00
|
|
|
doc/$(1)/index.html: CFG_COMPILER_HOST_TRIPLE = $(CFG_TARGET)
|
2014-03-08 15:41:31 +01:00
|
|
|
doc/$(1)/index.html: $$(LIB_DOC_DEP_$(1))
|
|
|
|
@$$(call E, rustdoc $$@)
|
2014-04-02 00:04:42 +02:00
|
|
|
$$(Q)$$(RUSTDOC) --cfg dox --cfg stage2 $$<
|
2013-12-29 06:13:19 +01:00
|
|
|
endef
|
|
|
|
|
2014-03-08 15:41:31 +01: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 23:14:28 +01:00
|
|
|
|
|
|
|
ifdef CFG_DISABLE_DOCS
|
|
|
|
$(info cfg: disabling doc build (CFG_DISABLE_DOCS))
|
2014-03-08 15:41:31 +01:00
|
|
|
DOC_TARGETS :=
|
2014-05-28 02:17:17 +02:00
|
|
|
COMPILER_DOC_TARGETS :=
|
2012-01-18 23:14:28 +01:00
|
|
|
endif
|
|
|
|
|
2014-03-08 15:41:31 +01:00
|
|
|
docs: $(DOC_TARGETS)
|
|
|
|
compiler-docs: $(COMPILER_DOC_TARGETS)
|
2013-08-08 15:38:33 +02:00
|
|
|
|
2014-03-08 15:41:31 +01:00
|
|
|
docs-l10n: $(DOC_L10N_TARGETS)
|
2013-07-07 21:12:00 +02:00
|
|
|
|
|
|
|
.PHONY: docs-l10n
|