Metadata-Version: 2.1
Name: pyupgrade-docs
Version: 0.3.0
Summary: Run `pyupgrade` on python code blocks in documentation files
Home-page: https://github.com/verhovsky/pyupgrade-docs
Author: Boris Verkhovskiy
Author-email: boris.verk@gmail.com
License: MIT
Platform: UNKNOWN
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: PyPy
Requires-Python: >=3.7
Description-Content-Type: text/markdown
License-File: LICENSE

pyupgrade-docs
============

Run [`pyupgrade`](https://pypi.org/project/pyupgrade/) on python code blocks in documentation files.

## install

`pip install pyupgrade-docs`

## usage

`pyupgrade-docs` provides a single executable (`pyupgrade-docs`) which will modify
`.rst` / `.md` / `.tex` files in place.

It currently supports the following [`pyupgrade`](https://github.com/asottile/pyupgrade)
options:

- `--keep-percent-format`
- `--keep-mock`
- `--keep-runtime-typing`
- `--py3-plus` `--py3-only`
- `--py36-plus`
- `--py37-plus`
- `--py38-plus`
- `--py39-plus`
- `--py310-plus`

The following additional parameters can be used:

 - `-E` / `--skip-errors`

`pyupgrade-docs` will format code in the following block types:

(markdown)
```markdown
    ```python
    def hello():
        print("hello world")
    ```
```

(markdown `pycon`)
```markdown
    ```pycon

    >>> def hello():
    ...     print("hello world")
    ...

    ```
```

(rst)
```rst
    .. code-block:: python

        def hello():
            print("hello world")
```

(rst `pycon`)
```rst
    .. code-block:: pycon

        >>> def hello():
        ...     print("hello world")
        ...
```

(latex)
```latex
\begin{minted}{python}
def hello():
    print("hello world")
\end{minted}
```

(latex `pycon`)
```latex
\begin{minted}{pycon}
>>> def hello():
...     print("hello world")
...
\end{minted}
```

(latex with pythontex)
```latex
\begin{pycode}
def hello():
    print("hello world")
\end{pycode}
```

(markdown/rst in python docstrings)
```python
def f():
    """docstring here

    .. code-block:: python

        print("hello world")

    ```python
    print("hello world")
    ```
    """
```

## usage with pre-commit

See [pre-commit](https://pre-commit.com) for instructions

Sample `.pre-commit-config.yaml`:


```yaml
-   repo: https://github.com/verhovsky/pyupgrade-docs
    rev: v0.3.0
    hooks:
    -   id: pyupgrade-docs
```


