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

Direct link when searching for a short code #13684

Closed
opk12 opened this issue Oct 8, 2024 · 6 comments
Closed

Direct link when searching for a short code #13684

opk12 opened this issue Oct 8, 2024 · 6 comments
Labels
documentation Improvements or additions to documentation help wanted Contributions especially welcome

Comments

@opk12
Copy link

opk12 commented Oct 8, 2024

When I type a short code in the search bar on the website (https://docs.astral.sh/ruff), for example ruf005, the search suggestion is a link to the list of warnings. When I type a long code, for example collection-literal-concatenation, the search suggestion is a direct link to the warning's article. Could the short code case be changed?

@MichaReiser
Copy link
Member

Hmm, that's unfortunate. We would have to look into our Algolia search configuration to see how it index pages and either change the Algolia configuration or the structure of the rule's page. I don't think I've access to Algolia (@charliermarsh )

@MichaReiser MichaReiser added the documentation Improvements or additions to documentation label Oct 9, 2024
@charliermarsh
Copy link
Member

I think we'd need some sort of support in material-for-mkdocs, e.g., via https://squidfunk.github.io/mkdocs-material/plugins/search/.

@squidfunk
Copy link

squidfunk commented Oct 10, 2024

Author of Material for MkDocs here – results should drastically improve once we release the new search, which is currently blocked by a bigger refactor we're working on in the background (@charliermarsh we talked about this recently), as mentioned in our latest blog post. Once we got a first version of that ready, we'll reach out to you for giving it a try ☺️ We estimate that this should be the case by the beginning of next year.

In the meantime, as a bandaid, you should be able to improve discovery by using tags, and tagging each rule with its modifier. Tags currently take precedence over everything else in search:

---
tags:
- ruf005
---

# Tag name

@MichaReiser MichaReiser added the help wanted Contributions especially welcome label Oct 10, 2024
@MichaReiser
Copy link
Member

Wow thanks @squidfunk for the details! Adding the tags should be a very straightforward change and looking forward to the new search engine

@hreeder
Copy link
Contributor

hreeder commented Nov 1, 2024

I've pushed a PR that adds these tags to the function used to generate the page metadata - I think this should be all that's required but absolutely open to input & feedback on how to do it.

charliermarsh added a commit that referenced this issue Nov 1, 2024
## Summary

<!-- What's the purpose of the change? What does it do, and why? -->
This PR updates the metadata in the YAML frontmatter of the mkdocs
documentation to include the rule short code as a tag, so it can be
easily searched.
Ref: #13684

## Test Plan

<!-- How was it tested? -->
This has been tested locally using the documentation provided
[here](https://docs.astral.sh/ruff/contributing/#mkdocs) for generating
docs.

This generates docs that now have the tags section:
```markdown
---
description: Checks for abstract classes without abstract methods.
tags:
- B024
---

# abstract-base-class-without-abstract-method (B024)
... trimmed
```

I've also verified that this gives the ability to get straight to the
page via search when serving mkdocs locally.

---------

Co-authored-by: Charlie Marsh <[email protected]>
TomerBin pushed a commit to TomerBin/ruff that referenced this issue Nov 3, 2024
## Summary

<!-- What's the purpose of the change? What does it do, and why? -->
This PR updates the metadata in the YAML frontmatter of the mkdocs
documentation to include the rule short code as a tag, so it can be
easily searched.
Ref: astral-sh#13684

## Test Plan

<!-- How was it tested? -->
This has been tested locally using the documentation provided
[here](https://docs.astral.sh/ruff/contributing/#mkdocs) for generating
docs.

This generates docs that now have the tags section:
```markdown
---
description: Checks for abstract classes without abstract methods.
tags:
- B024
---

# abstract-base-class-without-abstract-method (B024)
... trimmed
```

I've also verified that this gives the ability to get straight to the
page via search when serving mkdocs locally.

---------

Co-authored-by: Charlie Marsh <[email protected]>
@dhruvmanila
Copy link
Member

The PR implementing this (#14040) has been merged and has been deployed with the release of 0.7.2.

Screenshot 2024-11-04 at 9 19 22 AM

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 help wanted Contributions especially welcome
Projects
None yet
Development

No branches or pull requests

7 participants
@hreeder @squidfunk @MichaReiser @charliermarsh @opk12 @dhruvmanila and others