rustdoc: Enable the footnote markdown extension

This enables hoedown's footnote extension, and fixes all footnotes in the
reference manual to use the new syntax.
This commit is contained in:
Alex Crichton 2014-05-02 19:56:19 -07:00
parent 9306e840f5
commit 15856139e4
3 changed files with 59 additions and 37 deletions

View File

@ -220,8 +220,8 @@ ALL_CS := $(wildcard $(S)src/rt/*.cpp \
$(S)src/rt/*/*/*.cpp \
$(S)src/rustllvm/*.cpp)
ALL_CS := $(filter-out $(S)src/rt/miniz.cpp \
$(wildcard $(S)src/rt/sundown/src/*.c) \
$(wildcard $(S)src/rt/sundown/html/*.c) \
$(wildcard $(S)src/rt/hoedown/src/*.c) \
$(wildcard $(S)src/rt/hoedown/bin/*.c) \
,$(ALL_CS))
ALL_HS := $(wildcard $(S)src/rt/*.h \
$(S)src/rt/*/*.h \
@ -232,8 +232,8 @@ ALL_HS := $(filter-out $(S)src/rt/vg/valgrind.h \
$(S)src/rt/msvc/typeof.h \
$(S)src/rt/msvc/stdint.h \
$(S)src/rt/msvc/inttypes.h \
$(wildcard $(S)src/rt/sundown/src/*.h) \
$(wildcard $(S)src/rt/sundown/html/*.h) \
$(wildcard $(S)src/rt/hoedown/src/*.h) \
$(wildcard $(S)src/rt/hoedown/bin/*.h) \
,$(ALL_HS))
# Run the tidy script in multiple parts to avoid huge 'echo' commands
@ -266,6 +266,7 @@ tidy:
-and -not -name '*.sh' \
| grep '^$(S)src/llvm' -v \
| grep '^$(S)src/libuv' -v \
| grep '^$(S)src/rt/hoedown' -v \
| grep '^$(S)src/gyp' -v \
| grep '^$(S)src/etc' -v \
| grep '^$(S)src/doc' -v \

View File

@ -116,8 +116,12 @@ production. See [tokens](#tokens) for more information.
Rust input is interpreted as a sequence of Unicode codepoints encoded in UTF-8,
normalized to Unicode normalization form NFKC.
Most Rust grammar rules are defined in terms of printable ASCII-range codepoints,
but a small number are defined in terms of Unicode properties or explicit codepoint lists.
^[Substitute definitions for the special Unicode productions are provided to the grammar verifier, restricted to ASCII range, when verifying the grammar in this document.]
but a small number are defined in terms of Unicode properties or explicit
codepoint lists. [^inputformat]
[^inputformat]: Substitute definitions for the special Unicode productions are
provided to the grammar verifier, restricted to ASCII range, when verifying
the grammar in this document.
## Special Unicode Productions
@ -631,10 +635,13 @@ Semantic rules called "dynamic semantics" govern the behavior of programs at run
A program that fails to compile due to violation of a compile-time rule has no defined dynamic semantics; the compiler should halt with an error report, and produce no executable artifact.
The compilation model centres on artifacts called _crates_.
Each compilation processes a single crate in source form, and if successful, produces a single crate in binary form: either an executable or a library.^[A crate is somewhat
analogous to an *assembly* in the ECMA-335 CLI model, a *library* in the
SML/NJ Compilation Manager, a *unit* in the Owens and Flatt module system,
or a *configuration* in Mesa.]
Each compilation processes a single crate in source form, and if successful,
produces a single crate in binary form: either an executable or a
library.[^cratesourcefile]
[^cratesourcefile]: A crate is somewhat analogous to an *assembly* in the
ECMA-335 CLI model, a *library* in the SML/NJ Compilation Manager, a *unit*
in the Owens and Flatt module system, or a *configuration* in Mesa.
A _crate_ is a unit of compilation and linking, as well as versioning, distribution and runtime loading.
A crate contains a _tree_ of nested [module](#modules) scopes.
@ -3246,12 +3253,17 @@ types. User-defined types have limited capabilities.
The primitive types are the following:
* The "unit" type `()`, having the single "unit" value `()` (occasionally called "nil").
^[The "unit" value `()` is *not* a sentinel "null pointer" value for reference slots; the "unit" type is the implicit return type from functions otherwise lacking a return type, and can be used in other contexts (such as message-sending or type-parametric code) as a zero-size type.]
* The "unit" type `()`, having the single "unit" value `()` (occasionally called
"nil"). [^unittype]
* The boolean type `bool` with values `true` and `false`.
* The machine types.
* The machine-dependent integer and floating-point types.
[^unittype]: The "unit" value `()` is *not* a sentinel "null pointer" value for
reference slots; the "unit" type is the implicit return type from functions
otherwise lacking a return type, and can be used in other contexts (such as
message-sending or type-parametric code) as a zero-size type.]
#### Machine types
The machine types are the following:
@ -3270,16 +3282,19 @@ The machine types are the following:
#### Machine-dependent integer types
The Rust type `uint`^[A Rust `uint` is analogous to a C99 `uintptr_t`.] is an
The Rust type `uint` [^rustuint] is an
unsigned integer type with target-machine-dependent size. Its size, in
bits, is equal to the number of bits required to hold any memory address on
the target machine.
The Rust type `int`^[A Rust `int` is analogous to a C99 `intptr_t`.] is a
The Rust type `int` [^rustint] is a
two's complement signed integer type with target-machine-dependent size. Its
size, in bits, is equal to the size of the rust type `uint` on the same target
machine.
[^rustuint]: A Rust `uint` is analogous to a C99 `uintptr_t`.
[^rustint]: A Rust `int` is analogous to a C99 `intptr_t`.
### Textual types
The types `char` and `str` hold textual data.
@ -3352,10 +3367,12 @@ and access to a vector is always bounds-checked.
### Structure types
A `struct` *type* is a heterogeneous product of other types, called the *fields* of the type.
^[`struct` types are analogous `struct` types in C,
the *record* types of the ML family,
or the *structure* types of the Lisp family.]
A `struct` *type* is a heterogeneous product of other types, called the *fields*
of the type.[^structtype]
[^structtype]: `struct` types are analogous `struct` types in C,
the *record* types of the ML family,
or the *structure* types of the Lisp family.
New instances of a `struct` can be constructed with a [struct expression](#structure-expressions).
@ -3375,9 +3392,10 @@ is the only value that inhabits such a type.
### Enumerated types
An *enumerated type* is a nominal, heterogeneous disjoint union type,
denoted by the name of an [`enum` item](#enumerations).
^[The `enum` type is analogous to a `data` constructor declaration in ML,
or a *pick ADT* in Limbo.]
denoted by the name of an [`enum` item](#enumerations). [^enumtype]
[^enumtype]: The `enum` type is analogous to a `data` constructor declaration in
ML, or a *pick ADT* in Limbo.
An [`enum` item](#enumerations) declares both the type and a number of *variant constructors*,
each of which is independently named and takes an optional tuple of arguments.
@ -3804,14 +3822,15 @@ By default, the scheduler chooses the number of threads based on
the number of concurrent physical CPUs detected at startup.
It's also possible to override this choice at runtime.
When the number of tasks exceeds the number of threads — which is likely —
the scheduler multiplexes the tasks onto threads.^[
This is an M:N scheduler,
which is known to give suboptimal results for CPU-bound concurrency problems.
In such cases, running with the same number of threads and tasks can yield better results.
Rust has M:N scheduling in order to support very large numbers of tasks
in contexts where threads are too resource-intensive to use in large number.
The cost of threads varies substantially per operating system, and is sometimes quite low,
so this flexibility is not always worth exploiting.]
the scheduler multiplexes the tasks onto threads.[^mnscheduler]
[^mnscheduler]: This is an M:N scheduler, which is known to give suboptimal
results for CPU-bound concurrency problems. In such cases, running with the
same number of threads and tasks can yield better results. Rust has M:N
scheduling in order to support very large numbers of tasks in contexts where
threads are too resource-intensive to use in large number. The cost of
threads varies substantially per operating system, and is sometimes quite
low, so this flexibility is not always worth exploiting.
### Communication between tasks

View File

@ -51,6 +51,14 @@ static HOEDOWN_EXT_TABLES: libc::c_uint = 1 << 0;
static HOEDOWN_EXT_FENCED_CODE: libc::c_uint = 1 << 1;
static HOEDOWN_EXT_AUTOLINK: libc::c_uint = 1 << 3;
static HOEDOWN_EXT_STRIKETHROUGH: libc::c_uint = 1 << 4;
static HOEDOWN_EXT_SUPERSCRIPT: libc::c_uint = 1 << 8;
static HOEDOWN_EXT_FOOTNOTES: libc::c_uint = 1 << 2;
static HOEDOWN_EXTENSIONS: libc::c_uint =
HOEDOWN_EXT_NO_INTRA_EMPHASIS | HOEDOWN_EXT_TABLES |
HOEDOWN_EXT_FENCED_CODE | HOEDOWN_EXT_AUTOLINK |
HOEDOWN_EXT_STRIKETHROUGH | HOEDOWN_EXT_SUPERSCRIPT |
HOEDOWN_EXT_FOOTNOTES;
type hoedown_document = libc::c_void; // this is opaque to us
@ -236,9 +244,6 @@ pub fn render(w: &mut io::Writer, s: &str, print_toc: bool) -> fmt::Result {
unsafe {
let ob = hoedown_buffer_new(DEF_OUNIT);
let extensions = HOEDOWN_EXT_NO_INTRA_EMPHASIS | HOEDOWN_EXT_TABLES |
HOEDOWN_EXT_FENCED_CODE | HOEDOWN_EXT_AUTOLINK |
HOEDOWN_EXT_STRIKETHROUGH;
let renderer = hoedown_html_renderer_new(0, 0);
let mut opaque = MyOpaque {
dfltblk: (*renderer).blockcode.unwrap(),
@ -248,7 +253,7 @@ pub fn render(w: &mut io::Writer, s: &str, print_toc: bool) -> fmt::Result {
(*renderer).blockcode = Some(block);
(*renderer).header = Some(header);
let document = hoedown_document_new(renderer, extensions, 16);
let document = hoedown_document_new(renderer, HOEDOWN_EXTENSIONS, 16);
hoedown_document_render(document, ob, s.as_ptr(),
s.len() as libc::size_t);
hoedown_document_free(document);
@ -319,15 +324,12 @@ pub fn find_testable_code(doc: &str, tests: &mut ::test::Collector) {
unsafe {
let ob = hoedown_buffer_new(DEF_OUNIT);
let extensions = HOEDOWN_EXT_NO_INTRA_EMPHASIS | HOEDOWN_EXT_TABLES |
HOEDOWN_EXT_FENCED_CODE | HOEDOWN_EXT_AUTOLINK |
HOEDOWN_EXT_STRIKETHROUGH;
let renderer = hoedown_html_renderer_new(0, 0);
(*renderer).blockcode = Some(block);
(*renderer).header = Some(header);
(*(*renderer).opaque).opaque = tests as *mut _ as *mut libc::c_void;
let document = hoedown_document_new(renderer, extensions, 16);
let document = hoedown_document_new(renderer, HOEDOWN_EXTENSIONS, 16);
hoedown_document_render(document, ob, doc.as_ptr(),
doc.len() as libc::size_t);
hoedown_document_free(document);