1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
|
######################################################################
# Doc variables and rules
######################################################################
DOCS :=
######################################################################
# Pandoc (reference-manual related)
######################################################################
ifeq ($(CFG_PANDOC),)
$(info cfg: no pandoc found, omitting doc/rust.pdf)
else
DOCS += doc/rust.html
doc/rust.html: rust.md doc/version.md doc/keywords.md
@$(call E, pandoc: $@)
$(Q)$(CFG_PANDOC) \
--standalone --toc \
--section-divs \
--number-sections \
--from=markdown --to=html \
--css=rust.css \
--output=$@ \
$<
@$(call E, cp: $(S)doc/rust.css)
-$(Q)cp -a $(S)doc/rust.css doc/rust.css 2> /dev/null
ifeq ($(CFG_PDFLATEX),)
$(info cfg: no pdflatex found, omitting doc/rust.pdf)
else
ifeq ($(CFG_XETEX),)
$(info cfg: no xetex found, disabling doc/rust.pdf)
else
ifeq ($(CFG_LUATEX),)
$(info cfg: lacking luatex, disabling pdflatex)
else
DOCS += doc/rust.pdf
doc/rust.tex: rust.md doc/version.md doc/keywords.md
@$(call E, pandoc: $@)
$(Q)$(CFG_PANDOC) \
--standalone --toc \
--number-sections \
--from=markdown --to=latex \
--output=$@ \
$<
doc/rust.pdf: doc/rust.tex
@$(call E, pdflatex: $@)
$(Q)$(CFG_PDFLATEX) \
-interaction=batchmode \
-output-directory=doc \
$<
endif
endif
endif
######################################################################
# Node (tutorial related)
######################################################################
ifeq ($(CFG_NODE),)
$(info cfg: no node found, omitting doc/tutorial.html)
else
DOCS += doc/tutorial.html
doc/tutorial.html: $(S)doc/tutorial.md
@$(call E, cp: $(S)doc/rust.css)
-$(Q)cp -a $(S)doc/rust.css doc/ 2> /dev/null
@$(call E, pandoc: $@)
$(Q)$(CFG_NODE) $(S)doc/prep.js --highlight $< | \
$(CFG_PANDOC) --standalone --toc \
--section-divs --number-sections \
--from=markdown --to=html --css=rust.css \
--output=$@
endif
endif
######################################################################
# LLnextgen (grammar analysis from refman)
######################################################################
ifeq ($(CFG_LLNEXTGEN),)
$(info cfg: no llnextgen found, omitting grammar-verification)
else
.PHONY: verify-grammar
doc/rust.g: rust.md $(S)src/etc/extract_grammar.py
@$(call E, extract_grammar: $@)
$(Q)$(S)src/etc/extract_grammar.py $< >$@
verify-grammar: doc/rust.g
@$(call E, LLnextgen: $<)
$(Q)$(CFG_LLNEXTGEN) --generate-lexer-wrapper=no $< >$@
$(Q)rm -f doc/rust.c doc/rust.h
endif
######################################################################
# Naturaldocs (library reference related)
######################################################################
ifeq ($(CFG_NATURALDOCS),)
$(info cfg: no naturaldocs found, omitting library doc build)
else
define libdoc
doc/$(1)/index.html: nd/$(1)/Languages.txt nd/$(1)/Topics.txt \
nd/$(1)/lib.css $(2)
@$$(call E, naturaldocs: $$@)
$(CFG_NATURALDOCS) -i $(S)src/lib$(1) -o HTML doc/$(1) \
-p nd/$(1) -r -s Default lib
nd/$(1)/Languages.txt: $(S)doc/Languages.txt
@$$(call E, cp: $$@)
$(Q)cp $$< $$@
nd/$(1)/Topics.txt: $(S)doc/Topics.txt
@$$(call E, cp: $$@)
$(Q)cp $$< $$@
nd/$(1)/lib.css: $(S)doc/lib.css
@$$(call E, cp: $$@)
$(Q)cp $$< $$@
GENERATED += nd/$(1)/Languages.txt \
nd/$(1)/Topics.txt \
nd/$(1)/Menu.txt \
nd/$(1)/Data
DOCS += doc/$(1)/index.html nd/$(1)/lib.css
endef
$(eval $(call libdoc,core,$(CORELIB_CRATE) $(CORELIB_INPUTS)))
$(eval $(call libdoc,std,$(STDLIB_CRATE) $(STDLIB_INPUTS)))
endif
ifdef CFG_DISABLE_DOCS
$(info cfg: disabling doc build (CFG_DISABLE_DOCS))
DOCS :=
endif
doc/version.md: $(MKFILE_DEPS) rust.md
@$(call E, version-stamp: $@)
$(Q)echo "$(CFG_VERSION)" >$@
doc/keywords.md: $(MKFILE_DEPS) rust.md
@$(call E, grep -v: $$@)
$(Q)grep -v '^#' $< >$@
GENERATED += doc/keywords.md doc/version.md
docs: $(DOCS)
|