1 # Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
2 # file at the top-level directory of this distribution and at
3 # http://rust-lang.org/COPYRIGHT.
5 # Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 # http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 # <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 # option. This file may not be copied, modified, or distributed
9 # except according to those terms.
11 ######################################################################
12 # The various pieces of standalone documentation.
14 # The DOCS variable is their names (with no file extension).
16 # RUSTDOC_FLAGS_xyz variables are extra arguments to pass to the
17 # rustdoc invocation for xyz.
19 # RUSTDOC_DEPS_xyz are extra dependencies for the rustdoc invocation
22 # L10N_LANGS are the languages for which the docs have been
24 ######################################################################
26 complement-lang-faq complement-design-faq complement-project-faq \
27 rustdoc reference grammar
29 # Legacy guides, preserved for a while to reduce the number of 404s
30 DOCS += guide-crates guide-error-handling guide-ffi guide-macros guide \
31 guide-ownership guide-plugins guide-pointers guide-strings guide-tasks \
32 guide-testing tutorial intro
35 RUSTDOC_DEPS_reference := doc/full-toc.inc
36 RUSTDOC_FLAGS_reference := --html-in-header=doc/full-toc.inc
40 # Generally no need to edit below here.
42 # The options are passed to the documentation generators.
43 RUSTDOC_HTML_OPTS_NO_CSS = --html-before-content=doc/version_info.html \
44 --html-in-header=doc/favicon.inc \
45 --html-after-content=doc/footer.inc \
46 --markdown-playground-url='https://play.rust-lang.org/'
48 RUSTDOC_HTML_OPTS = $(RUSTDOC_HTML_OPTS_NO_CSS) --markdown-css rust.css
50 # The rustdoc executable...
51 RUSTDOC_EXE = $(HBIN2_H_$(CFG_BUILD))/rustdoc$(X_$(CFG_BUILD))
52 # ...with rpath included in case --disable-rpath was provided to
54 RUSTDOC = $(RPATH_VAR2_T_$(CFG_BUILD)_H_$(CFG_BUILD)) $(RUSTDOC_EXE)
56 # The rustbook executable...
57 RUSTBOOK_EXE = $(HBIN2_H_$(CFG_BUILD))/rustbook$(X_$(CFG_BUILD))
58 # ...with rpath included in case --disable-rpath was provided to
60 RUSTBOOK = $(RPATH_VAR2_T_$(CFG_BUILD)_H_$(CFG_BUILD)) $(RUSTBOOK_EXE)
62 # The error_index_generator executable...
63 ERR_IDX_GEN_EXE = $(HBIN2_H_$(CFG_BUILD))/error_index_generator$(X_$(CFG_BUILD))
64 ERR_IDX_GEN = $(RPATH_VAR2_T_$(CFG_BUILD)_H_$(CFG_BUILD)) $(ERR_IDX_GEN_EXE)
65 ERR_IDX_GEN_MD = $(RPATH_VAR2_T_$(CFG_BUILD)_H_$(CFG_BUILD)) $(ERR_IDX_GEN_EXE) markdown
69 DOC_TARGETS := book nomicon error-index
70 COMPILER_DOC_TARGETS :=
73 # If NO_REBUILD is set then break the dependencies on rustdoc so we
74 # build the documentation without having to rebuild rustdoc.
76 HTML_DEPS := $(RUSTDOC_EXE)
81 ######################################################################
83 ######################################################################
85 HTML_DEPS += doc/version_info.html
86 doc/version_info.html: $(D)/version_info.html.template $(MKFILE_DEPS) \
87 $(wildcard $(D)/*.*) | doc/
88 @$(call E, version-info: $@)
89 $(Q)sed -e "s/VERSION/$(CFG_RELEASE)/; \
90 s/SHORT_HASH/$(CFG_SHORT_VER_HASH)/; \
91 s/STAMP/$(CFG_VER_HASH)/;" $< >$@
93 GENERATED += doc/version_info.html
95 ######################################################################
97 ######################################################################
102 HTML_DEPS += doc/rust.css
103 doc/rust.css: $(D)/rust.css | doc/
105 $(Q)cp -PRp $< $@ 2> /dev/null
107 HTML_DEPS += doc/favicon.inc
108 doc/favicon.inc: $(D)/favicon.inc | doc/
110 $(Q)cp -PRp $< $@ 2> /dev/null
112 doc/full-toc.inc: $(D)/full-toc.inc | doc/
114 $(Q)cp -PRp $< $@ 2> /dev/null
116 HTML_DEPS += doc/footer.inc
117 doc/footer.inc: $(D)/footer.inc | doc/
119 $(Q)cp -PRp $< $@ 2> /dev/null
121 # The (english) documentation for each doc item.
122 DOC_TARGETS += doc/not_found.html
123 doc/not_found.html: $(D)/not_found.md $(HTML_DEPS) | doc/
124 @$(call E, rustdoc: $@)
125 $(Q)$(RUSTDOC) $(RUSTDOC_HTML_OPTS_NO_CSS) \
127 --markdown-css https://doc.rust-lang.org/rust.css $<
132 DOC_TARGETS += doc/$(1).html
133 doc/$(1).html: $$(D)/$(1).md $$(HTML_DEPS) $$(RUSTDOC_DEPS_$(1)) | doc/
134 @$$(call E, rustdoc: $$@)
135 $$(Q)$$(RUSTDOC) $$(RUSTDOC_HTML_OPTS) $$(RUSTDOC_FLAGS_$(1)) $$<
139 $(foreach docname,$(DOCS),$(eval $(call DEF_DOC,$(docname))))
142 ######################################################################
143 # Rustdoc (libstd/extra)
144 ######################################################################
147 # The library documenting macro
149 # $(1) - The crate name (std/extra)
151 # Passes --cfg stage2 to rustdoc because it uses the stage2 librustc.
154 # If NO_REBUILD is set then break the dependencies on rustdoc so we
155 # build crate documentation without having to rebuild rustdoc.
156 ifeq ($(NO_REBUILD),)
161 $$(foreach dep,$$(RUST_DEPS_$(1)_T_$(CFG_BUILD)), \
162 $$(TLIB2_T_$(CFG_BUILD)_H_$(CFG_BUILD))/stamp.$$(dep)) \
163 $$(foreach dep,$$(filter $$(DOC_CRATES), $$(RUST_DEPS_$(1)_T_$(CFG_BUILD))), \
166 LIB_DOC_DEP_$(1) = $$(CRATEFILE_$(1)) $$(RSINPUTS_$(1))
172 doc/$(1)/index.html: CFG_COMPILER_HOST_TRIPLE = $(CFG_TARGET)
173 doc/$(1)/index.html: $$(LIB_DOC_DEP_$(1)) doc/$(1)/
174 @$$(call E, rustdoc: $$@)
175 $$(Q)CFG_LLVM_LINKAGE_FILE=$$(LLVM_LINKAGE_PATH_$(CFG_BUILD)) \
176 $$(RUSTDOC) --cfg dox --cfg stage2 $$(RUSTFLAGS_$(1)) $$<
179 $(foreach crate,$(CRATES),$(eval $(call DEF_LIB_DOC,$(crate))))
181 COMPILER_DOC_TARGETS := $(CRATES:%=doc/%/index.html)
182 ifdef CFG_ENABLE_COMPILER_DOCS
183 DOC_TARGETS += $(COMPILER_DOC_TARGETS)
185 DOC_TARGETS += $(DOC_CRATES:%=doc/%/index.html)
188 ifdef CFG_DISABLE_DOCS
189 $(info cfg: disabling doc build (CFG_DISABLE_DOCS))
191 COMPILER_DOC_TARGETS :=
196 compiler-docs: $(COMPILER_DOC_TARGETS)
198 book: doc/book/index.html
200 doc/book/index.html: $(RUSTBOOK_EXE) $(wildcard $(S)/src/doc/book/*.md) | doc/
201 @$(call E, rustbook: $@)
203 $(Q)$(RUSTBOOK) build $(S)src/doc/book doc/book
205 nomicon: doc/nomicon/index.html
207 doc/nomicon/index.html: $(RUSTBOOK_EXE) $(wildcard $(S)/src/doc/nomicon/*.md) | doc/
208 @$(call E, rustbook: $@)
209 $(Q)rm -rf doc/nomicon
210 $(Q)$(RUSTBOOK) build $(S)src/doc/nomicon doc/nomicon
212 error-index: doc/error-index.html
214 # Metadata used to generate the index is created as a side effect of
215 # the build so this depends on every crate being up to date.
216 doc/error-index.html: $(ERR_IDX_GEN_EXE) $(CSREQ$(2)_T_$(CFG_BUILD)_H_$(CFG_BUILD)) | doc/
217 $(Q)$(call E, error_index_generator: $@)
220 doc/error-index.md: $(ERR_IDX_GEN_EXE) $(CSREQ$(2)_T_$(CFG_BUILD)_H_$(CFG_BUILD)) | doc/
221 $(Q)$(call E, error_index_generator: $@)
222 $(Q)$(ERR_IDX_GEN_MD)