Skip to content
Lints Python code blocks in Markdown files using flake8
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
flake8_markdown
tests
.editorconfig Prepare initial published release May 19, 2019
.gitignore Prepare initial published release May 19, 2019
.pre-commit-hooks.yaml Add support for pre-commit May 17, 2019
.travis.yml Prepare initial published release May 19, 2019
LICENSE Prepare initial published release May 19, 2019
README.md Add support for linting pycon code blocks Jun 15, 2019
pyproject.toml
tox.ini

README.md

Flake8 Markdown

PyPI PyPI PyPI TravisCI

Flake8 Markdown lints GitHub-style Python code blocks in Markdown files using flake8.

This package helps improve a Python project's documentation by ensuring that code samples are error-free.

Features

  • Lints code blocks containing regular Python and Python interpreter code (pycon)
  • pre-commit hook to lint on commit

Installation

Flake8 Markdown can be installed from PyPI using pip or your package manager of choice:

pip install flake8-markdown

Usage

CLI

You can use Flake8 Markdown as a CLI tool using the flake8-markdown command.

flake8-markdown accepts one or more globs as its arguments.

Example:

$ flake8-markdown flake8-markdown "tests/samples/*.md"
tests/samples/emphasized_lines.md:6:1: F821 undefined name 'emphasized_imaginary_function'
tests/samples/basic.md:8:48: E999 SyntaxError: EOL while scanning string literal
tests/samples/basic.md:14:7: F821 undefined name 'undefined_variable'

pre-commit hook

You can also add flake8-markdown to your project using pre-commit. When configured, any staged Markdown files will be linted using flake8-markdown once you run git commit.

To enable this hook in your local repository, add the following repo to your .pre-commit-config.yaml file:

# .pre-commit-config.yaml
repos:
  - repo: https://github.com/johnfraney/flake8-markdown
    rev: v0.2.0
    hooks:
      - id: flake8-markdown

Code of Conduct

Everyone interacting in the project's codebases, issue trackers, chat rooms, and mailing lists is expected to follow the PyPA Code of Conduct.

History

[0.2.0] - 2019-06-14

Added

  • pycon code block support

[0.1.1] - 2019-05-19

Changed

  • Fixed pre-commit example in README

[0.1.0] - 2019-05-19

Added

  • Added code for initial release
You can’t perform that action at this time.