Skip to content

Commit 32df5ad

Browse files
committed
Add Docs spellchecking Test.
Not sure this is the best way to go, but it works. I'm not crazy about running the spellcheck against the built docs, but aspell has a builtin option to easily ignore everything in `<code>` tags which greatly simplfies things. I looked at Doug Hellmans' sphinxcontrib-spelling package which does something similar for Sphinx. However, as Sphinx uses rST and the rST parser outputs a parse tree, Doug is essentially taking that parse tree and running the spellcheck on the appropriate parts (skipping code, etc.). He did a nice [writeup][5] of his development process if you are interested. As Python-Markdown's parse tree is represented as HTML (through ElementTree) I would have to use HTML anyway. And [PyEnchant][2] doesn't currently have good support for HTML. So I used [aspell][3], with inspiration from the [git-spell-check][4] hook. [1]: http://sphinxcontrib-spelling.readthedocs.org/en/latest/index.html [2]: https://pythonhosted.org/pyenchant/ [3]: http://aspell.net/ [4]: https://github.com/mprpic/git-spell-check [5]: http://doughellmann.com/2011/05/26/creating-a-spelling-checker-for-restructuredtext-documents.html
1 parent 93dad08 commit 32df5ad

File tree

4 files changed

+157
-1
lines changed

4 files changed

+157
-1
lines changed

.spell-dict

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
Abrahamsen
2+
Altmayer
3+
API
4+
Artem
5+
Babelmark
6+
backtick
7+
backticks
8+
Balogh
9+
BlockParser
10+
Blockprocessor
11+
Blockprocessors
12+
blockquote
13+
blockquotes
14+
CamelCase
15+
Chodarev
16+
CLI
17+
CodeHilite
18+
Cogumbreiro
19+
CSS
20+
Dmitry
21+
ElementTree
22+
extendMarkdown
23+
Fauske
24+
Formatter
25+
Fortin
26+
GitHub
27+
Gruber
28+
GSoC
29+
hacky
30+
HeaderId
31+
HTTPS
32+
implementers
33+
InlineProcessor
34+
Jiryu
35+
JSON
36+
Kjell
37+
Krech
38+
kwargs
39+
Limberg
40+
Magne
41+
MAILTO
42+
makeExtension
43+
Manfed
44+
markdownFromFile
45+
Maruku
46+
multi
47+
MultiMarkdown
48+
munge
49+
namespace
50+
NanoDOM
51+
Neale
52+
nosetests
53+
OrderedDict
54+
OrderedDicts
55+
OSX
56+
Ph
57+
PHP
58+
Postprocessor
59+
Postprocessors
60+
Preprocessor
61+
Preprocessors
62+
Pygments
63+
PyPI
64+
PyPy
65+
PYTHONPATH
66+
PyTidyLib
67+
PyYAML
68+
rc
69+
refactor
70+
refactored
71+
refactors
72+
registerExtension
73+
RSS
74+
rST
75+
ryneeverett
76+
sanitizer
77+
sanitizers
78+
Sauder
79+
schemeless
80+
Sergej
81+
serializer
82+
serializers
83+
Shachnev
84+
slugify
85+
SmartyPants
86+
Sourceforge
87+
StackOverflow
88+
Stansifer
89+
stdout
90+
Stelios
91+
Stienstra
92+
subclasses
93+
svn
94+
Swartz
95+
Szakmeister
96+
Takteyev
97+
Tiago
98+
tokenized
99+
tox
100+
Trac
101+
traceback
102+
Tredinnick
103+
Treeprocessor
104+
Treeprocessors
105+
tuples
106+
unordered
107+
untrusted
108+
UTF
109+
uTidylib
110+
versa
111+
Waylan
112+
WikiLink
113+
WikiLinks
114+
Wolever
115+
Xanthakis
116+
XHTML
117+
YAML
118+
Yunusov

.travis.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@ env:
66
- TOXENV=py34
77
- TOXENV=pypy
88
- TOXENV=flake8
9+
- TOXENV=checkspelling
910
before_install:
1011
- sudo apt-get update -qq
1112
- sudo apt-get install libtidy-0.99-0
13+
- sudo apt-get install aspell
1214
install:
1315
- pip install tox
1416
- pip install coveralls

checkspelling.sh

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/bash
2+
3+
echo "Building docs..."
4+
python setup.py --quiet build_docs --force
5+
echo "Compiling Dictionary..."
6+
aspell --lang=en create master ./tmp <.spell-dict
7+
echo "Checking spelling...\n"
8+
9+
let "fails=0"
10+
11+
for file in $(find build/docs/ -type f -name "*.html"); do
12+
words=$(aspell list --lang=en --mode=html --add-html-skip=code --extra-dicts=./tmp <$file)
13+
if [ "$words" ]; then
14+
uniquewords=$(tr ' ' '\n' <<< "${words[@]}" | sort -u | tr '\n' ' ')
15+
let "fails++"
16+
echo "Misspelled words in '$file':"
17+
echo "-----------------------------------------------------------------"
18+
for word in ${uniquewords[@]}; do
19+
echo $word
20+
done
21+
echo "-----------------------------------------------------------------"
22+
fi
23+
done
24+
rm -f ./tmp
25+
rm -rf build
26+
27+
if [ $fails -gt 0 ]; then
28+
echo "$fails files with misspelled words."
29+
exit 1
30+
else
31+
exit 0
32+
fi

tox.ini

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[tox]
2-
envlist = py27, py32, py33, py34, pypy, flake8
2+
envlist = py27, py32, py33, py34, pypy, flake8, checkspelling
33

44
[testenv]
55
downloadcache = {toxworkdir}/cache
@@ -11,5 +11,9 @@ commands = coverage run --source=markdown {toxinidir}/run-tests.py {posargs}
1111
deps = flake8
1212
commands = flake8 {toxinidir}/markdown {toxinidir}/tests {toxinidir}/setup.py {toxinidir}/run-tests.py
1313

14+
[testenv:checkspelling]
15+
deps =
16+
commands = {toxinidir}/checkspelling.sh
17+
1418
[flake8]
1519
max-line-length = 119

0 commit comments

Comments
 (0)