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

Rework the documentation to incorporate the Ruff formatter #7732

Merged
merged 1 commit into from
Oct 20, 2023

Conversation

charliermarsh
Copy link
Member

@charliermarsh charliermarsh commented Oct 1, 2023

Summary

This PR updates our documentation for the upcoming formatter release.

Broadly, the documentation is now structured as follows:

  • Overview
  • Tutorial
  • Installing Ruff
  • The Ruff Linter
    • Overview
    • ruff check
    • Rule selection
    • Error suppression
    • Exit codes
  • The Ruff Formatter
    • Overview
    • ruff format
    • Philosophy
    • Configuration
    • Format suppression
    • Exit codes
    • Black compatibility
      • Known deviations
  • Configuring Ruff
    • pyproject.toml
    • File discovery
    • Configuration discovery
    • CLI
    • Shell autocompletion
  • Preview
  • Rules
  • Settings
  • Integrations
    • pre-commit
    • VS Code
    • LSP
    • PyCharm
    • GitHub Actions
  • FAQ
  • Contributing

The major changes include:

  • Removing the "Usage" section from the docs, and instead folding that information into "Integrations" and the new Linter and Formatter sections.
  • Breaking up "Configuration" into "Configuring Ruff" (for generic configuration), and new Linter- and Formatter-specific sections.
  • Updating all example configurations to use [tool.ruff.lint] and [tool.ruff.format].

My suggestion is to pull and build the docs locally, and review by reading them in the browser rather than trying to parse all the code changes.

Closes #7235.

Closes #7647.

@charliermarsh charliermarsh added the documentation Improvements or additions to documentation label Oct 1, 2023
@charliermarsh charliermarsh force-pushed the charlie/formatter-docs branch 7 times, most recently from e81c509 to c64f374 Compare October 1, 2023 03:37
- [`bad-quotes-inline-string`](rules/bad-quotes-inline-string.md)
- [`bad-quotes-multiline-string`](rules/bad-quotes-multiline-string.md)
- [`bad-quotes-docstring`](rules/bad-quotes-docstring.md)
- [`avoidable-escaped-quote`](rules/avoidable-escaped-quote.md)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These aren't necessarily conflicting with the formatter. The quote rules are probably consistent with it, assuming you have the same quote settings. And the trailing comma rules won't conflict with the formatter, they'll just end up changing the resulting formatting.


This will likely be incorporated into Black's preview style ([#3823](https://github.com/psf/black/pull/3823)).

<h4><code>global</code> and <code>nonlocal</code> names are broken across multiple lines by continuations</h4>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using <h4> here ensures that this long list of intentional deviations is omitted from the table of contents on the left side of the page, which IMO is good. However, it also means they can't be permalinked, which IMO is bad...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you manually give them id? It's still not really accessible to users but at least it's possible if you know.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I decided to move them to their own page.

@github-actions
Copy link
Contributor

github-actions bot commented Oct 1, 2023

PR Check Results

Ecosystem

✅ ecosystem check detected no changes.

Copy link
Member

@konstin konstin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📜 📜 📜

docs/configuration.md Outdated Show resolved Hide resolved
docs/faq.md Show resolved Hide resolved
docs/faq.md Outdated Show resolved Hide resolved
docs/formatter.md Show resolved Hide resolved
docs/formatter.md Show resolved Hide resolved
docs/formatter.md Outdated Show resolved Hide resolved
docs/formatter.md Outdated Show resolved Hide resolved

This will likely be incorporated into Black's preview style ([#3823](https://github.com/psf/black/pull/3823)).

<h4><code>global</code> and <code>nonlocal</code> names are broken across multiple lines by continuations</h4>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you manually give them id? It's still not really accessible to users but at least it's possible if you know.

docs/linter.md Outdated Show resolved Hide resolved
docs/tutorial.md Show resolved Hide resolved
@codspeed-hq
Copy link

codspeed-hq bot commented Oct 1, 2023

CodSpeed Performance Report

Merging #7732 will not alter performance

Comparing charlie/formatter-docs (27a56f6) with main (fa556d1)

Summary

✅ 25 untouched benchmarks

docs/formatter.md Outdated Show resolved Hide resolved
@charliermarsh charliermarsh force-pushed the charlie/formatter-docs branch 2 times, most recently from 72a64c6 to 72a1f4d Compare October 2, 2023 23:03
docs/formatter/black.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
docs/configuration.md Outdated Show resolved Hide resolved
docs/configuration.md Outdated Show resolved Hide resolved
docs/faq.md Outdated Show resolved Hide resolved
docs/formatter.md Show resolved Hide resolved
scripts/generate_mkdocs.py Show resolved Hide resolved
@charliermarsh charliermarsh force-pushed the charlie/formatter-docs branch 2 times, most recently from 9fd6737 to 0b67439 Compare October 5, 2023 15:42
zanieb added a commit that referenced this pull request Oct 11, 2023
Adds documentation for using `ruff check . --fix`

Uses the draft of the "Automatic fixes" section from
#7732 and adds documentation for
unsafe fixes, applicability levels, and
#7841

I enabled admonitions because they're nice. We should use them more.
docs/configuration.md Outdated Show resolved Hide resolved
docs/configuration.md Outdated Show resolved Hide resolved
docs/faq.md Outdated Show resolved Hide resolved
docs/formatter.md Show resolved Hide resolved
docs/formatter.md Outdated Show resolved Hide resolved
docs/formatter.md Outdated Show resolved Hide resolved
docs/formatter.md Outdated Show resolved Hide resolved
@MichaReiser
Copy link
Member

We should add an example for how to exclude certain files from linting / formatting only #8000

README.md Outdated Show resolved Hide resolved
docs/configuration.md Outdated Show resolved Hide resolved
@@ -208,26 +217,44 @@ exclude = [
# Same as Black.
line-length = 88
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
line-length = 88
line-length = 88
indent-width = 4

@@ -45,22 +37,45 @@ exclude = [
"node_modules",
"venv",
]
per-file-ignores = {}

# Same as Black.
line-length = 88
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
line-length = 88
indent-width = 4

@@ -45,22 +37,45 @@ exclude = [
"node_modules",
"venv",
]
per-file-ignores = {}

# Same as Black.
line-length = 88
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
line-length = 88
line-width = 88

Comment on lines +177 to +179
# ...but use a different line length.
line-length = 100
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# ...but use a different line length.
line-length = 100
# ...but use a different line width.
line-width = 100

docs/formatter.md Outdated Show resolved Hide resolved
docs/tutorial.md Outdated
Comment on lines 130 to 138
# Decrease the maximum line length to 79 characters.
line-length = 79
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# Decrease the maximum line length to 79 characters.
line-length = 79
# Decrease the maximum line width to 79.
line-width = 79

formatter's treatment of import statements when set to non-default values:

- [`lines-after-imports`](https://docs.astral.sh/ruff/settings/#isort-lines-after-imports)
- [`lines-between-types`](https://docs.astral.sh/ruff/settings/#isort-lines-between-types)
Copy link
Member

@MichaReiser MichaReiser Oct 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Our internal configuration document mentions more conflicting rules and isort options. Are there reasons why you excluded some of the rules and options from here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll add them, but it's the same confusion as in your PR that enables the warnings -- what constitutes a "conflict"?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also added ISC001 and Q003, were those intentionally omitted?

@charliermarsh charliermarsh force-pushed the charlie/formatter-docs branch 2 times, most recently from 7acc677 to c365de2 Compare October 20, 2023 22:44
@charliermarsh
Copy link
Member Author

Made all changes except I haven't done the length to width tweaks yet, since that hasn't merged.

@charliermarsh charliermarsh enabled auto-merge (squash) October 20, 2023 22:46
@charliermarsh charliermarsh force-pushed the charlie/formatter-docs branch 5 times, most recently from 2adc81f to cf8ba7a Compare October 20, 2023 22:50
@charliermarsh charliermarsh force-pushed the charlie/formatter-docs branch 5 times, most recently from 527b370 to 27a56f6 Compare October 20, 2023 23:00
@charliermarsh charliermarsh enabled auto-merge (squash) October 20, 2023 23:00
@charliermarsh charliermarsh merged commit f6d6200 into main Oct 20, 2023
15 checks passed
@charliermarsh charliermarsh deleted the charlie/formatter-docs branch October 20, 2023 23:08
zanieb pushed a commit that referenced this pull request Oct 28, 2023
## Summary

As a follow-up of #7732, use
`tool.ruff.lint` in more places in documentations, tests and internal
usages.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Document rules potentially conflicting with the formatter Formatter: Documentation
7 participants