Skip to content

Commit 1a17ccb

Browse files
committed
---
yaml --- r: 232325 b: refs/heads/try c: 872f8c3 h: refs/heads/master i: 232323: b9589dc v: v3
1 parent 70718fd commit 1a17ccb

File tree

14 files changed

+122
-290
lines changed

14 files changed

+122
-290
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: edeb4f1c86cbf6af8ef9874d4b3af50f721ea1b8
33
refs/heads/snap-stage3: 1af31d4974e33027a68126fa5a5a3c2c6491824f
4-
refs/heads/try: 2da80ef114f33250bd9873b53bcdf76ab36fe9cd
4+
refs/heads/try: 872f8c3234ba02b32dd40a5be08f5b1328579197
55
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
66
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
77
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try/mk/docs.mk

Lines changed: 89 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
#
1414
# The DOCS variable is their names (with no file extension).
1515
#
16+
# PDF_DOCS lists the targets for which PDF documentation should be
17+
# build.
18+
#
1619
# RUSTDOC_FLAGS_xyz variables are extra arguments to pass to the
1720
# rustdoc invocation for xyz.
1821
#
@@ -32,6 +35,8 @@ DOCS += guide-crates guide-error-handling guide-ffi guide-macros guide \
3235
guide-testing
3336

3437

38+
PDF_DOCS := reference
39+
3540
RUSTDOC_DEPS_reference := doc/full-toc.inc
3641
RUSTDOC_FLAGS_reference := --html-in-header=doc/full-toc.inc
3742

@@ -47,6 +52,13 @@ RUSTDOC_HTML_OPTS_NO_CSS = --html-before-content=doc/version_info.html \
4752

4853
RUSTDOC_HTML_OPTS = $(RUSTDOC_HTML_OPTS_NO_CSS) --markdown-css rust.css
4954

55+
PANDOC_BASE_OPTS := --standalone --toc --number-sections
56+
PANDOC_TEX_OPTS = $(PANDOC_BASE_OPTS) --from=markdown --to=latex \
57+
--include-before-body=doc/version.tex \
58+
--include-before-body=doc/footer.tex \
59+
--include-in-header=doc/uptack.tex
60+
PANDOC_EPUB_OPTS = $(PANDOC_BASE_OPTS) --to=epub
61+
5062
# The rustdoc executable...
5163
RUSTDOC_EXE = $(HBIN2_H_$(CFG_BUILD))/rustdoc$(X_$(CFG_BUILD))
5264
# ...with rpath included in case --disable-rpath was provided to
@@ -77,10 +89,30 @@ else
7789
HTML_DEPS :=
7890
endif
7991

92+
# Check for xelatex
93+
94+
ifneq ($(CFG_XELATEX),)
95+
CFG_LATEX := $(CFG_XELATEX)
96+
XELATEX = 1
97+
else
98+
$(info cfg: no xelatex found, disabling LaTeX docs)
99+
NO_PDF_DOCS = 1
100+
endif
101+
102+
ifeq ($(CFG_PANDOC),)
103+
$(info cfg: no pandoc found, omitting PDF and EPUB docs)
104+
ONLY_HTML_DOCS = 1
105+
endif
106+
107+
80108
######################################################################
81109
# Rust version
82110
######################################################################
83111

112+
doc/version.tex: $(MKFILE_DEPS) $(wildcard $(D)/*.*) | doc/
113+
@$(call E, version-stamp: $@)
114+
$(Q)echo "$(CFG_VERSION)" >$@
115+
84116
HTML_DEPS += doc/version_info.html
85117
doc/version_info.html: $(D)/version_info.html.template $(MKFILE_DEPS) \
86118
$(wildcard $(D)/*.*) | doc/
@@ -89,10 +121,10 @@ doc/version_info.html: $(D)/version_info.html.template $(MKFILE_DEPS) \
89121
s/SHORT_HASH/$(CFG_SHORT_VER_HASH)/; \
90122
s/STAMP/$(CFG_VER_HASH)/;" $< >$@
91123

92-
GENERATED += doc/version_info.html
124+
GENERATED += doc/version.tex doc/version_info.html
93125

94126
######################################################################
95-
# Docs from rustdoc
127+
# Docs, from rustdoc and sometimes pandoc
96128
######################################################################
97129

98130
doc/:
@@ -118,6 +150,20 @@ doc/footer.inc: $(D)/footer.inc | doc/
118150
$(Q)cp -PRp $< $@ 2> /dev/null
119151

120152
# The (english) documentation for each doc item.
153+
154+
define DEF_SHOULD_BUILD_PDF_DOC
155+
SHOULD_BUILD_PDF_DOC_$(1) = 1
156+
endef
157+
$(foreach docname,$(PDF_DOCS),$(eval $(call DEF_SHOULD_BUILD_PDF_DOC,$(docname))))
158+
159+
doc/footer.tex: $(D)/footer.inc | doc/
160+
@$(call E, pandoc: $@)
161+
$(CFG_PANDOC) --from=html --to=latex $< --output=$@
162+
163+
doc/uptack.tex: $(D)/uptack.tex | doc/
164+
$(Q)cp $< $@
165+
166+
# HTML (rustdoc)
121167
DOC_TARGETS += doc/not_found.html
122168
doc/not_found.html: $(D)/not_found.md $(HTML_DEPS) | doc/
123169
@$(call E, rustdoc: $@)
@@ -133,6 +179,47 @@ doc/$(1).html: $$(D)/$(1).md $$(HTML_DEPS) $$(RUSTDOC_DEPS_$(1)) | doc/
133179
@$$(call E, rustdoc: $$@)
134180
$$(Q)$$(RUSTDOC) $$(RUSTDOC_HTML_OPTS) $$(RUSTDOC_FLAGS_$(1)) $$<
135181

182+
ifneq ($(ONLY_HTML_DOCS),1)
183+
184+
# EPUB (pandoc directly)
185+
DOC_TARGETS += doc/$(1).epub
186+
doc/$(1).epub: $$(D)/$(1).md | doc/
187+
@$$(call E, pandoc: $$@)
188+
$$(CFG_PANDOC) $$(PANDOC_EPUB_OPTS) $$< --output=$$@
189+
190+
# PDF (md =(pandoc)=> tex =(pdflatex)=> pdf)
191+
DOC_TARGETS += doc/$(1).tex
192+
doc/$(1).tex: $$(D)/$(1).md doc/uptack.tex doc/footer.tex doc/version.tex | doc/
193+
@$$(call E, pandoc: $$@)
194+
$$(CFG_PANDOC) $$(PANDOC_TEX_OPTS) $$< --output=$$@
195+
196+
ifneq ($(NO_PDF_DOCS),1)
197+
ifeq ($$(SHOULD_BUILD_PDF_DOC_$(1)),1)
198+
DOC_TARGETS += doc/$(1).pdf
199+
ifneq ($(XELATEX),1)
200+
doc/$(1).pdf: doc/$(1).tex
201+
@$$(call E, latex compiler: $$@)
202+
$$(Q)$$(CFG_LATEX) \
203+
-interaction=batchmode \
204+
-output-directory=doc \
205+
$$<
206+
else
207+
# The version of xelatex on the snap bots seemingly ingores -output-directory
208+
# So we'll output to . and move to the doc directory manually.
209+
# This will leave some intermediate files in the build directory.
210+
doc/$(1).pdf: doc/$(1).tex
211+
@$$(call E, latex compiler: $$@)
212+
$$(Q)$$(CFG_LATEX) \
213+
-interaction=batchmode \
214+
-output-directory=. \
215+
$$<
216+
$$(Q)mv ./$(1).pdf $$@
217+
endif # XELATEX
218+
endif # SHOULD_BUILD_PDF_DOCS_$(1)
219+
endif # NO_PDF_DOCS
220+
221+
endif # ONLY_HTML_DOCS
222+
136223
endef
137224

138225
$(foreach docname,$(DOCS),$(eval $(call DEF_DOC,$(docname))))

branches/try/src/doc/README.md

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Rust documentations
22

3+
## Dependencies
4+
5+
[Pandoc](http://johnmacfarlane.net/pandoc/installing.html), a universal
6+
document converter, is required to generate docs as HTML from Rust's
7+
source code.
8+
39
## Building
410

511
To generate all the docs, just run `make docs` from the root of the repository.
@@ -20,12 +26,15 @@ To generate an HTML version of a doc from Markdown manually, you can do
2026
something like:
2127

2228
~~~~
23-
rustdoc reference.md
29+
pandoc --from=markdown --to=html5 --number-sections -o reference.html reference.md
2430
~~~~
2531

2632
(`reference.md` being the Rust Reference Manual.)
2733

28-
An overview of how to use the `rustdoc` command is available [in the docs][1].
29-
Further details are available from the command line by with `rustdoc --help`.
34+
The syntax for pandoc flavored markdown can be found at:
35+
36+
- http://johnmacfarlane.net/pandoc/README.html#pandocs-markdown
37+
38+
A nice quick reference (for non-pandoc markdown) is at:
3039

31-
[1]: https://github.com/rust-lang/rust/blob/master/src/doc/trpl/documentation.md
40+
- http://kramdown.gettalong.org/quickref.html

branches/try/src/libcore/slice.rs

Lines changed: 0 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ use ptr;
5050
use mem;
5151
use mem::size_of;
5252
use marker::{Send, Sync, self};
53-
use num::wrapping::OverflowingOps;
5453
use raw::Repr;
5554
// Avoid conflicts with *both* the Slice trait (buggy) and the `slice::raw` module.
5655
use raw::Slice as RawSlice;
@@ -1181,34 +1180,6 @@ impl<'a, T> Iterator for Windows<'a, T> {
11811180
(size, Some(size))
11821181
}
11831182
}
1184-
1185-
#[inline]
1186-
fn count(self) -> usize {
1187-
self.size_hint().0
1188-
}
1189-
1190-
#[inline]
1191-
fn nth(&mut self, n: usize) -> Option<Self::Item> {
1192-
let (end, overflow) = self.size.overflowing_add(n);
1193-
if end > self.v.len() || overflow {
1194-
self.v = &[];
1195-
None
1196-
} else {
1197-
let nth = &self.v[n..end];
1198-
self.v = &self.v[n+1..];
1199-
Some(nth)
1200-
}
1201-
}
1202-
1203-
#[inline]
1204-
fn last(self) -> Option<Self::Item> {
1205-
if self.size > self.v.len() {
1206-
None
1207-
} else {
1208-
let start = self.v.len() - self.size;
1209-
Some(&self.v[start..])
1210-
}
1211-
}
12121183
}
12131184

12141185
#[stable(feature = "rust1", since = "1.0.0")]
@@ -1295,38 +1266,6 @@ impl<'a, T> Iterator for Chunks<'a, T> {
12951266
(n, Some(n))
12961267
}
12971268
}
1298-
1299-
#[inline]
1300-
fn count(self) -> usize {
1301-
self.size_hint().0
1302-
}
1303-
1304-
#[inline]
1305-
fn nth(&mut self, n: usize) -> Option<Self::Item> {
1306-
let (start, overflow) = n.overflowing_mul(self.size);
1307-
if start >= self.v.len() || overflow {
1308-
self.v = &[];
1309-
None
1310-
} else {
1311-
let end = match start.checked_add(self.size) {
1312-
Some(sum) => cmp::min(self.v.len(), sum),
1313-
None => self.v.len(),
1314-
};
1315-
let nth = &self.v[start..end];
1316-
self.v = &self.v[end..];
1317-
Some(nth)
1318-
}
1319-
}
1320-
1321-
#[inline]
1322-
fn last(self) -> Option<Self::Item> {
1323-
if self.v.is_empty() {
1324-
None
1325-
} else {
1326-
let start = (self.v.len() - 1) / self.size * self.size;
1327-
Some(&self.v[start..])
1328-
}
1329-
}
13301269
}
13311270

13321271
#[stable(feature = "rust1", since = "1.0.0")]
@@ -1407,40 +1346,6 @@ impl<'a, T> Iterator for ChunksMut<'a, T> {
14071346
(n, Some(n))
14081347
}
14091348
}
1410-
1411-
#[inline]
1412-
fn count(self) -> usize {
1413-
self.size_hint().0
1414-
}
1415-
1416-
#[inline]
1417-
fn nth(&mut self, n: usize) -> Option<&'a mut [T]> {
1418-
let (start, overflow) = n.overflowing_mul(self.chunk_size);
1419-
if start >= self.v.len() || overflow {
1420-
self.v = &mut [];
1421-
None
1422-
} else {
1423-
let end = match start.checked_add(self.chunk_size) {
1424-
Some(sum) => cmp::min(self.v.len(), sum),
1425-
None => self.v.len(),
1426-
};
1427-
let tmp = mem::replace(&mut self.v, &mut []);
1428-
let (head, tail) = tmp.split_at_mut(end);
1429-
let (_, nth) = head.split_at_mut(start);
1430-
self.v = tail;
1431-
Some(nth)
1432-
}
1433-
}
1434-
1435-
#[inline]
1436-
fn last(self) -> Option<Self::Item> {
1437-
if self.v.is_empty() {
1438-
None
1439-
} else {
1440-
let start = (self.v.len() - 1) / self.chunk_size * self.chunk_size;
1441-
Some(&mut self.v[start..])
1442-
}
1443-
}
14441349
}
14451350

14461351
#[stable(feature = "rust1", since = "1.0.0")]

0 commit comments

Comments
 (0)