Skip to content

Commit

Permalink
Prepare initial published release
Browse files Browse the repository at this point in the history
This commit prepares the package for an initial release on PyPI:

- Updates pyproject.toml file for release
- Adds tests
- Adds Python 3.6 and PyPy3.6 support
- Adds Tox for local testing
- Adds Travis CI
- Adds EditorConfig
- Improves README
- Adds LICENSE file
  • Loading branch information
johnfraney committed May 19, 2019
1 parent db882f1 commit 4d91634
Show file tree
Hide file tree
Showing 11 changed files with 238 additions and 147 deletions.
13 changes: 13 additions & 0 deletions .editorconfig
@@ -0,0 +1,13 @@
# http://editorconfig.org

root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

[*.{py,md,toml}]
indent_style = space
indent_size = 4
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -26,6 +26,7 @@ share/python-wheels/
.installed.cfg
*.egg
MANIFEST
poetry.lock

# PyInstaller
# Usually these files are written by a python script from a template
Expand Down
15 changes: 15 additions & 0 deletions .travis.yml
@@ -0,0 +1,15 @@
dist: xenial # required for Python >= 3.7
language: python
cache: pip
matrix:
include:
- name: "3.6"
python: 3.6
- name: "3.7"
python: 3.7
before_install:
- pip install poetry
install:
- poetry install -v
script:
- pytest
22 changes: 22 additions & 0 deletions LICENSE
@@ -0,0 +1,22 @@
MIT License

Copyright (c) 2019 John Franey

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

53 changes: 51 additions & 2 deletions README.md
@@ -1,3 +1,52 @@
# flake8-markdown
# Flake8 Markdown

This package lints Python code blocks in Markdown files using [`flake8`](https://flake8.readthedocs.io/en/stable/).
[
![PyPI](https://img.shields.io/pypi/v/flake8-markdown.svg)
![PyPI](https://img.shields.io/pypi/pyversions/flake8-markdown.svg)
![PyPI](https://img.shields.io/pypi/l/flake8-markdown.svg)
](https://pypi.org/project/flake8-markdown/)
[![TravisCI](https://travis-ci.org/johnfraney/flake8-markdown.svg?branch=master)](https://travis-ci.org/johnfraney/flake8-markdown)

Flake8 Markdown lints [GitHub-style Python code blocks](https://help.github.com/en/articles/creating-and-highlighting-code-blocks#fenced-code-blocks) in Markdown files using [`flake8`](https://flake8.readthedocs.io/en/stable/).

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

## Usage

### CLI

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

`flake8-markdown` accepts one or more [globs](https://docs.python.org/3.7/library/glob.html) as its arguments.

Example:

```console
$ 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](https://pre-commit.com/). 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:

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

## History

### [0.1.0] - 2019-05-19

#### Added

- Added code for initial release
5 changes: 3 additions & 2 deletions flake8_markdown/__init__.py
Expand Up @@ -5,6 +5,8 @@
import sys
from concurrent.futures import ThreadPoolExecutor

from .constants import SUBPROCESS_ARGS

__version__ = '0.1.0'


Expand Down Expand Up @@ -50,9 +52,8 @@ def lint_markdown_file(markdown_file_path):
match_text = match.lstrip()
flake8_process = subprocess.run(
['flake8', '-'],
capture_output=True,
input=match_text,
encoding='ascii',
**SUBPROCESS_ARGS,
)
flake8_output = flake8_process.stdout
markdown_line_number = code_block_start_lines[match_number] + 1
Expand Down
16 changes: 16 additions & 0 deletions flake8_markdown/constants.py
@@ -0,0 +1,16 @@
import subprocess
import sys


if sys.version_info.major == 3 and sys.version_info.minor >= 7:
SUBPROCESS_ARGS = dict(
capture_output=True,
text=True,
)
else:
SUBPROCESS_ARGS = dict(
encoding='ascii',
universal_newlines=True,
stderr=subprocess.PIPE,
stdout=subprocess.PIPE,
)
139 changes: 0 additions & 139 deletions poetry.lock

This file was deleted.

21 changes: 19 additions & 2 deletions pyproject.toml
@@ -1,15 +1,32 @@
[tool.poetry]
name = "flake8-markdown"
version = "0.1.0"
description = ""
description = "Lints Python code blocks in Markdown files using flake8"
authors = ["John Franey <johnfraney@gmail.com>"]
repository = "https://github.com/johnfraney/flake8-markdown"
homepage = "https://github.com/johnfraney/flake8-markdown"
license = "MIT"
readme = "README.md"
keywords = ["flake8", "markdown", "lint"]
classifiers = [
"Environment :: Console",
"Framework :: Flake8",
"Operating System :: OS Independent",
"Topic :: Software Development :: Documentation",
"Topic :: Software Development :: Libraries :: Python Modules",
"Topic :: Software Development :: Quality Assurance",
]
include = [
"LICENCE",
]

[tool.poetry.dependencies]
python = "^3.7"
python = "^3.6"
flake8 = "^3.7"

[tool.poetry.dev-dependencies]
pytest = "^3.0"
twine = "^1.13"

[tool.poetry.scripts]
flake8-markdown = 'flake8_markdown:main'
Expand Down

0 comments on commit 4d91634

Please sign in to comment.