sphinx-doc / sphinx-doc/sphinx
Improve error message for when reference target not found
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 8k
- Forks
- 2.6k
- PR merge metrics
- No merged PRs in 30d
Description
Is your feature request related to a problem? Please describe.
When doing a nitpicky documentation build, warnings are issued when single backticks are used and the corresponding object cannot be found. For example, if we have the following reStructuredText...
A user can provide any of these arguments: `T`, `Vperp`, or `lorentzfactor`.
...then we will get warnings like the following (where py:obj is the default role).
<unknown>:21: WARNING: py:obj reference target not found: T
<unknown>:21: WARNING: py:obj reference target not found: Vperp
<unknown>:21: WARNING: py:obj reference target not found: lorentzfactor
For a new contributor, these warning messages can be quite confusing. It's not necessarily clear what py:obj refers to, or what it means for something to be a "reference target". Most importantly, it doesn't provide the user any hints on how to fix the problem, so they might get stuck.
Describe the solution you'd like
It would be really helpful to make this warning message friendlier to newcomers such as by giving them a hint about how to fix the warning. For example, the message could ask the user if there was a misspelling, or if they intended to use double backticks.
Additional context
We might be able to take some inspiration from the improved error messages that are planned for Python 3.12. One example:
>>> sys.version_info
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'sys' is not defined. Did you forget to import 'sys'?
Thank you!
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue does not name an implementation file, test, or entry point. Start by locating the code that emits the “reference target not found” warning and its existing tests, then compare the current message with the requested guidance about misspellings and double backticks. Done means the warning is clearer for newcomers and the relevant tests cover the new wording.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- documentation
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100