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

docs: feature-request: add aliases for short codes and add new format mode #4710

Closed
saippuakauppias opened this issue May 29, 2023 · 5 comments · Fixed by #8636
Closed

docs: feature-request: add aliases for short codes and add new format mode #4710

saippuakauppias opened this issue May 29, 2023 · 5 comments · Fixed by #8636
Labels
documentation Improvements or additions to documentation

Comments

@saippuakauppias
Copy link

It would be great if for every rule that has a page in the documentation you could go to it not only by its full name (unused-import: https://beta.ruff.rs/docs/rules/unused-import/ ) but also by its short code (F401: https://beta.ruff.rs/docs/rules/F401/).
This would make it easier to find best practice examples for this bug.

Also, I suggest adding a separate formatting mode based on text (e.g., call it text_links). In which a link to such pages would be given next to the short error code. For example, it could look like this:

web/currency/models.py:1:1: I001 (https://beta.ruff.rs/docs/rules/I001/) [*] Import block is un-sorted or un-formatted
web/currency/models.py:10:7: N818 (https://beta.ruff.rs/docs/rules/N818/) Exception name `CurrencyNotFound` should be named with an Error suffix
web/currency/models.py:20:121: E501 (https://beta.ruff.rs/docs/rules/E501/) Line too long (152 > 120 characters)

Or, for example, add a separate setting to enable link display mode, which will add links for formatting modes: text, grouped

This would make it a lot easier to find "how to do it better" examples and links to the original rules from the linters (which are on the rules pages) and would speed up the process of correcting mistakes.

PS: In option format there is no groupped in the default values.

@charliermarsh
Copy link
Member

You actually can link to these on the main page via anchors, like https://beta.ruff.rs/docs/rules#F401, but it's not ideal. However, we do want to move towards using the human-readable names everywhere eventually, so I'm not likely to prioritize this personally.

@charliermarsh charliermarsh added the documentation Improvements or additions to documentation label May 29, 2023
@saippuakauppias
Copy link
Author

Long names are great too, but they will take up a lot of space in the links (if implemented) within the error.

I saw this idea in the linter ShellCheck for Visual Studio Code, when hovering over the error in the IDE - a link is displayed (in the example it is SC2086 on the right) and when you click on it we get to the page: https://www.shellcheck.net/wiki/SC2086
Снимок экрана 2023-05-30 в 00 32 56

This is very handy: if you don't know what is the right fix, go to the documentation for the rule and see examples.

PS: or make a subdomain with short links that will redirect to long links. For example: https://r.ruff.rs/F401 will redirect to https://beta.ruff.rs/docs/rules/unused-import/

@charliermarsh
Copy link
Member

It would be nice to include those links in the LSP.

@charliermarsh
Copy link
Member

One thing we could do: add a Cloudflare Worker to redirect /rules/F401 to /rules/unused-import.

@saippuakauppias
Copy link
Author

That would be wonderful!

After that, someone can embed links in the error log to go directly from the console to the rule description

charliermarsh added a commit that referenced this issue Nov 12, 2023
## Summary

This adds redirects from, e.g., `https://docs.astral.sh/ruff/rules/F401`
to `https://docs.astral.sh/ruff/rules/unused-import`, which are
generated automatically when creating the documentation. Though we want
to move towards human-readable names eventually, I think this is a nice
and user-friendly change (and doesn't require any fancy infrastructure,
since the redirects are handled via a plugin and added client-side).

Closes #4710.
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 a pull request may close this issue.

2 participants