2015-12-12 06:50:02 +08:00
|
|
|
|
# The Rust Programming Language
|
|
|
|
|
|
2016-08-11 07:30:49 +08:00
|
|
|
|
[![Build Status](https://travis-ci.org/rust-lang/book.svg?branch=master)](https://travis-ci.org/rust-lang/book)
|
|
|
|
|
|
2015-12-12 06:50:02 +08:00
|
|
|
|
This is the next iteration of “The Rust Programming Language”, which is
|
|
|
|
|
currently located [in the main Rust repository][src]. If you want to read the
|
|
|
|
|
book, you should check it out there or [on the web][prod].
|
|
|
|
|
|
|
|
|
|
[src]: https://github.com/rust-lang/rust/tree/master/src/doc/book
|
|
|
|
|
[prod]: https://doc.rust-lang.org/book/
|
|
|
|
|
|
2015-12-16 05:49:11 +08:00
|
|
|
|
If you would like to see this version rendered, it’s [on GitHub pages][html].
|
2015-12-15 04:00:58 +08:00
|
|
|
|
|
|
|
|
|
[html]: http://rust-lang.github.io/book/
|
|
|
|
|
|
2015-12-12 06:50:02 +08:00
|
|
|
|
## Requirements
|
|
|
|
|
|
2016-08-02 23:07:06 +08:00
|
|
|
|
Building the book requires [mdBook] >= v0.0.13. To get it:
|
2015-12-12 06:50:02 +08:00
|
|
|
|
|
2015-12-14 22:45:33 +08:00
|
|
|
|
[mdBook]: https://github.com/azerupi/mdBook
|
2015-12-12 06:50:02 +08:00
|
|
|
|
|
2016-11-15 01:18:48 +08:00
|
|
|
|
```
|
2015-12-12 06:50:02 +08:00
|
|
|
|
$ cargo install mdbook
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## Building
|
|
|
|
|
|
|
|
|
|
To build the book, type:
|
|
|
|
|
|
2016-11-15 01:18:48 +08:00
|
|
|
|
```
|
2016-01-21 08:31:27 +08:00
|
|
|
|
$ mdbook build
|
2015-12-12 06:50:02 +08:00
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
The output will be in the `book` subdirectory. To check it out, open it in
|
2016-08-24 12:59:18 +08:00
|
|
|
|
your web browser.
|
2015-12-12 06:50:02 +08:00
|
|
|
|
|
2016-08-24 12:59:18 +08:00
|
|
|
|
_Firefox:_
|
2016-11-15 01:18:48 +08:00
|
|
|
|
```
|
2016-09-12 04:12:15 +08:00
|
|
|
|
$ firefox book/index.html # Linux
|
|
|
|
|
$ open -a "Firefox" book/index.html # OS X
|
2015-12-12 06:50:02 +08:00
|
|
|
|
```
|
|
|
|
|
|
2016-08-24 12:59:18 +08:00
|
|
|
|
_Chrome:_
|
2016-11-15 01:18:48 +08:00
|
|
|
|
```
|
2016-09-13 08:12:58 +08:00
|
|
|
|
$ google-chrome book/index.html # Linux
|
2016-09-12 04:12:15 +08:00
|
|
|
|
$ open -a "Google Chrome" book/index.html # OS X
|
2016-08-24 12:57:53 +08:00
|
|
|
|
```
|
|
|
|
|
|
2015-12-15 01:11:06 +08:00
|
|
|
|
To run the tests:
|
|
|
|
|
|
2016-11-15 01:18:48 +08:00
|
|
|
|
```
|
2016-01-21 08:31:27 +08:00
|
|
|
|
$ mdbook test
|
2015-12-15 01:11:06 +08:00
|
|
|
|
```
|
|
|
|
|
|
2015-12-12 06:50:02 +08:00
|
|
|
|
## Contributing
|
|
|
|
|
|
2016-11-11 06:36:47 +08:00
|
|
|
|
We'd love your help! Please see [CONTRIBUTING.md][contrib].
|
2015-12-12 06:50:02 +08:00
|
|
|
|
|
2016-11-11 06:36:47 +08:00
|
|
|
|
[contrib]: https://github.com/rust-lang/book/blob/master/CONTRIBUTING.md
|
2015-12-19 03:48:16 +08:00
|
|
|
|
|
2016-01-09 01:09:26 +08:00
|
|
|
|
## No Starch
|
|
|
|
|
|
|
|
|
|
As the book will be published by No Starch, we first iterate here, then ship the
|
|
|
|
|
text off to No Starch. Then they do editing, and we fold it back in.
|
|
|
|
|
|
2016-10-15 11:32:37 +08:00
|
|
|
|
As such, there’s a directory, *nostarch*, which corresponds to the text in No
|
2016-05-07 02:58:36 +08:00
|
|
|
|
Starch’s system.
|
2016-10-15 11:32:37 +08:00
|
|
|
|
|
|
|
|
|
When we've started working with No Starch in a word doc, we will also check
|
|
|
|
|
those into the repo in the *nostarch/odt* directory. To extract the text from
|
|
|
|
|
the word doc as markdown in order to backport changes to the online book:
|
|
|
|
|
|
|
|
|
|
1. Open the doc file in LibreOffice
|
|
|
|
|
1. Accept all tracked changes
|
|
|
|
|
1. Save as Microsoft Word 2007-2013 XML (.docx) in the *tmp* directory
|
|
|
|
|
1. Run `./doc-to-md.sh`
|
|
|
|
|
1. Inspect changes made to the markdown file in the *nostarch* directory and copy the changes to the *src* directory as appropriate.
|
2016-11-11 06:59:12 +08:00
|
|
|
|
|
|
|
|
|
## Graphviz dot
|
|
|
|
|
|
|
|
|
|
This is mostly for Carol's reference because she keeps having to look it up.
|
|
|
|
|
|
|
|
|
|
We're using [Graphviz](http://graphviz.org/) for some of the diagrams in the
|
|
|
|
|
book. The source for those files live in the `dot` directory. To turn a `dot`
|
|
|
|
|
file, for example, `dot/trpl04-01.dot` into an `svg`, run:
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
$ dot dot/trpl04-01.dot -Tsvg > src/img/trpl04-01.svg
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
In the generated SVG, remove the width and the height attributes from the `svg`
|
|
|
|
|
element and set the `viewBox` attribute to `0.00 0.00 1000.00 1000.00` or other
|
|
|
|
|
values that don't cut off the image.
|
2016-12-05 23:56:08 +08:00
|
|
|
|
|
2016-12-02 01:54:51 +08:00
|
|
|
|
## Spellchecking
|
|
|
|
|
|
2016-12-01 22:33:09 +08:00
|
|
|
|
To scan source files for spelling errors, you can use the `spellcheck.sh`
|
|
|
|
|
script. It needs a dictionary of valid words, which is provided in
|
|
|
|
|
`dictionary.txt`. If the script produces a false positive (say, you used word
|
|
|
|
|
`BTreeMap` which the script considers invalid), you need to add this word to
|
|
|
|
|
`dictionary.txt` (keep the sorted order for consistency).
|
2016-12-12 00:54:44 +08:00
|
|
|
|
|
2016-12-05 23:56:08 +08:00
|
|
|
|
## Converting Windows newlines to Unix
|
|
|
|
|
|
|
|
|
|
This is mostly for Carol's reference because she keeps having to look it up.
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
$ tr -d '\015' < DOS-file > UNIX-file
|
|
|
|
|
```
|