Skip to content

Rule documentation link does not work with lower case code #15016

Description

@DaniBodor

When trying to load a specific rule's documentation page using a the lower case letter for that rule (e.g. https://docs.astral.sh/ruff/rules/f401), I get a 404 - Not Found.
After loading the page once using an uppercase letter instead (which does work), if I then try it again with the lowercase, my browser (Firefox) automatically corrects the lowercase to the uppercase and the site does load.
It might be nice to make the mirror work immediately in a case insensitive manner.

Activity

  1. changed the title [-]documentation mirror does not work with lower case letters[/-] [+]Rule documentation link does not work with lower case code[/+] on Dec 17, 2024
  2. dhruvmanila commented on Dec 17, 2024

    @dhruvmanila
    Member

    Yeah, I noticed this last week and I was wondering if this should be allowed because the rule selection wouldn't allow lowercase either (select = ["f401"] doesn't work). The same argument can be applied to rule names as well as it only works with lower case names so https://docs.astral.sh/ruff/rules/Unused-Import doesn't work.

  3. DaniBodor commented on Dec 17, 2024

    @DaniBodor
    Author

    What would be the argument not to allow it?
    I guess formally you're right that it's an "invalid" rule code, but I don't think there's any level of confusion of what is intended when a user inputs a rule code with a lower case letter.
    I find it convenient to type the rule code without worrying about the capitalization, and have now a few times been surprised as to why it doesnt always work (until I discovered that it'll only work if I've been on that page before).

  4. dhruvmanila commented on Jan 17, 2025

    @dhruvmanila
    Member

    I think it's fine to add the lowercase variant. The following would need to be updated to generate the redirects from lowercase rule codes as well:

    config["plugins"].append(
    {
    "redirects": {
    "redirect_maps": {
    f"rules/{rule['code']}.md": f"rules/{rule['name']}.md"
    for rule in rules
    },
    },
    },
    )

  5. added a commit that references this issue on Jan 18, 2025
    9730ff3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to public-facing documentation

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions