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

sphinx-build reports duplicated label #9707

Open
gucio321 opened this issue Oct 5, 2021 · 5 comments
Open

sphinx-build reports duplicated label #9707

gucio321 opened this issue Oct 5, 2021 · 5 comments

Comments

@gucio321
Copy link

gucio321 commented Oct 5, 2021

Describe the bug

I'm getting the following warnings in my project :

/home/user/git/fizyka/assets/dzial_1/temat_3/intro.rst:34: WARNING: duplicate label of equation V, other instance in assets/dzial_1/index

How to Reproduce

$ git clone https://github.com/gucio321/fizyka && cd fizyka
$ pip install -r requirements.txt
$ make html

you'll see warnings

Expected behavior

warning about duplicated label shouldn't appear because the label isn't duplicated

Your project

https://github.com/gucio321/fizyka

Screenshots

No response

OS

linux - fedora 34

Python version

Python 3.9.7

Sphinx version

4.2.0

Sphinx extensions

extensions = [ "sphinx.ext.githubpages", "sphinxcontrib.images", "myst_parser", "cloud_sptheme.ext.issue_tracker" ]

Extra tools

No response

Additional context

No response

@tk0miya
Copy link
Member

tk0miya commented Oct 6, 2021

The label V is defined at assets/dzial_1/temat_3/intro.rst. It's appeared twice in your project because assets/dzial_1/index.rst includes the file. In other words, both assets/dzial_1/index.rst and assets/dzial_1/temat_3/intro.rst have the same label. It's correct behavior.

@gucio321
Copy link
Author

gucio321 commented Oct 7, 2021

hmm, but intor.rst is only used in index.rst so this label isn't duplicated in fact. the intro.rst isn't used in any other way and I'd expect file is not included anywhere warning for it.
Why does sphinx consider it otherway than from assets/dzial_1/index.rst?

@tk0miya
Copy link
Member

tk0miya commented Oct 9, 2021

Sphinx scans source files from the source directory. So intro.rst is also processed because it has .rst extension. As a result, the label is defined twice. To avoid this behavior, please consider 1) renaming the file to other extensions (like .txt), or 2) setting exclude_patterns up in your conf.py.

@gucio321
Copy link
Author

gucio321 commented Oct 9, 2021

  1. renaming the file to other extensions (like .txt),

I don't think it is good solution because:

  • rst syntax will not work anymore
  • it is after all rst file, so it should have rst extension
  1. setting exclude_patterns up in your conf.py

it may work but it will be a bit annoing to add a new path each time i'm adding a new chapter/topic

I cannot even understand why it isn't a bug.
is including another rst files non-standard solution?
And why Sphinx scans source files from the source directory.? Shouldn't it scan only the files included anyway?

@tk0miya
Copy link
Member

tk0miya commented Oct 10, 2021

And why Sphinx scans source files from the source directory.? Shouldn't it scan only the files included anyway?

This is the current design of Sphinx. Indeed, it would be nice if improved. We'll welcome your contribution :-)

vincentkfu added a commit to vincentkfu/fio that referenced this issue Sep 26, 2022
The GitHub actions macOS 11 image changed its sphinx version from
5.1.1[1] to 5.2.1[2]. This new version now issues warnings about
duplicate identifiers:

/Users/runner/work/fio/fio/HOWTO.rst:: WARNING: duplicate label int, other instance in /Users/runner/work/fio/fio/doc/fio_doc.rst
looking for now-outdated files... none found
/Users/runner/work/fio/fio/HOWTO.rst:: WARNING: duplicate label bool, other instance in /Users/runner/work/fio/fio/doc/fio_doc.rst
/Users/runner/work/fio/fio/HOWTO.rst:: WARNING: duplicate label irange, other instance in /Users/runner/work/fio/fio/doc/fio_doc.rst

Try to work around this issue by excluding HOWTO.rst.

Related issue: sphinx-doc/sphinx#9707

[1] https://github.com/axboe/fio/actions/runs/3106980788/jobs/5034529793
[2] https://github.com/axboe/fio/actions/runs/3129974184/jobs/5079696775

Signed-off-by: Vincent Fu <vincent.fu@samsung.com>
@AA-Turner AA-Turner added this to the some future version milestone Sep 29, 2022
patchew-importer pushed a commit to patchew-project/qemu that referenced this issue Jan 30, 2024
We can't just embed labels directly into files like qemu-options.hx which
are included from multiple top-level rST files, because Sphinx sees the
labels as duplicate: sphinx-doc/sphinx#9707

So add an optional argument to the SRST directive which causes a label
of the form '.. _DOCNAME-HXFILE-LABEL:' to be emitted, where 'DOCNAME'
is the name of the top level rST file, 'HXFILE' is the filename of the
.hx file, and 'LABEL' is the text provided within the 'SRST()' directive.
Using the DOCNAME of the top-level rST document means that it is unique
even when the .hx file is included from two different documents, as is
the case for qemu-options.hx

Now where the Xen PV documentation refers to the documentation for the
-initrd command line option, it can emit a link directly to it as
'<system/invocation-qemu-options-initrd>'.

Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
Reviewed-by: Paul Durrant <paul@xen.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Message-Id: <20240130190348.682912-1-dwmw2@infradead.org>
patchew-importer pushed a commit to patchew-project/qemu that referenced this issue Feb 2, 2024
We can't just embed labels directly into files like qemu-options.hx which
are included from multiple top-level rST files, because Sphinx sees the
labels as duplicate: sphinx-doc/sphinx#9707

So add an optional argument to the SRST directive which causes a label
of the form '.. _DOCNAME-HXFILE-LABEL:' to be emitted, where 'DOCNAME'
is the name of the top level rST file, 'HXFILE' is the filename of the
.hx file, and 'LABEL' is the text provided within the 'SRST()' directive.
Using the DOCNAME of the top-level rST document means that it is unique
even when the .hx file is included from two different documents, as is
the case for qemu-options.hx

Now where the Xen PV documentation refers to the documentation for the
-initrd command line option, it can emit a link directly to it as
'<system/invocation-qemu-options-initrd>'.

Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
Reviewed-by: Paul Durrant <paul@xen.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Message-id: 20240130190348.682912-1-dwmw2@infradead.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Message-Id: <20240202153637.3710444-13-peter.maydell@linaro.org>
stsquad pushed a commit to qemu/qemu that referenced this issue Feb 2, 2024
We can't just embed labels directly into files like qemu-options.hx which
are included from multiple top-level rST files, because Sphinx sees the
labels as duplicate: sphinx-doc/sphinx#9707

So add an optional argument to the SRST directive which causes a label
of the form '.. _DOCNAME-HXFILE-LABEL:' to be emitted, where 'DOCNAME'
is the name of the top level rST file, 'HXFILE' is the filename of the
.hx file, and 'LABEL' is the text provided within the 'SRST()' directive.
Using the DOCNAME of the top-level rST document means that it is unique
even when the .hx file is included from two different documents, as is
the case for qemu-options.hx

Now where the Xen PV documentation refers to the documentation for the
-initrd command line option, it can emit a link directly to it as
'<system/invocation-qemu-options-initrd>'.

Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
Reviewed-by: Paul Durrant <paul@xen.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Message-id: 20240130190348.682912-1-dwmw2@infradead.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants