Skip to content

Commit 6f07e9e

Browse files
committed
---
yaml --- r: 92189 b: refs/heads/auto c: 94e0a03 h: refs/heads/master i: 92187: dd48e25 v: v3
1 parent d0a5fc7 commit 6f07e9e

File tree

4 files changed

+85
-4
lines changed

4 files changed

+85
-4
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0
1313
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1414
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1515
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
16-
refs/heads/auto: 039a5933fb350dda5263cce824f7da8b86c473df
16+
refs/heads/auto: 94e0a03f5d1d27d34d97c691964c1ff9b5cab086
1717
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1818
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1919
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336

branches/auto/doc/rustdoc.md

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
% Rust Documentation
2+
3+
`rustdoc` is the built-in tool for generating documentation. It integrates
4+
with the compiler to provide accurate hyperlinking between usage of types and
5+
their documentation. Furthermore, by not using a separate parser, it will
6+
never reject your valid Rust code.
7+
8+
# Creating Documentation
9+
10+
Documenting Rust APIs is quite simple. To document a given item, we have "doc
11+
comments":
12+
13+
~~~
14+
// the "link" crate attribute is currently required for rustdoc, but normally
15+
// isn't needed.
16+
#[link(name="universe")];
17+
#[crate_type="lib"];
18+
19+
//! Tools for dealing with universes (this is a doc comment, and is shown on
20+
//! the crate index page. The ! makes it apply to the parent of the comment,
21+
//! rather than what follows).
22+
23+
/// Widgets are very common (this is a doc comment, and will show up on
24+
/// Widget's documentation).
25+
pub struct Widget {
26+
/// All widgets have a purpose (this is a doc comment, and will show up
27+
/// the field's documentation).
28+
purpose: ~str,
29+
/// Humans are not allowed to understand some widgets
30+
understandable: bool
31+
}
32+
33+
pub fn recalibrate() {
34+
//! Recalibrate a pesky universe (this is also a doc comment, like above,
35+
//! the documentation will be applied to the *parent* item, so
36+
//! `recalibrate`).
37+
/* ... */
38+
}
39+
~~~
40+
41+
Then, one can run `rustdoc universe.rs`. By default, it generates a directory
42+
called `doc`, with the documentation for `universe` being in
43+
`doc/universe/index.html`. If you are using other crates with `extern mod`,
44+
rustdoc will even link to them when you use their types, as long as their
45+
documentation has already been generated by a previous run of rustdoc, or the
46+
crate advertises that its documentation is hosted at a given URL.
47+
48+
The generated output can be controlled with the `doc` crate attribute, which
49+
is how the above advertisement works. An example from the `libstd`
50+
documentation:
51+
52+
~~~
53+
#[doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk.png",
54+
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
55+
html_root_url = "http://static.rust-lang.org/doc/master")];
56+
~~~
57+
58+
The `html_root_url` is the prefix that rustdoc will apply to any references to
59+
that crate's types etc.
60+
61+
rustdoc can also generate JSON, for consumption by other tools, with
62+
`rustdoc --output-format json`, and also consume already-generated JSON with
63+
`rustdoc --input-format json`.
64+
65+
# Using the Documentation
66+
67+
The web pages generated by rustdoc present the same logical heirarchy that one
68+
writes a library with. Every kind of item (function, struct, etc) has its own
69+
color, and one can always click on a colored type to jump to its
70+
documentation. There is a search bar at the top, which is powered by some
71+
javascript and a statically-generated search index. No special web server is
72+
required for the search.

branches/auto/doc/tutorial.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -872,9 +872,9 @@ A *destructor* is a function responsible for cleaning up the resources used by
872872
an object when it is no longer accessible. Destructors can be defined to handle
873873
the release of resources like files, sockets and heap memory.
874874

875-
Objects are never accessible after their destructor has been called, so there
876-
are no dynamic failures from accessing freed resources. When a task fails, the
877-
destructors of all objects in the task are called.
875+
Objects are never accessible after their destructor has been called, so no
876+
dynamic failures are possible from accessing freed resources. When a task
877+
fails, destructors of all objects in the task are called.
878878

879879
The `~` sigil represents a unique handle for a memory allocation on the heap:
880880

@@ -3254,6 +3254,7 @@ tutorials on individual topics.
32543254
* [Containers and iterators][container]
32553255
* [Error-handling and Conditions][conditions]
32563256
* [Packaging up Rust code][rustpkg]
3257+
* [Documenting Rust code][rustdoc]
32573258

32583259
There is further documentation on the [wiki], however those tend to be even
32593260
more out of date than this document.
@@ -3265,6 +3266,7 @@ more out of date than this document.
32653266
[container]: tutorial-container.html
32663267
[conditions]: tutorial-conditions.html
32673268
[rustpkg]: tutorial-rustpkg.html
3269+
[rustdoc]: tutorial-rustdoc.html
32683270

32693271
[wiki]: https://github.com/mozilla/rust/wiki/Docs
32703272
[wiki-packages]: https://github.com/mozilla/rust/wiki/Doc-packages,-editors,-and-other-tools

branches/auto/mk/docs.mk

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,13 @@ doc/rustpkg.html: rustpkg.md doc/version_info.html doc/rust.css \
7474
$(Q)$(CFG_NODE) $(S)doc/prep.js --highlight $< | \
7575
$(CFG_PANDOC) $(HTML_OPTS) --output=$@
7676

77+
DOCS += doc/rustdoc.html
78+
doc/rustdoc.html: rustdoc.md doc/version_info.html doc/rust.css \
79+
doc/favicon.inc
80+
@$(call E, pandoc: $@)
81+
$(Q)$(CFG_NODE) $(S)doc/prep.js --highlight $< | \
82+
$(CFG_PANDOC) $(HTML_OPTS) --output=$@
83+
7784
DOCS += doc/tutorial.html
7885
doc/tutorial.html: tutorial.md doc/version_info.html doc/rust.css \
7986
doc/favicon.inc

0 commit comments

Comments
 (0)