Skip to content

Commit 29f4991

Browse files
committed
Fix broken links
support for additional linters (link-checker & aspell) (#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.
1 parent 87b43bb commit 29f4991

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+693
-86
lines changed

.github/PULL_REQUEST_TEMPLATE.md

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ No worries if anything in these lists is unclear. Just submit the PR and ask awa
1212
- [ ] commits are squashed into one and rebased to latest master
1313
- [ ] PR contains correct "fixes #ISSUE_ID" clause to autoclose the issue on PR merge
1414
- if issue does not exist consider creating it or remove the clause
15+
- [ ] spell check runs without errors `./ci/spellchecker.sh`
16+
- [ ] link check runs without errors `link-checker ./book`
1517
- [ ] non rendered items are in sorted order (links, reference, identifiers, Cargo.toml)
1618
- [ ] links to docs.rs have wildcard version `https://docs.rs/tar/*/tar/struct.Entry.html`
1719
- [ ] example has standard [error handling](https://rust-lang-nursery.github.io/rust-cookbook/about.html#a-note-about-error-handling)

.travis.yml

+23-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,29 @@ env:
1212
global:
1313
- 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=
1414

15+
matrix:
16+
include:
17+
- rust: stable
18+
os: linux
19+
env: CONTENT_TESTS=1
20+
- rust: stable
21+
os: linux
22+
env: CONTENT_TESTS=1 CONTENT_TESTS_LINKS=1
23+
allow_failures:
24+
- rust: stable
25+
os: linux
26+
env: CONTENT_TESTS=1 CONTENT_TESTS_LINKS=1
27+
28+
addons:
29+
apt:
30+
packages:
31+
- aspell
32+
- aspell-en
33+
1534
before_install:
16-
- cargo install mdbook --vers '0.1.7' --debug
35+
- ./ci/install_deps.sh
1736
- export PATH=$HOME/.cargo/bin:$PATH
1837

19-
after_success: ./deploy.sh
38+
script: ./ci/test_script.sh
39+
40+
after_success: ./ci/deploy.sh

CONTRIBUTING.md

+52
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,61 @@ To run the cookbook test suite:
4444
cargo test
4545
```
4646

47+
## Linters
48+
49+
The Rust Cookbook comes with link checking and spell checking linters that
50+
run on the continuous integration server. These linters should be run locally
51+
before submitting a pull request to ensure there are no dead links or spelling
52+
errors made.
53+
54+
To install the link checker, review the documentation for [python] to install
55+
python 3.6 and pip3. Installing link-checker once the dependencies are met
56+
is done with pip3.
57+
58+
```
59+
[sudo] pip3 install link-checker==0.1.0
60+
```
61+
62+
Alternatively, set up the user install directory on your PATH variable and
63+
install link-checker for your user
64+
65+
```
66+
pip3 install -user link-checker==0.1.0
67+
```
68+
69+
Checking the links of the book locally first requires the book to be built
70+
with mdBook. From the root directory of the cookbook, the following commands
71+
run the link checker.
72+
73+
```
74+
mdbook build
75+
link-checker ./book
76+
```
77+
78+
The aspell binary provides spell checking. Apt packages provide installation
79+
on Debian based operating systems.
80+
81+
```
82+
[sudo] apt install aspell -y
83+
```
84+
85+
To check the spelling of the Rust Cookbook locally, run the following command
86+
from the root of the Cookbook.
87+
88+
```
89+
./ci/spellchecker.sh
90+
```
91+
92+
If the spell checker finds a misspelled word, you have the opportunity to
93+
correct the spelling mistake with the number keys. If the spelling mistake
94+
is erroneous, add the word to the dictionary located in `ci/dictionary.txt`.
95+
Pressing `a` or `l` will not add the word to the custom dictionary.
96+
4797
[mdbook]: http://azerupi.github.io/mdBook/index.html
98+
[python]: https://packaging.python.org/tutorials/installing-packages/#install-pip-setuptools-and-wheel
4899
[skeptic]: https://github.com/brson/rust-skeptic
49100

101+
50102
## Finding what to contribute
51103

52104
This project is intended to be simple to contribute to, and to always

deploy.sh renamed to ci/deploy.sh

+17-9
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
set -o errexit -o nounset
44

5+
echo "Running $0"
6+
57
if [ -z "${TRAVIS_BRANCH:-}" ]; then
68
echo "This script may only be run from Travis!"
79
exit 1
@@ -14,16 +16,22 @@ if [[ "$TRAVIS_BRANCH" != "master" || "$TRAVIS_RUST_VERSION" != "stable" || "$TR
1416
exit 0
1517
fi
1618

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

25-
cargo test || { echo "Cron build failed! Dependencies outdated!"; exit 1; }
26-
echo "Cron build success! Dependencies are up to date!"
20+
if [ -z "${CONTENT_TESTS:-}" ]; then
21+
# check for outdated dependencies on nightly builds
22+
if [ "${TRAVIS_EVENT_TYPE:-}" == "cron" ]; then
23+
echo "This is cron build. Checking for outdated dependencies!"
24+
rm ./Cargo.lock
25+
cargo clean
26+
# replace all [dependencies] versions with "*"
27+
sed -i -e "/^\[dependencies\]/,/^\[.*\]/ s|^\(.*=[ \t]*\).*$|\1\"\*\"|" ./Cargo.toml
28+
29+
cargo test || { echo "Cron build failed! Dependencies outdated!"; exit 1; }
30+
echo "Cron build success! Dependencies are up to date!"
31+
exit 0
32+
fi
33+
34+
echo "We deploy only after we also test the markup and descriptions!"
2735
exit 0
2836
fi
2937

0 commit comments

Comments
 (0)