A browser extension to show key data about a PEP

When talking about PEPs, we often refer to them only by their number (as in “PEP 705”), sometimes without a link or any information about their subject.

I don’t think it’s inherently a bad habit: if you actually know that PEP number, it’s the most concise of referring to it unambiguously, saving time for both the writer and the reader.

If you don’t, though, you tipically have to search it up – not necessarily to read the whole PEP, but just to figure out “ah yes, it’s that one!” or “oh right, it deals with that subject, written 15 years ago!”

In some discussions covering a lot of background with different PEPs involved, I found that this quickly led to a lot of back and forth between Discourse and the PEP pages, with the consequent loss of focus and time.


To make this experience easier, I’d like to present here a small Chrome extension I’ve developed for myself, if anyone here finds it useful: PEP Tooltip!

Features :

  • Add a :information_source: character[1] alongside each “PEP XXX” pattern in any discourse.python.org message;
  • On hover, reveals a small tooltip containing key information[2] about this PEP (fetched from peps.python.org official API), with a link to the PEP;
  • Integrates well in both dark and light modes, and within various markdown / Discourse markups;
  • Handles new posts loaded when scrolling a page;
  • Lightweight, only requires read / update permission on discourse.python.org, does not collect any data whatsoever;
  • Totally open source (written in TypeScript); I wholeheartedly welcome any feedback or contributions on the GitHub repo!

While I only tested it on Chrome, I’m pretty sure it works well on any Chromium-based browser. I’m totally open to the idea of making a Firefox version if there is interest![3]


Hope this kind of message is welcome in Discourse Feedback; since it meta and Discourse-specific, I thought so, but I can move it to Python Help or anywhere :smile:


  1. I tried to use various Unicode symbols and a custom SVG, I found this emoji the most usable (automatically adjusts to text size/style) and portable across plarforms (all Unicode characters are not), but this is open to change! ↩︎

  2. Picked somewhat arbitrairely, open to change! ↩︎

  3. I considered making it a Discourse plugin, but what I wanted looked way arder to achieve, if even possible… ↩︎

10 Likes

In this post PEP 13 (both inside and outside a link) aren’t being tagged.

Still, a very cool tool!

1 Like

Thanks for trying it out! Your example seem to works well for me, did you refresh after install? Do you have anything in the console?

Screenshot

(you can also open an issue if you feel like it!)

I did, but I had to refresh that page to see the changes – probably cached.

Thanks, again!

1 Like

Worked for me in Brave. I hadn’t looked at that page before though.

1 Like

It seems Discourse might have a feature to allow auto-replacing certain words with links. Wouldn’t that be an option as well?

Interesting! That looks useful too, but it seems to be a side-wide option (“required user level : Adminitrator”). I suppose automatically adding links to “PEP XXX” patterns would be feasible and not too controversial (and useful to all users by default!).

That doesn’t quite adress my goal though, which is to have information such as PEP title, status, date… directly in the page, without the need to click a link :smile:

1 Like

That would only apply to PEP references on Discourse though, correct? What if some package’s docs referenced a PEP? Tooltips would help there as well I would think.

Ideally, documentation would link to references where appropriate [1] (PEPs, RFCs, etc) — e.g. in Sphinx one may use the PEP, RFC, CVE, etc roles in text. Replacing all patterns of PEP[- ][0-9]{,4} on every webpage might lead to annoying false-positives!

A


  1. and should be encouraged to if not ↩︎

Shouldn’t it add a link in the title too?

The extension is also limited to Discouse, both by design (I think it would be way too intrusive to alter text on all sites, and lead to false positives as Adam pointed out) and for technical reasons (for example, I use some Discourse CSS variables to handle well light vs. dark mode).

That said, I thought to extend it to other relevant sites such as GitHub, maybe some day!

I chose to only process text in messages, to avoid annoying tooltips showing up in unexpected places throughout the site (eg. in the posts lists, in the top-right menus…)

Post titles could be special-cased, though if a PEP number is mentioned in a title, it’s very likely to appear in the first lines of the message!