Skip to content
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

References not picking correct entry #9689

Closed
david-cortes opened this issue Sep 30, 2021 · 3 comments
Closed

References not picking correct entry #9689

david-cortes opened this issue Sep 30, 2021 · 3 comments
Labels

Comments

@david-cortes
Copy link

Describe the bug

References not picking correct entry

I have a Python project with NumPy-style docstrings which uses numbered references like [1]_ and then a section called References with entries like .. [1]. Usually, these are rendered as a clickable superscript which takes to the reference in the references section when clicked, but if the index.rst contains internal hyperlinks (not 100% sure that's the culprit), these references ([1]_) will not render as clickacle superscripts anymore, but will rather take to some non-existing internal (same-page) link.

Example: https://cmfrec.readthedocs.io/en/latest/

Ctrl+F for add_implicit_features for a case that doesn't render properly, and scale_lam for a case that does.

How to Reproduce

Not sure.

Expected behavior

No response

Your project

https://cmfrec.readthedocs.io/en/latest/

Screenshots

No response

OS

Linux

Python version

3.7.9

Sphinx version

4.2.0

Sphinx extensions

No response

Extra tools

No response

Additional context

No response

@tk0miya
Copy link
Member

tk0miya commented Oct 6, 2021

I confirmed your error with this Dockerfile:

FROM python:3.8-slim

RUN apt update; apt install -y build-essential curl git unzip vim
RUN git clone https://github.com/david-cortes/cmfrec/
WORKDIR /cmfrec
RUN pip install .
RUN pip install threadpoolctl
WORKDIR /cmfrec/docs
RUN pip install -r requirements.txt
RUN pip install mock
RUN pip install sphinx_rtd_theme
RUN make html

On building the document, I saw the following warnings. It says footnote numbers are conflicted. For example, both cmfrec.CMF and cmfrec.CMF_implicit have a footnote numbered as [5]. Therefore, Sphinx failed to refer it correctly.

/cmfrec/cmfrec/__init__.py:docstring of cmfrec.CMF_implicit:238: WARNING: Duplicate explicit target name: "1".
/cmfrec/cmfrec/__init__.py:docstring of cmfrec.CMF_implicit:241: WARNING: Duplicate explicit target name: "2".
/cmfrec/cmfrec/__init__.py:docstring of cmfrec.CMF_implicit:248: WARNING: Duplicate explicit target name: "4".
/cmfrec/cmfrec/__init__.py:docstring of cmfrec.CMF_implicit:251: WARNING: Duplicate explicit target name: "5".
/cmfrec/cmfrec/__init__.py:docstring of cmfrec.OMF_explicit:254: WARNING: Duplicate explicit target name: "1".
/cmfrec/cmfrec/__init__.py:docstring of cmfrec.OMF_implicit:138: WARNING: Duplicate explicit target name: "1".
/cmfrec/cmfrec/__init__.py:docstring of cmfrec.OMF_implicit:141: WARNING: Duplicate explicit target name: "2".
/cmfrec/cmfrec/__init__.py:docstring of cmfrec.OMF_implicit:144: WARNING: Duplicate explicit target name: "3".
/cmfrec/cmfrec/__init__.py:docstring of cmfrec.ContentBased:152: WARNING: Duplicate explicit target name: "1".
/cmfrec/cmfrec/__init__.py:docstring of cmfrec.MostPopular:110: WARNING: Duplicate explicit target name: "1".
/cmfrec/cmfrec/__init__.py:docstring of cmfrec.MostPopular:113: WARNING: Duplicate explicit target name: "2".

I'm not sure this is a bug. How about separating a page?

@david-cortes
Copy link
Author

Oh, didn't know that those reference were global. I however see that other docs still use repeated reference names which work locally within a given class, such as this one (reference TPT2011):
https://lkpy.readthedocs.io/en/stable/mf.html
https://github.com/lenskit/lkpy/blob/0678cd1dcef75bbf7c51953078837f093f118f27/doc/mf.rst
https://github.com/lenskit/lkpy/blob/main/lenskit/algorithms/als.py

Is there some difference that I am missing between the docs in the description and the ones here above?

@tk0miya
Copy link
Member

tk0miya commented Oct 9, 2021

In Sphinx and reStructuredText, both footnotes and citation definitions should not be duplicated. So both they are warned.

Indeed, citation references are built as hyperlinked. But links are not correct. The TPT2011 reference on the BiasedMF class is linked to the TPT2011 entry on the ImplicitMF class instead of the BiasedMF class. I think it's not working correctly.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants