Search code examples
pythonpython-sphinxglobtoctree

Location of Sphinx sources for my notes - WARNING: document isn't included in any toctree


How can you fix the Sphinx's warning at the bottom?

I am trying to have my Python notes in Sphinx. I have my notes in separate files at the same directory level as the index.rst.

I get the following warnings after building HTML

The warning

/home/heo/S_codes/trig_functions.rst:: WARNING: document isn't included in any toctree

in

The complete message when building

sudo sphinx-build -b html ./ _build/html
Running Sphinx v0.6.2
loading pickled environment... done
building [html]: targets for 0 source files that are out of date
updating environment: 1 added, 2 changed, 0 removed
reading sources... [100%] trig_functions
/home/heo/S_codes/databooklet.rst:1: (WARNING/2) malformed hyperlink target.
/home/heo/S_codes/index.rst:11: (ERROR/3) Error in "toctree" directive:
invalid option block.

.. toctree::
   :numbered:
   :glob:
   *
   databooklet.rst
   trig_functions.rst


/home/heo/S_codes/trig_functions.rst:11: (ERROR/3) Unexpected indentation.
looking for now-outdated files... none found
pickling environment... done
checking consistency... /home/heo/S_codes/databooklet.rst:: WARNING: document isn't included in any toctree
/home/heo/S_codes/trig_functions.rst:: WARNING: document isn't included in any toctree
done
preparing documents... done
writing output... [100%] trig_functions
writing additional files... genindex search
copying static files... done
dumping search index... done
dumping object inventory... done
build succeeded, 6 warnings.

Solution

  • Are you aware of Sphinx's documentation? https://www.sphinx-doc.org

    Specifically, read about the toctree directive: https://www.sphinx-doc.org/en/master/usage/restructuredtext/directives.html#directive-toctree

    You can have as many files as you want. Via toctree you can create a single document from many parts.


    Please actually read this: http://sphinx.pocoo.org/concepts.html#document-names

    Since the reST source files can have different extensions (some people like .txt, some like .rst – the extension can be configured with source_suffix) and different OSes have different path separators, Sphinx abstracts them: all “document names” are relative to the source directory, the extension is stripped, and path separators are converted to slashes. All values, parameters and suchlike referring to “documents” expect such a document name.

    Examples for document names are index, library/zipfile, or reference/datamodel/types. Note that there is no leading slash.

    Since you globbed with *, you do not need to list your files.

    If you want to list your files, please actually read and follow the above rules.