Sphinx: "WARNING: duplicate label" because of include

Created on 6 Jan 2015  路  5Comments  路  Source: sphinx-doc/sphinx

When I .. include:: <a file with a label defined.rst> I get these warnings:

/path/to/main/file.rst:lineno: WARNING: duplicate label ch-results, other instance in /path/to/included/file.rst

Most helpful comment

Ah, that sounds logical. I thought only the documents included in a toctree were included.

All 5 comments

If the label name is actually the same, this is expected. include works as if the target file is put into the current file literally.

Sorry, should have been clearer. There is only one label. See this gist: https://gist.github.com/tino/ae778c1795c1f199e0b0 (with a standard conf.py, with source_suffix = '.rst' and master_doc = 'index').

I also notice that the link that is inserted for the reference, links me to included.html, so somehow it appears it is not completely included but also rendered as a separate document. Hence the duplicate definiton.

Appears on 1.2.3 as well as on 1.3b2.

Thanks for the feedback. I'll have a look.

Ok, got it. The issue is that your included file is also found and read as a regular document since it matches the source_suffix. That's also why included.html exists.

You can either rename it (e.g. included.inc is popular) or add a pattern matching it to exclude_patterns.

Ah, that sounds logical. I thought only the documents included in a toctree were included.

Was this page helpful?
0 / 5 - 0 ratings