Automatic markdown and YAML formatting with Prettier (#874)

This commit is contained in:
Yngve Høiseth 2019-10-21 11:42:46 +02:00 committed by Łukasz Langa
parent ba2733dc81
commit a6d866990e
12 changed files with 748 additions and 845 deletions

View File

@ -1,26 +1,26 @@
install: install:
- C:\Python36\python.exe -m pip install mypy - C:\Python36\python.exe -m pip install mypy
- C:\Python36\python.exe -m pip install -e .[d] - C:\Python36\python.exe -m pip install -e .[d]
# Not a C# project # Not a C# project
build: off build: off
test_script: test_script:
- C:\Python36\python.exe tests/test_black.py - C:\Python36\python.exe tests/test_black.py
- C:\Python36\python.exe -m mypy black.py blackd.py tests/test_black.py - C:\Python36\python.exe -m mypy black.py blackd.py tests/test_black.py
after_test: after_test:
- C:\Python36\python.exe -m pip install pyinstaller - C:\Python36\python.exe -m pip install pyinstaller
- "%CMD_IN_ENV% C:\\Python36\\python.exe -m PyInstaller --clean -F --add-data blib2to3/;blib2to3 black.py" - "%CMD_IN_ENV% C:\\Python36\\python.exe -m PyInstaller --clean -F --add-data
blib2to3/;blib2to3 black.py"
artifacts: artifacts:
- path: dist/black.exe - path: dist/black.exe
deploy: deploy:
provider: GitHub provider: GitHub
description: '' description: ""
auth_token: auth_token:
secure: uplI9CJ2dTGcEBCbZuIn+Qb4rC38hOoRSH9lcwuGCr5g9fSnhK1MZdNT6Cjf/mFL secure: uplI9CJ2dTGcEBCbZuIn+Qb4rC38hOoRSH9lcwuGCr5g9fSnhK1MZdNT6Cjf/mFL
on: on:
APPVEYOR_REPO_TAG: true APPVEYOR_REPO_TAG: true

View File

@ -1,13 +1,11 @@
# Treat each other well # Treat each other well
Everyone participating in the *Black* project, and in particular in the Everyone participating in the _Black_ project, and in particular in the issue tracker,
issue tracker, pull requests, and social media activity, is expected pull requests, and social media activity, is expected to treat other people with respect
to treat other people with respect and more generally to follow the and more generally to follow the guidelines articulated in the
guidelines articulated in the [Python Community Code of [Python Community Code of Conduct](https://www.python.org/psf/codeofconduct/).
Conduct](https://www.python.org/psf/codeofconduct/).
At the same time, humor is encouraged. In fact, basic familiarity with At the same time, humor is encouraged. In fact, basic familiarity with Monty Python's
Monty Python's Flying Circus is expected. We are not savages. Flying Circus is expected. We are not savages.
And if you *really* need to slap somebody, do it with a fish while And if you _really_ need to slap somebody, do it with a fish while dancing.
dancing.

View File

@ -1,37 +1,35 @@
--- ---
name: Bug report name: Bug report
about: Create a report to help us improve about: Create a report to help us improve
title: '' title: ""
labels: bug labels: bug
assignees: '' assignees: ""
--- ---
**Describe the bug** **Describe the bug** A clear and concise description of what the bug is.
A clear and concise description of what the bug is.
**To Reproduce** Steps to reproduce the behavior:
**To Reproduce**
Steps to reproduce the behavior:
1. Take this file '...' 1. Take this file '...'
2. Run *Black* on it with these arguments '....' 2. Run _Black_ on it with these arguments '....'
3. See error 3. See error
**Expected behavior** **Expected behavior** A clear and concise description of what you expected to happen.
A clear and concise description of what you expected to happen.
**Environment (please complete the following information):** **Environment (please complete the following information):**
- Version: [e.g. master] - Version: [e.g. master]
- OS and Python version: [e.g. Linux/Python 3.7.4rc1] - OS and Python version: [e.g. Linux/Python 3.7.4rc1]
**Does this bug also happen on master?** **Does this bug also happen on master?** To answer this, you have two options:
To answer this, you have two options:
1. Use the online formatter at https://black.now.sh/?version=master, which will use the latest master branch.
2. Or run *Black* on your machine:
* create a new virtualenv (make sure it's the same Python version);
* clone this repository;
* run `pip install -e .`;
* make sure it's sane by running `python setup.py test`; and
* run `black` like you did last time.
**Additional context** 1. Use the online formatter at https://black.now.sh/?version=master, which will use the
Add any other context about the problem here. latest master branch.
2. Or run _Black_ on your machine:
- create a new virtualenv (make sure it's the same Python version);
- clone this repository;
- run `pip install -e .`;
- make sure it's sane by running `python setup.py test`; and
- run `black` like you did last time.
**Additional context** Add any other context about the problem here.

View File

@ -1,20 +1,19 @@
--- ---
name: Feature request name: Feature request
about: Suggest an idea for this project about: Suggest an idea for this project
title: '' title: ""
labels: enhancement labels: enhancement
assignees: '' assignees: ""
--- ---
**Is your feature request related to a problem? Please describe.** **Is your feature request related to a problem? Please describe.** A clear and concise
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] description of what the problem is. Ex. I'm always frustrated when [...]
**Describe the solution you'd like** **Describe the solution you'd like** A clear and concise description of what you want to
A clear and concise description of what you want to happen. happen.
**Describe alternatives you've considered** **Describe alternatives you've considered** A clear and concise description of any
A clear and concise description of any alternative solutions or features you've considered. alternative solutions or features you've considered.
**Additional context** **Additional context** Add any other context or screenshots about the feature request
Add any other context or screenshots about the feature request here. here.

View File

@ -1,30 +1,29 @@
--- ---
name: Style issue name: Style issue
about: Help us improve the Black style about: Help us improve the Black style
title: '' title: ""
labels: design labels: design
assignees: '' assignees: ""
--- ---
**Describe the style change** **Describe the style change** A clear and concise description of how the style can be
A clear and concise description of how the style can be improved. improved.
**Examples in the current _Black_ style** Think of some short code snippets that show
how the current _Black_ style is not great:
**Examples in the current *Black* style**
Think of some short code snippets that show how the current *Black* style is not great:
``` ```
def f(): def f():
"Make sure this code is blackened""" "Make sure this code is blackened"""
pass pass
``` ```
**Desired style** **Desired style** How do you think _Black_ should format the above snippets:
How do you think *Black* should format the above snippets:
``` ```
def f( def f(
): ):
pass pass
``` ```
**Additional context** **Additional context** Add any other context about the problem here.
Add any other context about the problem here.

View File

@ -22,3 +22,9 @@ repos:
hooks: hooks:
- id: mypy - id: mypy
exclude: ^docs/conf.py exclude: ^docs/conf.py
- repo: https://github.com/prettier/prettier
rev: 1.18.2
hooks:
- id: prettier
args: [--prose-wrap=always, --print-width=88]

View File

@ -1,8 +1,8 @@
- id: black - id: black
name: black name: black
description: 'Black: The uncompromising Python code formatter' description: "Black: The uncompromising Python code formatter"
entry: black entry: black
language: python language: python
language_version: python3 language_version: python3
require_serial: true require_serial: true
types: [python] types: [python]

View File

@ -4,14 +4,14 @@ cache:
directories: directories:
- $HOME/.cache/pre-commit - $HOME/.cache/pre-commit
env: env:
- TEST_CMD="coverage run tests/test_black.py" - TEST_CMD="coverage run tests/test_black.py"
install: install:
- pip install coverage coveralls pre-commit - pip install coverage coveralls pre-commit
- pip install -e '.[d]' - pip install -e '.[d]'
script: script:
- $TEST_CMD - $TEST_CMD
after_success: after_success:
- coveralls - coveralls
notifications: notifications:
on_success: change on_success: change
on_failure: always on_failure: always

View File

@ -1,61 +1,54 @@
# Contributing to *Black* # Contributing to _Black_
Welcome! Happy to see you willing to make the project better. Have you
read the entire [user documentation](https://black.readthedocs.io/en/latest/)
yet?
Welcome! Happy to see you willing to make the project better. Have you read the entire
[user documentation](https://black.readthedocs.io/en/latest/) yet?
## Bird's eye view ## Bird's eye view
In terms of inspiration, *Black* is about as configurable as *gofmt*. In terms of inspiration, _Black_ is about as configurable as _gofmt_. This is
This is deliberate. deliberate.
Bug reports and fixes are always welcome! Please follow the [issue Bug reports and fixes are always welcome! Please follow the
template on GitHub](https://github.com/psf/black/issues/new) for best [issue template on GitHub](https://github.com/psf/black/issues/new) for best results.
results.
Before you suggest a new feature or configuration knob, ask yourself why
you want it. If it enables better integration with some workflow, fixes
an inconsistency, speeds things up, and so on - go for it! On the other
hand, if your answer is "because I don't like a particular formatting"
then you're not ready to embrace *Black* yet. Such changes are unlikely
to get accepted. You can still try but prepare to be disappointed.
Before you suggest a new feature or configuration knob, ask yourself why you want it. If
it enables better integration with some workflow, fixes an inconsistency, speeds things
up, and so on - go for it! On the other hand, if your answer is "because I don't like a
particular formatting" then you're not ready to embrace _Black_ yet. Such changes are
unlikely to get accepted. You can still try but prepare to be disappointed.
## Technicalities ## Technicalities
Development on the latest version of Python is preferred. As of this Development on the latest version of Python is preferred. As of this writing it's 3.8.
writing it's 3.8. You can use any operating system. I am using macOS You can use any operating system. I am using macOS myself and CentOS at work.
myself and CentOS at work.
Install all development dependencies using: Install all development dependencies using:
``` ```
$ pipenv install --dev $ pipenv install --dev
$ pipenv shell $ pipenv shell
$ pre-commit install $ pre-commit install
``` ```
If you haven't used `pipenv` before but are comfortable with virtualenvs,
just run `pip install pipenv` in the virtualenv you're already using and If you haven't used `pipenv` before but are comfortable with virtualenvs, just run
invoke the command above from the cloned *Black* repo. It will do the `pip install pipenv` in the virtualenv you're already using and invoke the command above
correct thing. from the cloned _Black_ repo. It will do the correct thing.
Before submitting pull requests, run tests with: Before submitting pull requests, run tests with:
``` ```
$ python setup.py test $ python setup.py test
``` ```
## Hygiene ## Hygiene
If you're fixing a bug, add a test. Run it first to confirm it fails, If you're fixing a bug, add a test. Run it first to confirm it fails, then fix the bug,
then fix the bug, run it again to confirm it's really fixed. run it again to confirm it's really fixed.
If adding a new feature, add a test. In fact, always add a test. But
wait, before adding any large feature, first open an issue for us to
discuss the idea first.
If adding a new feature, add a test. In fact, always add a test. But wait, before adding
any large feature, first open an issue for us to discuss the idea first.
## Finally ## Finally
Thanks again for your interest in improving the project! You're taking Thanks again for your interest in improving the project! You're taking action when most
action when most people decide to sit and watch. people decide to sit and watch.

1372
README.md

File diff suppressed because it is too large Load Diff

View File

@ -2,9 +2,9 @@ name: black_docs
channels: channels:
- conda-forge - conda-forge
dependencies: dependencies:
- python>=3.6 - python>=3.6
- Sphinx==1.7.2 - Sphinx==1.7.2
- pip: - pip:
- recommonmark==0.4.0 - recommonmark==0.4.0
- git+https://git@github.com/psf/black.git - git+https://git@github.com/psf/black.git
- setuptools_scm==3.3.3 - setuptools_scm==3.3.3

View File

@ -1,6 +1,6 @@
name: black name: black
type: sphinx type: sphinx
conda: conda:
file: docs/environment.yml file: docs/environment.yml
python: python:
version: 3 version: 3