Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added the mdbook-linkcheck backend #27

Merged
merged 8 commits into from
Jan 31, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
language: rust
cache:
- pip
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice, I meant to purge these at some point...

- cargo
install:
- source ~/.cargo/env || true
- bash ci/install.sh
script:
- true
after_success:
- bash ci/github_pages.sh
- mdbook build
notifications:
email:
on_success: never
Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,11 @@ for you to talk with someone who **does** know the code, or who wants
to pair with you and figure it out. Then you can work on writing up
what you learned.

To help prevent accidentally introducing broken links, we use the
`mdbook-linkcheck`. If installed on your machine `mdbook` will automatically
invoke this link checker, otherwise it will emit a warning saying it couldn't
be found.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what kind of links does this check? can it test https links too?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It reads the contents of the raw chapters then uses pulldown-cmark to find all the links on a page. Then if it's a link to another chapter we make sure that chapter exists, otherwise if its http(s) it'll try to GET the page using reqwests.

Fetching pages from the web is disabled by default because it can take a while when your book has lots of them. Therefore you need to set output.linkcheck.follow-web-links to true in your book.toml.


```
$ cargo install mdbook-linkcheck
```
3 changes: 3 additions & 0 deletions book.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@ title = "Guide to Rustc Development"
author = "Rustc developers"
description = "A guide to developing rustc "

[output.html]

[output.linkcheck]
11 changes: 0 additions & 11 deletions ci/github_pages.sh

This file was deleted.

25 changes: 13 additions & 12 deletions ci/install.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
#!/bin/bash
set -ex

if command -v mdbook >/dev/null 2>&1; then
echo "mdbook already installed at $(command -v mdbook)"
else
echo "installing mdbook"
cargo install mdbook --vers "0.0.28"
fi
function cargo_install() {
local name=$1
local version=$2

if command -v ghp-import >/dev/null 2>&1; then
echo "ghp-import already installed at $(which ghp-import)"
else
echo "installing ghp-import"
pip install --user ghp-import
fi
if command -v $name >/dev/null 2>&1; then
echo "$name is already installed at $(command -v $name)"
else
echo "Installing $name"
cargo install $name --version $version
fi
}

cargo_install mdbook 0.1.1
cargo_install mdbook-linkcheck 0.1.0
5 changes: 4 additions & 1 deletion src/high-level-overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ The `rustc_driver` crate, at the top of this lattice, is effectively
the "main" function for the rust compiler. It doesn't have much "real
code", but instead ties together all of the code defined in the other
crates and defines the overall flow of execution. (As we transition
more and more to the [query model](ty/maps/README.md), however, the
more and more to the [query model], however, the
"flow" of compilation is becoming less centrally defined.)

At the other extreme, the `rustc` crate defines the common and
Expand Down Expand Up @@ -134,3 +134,6 @@ take:
(one for each "codegen unit").
6. **Linking**
- Finally, those `.o` files are linked together.


[query model]: query.html
2 changes: 1 addition & 1 deletion src/macro-expansion.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,4 +158,4 @@ TODO
[code_mp]: https://github.com/rust-lang/rust/tree/master/src/libsyntax/ext/tt/macro_parser.rs
[code_mp]: https://github.com/rust-lang/rust/tree/master/src/libsyntax/ext/tt/macro_rules.rs
[code_parse_int]: https://github.com/rust-lang/rust/blob/a97cd17f5d71fb4ec362f4fbd79373a6e7ed7b82/src/libsyntax/ext/tt/macro_parser.rs#L421
[parsing]: ./the-parser.md
[parsing]: ./the-parser.html
2 changes: 1 addition & 1 deletion src/ty.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ is in fact a simple type alias for a reference with `'tcx` lifetime:
pub type Ty<'tcx> = &'tcx TyS<'tcx>;
```

[the HIR]: ../hir/README.md
[the HIR]: ./hir.html

You can basically ignore the `TyS` struct -- you will basically never
access it explicitly. We always pass it by reference using the
Expand Down
4 changes: 2 additions & 2 deletions src/type-inference.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ fresh types and things that it will create, as described in
[the README in the ty module][ty-readme]. This arena is created by the `enter`
function and disposed after it returns.

[ty-readme]: src/librustc/ty/README.md
[ty-readme]: ty.html

Within the closure, the infcx will have the type `InferCtxt<'cx, 'gcx,
'tcx>` for some fresh `'cx` and `'tcx` -- the latter corresponds to
Expand Down Expand Up @@ -107,7 +107,7 @@ actual return type is not `()`, but rather `InferOk<()>`. The
to ensure that these are fulfilled (typically by enrolling them in a
fulfillment context). See the [trait README] for more background here.

[trait README]: ../traits/README.md
[trait README]: trait-resolution.html

You can also enforce subtyping through `infcx.at(..).sub(..)`. The same
basic concepts apply as above.
Expand Down