Skip to content

Add a Sphinx role to link to GitHub labels #932

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

Merged
merged 3 commits into from
Oct 7, 2022

Conversation

hugovk
Copy link
Member

@hugovk hugovk commented Aug 8, 2022

This adds a :gh-label: role to link to a GitHub label on https://github.com/python/cpython.

For example:

  • `:gh-label:`docs` -> https://github.com/python/cpython/issues?q=is%3Aopen+sort%3Aupdated-desc+label%3Adocs

  • :gh-label:`skip news` -> https://github.com/python/cpython/issues?q=is%3Aopen+sort%3Aupdated-desc+label%3A%22skip+news%22

This makes it easy to click through to see recent examples of the actual label in use.

It also helps #821 because we can click through and find which labels have since been deleted (e.g. invalid) or renamed (library).

Copy link
Contributor

@erlend-aasland erlend-aasland left a comment

Choose a reason for hiding this comment

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

Neat!

@ezio-melotti
Copy link
Member

This makes it easy to click through to see recent examples of the actual label in use.

This might also be helpful in a couple of other places in the devguide that link e.g. to doc or easy issues, but I wonder if it's a bit overkill to create a role just for it 🤔

It also helps #821 because we can click through and find which labels have since been deleted (e.g. invalid) or renamed (library).

This will only work by clicking through the links manually, right? Even invalid labels will return a valid search page with no results, so we won't be able to detect them automatically. Also, FWIW, I'm fixing that section in #930.

@hugovk
Copy link
Member Author

hugovk commented Aug 9, 2022

This might also be helpful in a couple of other places in the devguide that link e.g. to doc or easy issues, but I wonder if it's a bit overkill to create a role just for it 🤔

My thinking behind creating a role was that we can define all the params stuff in a single place, and it'll then also be consistent. Using GitHub's defaults here:

https://github.com/python/cpython/issues?q=is%3Aopen+sort%3Aupdated-desc+label%3Afoo

It also deals with escaping and quoting labels that contains spaces.


This will only work by clicking through the links manually, right?

Yep.

Even invalid labels will return a valid search page with no results, so we won't be able to detect them automatically.

Correct, just for manual checking.

Also, FWIW, I'm fixing that section in #930.

Great, I knew you were working on it somewhere, thank you!

@terryjreedy
Copy link
Member

Any particular reason to sort by last update rather than the default of opening time? I don't know if it makes any difference on the load on GH. docs takes several seconds to return about 1200. Seems like overkill for examples.

@hugovk
Copy link
Member Author

hugovk commented Aug 9, 2022

I used the default options GitHub gave me after clicking one of the labels in the issue list, at https://github.com/python/devguide/issues

Here's timings in a fresh Incognito window with local cache disabled, 3 loads for each.

The URLs used in this PR:

  • https://github.com/python/cpython/issues?q=is%3Aopen+sort%3Aupdated-desc+label%3Adocs
  • 5.81s
  • 6.25s
  • 6.55s
  • Average: 6.20s

image

The same but removing the sort%3Aupdated-desc parameter:

  • https://github.com/python/cpython/issues?q=is%3Aopen+label%3Adocs
  • Resolved to https://github.com/python/cpython/labels/docs in the URL bar
  • 4.71s
  • 8.03s
  • 5.98s
  • Average: 6.24s

image

About the same?

But perhaps using the https://github.com/python/cpython/labels/docs form is the neatest?

@erlend-aasland
Copy link
Contributor

But perhaps using the https://github.com/python/cpython/labels/docs form is the neatest?

Definitely; I'd go for that.

@hugovk
Copy link
Member Author

hugovk commented Aug 10, 2022

Updated!

@ezio-melotti
Copy link
Member

This might also be helpful in a couple of other places in the devguide that link e.g. to doc or easy issues

I searched through the devguide and I can confirm these are the only two places where they are currently used, but they link to issues only so we might not be able to use the new role if it links to https://github.com/python/cpython/labels/{LABEL-NAME}:

.. _documentation issues: https://github.com/python/cpython/issues?q=is%3Aissue+is%3Aopen+label%3Adocs

.. _"easy" issues: https://github.com/python/cpython/issues?q=is%3Aissue+is%3Aopen+label%3Aeasy

In #930 I can add links to all the labels (the currently proposed link would work fine there), and I was also planning to add a page with several useful search queries (there it won't work). In addition in #930 I have another link that won't be able to use the role: https://github.com/python/cpython/labels?q=expert.

IOW, it looks like this role will be only useful in the page that lists the label, unless we make it more flexible.

@hugovk
Copy link
Member Author

hugovk commented Oct 5, 2022

Yep, that's right.

Originally this PR used ugly links like https://github.com/python/cpython/issues?q=is%3Aopen+sort%3Aupdated-desc+label%3Adocs, but now has nicer ones like https://github.com/python/cpython/labels/docs

So it's less useful than before, but I think it's more readable to see :gh-label:docs` than a long link.

But I'm happy to close this, or replace with normal links, or wait for normal links in #930 :)

@ezio-melotti ezio-melotti self-assigned this Oct 7, 2022
@ezio-melotti ezio-melotti merged commit 7a2a18b into python:main Oct 7, 2022
@hugovk hugovk deleted the label-role branch October 7, 2022 16:50
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

Successfully merging this pull request may close these issues.

4 participants