Name | mkdocs-code-validator JSON |
Version |
0.2.0
JSON |
| download |
home_page | |
Summary | Checks Markdown code blocks in a MkDocs site against user-defined actions |
upload_time | 2023-09-15 23:26:09 |
maintainer | |
docs_url | None |
author | |
requires_python | >=3.7 |
license | |
keywords |
mkdocs
mkdocs-plugin
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# mkdocs-code-validator
**Checks Markdown code blocks in a [MkDocs][] site against user-defined actions**
[![PyPI](https://img.shields.io/pypi/v/mkdocs-code-validator)](https://pypi.org/project/mkdocs-code-validator/)
[![License](https://img.shields.io/github/license/oprypin/mkdocs-code-validator)](https://github.com/oprypin/mkdocs-code-validator/blob/master/LICENSE.md)
[![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/oprypin/mkdocs-code-validator/ci.yml.svg)](https://github.com/oprypin/mkdocs-code-validator/actions?query=event%3Apush+branch%3Amaster)
```shell
pip install mkdocs-code-validator
```
## Usage
Activate the plugin in **mkdocs.yml**. The `identifiers` config is mandatory. And the plugin **doesn't work without [pymdownx.superfences][]**:
```yaml
plugins:
- search
- code-validator:
identifiers:
bash:
validators:
- grep a
markdown_extensions:
- pymdownx.superfences
```
The above contrived config checks that every <code>```bash</code> code block in the Markdown files of this MkDocs site must contain the letter "a", otherwise a warning will appear.
The content of each code block is piped as stdin to the command. The exit code of the command is what's checked: a non-zero code will produce a warning (which in MkDocs you can make fatal with the `--strict` flag). The output of the command is not used in any way, only preserved on the screen as part of a warning.
You can add any number of identifiers, and within them any number of `validators` commands, each of them has the ability to produce a warning.
If stdin is not usable with your command, the input can be passed as a temporary file instead -- that is done if the command contains the exact argument `$<` (which is then replaced with a file path). For the above example, changing the command to `grep a $<` would be equivalent (other than technicalities).
The commands do *not* allow freeform shell syntax, it's just one subprocess to call with its arguments. To explicitly opt into a shell, just run it as (e.g.) `sh -c 'if grep a; then exit 1; fi'`. Or, with a temporary file: `sh -c 'if grep a "$1"; then exit 1; fi' $<`.
The definition of what a code block is is all according to the [pymdownx.superfences][] extension. It must be enabled; the plugin won't do anything without it.
[mkdocs]: https://www.mkdocs.org/
[documentation site]: https://oprypin.github.io/mkdocs-code-validator
[pymdownx.superfences]: https://facelessuser.github.io/pymdown-extensions/extensions/superfences/
Raw data
{
"_id": null,
"home_page": "",
"name": "mkdocs-code-validator",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": "",
"keywords": "mkdocs,mkdocs-plugin",
"author": "",
"author_email": "Oleh Prypin <oleh@pryp.in>",
"download_url": "https://files.pythonhosted.org/packages/fd/b5/dd7a910313fc66b6319f8647d930ff6d53612b87c112f9756e3ecaef556c/mkdocs_code_validator-0.2.0.tar.gz",
"platform": null,
"description": "# mkdocs-code-validator\n\n**Checks Markdown code blocks in a [MkDocs][] site against user-defined actions**\n\n[![PyPI](https://img.shields.io/pypi/v/mkdocs-code-validator)](https://pypi.org/project/mkdocs-code-validator/)\n[![License](https://img.shields.io/github/license/oprypin/mkdocs-code-validator)](https://github.com/oprypin/mkdocs-code-validator/blob/master/LICENSE.md)\n[![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/oprypin/mkdocs-code-validator/ci.yml.svg)](https://github.com/oprypin/mkdocs-code-validator/actions?query=event%3Apush+branch%3Amaster)\n\n```shell\npip install mkdocs-code-validator\n```\n\n## Usage\n\nActivate the plugin in **mkdocs.yml**. The `identifiers` config is mandatory. And the plugin **doesn't work without [pymdownx.superfences][]**:\n\n```yaml\nplugins:\n - search\n - code-validator:\n identifiers:\n bash:\n validators:\n - grep a\nmarkdown_extensions:\n - pymdownx.superfences\n```\n\nThe above contrived config checks that every <code>```bash</code> code block in the Markdown files of this MkDocs site must contain the letter \"a\", otherwise a warning will appear.\n\nThe content of each code block is piped as stdin to the command. The exit code of the command is what's checked: a non-zero code will produce a warning (which in MkDocs you can make fatal with the `--strict` flag). The output of the command is not used in any way, only preserved on the screen as part of a warning.\n\nYou can add any number of identifiers, and within them any number of `validators` commands, each of them has the ability to produce a warning.\n\nIf stdin is not usable with your command, the input can be passed as a temporary file instead -- that is done if the command contains the exact argument `$<` (which is then replaced with a file path). For the above example, changing the command to `grep a $<` would be equivalent (other than technicalities).\n\nThe commands do *not* allow freeform shell syntax, it's just one subprocess to call with its arguments. To explicitly opt into a shell, just run it as (e.g.) `sh -c 'if grep a; then exit 1; fi'`. Or, with a temporary file: `sh -c 'if grep a \"$1\"; then exit 1; fi' $<`.\n\nThe definition of what a code block is is all according to the [pymdownx.superfences][] extension. It must be enabled; the plugin won't do anything without it.\n\n\n[mkdocs]: https://www.mkdocs.org/\n[documentation site]: https://oprypin.github.io/mkdocs-code-validator\n[pymdownx.superfences]: https://facelessuser.github.io/pymdown-extensions/extensions/superfences/\n",
"bugtrack_url": null,
"license": "",
"summary": "Checks Markdown code blocks in a MkDocs site against user-defined actions",
"version": "0.2.0",
"project_urls": {
"Documentation": "https://oprypin.github.io/mkdocs-code-validator/",
"Issues": "https://github.com/oprypin/mkdocs-code-validator/issues",
"Source": "https://github.com/oprypin/mkdocs-code-validator"
},
"split_keywords": [
"mkdocs",
"mkdocs-plugin"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "a83fab35145de20859a0332b5c0db8ecbf0f20994d4ae382c1bc356deb635822",
"md5": "46e362b7f922141f57c954da97c53351",
"sha256": "0ef5053c2fa839b22f611b5130868d738804d1b25826d6c21e7f58c9aec18167"
},
"downloads": -1,
"filename": "mkdocs_code_validator-0.2.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "46e362b7f922141f57c954da97c53351",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 5917,
"upload_time": "2023-09-15T23:26:07",
"upload_time_iso_8601": "2023-09-15T23:26:07.809705Z",
"url": "https://files.pythonhosted.org/packages/a8/3f/ab35145de20859a0332b5c0db8ecbf0f20994d4ae382c1bc356deb635822/mkdocs_code_validator-0.2.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "fdb5dd7a910313fc66b6319f8647d930ff6d53612b87c112f9756e3ecaef556c",
"md5": "f925c98e3f00b0fe06722740d109b93b",
"sha256": "486fee004da88659bafe0dc2c0439792e067c181f5168d4b4be990261db4a14e"
},
"downloads": -1,
"filename": "mkdocs_code_validator-0.2.0.tar.gz",
"has_sig": false,
"md5_digest": "f925c98e3f00b0fe06722740d109b93b",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 5391,
"upload_time": "2023-09-15T23:26:09",
"upload_time_iso_8601": "2023-09-15T23:26:09.484725Z",
"url": "https://files.pythonhosted.org/packages/fd/b5/dd7a910313fc66b6319f8647d930ff6d53612b87c112f9756e3ecaef556c/mkdocs_code_validator-0.2.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-09-15 23:26:09",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "oprypin",
"github_project": "mkdocs-code-validator",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "mkdocs-code-validator"
}