Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Public programmatic api #292

Closed
asottile opened this issue Jun 2, 2018 · 4 comments
Closed

Public programmatic api #292

asottile opened this issue Jun 2, 2018 · 4 comments

Comments

@asottile
Copy link
Contributor

asottile commented Jun 2, 2018

I'd like to use the functionality of black to apply to unique cases where black is (probably) not interested in covering.

The specific example I had in mind, was parsing out .. code-block:: python portions in .rst files or fenced python blocks in markdown and formatting them.

Initial idea inspired from here

@zsol
Copy link
Collaborator

zsol commented Jun 2, 2018

You should be able to depend on black as a library and use format_str for this for now, but you probably already figured this out.

So your real question seems to be how stable do we expect these APIs to be. I think until we're out of beta we won't give any promises, but I'll let @ambv give you a definitive answer

@asottile
Copy link
Contributor Author

asottile commented Jun 2, 2018

Yep, definitely found that -- though it's not documented anywhere and I wasn't sure about the stability there.

@ambv
Copy link
Collaborator

ambv commented Jun 2, 2018

Anthony, we don't define __all__ yet and at some point we might break black into a few modules. We've grown quite a bit in the last three months.

That being said, if you are using format_str(), you should be fine. I'm already trying not to break its compatibility (there are already existing use cases for it).

This was referenced Jun 3, 2018
gaborbernat pushed a commit to tox-dev/tox that referenced this issue Jun 3, 2018
Hi friends, I made a terrific (terrible? terrifying?) thing.

I needed one manual `,` addition to the `setup.py` example so it could be parsed -- otherwise this is fully automated!

Using the new thing I made today: https://github.com/asottile/blacken-docs

Heavily inspired by pytest-dev/pytest#3525.  See also psf/black#292, psf/black#294.
@asottile
Copy link
Contributor Author

asottile commented Jun 3, 2018

Cool, this wasn't so bad. In all I needed:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants