1 ######################################################################
2 # Doc variables and rules
3 ######################################################################
8 ######################################################################
9 # Pandoc (reference-manual related)
10 ######################################################################
12 $(info cfg: no pandoc found, omitting doc/rust.pdf)
16 $(info cfg: no node found, omitting doc/tutorial.html)
19 doc/rust.css: rust.css
21 $(Q)cp -a $< $@ 2> /dev/null
24 doc/rust.html: rust.md doc/version_info.html doc/rust.css
25 @$(call E, pandoc: $@)
26 $(Q)$(CFG_NODE) $(S)doc/prep.js --highlight $< | \
31 --from=markdown --to=html \
33 --include-before-body=doc/version_info.html \
37 ifeq ($(CFG_PDFLATEX),)
38 $(info cfg: no pdflatex found, omitting doc/rust.pdf)
41 $(info cfg: no xetex found, disabling doc/rust.pdf)
44 $(info cfg: lacking luatex, disabling pdflatex)
48 doc/rust.tex: rust.md doc/version.md
49 @$(call E, pandoc: $@)
50 $(Q)$(CFG_NODE) $(S)doc/prep.js $< | \
54 --from=markdown --to=latex \
57 doc/rust.pdf: doc/rust.tex
58 @$(call E, pdflatex: $@)
60 -interaction=batchmode \
61 -output-directory=doc \
68 ######################################################################
69 # Node (tutorial related)
70 ######################################################################
72 $(info cfg: no node found, omitting doc/tutorial.html)
75 DOCS += doc/tutorial.html
76 doc/tutorial.html: tutorial.md doc/version_info.html doc/rust.css
77 @$(call E, pandoc: $@)
78 $(Q)$(CFG_NODE) $(S)doc/prep.js --highlight $< | \
79 $(CFG_PANDOC) --standalone --toc \
80 --section-divs --number-sections \
81 --from=markdown --to=html --css=rust.css \
82 --include-before-body=doc/version_info.html \
85 DOCS += doc/tutorial-macros.html
86 doc/tutorial-macros.html: tutorial-macros.md doc/version_info.html \
88 @$(call E, pandoc: $@)
89 $(Q)$(CFG_NODE) $(S)doc/prep.js --highlight $< | \
90 $(CFG_PANDOC) --standalone --toc \
91 --section-divs --number-sections \
92 --from=markdown --to=html --css=rust.css \
93 --include-before-body=doc/version_info.html \
96 DOCS += doc/tutorial-ffi.html
97 doc/tutorial-ffi.html: tutorial-ffi.md doc/version_info.html doc/rust.css
98 @$(call E, pandoc: $@)
99 $(Q)$(CFG_NODE) $(S)doc/prep.js --highlight $< | \
100 $(CFG_PANDOC) --standalone --toc \
101 --section-divs --number-sections \
102 --from=markdown --to=html --css=rust.css \
103 --include-before-body=doc/version_info.html \
106 DOCS += doc/tutorial-borrowed-ptr.html
107 doc/tutorial-borrowed-ptr.html: tutorial-borrowed-ptr.md doc/version_info.html doc/rust.css
108 @$(call E, pandoc: $@)
109 $(Q)$(CFG_NODE) $(S)doc/prep.js --highlight $< | \
110 $(CFG_PANDOC) --standalone --toc \
111 --section-divs --number-sections \
112 --from=markdown --to=html --css=rust.css \
113 --include-before-body=doc/version_info.html \
120 ######################################################################
121 # LLnextgen (grammar analysis from refman)
122 ######################################################################
123 ifeq ($(CFG_LLNEXTGEN),)
124 $(info cfg: no llnextgen found, omitting grammar-verification)
126 .PHONY: verify-grammar
128 doc/rust.g: rust.md $(S)src/etc/extract_grammar.py
129 @$(call E, extract_grammar: $@)
130 $(Q)$(S)src/etc/extract_grammar.py $< >$@
132 verify-grammar: doc/rust.g
133 @$(call E, LLnextgen: $<)
134 $(Q)$(CFG_LLNEXTGEN) --generate-lexer-wrapper=no $< >$@
135 $(Q)rm -f doc/rust.c doc/rust.h
139 ######################################################################
140 # Rustdoc (libcore/std)
141 ######################################################################
143 ifeq ($(CFG_PANDOC),)
144 $(info cfg: no pandoc found, omitting library doc build)
147 # The rustdoc executable
148 RUSTDOC = $(HBIN2_H_$(CFG_HOST_TRIPLE))/rustdoc$(X)
150 # The library documenting macro
151 # $(1) - The output directory
152 # $(2) - The crate file
153 # $(3) - The crate soruce files
155 doc/$(1)/index.html: $(2) $(3) $$(RUSTDOC) doc/$(1)/rust.css
156 @$$(call E, rustdoc: $$@)
157 $(Q)$(RUSTDOC) $(2) --output-dir=doc/$(1)
159 doc/$(1)/rust.css: rust.css
163 DOCS += doc/$(1)/index.html
166 $(eval $(call libdoc,core,$(CORELIB_CRATE),$(CORELIB_INPUTS)))
167 $(eval $(call libdoc,std,$(STDLIB_CRATE),$(STDLIB_INPUTS)))
171 ifdef CFG_DISABLE_DOCS
172 $(info cfg: disabling doc build (CFG_DISABLE_DOCS))
177 doc/version.md: $(MKFILE_DEPS) rust.md
178 @$(call E, version-stamp: $@)
179 $(Q)echo "$(CFG_VERSION)" >$@
181 doc/version_info.html: version_info.html.template
182 @$(call E, version-info: $@)
183 sed -e "s/VERSION/$(CFG_RELEASE)/; s/SHORT_HASH/$(shell echo \
184 $(CFG_VER_HASH) | head -c 8)/;\
185 s/STAMP/$(CFG_VER_HASH)/;" $< >$@
187 GENERATED += doc/version.md