Skip to content

Commit

Permalink
Add checklinks tox env and shell script. (#955)
Browse files Browse the repository at this point in the history
Also clean up dead links.
  • Loading branch information
waylan committed May 8, 2020
1 parent 375db8c commit a605265
Show file tree
Hide file tree
Showing 11 changed files with 51 additions and 11 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ matrix:
- aspell
- aspell-en
- env: TOXENV=pep517check
- env: TOXENV=checklinks
before_install: npm install -g markdown-link-check

addons:
apt:
Expand Down
31 changes: 31 additions & 0 deletions checklinks.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash

echo "Checking links in documentation..."

# List of files in docs dir
docs=$(find . -path './docs/*.md')
# List of files in project root (README, etc)
extras=$(find . -maxdepth 1 -name '*.md')
# Combined list of files to check
files=("${docs[@]}" "${extras[@]}")

let "fails=0"
let "count=0"

for file in ${files[@]}; do
let "count++"
markdown-link-check -q "$file"
if [ $? -ne 0 ]; then
let "fails++"
fi
done

echo -e "\n\033[0;33m$count files checked."

if [ $fails -gt 0 ]; then
echo -e "\033[0;31mERROR: $fails files with dead links found!"
exit 1
else
echo -e "\033[0;32mCongratulations! No dead links found."
exit 0
fi
2 changes: 1 addition & 1 deletion docs/authors.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Primary Authors
Ph.D. Various pieces of his code still exist, most notably the basic
structure.

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

Manfed wrote the original version of the script and is responsible for
various parts of the existing code base.
Expand Down
3 changes: 2 additions & 1 deletion docs/change_log/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Python-Markdown Change Log

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

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

Apr. 2004: Manfred's version at <http://www.dwerg.net/projects/markdown/>
Apr. 2004: Manfred's version at `http://www.dwerg.net/projects/markdown/`
2 changes: 1 addition & 1 deletion docs/change_log/release-2.2.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ What's New in Python-Markdown 2.2
---------------------------------

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

The [Sane_Lists](../extensions/sane_lists.md)
Expand Down
2 changes: 1 addition & 1 deletion docs/change_log/release-2.3.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ Backwards-incompatible Changes
PyTidyLib rather than using an extension (for example:
`tidylib.tidy_fragment(markdown.markdown(source), options={...})`).

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

What's New in Python-Markdown 2.3
---------------------------------
Expand Down
5 changes: 3 additions & 2 deletions docs/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ propose changes to this document in a pull request.

This project and everyone participating in it is governed by the
[Python-Markdown Code of Conduct]. By participating, you are expected to uphold
this code. Please report unacceptable behavior to <markdown@freewisdom.org>.
this code. Please report unacceptable behavior to [markdown@freewisdom.org][email].

## Project Organization

Expand Down Expand Up @@ -473,6 +473,7 @@ label from the same group.

[Python-Markdown Organization]: https://github.com/Python-Markdown
[Python-Markdown Code of Conduct]: https://github.com/Python-Markdown/markdown/blob/master/CODE_OF_CONDUCT.md
[email]: mailto:markdown@freewisdom.org
[Python-Markdown/markdown]: https://github.com/Python-Markdown/markdown
[issue tracker]: https://github.com/Python-Markdown/markdown/issues
[syntax rules]: https://daringfireball.net/projects/markdown/syntax
Expand All @@ -495,7 +496,7 @@ label from the same group.
[configure a remote]: https://help.github.com/articles/configuring-a-remote-for-a-fork
[sync changes]: https://help.github.com/articles/syncing-a-fork
[virtual environment]: https://virtualenv.pypa.io/en/stable/
[User Guide]: https://virtualenv.pypa.io/en/stable/userguide/#usage
[User Guide]: https://virtualenv.pypa.io/en/stable/user_guide.html
[Development Mode]: https://setuptools.readthedocs.io/en/latest/setuptools.html#development-mode
[PyTidyLib]: https://countergram.github.io/pytidylib/
[HTML Tidy]: https://www.html-tidy.org/
Expand Down
2 changes: 1 addition & 1 deletion docs/extensions/admonition.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ Styling
There is no CSS included as part of this extension. Check out the default
[Sphinx][sphinx] theme for inspiration.

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

## Usage

Expand Down
4 changes: 2 additions & 2 deletions docs/extensions/attr_list.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ This extension is included in the standard Markdown library.

## Syntax

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

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

### The List

Expand Down
2 changes: 1 addition & 1 deletion docs/test_tools.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,6 @@ rules apply.
[unittest]: https://docs.python.org/3/library/unittest.html
[Perl]: https://daringfireball.net/projects/markdown/
[PHP]: http://michelf.com/projects/php-markdown/
[PyTidyLib]: http://countergram.com/open-source/pytidylib/
[PyTidyLib]: http://countergram.github.io/pytidylib/
[Contributing Guide]: contributing.md
[development environment]: contributing.md#development-environment
7 changes: 6 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = py35, py36, py37, py38, pypy3, flake8, checkspelling, pep517check
envlist = py35, py36, py37, py38, pypy3, flake8, checkspelling, pep517check, checklinks
isolated_build = True
min_verison = 1.9

Expand All @@ -20,6 +20,11 @@ deps =
mkdocs_nature
commands = {toxinidir}/checkspelling.sh

[testenv:checklinks]
whitelist_externals = markdown-link-check
deps =
commands = {toxinidir}/checklinks.sh

[testenv:pep517check]
deps = pep517
commands = python -m pep517.check {toxinidir}
Expand Down

0 comments on commit a605265

Please sign in to comment.