Skip to content
This repository has been archived by the owner on Oct 27, 2023. It is now read-only.

Commit

Permalink
Use pyspelling to check spelling.
Browse files Browse the repository at this point in the history
In addition to checking the spelling in our documentation, we are now also checking the spelling of the README.md and similar files as well as comments in our Python code.
  • Loading branch information
waylan authored Apr 6, 2023
1 parent be1c283 commit 07b8b2c
Show file tree
Hide file tree
Showing 49 changed files with 544 additions and 480 deletions.
88 changes: 88 additions & 0 deletions .pyspelling.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
spellchecker: aspell

matrix:
- name: mkdocs
group: docs
sources:
- site/**/*.html
aspell:
lang: en
d: en_US
dictionary:
wordlists:
- .spell-dict
output: build/dictionary/mkdocs.dic
pipeline:
- pyspelling.filters.html:
comments: false
attributes:
- title
- alt
ignores:
- 'code, pre'
captures:
- '[role=main] *|*:not(script,style)'
- pyspelling.filters.context:
context_visible_first: true
delimiters:
# Ignore possessive endings
- open: '(?<=\w)’s(?!\w)'
close: '\b'
- pyspelling.filters.url:

- name: markdown
group: docs
sources:
- README.md
- INSTALL.md
- LICENSE.md
- CODE_OF_CONDUCT.md
aspell:
lang: en
d: en_US
mode: markdown
dictionary:
wordlists:
- .spell-dict
output: build/dictionary/markdown.dic

- name: python
group: source
sources:
- '{markdown,tests}/**/*.py'
aspell:
lang: en
d: en_US
mode: markdown
dictionary:
wordlists:
- .spell-dict
output: build/dictionary/python.dic
pipeline:
- pyspelling.filters.python:
group_comments: true
- pyspelling.flow_control.wildcard:
allow:
- py-comment
- pyspelling.filters.context:
context_visible_first: true
delimiters:
# Ignore lint (noqa) and coverage (pragma) as well as shebang (#!)
- open: '^(?: *(?:noqa\b|pragma: no cover)|!)'
close: '$'
# Ignore Python encoding string -*- encoding stuff -*-
- open: '^ *-\*-'
close: '-\*-$'
# Ignore possessive endings
- open: '(?<=\w)''s(?!\w)'
close: '\b'
- pyspelling.filters.context:
context_visible_first: true
escapes: '\\[\\`]'
delimiters:
# Ignore lines which are inedented at least one level (Markdown code block)
# For some reason indented code blocks are not properly ignored by aspell in markdown mode.
# Warning: This could ignore a nested list item
- open: '^ {4,}'
close: '$'
- pyspelling.filters.url:
28 changes: 27 additions & 1 deletion .spell-dict
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ Fortin
GitHub
globals
Gruber
Gruber's
GSoC
hacky
HeaderId
Expand All @@ -59,6 +60,7 @@ Manfed
markdownFromFile
Maruku
md
merchantability
metadata
MkDocs
multi
Expand Down Expand Up @@ -88,6 +90,8 @@ PYTHONPATH
PyTidyLib
PyYAML
rc
redistribution
redistributions
refactor
refactored
refactors
Expand All @@ -104,6 +108,7 @@ setuptools
Sergej
serializer
serializers
sexualized
Shachnev
sitemap
slugify
Expand All @@ -119,7 +124,7 @@ SuperFences
svn
Swartz
Szakmeister
Takteyev
Takhteyev
Tiago
toc
tokenized
Expand Down Expand Up @@ -161,3 +166,24 @@ plugins
configs
pre
formatters

dedented
Setext
unindented
monkeypatch
TODO
Nko
Thaana
Tifinagh
backport
Fredrik
Lundh
subclass
tortious
performantly
Seemant
Kulleen
Serafim
overridable
unescaped
APIs
38 changes: 0 additions & 38 deletions checkspelling.sh

This file was deleted.

2 changes: 1 addition & 1 deletion docs/authors.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Primary Authors
and has been assisting with maintenance, reviewing pull requests and ticket
triage.

* __[Yuri Takteyev](https://github.com/yuri)__
* __[Yuri Takhteyev](https://github.com/yuri)__

Yuri wrote most of the code found in version 1.x while procrastinating his
Ph.D. Various pieces of his code still exist, most notably the basic
Expand Down
6 changes: 3 additions & 3 deletions docs/change_log/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,10 @@ August 18 2008: Reorganized directory structure. Added a 'docs' directory
and moved all extensions into a 'markdown-extensions' package.
Added additional documentation and a few bug fixes. (v2.0-beta)

August 4 2008: Updated included extensions to ElementTree. Added a
August 4 2008: Updated included extensions to `ElementTree`. Added a
separate command line script. (v2.0-alpha)

July 2008: Switched from home-grown NanoDOM to ElementTree and
July 2008: Switched from home-grown `NanoDOM` to `ElementTree` and
various related bugs (thanks Artem Yunusov).

June 2008: Fixed issues with nested inline patterns and cleaned
Expand Down Expand Up @@ -310,7 +310,7 @@ syntax in headers (e.g. links) and got the lists to use p-tags
correctly (v. 0.8)

Aug. 29, 2005: Added flexible tabs, fixed a few small issues, added
basic support for footnotes. Got rid of xml.dom.minidom and added
basic support for footnotes. Got rid of `xml.dom.minidom` and added
pretty-printing. (v. 0.7)

Aug. 13, 2005: Fixed a number of small bugs in order to conform to the
Expand Down
2 changes: 1 addition & 1 deletion docs/change_log/release-3.3.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ The following new features have been included in the 3.3 release:
blocks when the `attr_list` extension is enabled (#816).

* The HTML parser has been completely replaced. The new HTML parser is built on Python's
[html.parser.HTMLParser](https://docs.python.org/3/library/html.parser.html), which
[`html.parser.HTMLParser`](https://docs.python.org/3/library/html.parser.html), which
alleviates various bugs and simplify maintenance of the code (#803, #830).

* The [Markdown in HTML](../extensions/md_in_html.md) extension has been rebuilt on the
Expand Down
5 changes: 3 additions & 2 deletions docs/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -421,8 +421,9 @@ following steps:

- Deploy an update to the documentation using [MkDocs]. The following example
assumes that local clones of the [Python-Markdown/markdown] and
[Python-Markdown/Python-Markdown.github.io] repositories are in sibling
directories named `markdown` and `Python-Markdown.github.io` respectively.
[`Python-Markdown/Python-Markdown.github.io`][Python-Markdown/Python-Markdown.github.io]
repositories are in sibling directories named `markdown` and `Python-Markdown.github.io`
respectively.

cd Python-Markdown.github.io
mkdocs gh-deploy --config-file ../markdown/mkdocs.yml --remote-branch master
Expand Down
4 changes: 2 additions & 2 deletions docs/test_tools.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Therefore, the tools are importable from `markdown.test_tools`.
The test tools include two different `unittest.TestCase` subclasses:
`markdown.test_tools.TestCase` and `markdown.test_tools.LegacyTestCase`.

## markdown.test_tools.TestCase
## `markdown.test_tools.TestCase`

The `markdown.test_tools.TestCase` class is a `unittest.TestCase` subclass with
a few additional helpers to make testing Markdown output easier.
Expand Down Expand Up @@ -66,7 +66,7 @@ class TestHr(TestCase):
)
```

## markdown.test_tools.LegacyTestCase
## `markdown.test_tools.LegacyTestCase`

In the past Python-Markdown exclusively used file-based tests. Many of those
tests still exist in Python-Markdown's test suite, including the test files from
Expand Down
4 changes: 2 additions & 2 deletions markdown/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,6 @@ def run(): # pragma: no cover


if __name__ == '__main__': # pragma: no cover
# Support running module as a commandline command.
# `python -m markdown [options] [args]`.
# Support running module as a command line command.
# python -m markdown [options] [args]
run()
12 changes: 6 additions & 6 deletions markdown/__meta__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@
"""

# __version_info__ format:
# (major, minor, patch, dev/alpha/beta/rc/final, #)
# (1, 1, 2, 'dev', 0) => "1.1.2.dev0"
# (1, 1, 2, 'alpha', 1) => "1.1.2a1"
# (1, 2, 0, 'beta', 2) => "1.2b2"
# (1, 2, 0, 'rc', 4) => "1.2rc4"
# (1, 2, 0, 'final', 0) => "1.2"
# (major, minor, patch, dev/alpha/beta/rc/final, #)
# (1, 1, 2, 'dev', 0) => "1.1.2.dev0"
# (1, 1, 2, 'alpha', 1) => "1.1.2a1"
# (1, 2, 0, 'beta', 2) => "1.2b2"
# (1, 2, 0, 'rc', 4) => "1.2rc4"
# (1, 2, 0, 'final', 0) => "1.2"
__version_info__ = (3, 4, 3, 'final', 0)


Expand Down
22 changes: 11 additions & 11 deletions markdown/blockparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
class State(list):
""" Track the current and nested state of the parser.
This utility class is used to track the state of the BlockParser and
This utility class is used to track the state of the `BlockParser` and
support multiple levels if nesting. It's just a simple API wrapped around
a list. Each time a state is set, that state is appended to the end of the
list. Each time a state is reset, that state is removed from the end of
Expand Down Expand Up @@ -58,10 +58,10 @@ def isstate(self, state):


class BlockParser:
""" Parse Markdown blocks into an ElementTree object.
""" Parse Markdown blocks into an `ElementTree` object.
A wrapper class that stitches the various BlockProcessors together,
looping through them and creating an ElementTree object.
A wrapper class that stitches the various `BlockProcessors` together,
looping through them and creating an `ElementTree` object.
"""

def __init__(self, md):
Expand All @@ -79,35 +79,35 @@ def parseDocument(self, lines):
This should only be called on an entire document, not pieces.
"""
# Create a ElementTree from the lines
# Create an `ElementTree` from the lines
self.root = etree.Element(self.md.doc_tag)
self.parseChunk(self.root, '\n'.join(lines))
return etree.ElementTree(self.root)

def parseChunk(self, parent, text):
""" Parse a chunk of markdown text and attach to given etree node.
""" Parse a chunk of markdown text and attach to given `etree` node.
While the ``text`` argument is generally assumed to contain multiple
While the `text` argument is generally assumed to contain multiple
blocks which will be split on blank lines, it could contain only one
block. Generally, this method would be called by extensions when
block parsing is required.
The ``parent`` etree Element passed in is altered in place.
The `parent` `etree` Element passed in is altered in place.
Nothing is returned.
"""
self.parseBlocks(parent, text.split('\n\n'))

def parseBlocks(self, parent, blocks):
""" Process blocks of markdown text and attach to given etree node.
""" Process blocks of markdown text and attach to given `etree` node.
Given a list of ``blocks``, each blockprocessor is stepped through
Given a list of `blocks`, each `blockprocessor` is stepped through
until there are no blocks left. While an extension could potentially
call this method directly, it's generally expected to be used
internally.
This is a public method as an extension may need to add/alter
additional BlockProcessors which call this method to recursively
additional `BlockProcessors` which call this method to recursively
parse a nested block.
"""
Expand Down
Loading

0 comments on commit 07b8b2c

Please sign in to comment.