Sphinx documentation gives me a warning about toctree refrences

Contents: .. toctree:: :maxdepth: 2 foo.rst bar.rst Indices and tables ================== * :ref:`genindex` * :ref:`modindex` * :ref:`search` 

I am trying to build it using sphinx-build . doc sphinx-build . doc This gives me a warning:

 (WARNING/2) toctree references unknown document u'bar' 

What could be the reason? thanks in advance.

+4
source share
2 answers

Sphinx does not need the .rst extension in the .rst directive. Assuming that toctree is in something like index.rst and that bar.rst is in the same directory, try replacing foo.rst and bar.rst in the toctree directive with foo and bar respectively.

Otherwise, make sure that bar.rst is in the correct directory (and not in the parent or subdirectory).

+3
source

I also got this error. For me it was due to indentation. "Toctree" was indented by 3 space characters, while I listed the first files by 4 spaces. To solve the problem, we must have the same level of indentation.

+2
source

All Articles