mkdocs_spellcheck
¤
MkDocs SpellCheck package.
A spell checker plugin for MkDocs.
Modules:
-
backends–Deprecated. Import directly from
mkdocs_spellcheckinstead. -
plugin–Deprecated. Import directly from
mkdocs_spellcheckinstead. -
words–Deprecated. Import directly from
mkdocs_spellcheckinstead.
Classes:
-
Backend–Abstract class for spelling backends.
-
CodespellBackend–Backend for the
codespelltool. -
SpellCheckPlugin–A
mkdocsplugin. -
SymspellpyBackend–Backend for the
symspellpylibrary.
Functions:
-
get_words–Get words in HTML text.
-
load_backend–Load the specified backend.
Backend
¤
Bases: ABC
Abstract class for spelling backends.
Parameters:
-
(config¤dict[str, Any]) –User configuration from
mkdocs.yml. -
(known_words¤set[str] | None, default:None) –Globally known words.
Methods:
-
check–Check a word appearing in a page.
Source code in src/mkdocs_spellcheck/_internal/backends/__init__.py
33 34 35 36 37 38 39 40 41 | |
check
abstractmethod
¤
Check a word appearing in a page.
Parameters:
Source code in src/mkdocs_spellcheck/_internal/backends/__init__.py
43 44 45 46 47 48 49 50 51 | |
CodespellBackend
¤
Bases: Backend
Backend for the codespell tool.
This backend needs to build a list of misspellings based
on dictionaries provided by codespell itself.
Parameters:
-
(config¤dict[str, Any]) –User configuration from
mkdocs.yml. -
(known_words¤set[str] | None, default:None) –Globally known words.
Methods:
-
check–Check a word against the
codespellmisspellings.
Attributes:
-
misspellings(dict[str, Misspelling]) –A mapping of misspelled words to their corrections.
Source code in src/mkdocs_spellcheck/_internal/backends/codespell.py
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 | |
misspellings
instance-attribute
¤
A mapping of misspelled words to their corrections.
check
¤
check(page: Page, word: str) -> None
Check a word against the codespell misspellings.
Source code in src/mkdocs_spellcheck/_internal/backends/codespell.py
93 94 95 96 97 98 | |
SpellCheckPlugin
¤
SpellCheckPlugin()
Bases: BasePlugin[_SpellCheckConfig]
A mkdocs plugin.
This plugin defines the following event hooks:
on_configon_page_content
Check the Developing Plugins page of mkdocs
for more information about its plugin system.
Methods:
-
on_config–Load words to ignore.
-
on_page_content–Spell check everything.
Attributes:
-
allow_unicode(bool) –Keep unicode characters.
-
backends_config(list[str | dict[str, Any]]) –Backend configuration.
-
ignore_code(bool) –Ignore words in code blocks.
-
known_words(set[str]) –Words to ignore.
-
max_capital(int) –Maximum number of capital letters in a word to consider it.
-
min_length(int) –Minimum word length.
-
run(bool) –Whether to run the plugin.
-
skip_files(list[str]) –Files to skip.
-
strict_only(bool) –Only run in strict mode.
Source code in src/mkdocs_spellcheck/_internal/plugin.py
111 112 113 114 | |
backends_config
instance-attribute
¤
Backend configuration.
max_capital
instance-attribute
¤
max_capital: int
Maximum number of capital letters in a word to consider it.
on_config
¤
on_config(config: MkDocsConfig) -> MkDocsConfig | None
Load words to ignore.
Hook for the on_config event.
Parameters:
-
(config¤MkDocsConfig) –The MkDocs config object.
Returns:
-
MkDocsConfig | None–The modified config.
Source code in src/mkdocs_spellcheck/_internal/plugin.py
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 | |
on_page_content
¤
Spell check everything.
Hook for the on_page_content event.
Parameters:
-
(html¤str) –The HTML text.
-
(page¤Page) –The page instance.
-
(**kwargs¤Any, default:{}) –Additional arguments passed by MkDocs.
Source code in src/mkdocs_spellcheck/_internal/plugin.py
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 | |
SymspellpyBackend
¤
Bases: Backend
Backend for the symspellpy library.
This backend needs to load dictionaries provided
by symspellpy itself.
Parameters:
-
(config¤dict[str, Any]) –User configuration from
mkdocs.yml. -
(known_words¤set[str] | None, default:None) –Globally known words.
Methods:
-
check–Check a word against the
symspellpydictionary.
Attributes:
-
spell–The
symspellpyspell checker.
Source code in src/mkdocs_spellcheck/_internal/backends/symspellpy.py
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | |
check
¤
check(page: Page, word: str) -> None
Check a word against the symspellpy dictionary.
Source code in src/mkdocs_spellcheck/_internal/backends/symspellpy.py
79 80 81 82 83 84 85 86 87 88 89 | |
get_words
¤
get_words(
html: str,
*,
known_words: set[str] | None = None,
min_length: int = 2,
max_capital: int = 1,
ignore_code: bool = True,
allow_unicode: bool = True,
) -> list[str]
Get words in HTML text.
Parameters:
-
(html¤str) –The HTML text.
-
(known_words¤set[str] | None, default:None) –Words to exclude.
-
(min_length¤int, default:2) –Words minimum length.
-
(max_capital¤int, default:1) –Maximum number of capital letters.
-
(ignore_code¤bool, default:True) –Ignore words in code tags.
-
(allow_unicode¤bool, default:True) –Keep unicode characters.
Returns:
Source code in src/mkdocs_spellcheck/_internal/words.py
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 | |
load_backend
¤
Load the specified backend.
This function imports the specified backend and returns its class. It is important not to import the backends at the top level, as they may not be installed.
Parameters:
Returns:
-
type[Backend]–The backend class.
Source code in src/mkdocs_spellcheck/_internal/plugin.py
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | |
backends
¤
Deprecated. Import directly from mkdocs_spellcheck instead.
Modules:
-
codespell–Deprecated. Import directly from
mkdocs_spellcheckinstead. -
symspellpy–Deprecated. Import directly from
mkdocs_spellcheckinstead.
plugin
¤
Deprecated. Import directly from mkdocs_spellcheck instead.
words
¤
Deprecated. Import directly from mkdocs_spellcheck instead.