question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Automatic links from code examples to reference documentation

See original GitHub issue

Proposal

Hi! I’d like to propose an improvement to urllib3’s documentation. The change would make urllib3’s functions and classes in code examples clickable to take the user to their reference documentation entries. I’ve built the documentation locally for a proof of concept, so here’s the home page example:

home page links

It would use the sphinx-codeautolink extension to automatically analyse the examples and produce links.

Context

Full disclosure: I’m the author of said extension. I spent the weekend building a bunch of different Python projects with it and fixed lots of issues. urllib3’s case was very neat though, so I decided to propose this to you directly. The library is in beta, but based on local testing it worked well. Currently the setup is only two lines of code in conf.py: activating the extension and configuring an “import urllib3” to be included before all examples:

extensions = [
    ...,
    "sphinx_codeautolink",
]
codeautolink_global_preface = "import urllib3"

Alternatives / against the change

The current solution of linking the relevant function before every example certainly works quite well especially since the examples are pretty simple, containing very few different functions per snippet! Perhaps some links could be stripped out if this change is adopted though. Also, it could be not entirely obvious that the code examples are clickable, leading to some confusion.

Contribution

I’d be willing to submit a PR for sure, once we figure out the details!


What do you think, would it be a good fit? If you don’t like the change, feel free to shoot me down immediately! I recognise this could be just adding some maintenance burden for little gain, but personally I think the links make user experience much better. Also, let me know if you have any questions!

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
sethmlarsoncommented, Nov 23, 2021

@felix-hilden Yeah! We build our docs on every PR and they can be viewed in a staging environment on RTD.

1reaction
felix-hildencommented, Nov 23, 2021

I think the ping missed me, but anyways, thank you for the kind words!

With his well-thought-out explanation, I think I agree too. But I’d love to help if I can! Your theme is Furo already, so what do you mean? Or simply submitting a PR to see it in action fully?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Automatic link generation - Doxygen Manual
For man pages no reference information is generated. The next sections show how to generate links to the various documented entities in a...
Read more >
How to use links in documentation - Contributor guide
To link to auto-generated API reference pages in the current docset or other docsets, use XRef links with the unique ID (UID) of...
Read more >
felix-hilden/sphinx-codeautolink: Automatic links from ... - GitHub
sphinx-codeautolink makes code examples clickable by inserting links from individual code elements to the corresponding reference documentation. We aim for a ...
Read more >
Cross-referencing with Sphinx - Read the Docs
Instead, Sphinx offers a powerful way to linking to the different elements of the document, called cross-references. Some advantages of using them:.
Read more >
sphinx-codeautolink - PyPI
Automatic links from code examples to reference documentation.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found