Skip to content

Commit

Permalink
Fix broken links
Browse files Browse the repository at this point in the history
support for additional linters (link-checker & aspell) (rust-lang-nursery#410)

* Added support for additional linters (html-proofer link checker)

- added additional test matrix item just for linters
- install and build mdbook only when needed to speedup CI
- reorganized the travis scripts

* Added spellchecking script from rust-book to CI

also fixed minor typos

* updated and moved serde_json links to propper position

* move link checking to link-checker

Move errors reorganize datetime add contributing instructions merge master

Renamed categories to avoid confusion fixed broken links

Use mdbook master branch until 0.1.8 releases

Revert "Use mdbook master branch until 0.1.8 releases"

This reverts commit a8dd8e3.
  • Loading branch information
AndyGauge committed Jul 2, 2018
1 parent 87b43bb commit 29f4991
Show file tree
Hide file tree
Showing 47 changed files with 693 additions and 86 deletions.
2 changes: 2 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ No worries if anything in these lists is unclear. Just submit the PR and ask awa
- [ ] commits are squashed into one and rebased to latest master
- [ ] PR contains correct "fixes #ISSUE_ID" clause to autoclose the issue on PR merge
- if issue does not exist consider creating it or remove the clause
- [ ] spell check runs without errors `./ci/spellchecker.sh`
- [ ] link check runs without errors `link-checker ./book`
- [ ] non rendered items are in sorted order (links, reference, identifiers, Cargo.toml)
- [ ] links to docs.rs have wildcard version `https://docs.rs/tar/*/tar/struct.Entry.html`
- [ ] example has standard [error handling](https://rust-lang-nursery.github.io/rust-cookbook/about.html#a-note-about-error-handling)
Expand Down
25 changes: 23 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,29 @@ env:
global:
- secure: m28oDDxTcaLlbCXv9la/yz0PzafOCDuhOhmHRoc1ELQC0wc3r6HT3a2myrP5ewQQhaxYDzd2XXYDJB3odFV1qLQOp0hFDgNn/w3ctWZpJdLxIJN6dsaPL/azhE2hz7T+SPEoWLwTW1va6bu4wwzSOykt9//RIK0ZoyVMCRSAlMB965iMV2Nkw7SWdQZ8SlskMVk8sB103N5+WTtt6rse54jHnXTpFEq9q0EAXC1R3GBDKEWB7iwb0c++Kw46Fz86ZJJDotiVuxMtsEk0VfT0Yxx665is5Ko6sV4cahbuXqMIqYYEfqpTHNHadHWD1m1i32hW9Rjtt9fFZ+a8m9zfTixPlkfOZvQ94RnD2zqv9qiwFr8oR7t2SsZaB4aqPlJd45DqgnwQ1B0cmrUAsjSB2+1DQDkR4FgKFB/o1c6F6g8imNh+2OwiZXVLwIimXNJQ5xfZeObXFMrEZ0+uj7oxFX49EcwE/SvwsVJHST3/zL5QuQwa9/uVhW/x135/Z2ypVao2xydpow/KL8VwhX9YsOSP5ApffL4OLJ5hE9qwS/SShHGg8AenFqqm/UNFqWDU+C097YaWvG5PEvCVXvOofic65AUTCmwB+h3MSQmZIqz2sb/kwdbtkoRRR6maMgelQmg1JdIfQcKeTJIStIihjk54VENHPVAslz0oV7Ia5Bo=

matrix:
include:
- rust: stable
os: linux
env: CONTENT_TESTS=1
- rust: stable
os: linux
env: CONTENT_TESTS=1 CONTENT_TESTS_LINKS=1
allow_failures:
- rust: stable
os: linux
env: CONTENT_TESTS=1 CONTENT_TESTS_LINKS=1

addons:
apt:
packages:
- aspell
- aspell-en

before_install:
- cargo install mdbook --vers '0.1.7' --debug
- ./ci/install_deps.sh
- export PATH=$HOME/.cargo/bin:$PATH

after_success: ./deploy.sh
script: ./ci/test_script.sh

after_success: ./ci/deploy.sh
52 changes: 52 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,61 @@ To run the cookbook test suite:
cargo test
```

## Linters

The Rust Cookbook comes with link checking and spell checking linters that
run on the continuous integration server. These linters should be run locally
before submitting a pull request to ensure there are no dead links or spelling
errors made.

To install the link checker, review the documentation for [python] to install
python 3.6 and pip3. Installing link-checker once the dependencies are met
is done with pip3.

```
[sudo] pip3 install link-checker==0.1.0
```

Alternatively, set up the user install directory on your PATH variable and
install link-checker for your user

```
pip3 install -user link-checker==0.1.0
```

Checking the links of the book locally first requires the book to be built
with mdBook. From the root directory of the cookbook, the following commands
run the link checker.

```
mdbook build
link-checker ./book
```

The aspell binary provides spell checking. Apt packages provide installation
on Debian based operating systems.

```
[sudo] apt install aspell -y
```

To check the spelling of the Rust Cookbook locally, run the following command
from the root of the Cookbook.

```
./ci/spellchecker.sh
```

If the spell checker finds a misspelled word, you have the opportunity to
correct the spelling mistake with the number keys. If the spelling mistake
is erroneous, add the word to the dictionary located in `ci/dictionary.txt`.
Pressing `a` or `l` will not add the word to the custom dictionary.

[mdbook]: http://azerupi.github.io/mdBook/index.html
[python]: https://packaging.python.org/tutorials/installing-packages/#install-pip-setuptools-and-wheel
[skeptic]: https://github.com/brson/rust-skeptic


## Finding what to contribute

This project is intended to be simple to contribute to, and to always
Expand Down
26 changes: 17 additions & 9 deletions deploy.sh → ci/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

set -o errexit -o nounset

echo "Running $0"

if [ -z "${TRAVIS_BRANCH:-}" ]; then
echo "This script may only be run from Travis!"
exit 1
Expand All @@ -14,16 +16,22 @@ if [[ "$TRAVIS_BRANCH" != "master" || "$TRAVIS_RUST_VERSION" != "stable" || "$TR
exit 0
fi

# check for outdated dependencies on nightly builds
if [ "${TRAVIS_EVENT_TYPE:-}" == "cron" ]; then
echo "This is cron build. Checking for outdated dependencies!"
rm ./Cargo.lock
cargo clean
# replace all [dependencies] versions with "*"
sed -i -e "/^\[dependencies\]/,/^\[.*\]/ s|^\(.*=[ \t]*\).*$|\1\"\*\"|" ./Cargo.toml

cargo test || { echo "Cron build failed! Dependencies outdated!"; exit 1; }
echo "Cron build success! Dependencies are up to date!"
if [ -z "${CONTENT_TESTS:-}" ]; then
# check for outdated dependencies on nightly builds
if [ "${TRAVIS_EVENT_TYPE:-}" == "cron" ]; then
echo "This is cron build. Checking for outdated dependencies!"
rm ./Cargo.lock
cargo clean
# replace all [dependencies] versions with "*"
sed -i -e "/^\[dependencies\]/,/^\[.*\]/ s|^\(.*=[ \t]*\).*$|\1\"\*\"|" ./Cargo.toml

cargo test || { echo "Cron build failed! Dependencies outdated!"; exit 1; }
echo "Cron build success! Dependencies are up to date!"
exit 0
fi

echo "We deploy only after we also test the markup and descriptions!"
exit 0
fi

Expand Down
Loading

0 comments on commit 29f4991

Please sign in to comment.