Skip to content

Commit 9306e84

Browse files
committed
rustdoc: Migrate from sundown to hoedown
This primary fix brought on by this upgrade is the proper matching of the ``` and ~~~ doc blocks. This also moves hoedown to a git submodule rather than a bundled repository. Additionally, hoedown is stricter about code blocks, so this ended up fixing a lot of invalid code blocks (ending with " ```" instead of "```", or ending with "~~~~" instead of "~~~"). Closes #12776
1 parent 9ac9245 commit 9306e84

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+191
-5636
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,6 @@
1212
[submodule "src/compiler-rt"]
1313
path = src/compiler-rt
1414
url = https://github.com/rust-lang/compiler-rt.git
15+
[submodule "src/rt/hoedown"]
16+
path = src/rt/hoedown
17+
url = https://github.com/rust-lang/hoedown.git

mk/crates.mk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
# DEPS_<crate>
3939
# These lists are the dependencies of the <crate> that is to be built.
4040
# Rust dependencies are listed bare (i.e. std, green) and native
41-
# dependencies have a "native:" prefix (i.e. native:sundown). All deps
41+
# dependencies have a "native:" prefix (i.e. native:hoedown). All deps
4242
# will be built before the crate itself is built.
4343
#
4444
# TOOL_DEPS_<tool>/TOOL_SOURCE_<tool>
@@ -63,7 +63,7 @@ DEPS_native := std
6363
DEPS_syntax := std term serialize collections log
6464
DEPS_rustc := syntax native:rustllvm flate arena serialize sync getopts \
6565
collections time log
66-
DEPS_rustdoc := rustc native:sundown serialize sync getopts collections \
66+
DEPS_rustdoc := rustc native:hoedown serialize sync getopts collections \
6767
test time
6868
DEPS_flate := std native:miniz
6969
DEPS_arena := std collections

mk/dist.mk

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ LICENSE.txt: $(S)COPYRIGHT $(S)LICENSE-APACHE $(S)LICENSE-MIT
3535

3636
PKG_TAR = dist/$(PKG_NAME).tar.gz
3737

38-
PKG_GITMODULES := $(S)src/libuv $(S)src/llvm $(S)src/gyp $(S)src/compiler-rt
38+
PKG_GITMODULES := $(S)src/libuv $(S)src/llvm $(S)src/gyp $(S)src/compiler-rt \
39+
$(S)src/rt/hoedown
3940
PKG_FILES := \
4041
$(S)COPYRIGHT \
4142
$(S)LICENSE-APACHE \

mk/rt.mk

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,19 +35,20 @@
3535
# that's per-target so you're allowed to conditionally add files based on the
3636
# target.
3737
################################################################################
38-
NATIVE_LIBS := rustrt sundown uv_support morestack miniz context_switch
38+
NATIVE_LIBS := rustrt hoedown uv_support morestack miniz context_switch
3939

4040
# $(1) is the target triple
4141
define NATIVE_LIBRARIES
4242

43-
NATIVE_DEPS_sundown_$(1) := sundown/src/autolink.c \
44-
sundown/src/buffer.c \
45-
sundown/src/stack.c \
46-
sundown/src/markdown.c \
47-
sundown/html/houdini_href_e.c \
48-
sundown/html/houdini_html_e.c \
49-
sundown/html/html_smartypants.c \
50-
sundown/html/html.c
43+
NATIVE_DEPS_hoedown_$(1) := hoedown/src/autolink.c \
44+
hoedown/src/buffer.c \
45+
hoedown/src/document.c \
46+
hoedown/src/escape.c \
47+
hoedown/src/html.c \
48+
hoedown/src/html_blocks.c \
49+
hoedown/src/html_smartypants.c \
50+
hoedown/src/stack.c \
51+
hoedown/src/version.c
5152
NATIVE_DEPS_uv_support_$(1) := rust_uv.c
5253
NATIVE_DEPS_miniz_$(1) = miniz.c
5354
NATIVE_DEPS_rustrt_$(1) := rust_builtin.c \
@@ -79,7 +80,7 @@ $$(RT_OUTPUT_DIR_$(1))/%.o: $(S)src/rt/%.c $$(MKFILE_DEPS)
7980
@mkdir -p $$(@D)
8081
@$$(call E, compile: $$@)
8182
$$(Q)$$(call CFG_COMPILE_C_$(1), $$@, \
82-
-I $$(S)src/rt/sundown/src -I $$(S)src/rt/sundown/html \
83+
-I $$(S)src/rt/hoedown/src \
8384
-I $$(S)src/libuv/include -I $$(S)src/rt \
8485
$$(RUNTIME_CFLAGS_$(1))) $$<
8586

src/doc/complement-cheatsheet.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ use std::str;
6262
6363
let x: Option<~str> = str::from_utf8_owned(~[104u8,105u8]);
6464
let y: ~str = x.unwrap();
65-
~~~~
65+
~~~
6666

6767
To return a [`MaybeOwned`](http://static.rust-lang.org/doc/master/std/str/enum.MaybeOwned.html) use the str helper function [`from_utf8_lossy`](http://static.rust-lang.org/doc/master/std/str/fn.from_utf8_owned.html). This function also replaces non-valid utf-8 sequences with U+FFFD replacement character.
6868

@@ -71,7 +71,7 @@ use std::str;
7171
7272
let x = bytes!(72u8,"ello ",0xF0,0x90,0x80,"World!");
7373
let y = str::from_utf8_lossy(x);
74-
~~~~
74+
~~~
7575

7676
# File operations
7777

src/doc/complement-lang-faq.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ For simplicity, we do not plan to do so. Implementing automatic semicolon insert
135135

136136
**Short answer** set the RUST_LOG environment variable to the name of your source file, sans extension.
137137

138-
``` {.sh .notrust}
138+
```notrust,sh
139139
rustc hello.rs
140140
export RUST_LOG=hello
141141
./hello

src/doc/guide-container.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ impl Iterator<int> for ZeroStream {
8181
Some(0)
8282
}
8383
}
84-
~~~~
84+
~~~
8585

8686
Reaching the end of the iterator is signalled by returning `None` instead of
8787
`Some(item)`:

src/doc/guide-tasks.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,7 @@ fn stringifier(channel: &sync::DuplexStream<~str, uint>) {
496496
}
497497
}
498498
# }
499-
~~~~
499+
~~~
500500

501501
The implementation of `DuplexStream` supports both sending and
502502
receiving. The `stringifier` function takes a `DuplexStream` that can
@@ -538,7 +538,7 @@ assert!(from_child.recv() == "23".to_owned());
538538
assert!(from_child.recv() == "0".to_owned());
539539
540540
# }
541-
~~~~
541+
~~~
542542

543543
The parent task first calls `DuplexStream` to create a pair of bidirectional
544544
endpoints. It then uses `task::spawn` to create the child task, which captures

src/doc/rust.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4085,7 +4085,7 @@ fn main() {
40854085

40864086
These four log levels correspond to levels 1-4, as controlled by `RUST_LOG`:
40874087

4088-
``` {.bash .notrust}
4088+
```notrust,bash
40894089
$ RUST_LOG=rust=3 ./rust
40904090
This is an error log
40914091
This is a warn log

src/doc/rustdoc.md

Lines changed: 34 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -107,68 +107,55 @@ code blocks as testable-by-default. In order to not run a test over a block of
107107
code, the `ignore` string can be added to the three-backtick form of markdown
108108
code block.
109109

110-
/**
111-
# nested code fences confuse sundown => indentation + comment to
112-
# avoid failing tests
113-
```
114-
// This is a testable code block
115-
```
110+
~~~notrust
111+
```
112+
// This is a testable code block
113+
```
116114
117-
```ignore
118-
// This is not a testable code block
119-
```
115+
```ignore
116+
// This is not a testable code block
117+
```
120118
121-
// This is a testable code block (4-space indent)
122-
*/
123-
# fn foo() {}
119+
// This is a testable code block (4-space indent)
120+
~~~
124121

125122
You can specify that the test's execution should fail with the `should_fail`
126123
directive.
127124

128-
/**
129-
# nested code fences confuse sundown => indentation + comment to
130-
# avoid failing tests
131-
```should_fail
132-
// This code block is expected to generate a failure when run
133-
```
134-
*/
135-
# fn foo() {}
125+
~~~notrust
126+
```should_fail
127+
// This code block is expected to generate a failure when run
128+
```
129+
~~~
136130

137131
You can specify that the code block should be compiled but not run with the
138132
`no_run` directive.
139133

140-
/**
141-
# nested code fences confuse sundown => indentation + comment to
142-
# avoid failing tests
143-
```no_run
144-
// This code will be compiled but not executed
145-
```
146-
*/
147-
# fn foo() {}
134+
~~~notrust
135+
```no_run
136+
// This code will be compiled but not executed
137+
```
138+
~~~
148139

149140
Rustdoc also supplies some extra sugar for helping with some tedious
150141
documentation examples. If a line is prefixed with `# `, then the line
151142
will not show up in the HTML documentation, but it will be used when
152143
testing the code block (NB. the space after the `#` is required, so
153144
that one can still write things like `#[deriving(Eq)]`).
154145

155-
/**
156-
# nested code fences confuse sundown => indentation + comment to
157-
# avoid failing tests
158-
```rust
159-
# /!\ The three following lines are comments, which are usually stripped off by
160-
# the doc-generating tool. In order to display them anyway in this particular
161-
# case, the character following the leading '#' is not a usual space like in
162-
# these first five lines but a non breakable one.
163-
#
164-
# // showing 'fib' in this documentation would just be tedious and detracts from
165-
# // what's actually being documented.
166-
# fn fib(n: int) { n + 2 }
167-
168-
spawn(proc() { fib(200); })
169-
```
170-
*/
171-
# fn foo() {}
146+
~~~notrust
147+
```
148+
# /!\ The three following lines are comments, which are usually stripped off by
149+
# the doc-generating tool. In order to display them anyway in this particular
150+
# case, the character following the leading '#' is not a usual space like in
151+
# these first five lines but a non breakable one.
152+
# // showing 'fib' in this documentation would just be tedious and detracts from
153+
# // what's actually being documented.
154+
# fn fib(n: int) { n + 2 }
155+
156+
spawn(proc() { fib(200); })
157+
```
158+
~~~
172159

173160
The documentation online would look like `spawn(proc() { fib(200); })`, but when
174161
testing this code, the `fib` function will be included (so it can compile).
@@ -182,10 +169,10 @@ rustc's `--test` flag. Extra arguments can be passed to rustdoc's test harness
182169
with the `--test-args` flag.
183170

184171
~~~ {.notrust}
185-
$ # Only run tests containing 'foo' in their name
172+
# Only run tests containing 'foo' in their name
186173
$ rustdoc --test lib.rs --test-args 'foo'
187174
188-
$ # See what's possible when running tests
175+
# See what's possible when running tests
189176
$ rustdoc --test lib.rs --test-args '--help'
190177
~~~
191178

src/doc/tutorial.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1408,7 +1408,7 @@ struct Point {
14081408
x: f64,
14091409
y: f64
14101410
}
1411-
~~~~
1411+
~~~
14121412

14131413
We can use this simple definition to allocate points in many different
14141414
ways. For example, in this code, each of these local variables

src/libfourcc/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ fn main() {
3131
let little_val = fourcc!("foo ", little);
3232
assert_eq!(little_val, 0x21EEFFC0u32);
3333
}
34-
```
34+
```
3535
3636
# References
3737

src/libhexfloat/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ extern crate hexfloat;
2727
fn main() {
2828
let val = hexfloat!("0x1.ffffb4", f32);
2929
}
30-
```
30+
```
3131
3232
# References
3333

0 commit comments

Comments
 (0)