Extract and process code blocks from markdown files.
Project description
codeblock
Extract and process code blocks from markdown files.
Examples
Extract Python code blocks:
codeblock --python README.md
Check formatting of Python code blocks with black:
codeblock --python README.md | black --check -
Reformat Python code blocks with black, in place:
codeblock --python README.md -- black -
Type check Python code blocks with mypy:
mypy somemodule anothermodule <(codeblock --python README.md)
Full type checking example
def plus(x: int, y: int) -> int:
return x + y
plus(1, '2')
$ mypy --pretty --strict <(codeblock --python README.md)
/dev/fd/63:5: error: Argument 2 to "plus" has incompatible type "str"; expected "int"
plus(1, '2')
^
Found 1 error in 1 file (checked 1 source file)
TODO
- protect against empty (and weird?) in-place modifications
- use same regex for both modes
- example for pytest
- automatically add
asyncfor functions withawaitin them - support other languages
- use proper markdown parser
- support multiple files
Related
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
codeblocks-0.1.1.tar.gz
(6.6 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file codeblocks-0.1.1.tar.gz.
File metadata
- Download URL: codeblocks-0.1.1.tar.gz
- Upload date:
- Size: 6.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.0.2 CPython/2.7.15 Darwin/18.7.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
707a53d04f7d0539bf45b3352213caa8ddf6dc4036e2859029b63234d729afdb
|
|
| MD5 |
77f25bb1bccdb60a3858e8f39ad7d715
|
|
| BLAKE2b-256 |
89f36000dce54012067f0e10e1a0c49ad54ce5a873f54935489bb73e0be9e46b
|
File details
Details for the file codeblocks-0.1.1-py3-none-any.whl.
File metadata
- Download URL: codeblocks-0.1.1-py3-none-any.whl
- Upload date:
- Size: 6.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.0.2 CPython/2.7.15 Darwin/18.7.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ac7a4eb1ed8aa0369e6329780e950eeab725526b4aaa9181a9ed46bff43328f9
|
|
| MD5 |
795933051ab3b0d4da9eb990ea035c68
|
|
| BLAKE2b-256 |
7f0ac02739604fca00e6412059309f9803357086c792cfd5d1d9fbc108bf86c9
|