From b9ad5b05a419c99b7a4e744d2671a90f7d840d1a Mon Sep 17 00:00:00 2001 From: Michael Bryan Date: Sat, 27 Jan 2018 14:30:07 +0800 Subject: [PATCH 1/8] Added the mdbook-linkcheck backend --- src/doc/rustc-dev-guide/book.toml | 3 +++ src/doc/rustc-dev-guide/src/high-level-overview.md | 4 +++- src/doc/rustc-dev-guide/src/ty.md | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/doc/rustc-dev-guide/book.toml b/src/doc/rustc-dev-guide/book.toml index 485a12ca3bbd..3c4c537e8b32 100644 --- a/src/doc/rustc-dev-guide/book.toml +++ b/src/doc/rustc-dev-guide/book.toml @@ -3,3 +3,6 @@ title = "Guide to Rustc Development" author = "Rustc developers" description = "A guide to developing rustc " +[output.html] + +[output.linkcheck] diff --git a/src/doc/rustc-dev-guide/src/high-level-overview.md b/src/doc/rustc-dev-guide/src/high-level-overview.md index 55b596a2a9c7..7da9b8ca19b6 100644 --- a/src/doc/rustc-dev-guide/src/high-level-overview.md +++ b/src/doc/rustc-dev-guide/src/high-level-overview.md @@ -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 @@ -134,3 +134,5 @@ take: (one for each "codegen unit"). 6. **Linking** - Finally, those `.o` files are linked together. + +[query model]: https://github.com/rust-lang/rust/blob/master/src/librustc/ty/maps/README.md diff --git a/src/doc/rustc-dev-guide/src/ty.md b/src/doc/rustc-dev-guide/src/ty.md index 8debb71c788e..906e99e71359 100644 --- a/src/doc/rustc-dev-guide/src/ty.md +++ b/src/doc/rustc-dev-guide/src/ty.md @@ -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]: https://github.com/rust-lang/rust/blob/master/src/librustc/hir/README.md You can basically ignore the `TyS` struct -- you will basically never access it explicitly. We always pass it by reference using the From 173a1083ea65b498d27ede37d841b02a4c5e7e65 Mon Sep 17 00:00:00 2001 From: Michael Bryan Date: Sat, 27 Jan 2018 14:36:23 +0800 Subject: [PATCH 2/8] Updated CI to install and use mdbook-linkcheck --- src/doc/rustc-dev-guide/ci/install.sh | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/doc/rustc-dev-guide/ci/install.sh b/src/doc/rustc-dev-guide/ci/install.sh index 2d32caaa9a03..81cbd8fb72de 100644 --- a/src/doc/rustc-dev-guide/ci/install.sh +++ b/src/doc/rustc-dev-guide/ci/install.sh @@ -1,12 +1,20 @@ #!/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 $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 if command -v ghp-import >/dev/null 2>&1; then echo "ghp-import already installed at $(which ghp-import)" From f48a68e481e2ce8eaf90f6471200569030102f3a Mon Sep 17 00:00:00 2001 From: Michael Bryan Date: Sat, 27 Jan 2018 14:41:40 +0800 Subject: [PATCH 3/8] Removed ghp-import and run mdbook build unconditionally --- src/doc/rustc-dev-guide/.travis.yml | 5 +---- src/doc/rustc-dev-guide/ci/github_pages.sh | 11 ----------- src/doc/rustc-dev-guide/ci/install.sh | 7 ------- 3 files changed, 1 insertion(+), 22 deletions(-) delete mode 100644 src/doc/rustc-dev-guide/ci/github_pages.sh diff --git a/src/doc/rustc-dev-guide/.travis.yml b/src/doc/rustc-dev-guide/.travis.yml index 2d107794f428..0862ff9bbf2f 100644 --- a/src/doc/rustc-dev-guide/.travis.yml +++ b/src/doc/rustc-dev-guide/.travis.yml @@ -1,14 +1,11 @@ language: rust cache: -- pip - cargo install: - source ~/.cargo/env || true - bash ci/install.sh script: -- true -after_success: -- bash ci/github_pages.sh +- RUST_LOG=debug mdbook build notifications: email: on_success: never diff --git a/src/doc/rustc-dev-guide/ci/github_pages.sh b/src/doc/rustc-dev-guide/ci/github_pages.sh deleted file mode 100644 index ffd89ad52271..000000000000 --- a/src/doc/rustc-dev-guide/ci/github_pages.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash -set -ex - -BOOK_DIR=book - -# Only upload the built book to github pages if it's a commit to master -if [ "$TRAVIS_BRANCH" = master -a "$TRAVIS_PULL_REQUEST" = false ]; then - mdbook build -else - echo Skipping 'mdbook build' because this is not master or this is just a PR. -fi diff --git a/src/doc/rustc-dev-guide/ci/install.sh b/src/doc/rustc-dev-guide/ci/install.sh index 81cbd8fb72de..99c85986cbb3 100644 --- a/src/doc/rustc-dev-guide/ci/install.sh +++ b/src/doc/rustc-dev-guide/ci/install.sh @@ -15,10 +15,3 @@ function cargo_install() { cargo_install mdbook 0.1.1 cargo_install mdbook-linkcheck 0.1.0 - -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 From fa38aac34cb41e8698eb2e6e68693a5c104d0a8d Mon Sep 17 00:00:00 2001 From: Michael Bryan Date: Sat, 27 Jan 2018 14:53:46 +0800 Subject: [PATCH 4/8] Added a note about how to use mdbook-linkcheck --- src/doc/rustc-dev-guide/README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/doc/rustc-dev-guide/README.md b/src/doc/rustc-dev-guide/README.md index 5ff51de2b738..352c4ce0ba5a 100644 --- a/src/doc/rustc-dev-guide/README.md +++ b/src/doc/rustc-dev-guide/README.md @@ -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. + +``` +$ cargo install mdbook-linkcheck +``` From 31a66439e05e3de1a6f9dee347b658031de91f24 Mon Sep 17 00:00:00 2001 From: Michael Bryan Date: Sat, 27 Jan 2018 14:54:56 +0800 Subject: [PATCH 5/8] Toned down the log verbosity --- src/doc/rustc-dev-guide/.travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/rustc-dev-guide/.travis.yml b/src/doc/rustc-dev-guide/.travis.yml index 0862ff9bbf2f..f17a947d4c88 100644 --- a/src/doc/rustc-dev-guide/.travis.yml +++ b/src/doc/rustc-dev-guide/.travis.yml @@ -5,7 +5,7 @@ install: - source ~/.cargo/env || true - bash ci/install.sh script: -- RUST_LOG=debug mdbook build +- mdbook build notifications: email: on_success: never From 51fc35b7cf49aba08c0e63bf4efeeb3197a98541 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Wed, 31 Jan 2018 11:30:17 -0500 Subject: [PATCH 6/8] update to link within the book --- src/doc/rustc-dev-guide/src/high-level-overview.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/doc/rustc-dev-guide/src/high-level-overview.md b/src/doc/rustc-dev-guide/src/high-level-overview.md index 7da9b8ca19b6..519d822e2708 100644 --- a/src/doc/rustc-dev-guide/src/high-level-overview.md +++ b/src/doc/rustc-dev-guide/src/high-level-overview.md @@ -135,4 +135,5 @@ take: 6. **Linking** - Finally, those `.o` files are linked together. -[query model]: https://github.com/rust-lang/rust/blob/master/src/librustc/ty/maps/README.md + +[query model]: query.html From f0ab2ecf95c9e8289718dd6a03d0601e2a9d5690 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Wed, 31 Jan 2018 11:31:43 -0500 Subject: [PATCH 7/8] Update link to hir --- src/doc/rustc-dev-guide/src/ty.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/rustc-dev-guide/src/ty.md b/src/doc/rustc-dev-guide/src/ty.md index 906e99e71359..e29ecb5e3dda 100644 --- a/src/doc/rustc-dev-guide/src/ty.md +++ b/src/doc/rustc-dev-guide/src/ty.md @@ -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]: https://github.com/rust-lang/rust/blob/master/src/librustc/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 From 986380820154c63cdff0da94c2926d4da54c9882 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Wed, 31 Jan 2018 14:13:49 -0500 Subject: [PATCH 8/8] fix some broken links --- src/doc/rustc-dev-guide/src/macro-expansion.md | 2 +- src/doc/rustc-dev-guide/src/type-inference.md | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/doc/rustc-dev-guide/src/macro-expansion.md b/src/doc/rustc-dev-guide/src/macro-expansion.md index a7777e80c3e9..ee4bd322cb25 100644 --- a/src/doc/rustc-dev-guide/src/macro-expansion.md +++ b/src/doc/rustc-dev-guide/src/macro-expansion.md @@ -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 diff --git a/src/doc/rustc-dev-guide/src/type-inference.md b/src/doc/rustc-dev-guide/src/type-inference.md index 6e2032feeab9..feb694196bf9 100644 --- a/src/doc/rustc-dev-guide/src/type-inference.md +++ b/src/doc/rustc-dev-guide/src/type-inference.md @@ -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 @@ -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.