Skip to content

Commit 22a421f

Browse files
committed
Rewrite the doc makefile for doc => src/doc
This continues to generate all documentation into doc, but it now looks for source files in src/doc Closes #11860 Closes #11970
1 parent 91882a4 commit 22a421f

File tree

5 files changed

+65
-76
lines changed

5 files changed

+65
-76
lines changed

.gitignore

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -71,20 +71,7 @@ src/.DS_Store
7171
/stage2/
7272
/stage3/
7373
*.bz2
74-
/doc/html
75-
/doc/latex
76-
/doc/std
77-
/doc/arena
78-
/doc/extra
79-
/doc/flate
80-
/doc/glob
81-
/doc/green
82-
/doc/native
83-
/doc/rustc
84-
/doc/syntax
85-
/doc/rustdoc
86-
/doc/rustuv
87-
/doc/rustpkg
74+
/doc
8875
/nd/
8976
/llvm/
9077
version.md

mk/clean.mk

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,7 @@ clean-misc:
4545
$(Q)rm -Rf $(GENERATED)
4646
$(Q)rm -Rf tmp/*
4747
$(Q)rm -Rf rust-stage0-*.tar.bz2 $(PKG_NAME)-*.tar.gz $(PKG_NAME)-*.exe dist
48-
$(Q)rm -Rf $(foreach ext, \
49-
html aux cp fn ky log pdf pg toc tp vr cps epub, \
50-
$(wildcard doc/*.$(ext)))
51-
$(Q)find doc/std doc/extra -mindepth 1 | xargs rm -Rf
52-
$(Q)rm -Rf doc/version.md
53-
$(Q)rm -Rf $(foreach sub, index styles files search javascript, \
54-
$(wildcard doc/*/$(sub)))
48+
$(Q)rm -Rf doc
5549

5650
define CLEAN_GENERIC
5751

mk/docs.mk

Lines changed: 61 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -15,25 +15,27 @@
1515
DOCS :=
1616
CDOCS :=
1717
DOCS_L10N :=
18-
HTML_DEPS :=
18+
HTML_DEPS := doc/
1919

2020
BASE_DOC_OPTS := --standalone --toc --number-sections
2121
HTML_OPTS = $(BASE_DOC_OPTS) --to=html5 --section-divs --css=rust.css \
2222
--include-before-body=doc/version_info.html --include-in-header=doc/favicon.inc
2323
TEX_OPTS = $(BASE_DOC_OPTS) --include-before-body=doc/version.md --to=latex
2424
EPUB_OPTS = $(BASE_DOC_OPTS) --to=epub
2525

26+
D := $(S)src/doc
27+
2628
######################################################################
2729
# Rust version
2830
######################################################################
2931

30-
doc/version.md: $(MKFILE_DEPS) $(wildcard $(S)doc/*.*)
32+
doc/version.md: $(MKFILE_DEPS) $(wildcard $(D)/*.*) | doc/
3133
@$(call E, version-stamp: $@)
3234
$(Q)echo "$(CFG_VERSION)" >$@
3335

3436
HTML_DEPS += doc/version_info.html
35-
doc/version_info.html: version_info.html.template $(MKFILE_DEPS) \
36-
$(wildcard $(S)doc/*.*)
37+
doc/version_info.html: $(D)/version_info.html.template $(MKFILE_DEPS) \
38+
$(wildcard $(D)/*.*) | doc/
3739
@$(call E, version-info: $@)
3840
sed -e "s/VERSION/$(CFG_RELEASE)/; s/SHORT_HASH/$(shell echo \
3941
$(CFG_VER_HASH) | head -c 8)/;\
@@ -45,17 +47,20 @@ GENERATED += doc/version.md doc/version_info.html
4547
# Docs, from pandoc, rustdoc (which runs pandoc), and node
4648
######################################################################
4749

50+
doc/:
51+
@mkdir -p $@
52+
4853
HTML_DEPS += doc/rust.css
49-
doc/rust.css: rust.css
54+
doc/rust.css: $(D)/rust.css | doc/
5055
@$(call E, cp: $@)
5156
$(Q)cp -a $< $@ 2> /dev/null
5257

53-
doc/full-toc.inc: full-toc.inc
58+
doc/full-toc.inc: $(D)/full-toc.inc | doc/
5459
@$(call E, cp: $@)
5560
$(Q)cp -a $< $@ 2> /dev/null
5661

5762
HTML_DEPS += doc/favicon.inc
58-
doc/favicon.inc: favicon.inc
63+
doc/favicon.inc: $(D)/favicon.inc | doc/
5964
@$(call E, cp: $@)
6065
$(Q)cp -a $< $@ 2> /dev/null
6166

@@ -72,52 +77,52 @@ endif
7277
ifneq ($(NO_DOCS),1)
7378

7479
DOCS += doc/rust.html
75-
doc/rust.html: rust.md doc/full-toc.inc $(HTML_DEPS)
80+
doc/rust.html: $(D)/rust.md doc/full-toc.inc $(HTML_DEPS) | doc/
7681
@$(call E, pandoc: $@)
77-
$(Q)$(CFG_NODE) $(S)doc/prep.js --highlight $< | \
82+
$(Q)$(CFG_NODE) $(D)/prep.js --highlight $< | \
7883
$(CFG_PANDOC) $(HTML_OPTS) --include-in-header=doc/full-toc.inc --output=$@
7984

8085
DOCS += doc/rust.tex
81-
doc/rust.tex: rust.md doc/version.md
86+
doc/rust.tex: $(D)/rust.md doc/version.md | doc/
8287
@$(call E, pandoc: $@)
83-
$(Q)$(CFG_NODE) $(S)doc/prep.js $< | \
88+
$(Q)$(CFG_NODE) $(D)/prep.js $< | \
8489
$(CFG_PANDOC) $(TEX_OPTS) --output=$@
8590

8691
DOCS += doc/rust.epub
87-
doc/rust.epub: rust.md
92+
doc/rust.epub: $(D)/rust.md | doc/
8893
@$(call E, pandoc: $@)
89-
$(Q)$(CFG_NODE) $(S)doc/prep.js --highlight $< | \
94+
$(Q)$(CFG_NODE) $(D)/prep.js --highlight $< | \
9095
$(CFG_PANDOC) $(EPUB_OPTS) --output=$@
9196

9297
DOCS += doc/rustdoc.html
93-
doc/rustdoc.html: rustdoc.md $(HTML_DEPS)
98+
doc/rustdoc.html: $(D)/rustdoc.md $(HTML_DEPS)
9499
@$(call E, pandoc: $@)
95-
$(Q)$(CFG_NODE) $(S)doc/prep.js --highlight $< | \
100+
$(Q)$(CFG_NODE) $(D)/prep.js --highlight $< | \
96101
$(CFG_PANDOC) $(HTML_OPTS) --output=$@
97102

98103
DOCS += doc/tutorial.html
99-
doc/tutorial.html: tutorial.md $(HTML_DEPS)
104+
doc/tutorial.html: $(D)/tutorial.md $(HTML_DEPS)
100105
@$(call E, pandoc: $@)
101-
$(Q)$(CFG_NODE) $(S)doc/prep.js --highlight $< | \
106+
$(Q)$(CFG_NODE) $(D)/prep.js --highlight $< | \
102107
$(CFG_PANDOC) $(HTML_OPTS) --output=$@
103108

104109
DOCS += doc/tutorial.tex
105-
doc/tutorial.tex: tutorial.md doc/version.md
110+
doc/tutorial.tex: $(D)/tutorial.md doc/version.md
106111
@$(call E, pandoc: $@)
107-
$(Q)$(CFG_NODE) $(S)doc/prep.js $< | \
112+
$(Q)$(CFG_NODE) $(D)/prep.js $< | \
108113
$(CFG_PANDOC) $(TEX_OPTS) --output=$@
109114

110115
DOCS += doc/tutorial.epub
111-
doc/tutorial.epub: tutorial.md
116+
doc/tutorial.epub: $(D)/tutorial.md
112117
@$(call E, pandoc: $@)
113-
$(Q)$(CFG_NODE) $(S)doc/prep.js --highlight $< | \
118+
$(Q)$(CFG_NODE) $(D)/prep.js --highlight $< | \
114119
$(CFG_PANDOC) $(EPUB_OPTS) --output=$@
115120

116121

117122
DOCS_L10N += doc/l10n/ja/tutorial.html
118123
doc/l10n/ja/tutorial.html: doc/l10n/ja/tutorial.md doc/version_info.html doc/rust.css
119124
@$(call E, pandoc: $@)
120-
$(Q)$(CFG_NODE) $(S)doc/prep.js --highlight doc/l10n/ja/tutorial.md | \
125+
$(Q)$(CFG_NODE) $(D)/prep.js --highlight doc/l10n/ja/tutorial.md | \
121126
$(CFG_PANDOC) --standalone --toc \
122127
--section-divs --number-sections \
123128
--from=markdown --to=html5 --css=../../rust.css \
@@ -127,95 +132,95 @@ doc/l10n/ja/tutorial.html: doc/l10n/ja/tutorial.md doc/version_info.html doc/rus
127132
# Complementary documentation
128133
#
129134
DOCS += doc/index.html
130-
doc/index.html: index.md $(HTML_DEPS)
135+
doc/index.html: $(D)/index.md $(HTML_DEPS)
131136
@$(call E, pandoc: $@)
132-
$(Q)$(CFG_NODE) $(S)doc/prep.js --highlight $< | \
137+
$(Q)$(CFG_NODE) $(D)/prep.js --highlight $< | \
133138
$(CFG_PANDOC) $(HTML_OPTS) --output=$@
134139

135140
DOCS += doc/complement-lang-faq.html
136-
doc/complement-lang-faq.html: $(S)doc/complement-lang-faq.md doc/full-toc.inc $(HTML_DEPS)
141+
doc/complement-lang-faq.html: $(D)/complement-lang-faq.md doc/full-toc.inc $(HTML_DEPS)
137142
@$(call E, pandoc: $@)
138-
$(Q)$(CFG_NODE) $(S)doc/prep.js --highlight $< | \
143+
$(Q)$(CFG_NODE) $(D)/prep.js --highlight $< | \
139144
$(CFG_PANDOC) $(HTML_OPTS) --include-in-header=doc/full-toc.inc --output=$@
140145

141146
DOCS += doc/complement-project-faq.html
142-
doc/complement-project-faq.html: $(S)doc/complement-project-faq.md $(HTML_DEPS)
147+
doc/complement-project-faq.html: $(D)/complement-project-faq.md $(HTML_DEPS)
143148
@$(call E, pandoc: $@)
144-
$(Q)$(CFG_NODE) $(S)doc/prep.js --highlight $< | \
149+
$(Q)$(CFG_NODE) $(D)/prep.js --highlight $< | \
145150
$(CFG_PANDOC) $(HTML_OPTS) --output=$@
146151

147152
DOCS += doc/complement-usage-faq.html
148-
doc/complement-usage-faq.html: $(S)doc/complement-usage-faq.md $(HTML_DEPS)
153+
doc/complement-usage-faq.html: $(D)/complement-usage-faq.md $(HTML_DEPS)
149154
@$(call E, pandoc: $@)
150-
$(Q)$(CFG_NODE) $(S)doc/prep.js --highlight $< | \
155+
$(Q)$(CFG_NODE) $(D)/prep.js --highlight $< | \
151156
$(CFG_PANDOC) $(HTML_OPTS) --output=$@
152157

153158
DOCS += doc/complement-cheatsheet.html
154-
doc/complement-cheatsheet.html: $(S)doc/complement-cheatsheet.md doc/full-toc.inc $(HTML_DEPS)
159+
doc/complement-cheatsheet.html: $(D)/complement-cheatsheet.md doc/full-toc.inc $(HTML_DEPS)
155160
@$(call E, pandoc: $@)
156-
$(Q)$(CFG_NODE) $(S)doc/prep.js --highlight $< | \
161+
$(Q)$(CFG_NODE) $(D)/prep.js --highlight $< | \
157162
$(CFG_PANDOC) $(HTML_OPTS) --include-in-header=doc/full-toc.inc --output=$@
158163

159164
DOCS += doc/complement-bugreport.html
160-
doc/complement-bugreport.html: $(S)doc/complement-bugreport.md $(HTML_DEPS)
165+
doc/complement-bugreport.html: $(D)/complement-bugreport.md $(HTML_DEPS)
161166
@$(call E, pandoc: $@)
162-
$(Q)$(CFG_NODE) $(S)doc/prep.js --highlight $< | \
167+
$(Q)$(CFG_NODE) $(D)/prep.js --highlight $< | \
163168
$(CFG_PANDOC) $(HTML_OPTS) --output=$@
164169

165170
# Guides
166171

167172
DOCS += doc/guide-macros.html
168-
doc/guide-macros.html: $(S)doc/guide-macros.md $(HTML_DEPS)
173+
doc/guide-macros.html: $(D)/guide-macros.md $(HTML_DEPS)
169174
@$(call E, pandoc: $@)
170-
$(Q)$(CFG_NODE) $(S)doc/prep.js --highlight $< | \
175+
$(Q)$(CFG_NODE) $(D)/prep.js --highlight $< | \
171176
$(CFG_PANDOC) $(HTML_OPTS) --output=$@
172177

173178
DOCS += doc/guide-container.html
174-
doc/guide-container.html: $(S)doc/guide-container.md $(HTML_DEPS)
179+
doc/guide-container.html: $(D)/guide-container.md $(HTML_DEPS)
175180
@$(call E, pandoc: $@)
176-
$(Q)$(CFG_NODE) $(S)doc/prep.js --highlight $< | \
181+
$(Q)$(CFG_NODE) $(D)/prep.js --highlight $< | \
177182
$(CFG_PANDOC) $(HTML_OPTS) --output=$@
178183

179184
DOCS += doc/guide-ffi.html
180-
doc/guide-ffi.html: $(S)doc/guide-ffi.md $(HTML_DEPS)
185+
doc/guide-ffi.html: $(D)/guide-ffi.md $(HTML_DEPS)
181186
@$(call E, pandoc: $@)
182-
$(Q)$(CFG_NODE) $(S)doc/prep.js --highlight $< | \
187+
$(Q)$(CFG_NODE) $(D)/prep.js --highlight $< | \
183188
$(CFG_PANDOC) $(HTML_OPTS) --output=$@
184189

185190
DOCS += doc/guide-testing.html
186-
doc/guide-testing.html: $(S)doc/guide-testing.md $(HTML_DEPS)
191+
doc/guide-testing.html: $(D)/guide-testing.md $(HTML_DEPS)
187192
@$(call E, pandoc: $@)
188-
$(Q)$(CFG_NODE) $(S)doc/prep.js --highlight $< | \
193+
$(Q)$(CFG_NODE) $(D)/prep.js --highlight $< | \
189194
$(CFG_PANDOC) $(HTML_OPTS) --output=$@
190195

191196
DOCS += doc/guide-lifetimes.html
192-
doc/guide-lifetimes.html: $(S)doc/guide-lifetimes.md $(HTML_DEPS)
197+
doc/guide-lifetimes.html: $(D)/guide-lifetimes.md $(HTML_DEPS)
193198
@$(call E, pandoc: $@)
194-
$(Q)$(CFG_NODE) $(S)doc/prep.js --highlight $< | \
199+
$(Q)$(CFG_NODE) $(D)/prep.js --highlight $< | \
195200
$(CFG_PANDOC) $(HTML_OPTS) --output=$@
196201

197202
DOCS += doc/guide-tasks.html
198-
doc/guide-tasks.html: $(S)doc/guide-tasks.md $(HTML_DEPS)
203+
doc/guide-tasks.html: $(D)/guide-tasks.md $(HTML_DEPS)
199204
@$(call E, pandoc: $@)
200-
$(Q)$(CFG_NODE) $(S)doc/prep.js --highlight $< | \
205+
$(Q)$(CFG_NODE) $(D)/prep.js --highlight $< | \
201206
$(CFG_PANDOC) $(HTML_OPTS) --output=$@
202207

203208
DOCS += doc/guide-conditions.html
204-
doc/guide-conditions.html: $(S)doc/guide-conditions.md $(HTML_DEPS)
209+
doc/guide-conditions.html: $(D)/guide-conditions.md $(HTML_DEPS)
205210
@$(call E, pandoc: $@)
206-
$(Q)$(CFG_NODE) $(S)doc/prep.js --highlight $< | \
211+
$(Q)$(CFG_NODE) $(D)/prep.js --highlight $< | \
207212
$(CFG_PANDOC) $(HTML_OPTS) --output=$@
208213

209214
DOCS += doc/guide-pointers.html
210-
doc/guide-pointers.html: $(S)doc/guide-pointers.md $(HTML_DEPS)
215+
doc/guide-pointers.html: $(D)/guide-pointers.md $(HTML_DEPS)
211216
@$(call E, pandoc: $@)
212-
$(Q)$(CFG_NODE) $(S)doc/prep.js --highlight $< | \
217+
$(Q)$(CFG_NODE) $(D)/prep.js --highlight $< | \
213218
$(CFG_PANDOC) $(HTML_OPTS) --output=$@
214219

215220
DOCS += doc/guide-runtime.html
216-
doc/guide-runtime.html: $(S)doc/guide-runtime.md $(HTML_DEPS)
221+
doc/guide-runtime.html: $(D)/guide-runtime.md $(HTML_DEPS)
217222
@$(call E, pandoc: $@)
218-
$(Q)$(CFG_NODE) $(S)doc/prep.js --highlight $< | \
223+
$(Q)$(CFG_NODE) $(D)/prep.js --highlight $< | \
219224
$(CFG_PANDOC) $(HTML_OPTS) --output=$@
220225

221226
ifeq ($(CFG_PDFLATEX),)
@@ -274,8 +279,10 @@ endif
274279
# Rustdoc (libstd/extra)
275280
######################################################################
276281

277-
# The rustdoc executable
278-
RUSTDOC = $(HBIN2_H_$(CFG_BUILD))/rustdoc$(X_$(CFG_BUILD))
282+
# The rustdoc executable, rpath included in case --disable-rpath was provided to
283+
# ./configure
284+
RUSTDOC = $(RPATH_VAR2_T_$(CFG_BUILD)_H_$(CFG_BUILD)) \
285+
$(HBIN2_H_$(CFG_BUILD))/rustdoc$(X_$(CFG_BUILD))
279286

280287
# The library documenting macro
281288
#

mk/tests.mk

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@ tidy:
260260
| grep '^$(S)src/libuv' -v \
261261
| grep '^$(S)src/gyp' -v \
262262
| grep '^$(S)src/etc' -v \
263+
| grep '^$(S)src/doc' -v \
263264
| xargs $(CFG_PYTHON) $(S)src/etc/check-binaries.py
264265

265266
endif
@@ -715,7 +716,7 @@ define DEF_DOC_TEST_HOST
715716
doc-$(2)-extract$(1):
716717
@$$(call E, extract: $(2) tests)
717718
$$(Q)rm -f $(1)/test/doc-$(2)/*.rs
718-
$$(Q)$$(EXTRACT_TESTS) $$(S)doc/$(2).md $(1)/test/doc-$(2)
719+
$$(Q)$$(EXTRACT_TESTS) $$(D)/$(2).md $(1)/test/doc-$(2)
719720

720721
endef
721722

src/doc/prep.js

100755100644
File mode changed.

0 commit comments

Comments
 (0)