numpy / numpy/numpydoc

Add default linkcode_resolve logic

Open
#156 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
355
Forks
181
Avg merge
1d 9h
Merged PRs (30d)
3

Description

Many libraries that use numpydoc also use the Sphinx linkcode feature. In order to use it, they all must define a linkcode_resolve function that returns the web URL where the code for a given Python object can be found.

These libraries mostly seem to be using slightly modified versions of the numpy one -- for example, here are the pandas version and the scikit-learn version. Consequently, an error in the original logic has propagated to these other libraries: decorated functions often generate incorrect links. See e.g. the source code links for numpy.isposinf and sklearn.pipeline.Pipeline.predict_log_proba.

I first noticed this bug in scikit-learn and reported it in https://github.com/scikit-learn/scikit-learn/issues/10542. @jnothman suggested that instead of fixing the bug in scikit-learn only, it might make sense to put a shared, default version of linkcode_resolve in numpydoc, so that changes propagate to other libraries that implement linkcode_resolve.

Does anyone have thoughts about whether

  1. it makes sense to consolidate this logic, and
  2. numpydoc is the right place to put it? (One possible alternative would be to put it in Sphinx.)

I might be able to help with this consolidation, as time permits 😄

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the Sphinx linkcode documentation and comparing the linked implementations in NumPy's doc/source/conf.py, pandas' doc/source/conf.py, and scikit-learn's doc/sphinxext/github_link.py. The issue is done only after the placement and scope of shared default linkcode_resolve logic are decided and an implementation plan is agreed.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
documentation
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.