Skip to content

Commit a605265

Browse files
authored
Add checklinks tox env and shell script. (#955)
Also clean up dead links.
1 parent 375db8c commit a605265

11 files changed

+51
-11
lines changed

.travis.yml

+2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ matrix:
2121
- aspell
2222
- aspell-en
2323
- env: TOXENV=pep517check
24+
- env: TOXENV=checklinks
25+
before_install: npm install -g markdown-link-check
2426

2527
addons:
2628
apt:

checklinks.sh

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/bash
2+
3+
echo "Checking links in documentation..."
4+
5+
# List of files in docs dir
6+
docs=$(find . -path './docs/*.md')
7+
# List of files in project root (README, etc)
8+
extras=$(find . -maxdepth 1 -name '*.md')
9+
# Combined list of files to check
10+
files=("${docs[@]}" "${extras[@]}")
11+
12+
let "fails=0"
13+
let "count=0"
14+
15+
for file in ${files[@]}; do
16+
let "count++"
17+
markdown-link-check -q "$file"
18+
if [ $? -ne 0 ]; then
19+
let "fails++"
20+
fi
21+
done
22+
23+
echo -e "\n\033[0;33m$count files checked."
24+
25+
if [ $fails -gt 0 ]; then
26+
echo -e "\033[0;31mERROR: $fails files with dead links found!"
27+
exit 1
28+
else
29+
echo -e "\033[0;32mCongratulations! No dead links found."
30+
exit 0
31+
fi

docs/authors.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Primary Authors
2828
Ph.D. Various pieces of his code still exist, most notably the basic
2929
structure.
3030

31-
* __[Manfed Stienstra](http://www.dwerg.net/)__
31+
* __Manfed Stienstra__
3232

3333
Manfed wrote the original version of the script and is responsible for
3434
various parts of the existing code base.

docs/change_log/index.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ Python-Markdown Change Log
55

66
Under development: version 3.2.2 (a bug-fix release).
77

8+
* Add `checklinks` tox environment to ensure all links in documentation are good.
89
* Refactor extension API documentation (#729).
910
* Load entry_points (for extensions) only once using `importlib.metadata`.
1011
* Do not double escape entities in TOC.
@@ -262,4 +263,4 @@ escape, emphasis in the beginning of the paragraph.
262263
Nov. 2004: Added links, blockquotes, HTML blocks to Manfred
263264
Stienstra's code
264265

265-
Apr. 2004: Manfred's version at <http://www.dwerg.net/projects/markdown/>
266+
Apr. 2004: Manfred's version at `http://www.dwerg.net/projects/markdown/`

docs/change_log/release-2.2.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ What's New in Python-Markdown 2.2
4040
---------------------------------
4141

4242
The docs were refactored and can now be found at
43-
<http://packages.python.org/Markdown/>. The docs are now maintained in the
43+
`http://packages.python.org/Markdown/`. The docs are now maintained in the
4444
Repository and are generated by the `setup.py build_docs` command.
4545

4646
The [Sane_Lists](../extensions/sane_lists.md)

docs/change_log/release-2.3.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ Backwards-incompatible Changes
5858
PyTidyLib rather than using an extension (for example:
5959
`tidylib.tidy_fragment(markdown.markdown(source), options={...})`).
6060

61-
[PyTidyLib]: http://countergram.com/open-source/pytidylib
61+
[PyTidyLib]: http://countergram.github.io/pytidylib/
6262

6363
What's New in Python-Markdown 2.3
6464
---------------------------------

docs/contributing.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ propose changes to this document in a pull request.
99

1010
This project and everyone participating in it is governed by the
1111
[Python-Markdown Code of Conduct]. By participating, you are expected to uphold
12-
this code. Please report unacceptable behavior to <[email protected]>.
12+
this code. Please report unacceptable behavior to [[email protected]][email].
1313

1414
## Project Organization
1515

@@ -473,6 +473,7 @@ label from the same group.
473473

474474
[Python-Markdown Organization]: https://github.com/Python-Markdown
475475
[Python-Markdown Code of Conduct]: https://github.com/Python-Markdown/markdown/blob/master/CODE_OF_CONDUCT.md
476+
[email]: mailto:[email protected]
476477
[Python-Markdown/markdown]: https://github.com/Python-Markdown/markdown
477478
[issue tracker]: https://github.com/Python-Markdown/markdown/issues
478479
[syntax rules]: https://daringfireball.net/projects/markdown/syntax
@@ -495,7 +496,7 @@ label from the same group.
495496
[configure a remote]: https://help.github.com/articles/configuring-a-remote-for-a-fork
496497
[sync changes]: https://help.github.com/articles/syncing-a-fork
497498
[virtual environment]: https://virtualenv.pypa.io/en/stable/
498-
[User Guide]: https://virtualenv.pypa.io/en/stable/userguide/#usage
499+
[User Guide]: https://virtualenv.pypa.io/en/stable/user_guide.html
499500
[Development Mode]: https://setuptools.readthedocs.io/en/latest/setuptools.html#development-mode
500501
[PyTidyLib]: https://countergram.github.io/pytidylib/
501502
[HTML Tidy]: https://www.html-tidy.org/

docs/extensions/admonition.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ Styling
9999
There is no CSS included as part of this extension. Check out the default
100100
[Sphinx][sphinx] theme for inspiration.
101101

102-
[sphinx]: http://sphinx.pocoo.org/
102+
[sphinx]: https://www.sphinx-doc.org/en/stable/
103103

104104
## Usage
105105

docs/extensions/attr_list.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ This extension is included in the standard Markdown library.
1111

1212
## Syntax
1313

14-
The basic syntax was inspired by [Maruku][]'s Attribute Lists feature.
14+
The basic syntax was inspired by Maruku's Attribute Lists feature (see [web archive][Maruku]).
1515

16-
[Maruku]: http://maruku.rubyforge.org/proposal.html#attribute_lists
16+
[Maruku]: https://web.archive.org/web/20170324172643/http://maruku.rubyforge.org/proposal.html
1717

1818
### The List
1919

docs/test_tools.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,6 @@ rules apply.
169169
[unittest]: https://docs.python.org/3/library/unittest.html
170170
[Perl]: https://daringfireball.net/projects/markdown/
171171
[PHP]: http://michelf.com/projects/php-markdown/
172-
[PyTidyLib]: http://countergram.com/open-source/pytidylib/
172+
[PyTidyLib]: http://countergram.github.io/pytidylib/
173173
[Contributing Guide]: contributing.md
174174
[development environment]: contributing.md#development-environment

tox.ini

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[tox]
2-
envlist = py35, py36, py37, py38, pypy3, flake8, checkspelling, pep517check
2+
envlist = py35, py36, py37, py38, pypy3, flake8, checkspelling, pep517check, checklinks
33
isolated_build = True
44
min_verison = 1.9
55

@@ -20,6 +20,11 @@ deps =
2020
mkdocs_nature
2121
commands = {toxinidir}/checkspelling.sh
2222

23+
[testenv:checklinks]
24+
whitelist_externals = markdown-link-check
25+
deps =
26+
commands = {toxinidir}/checklinks.sh
27+
2328
[testenv:pep517check]
2429
deps = pep517
2530
commands = python -m pep517.check {toxinidir}

0 commit comments

Comments
 (0)