python-sphinxrestructuredtext

Can the 'Unexpected indentation' error be suppressed with sphinx?


So I'm attempting to fix the warnings in an existing project, containing license.rst:

License
=======

.. include:: ../LICENSE.txt

where LICENSE.txt has this structure:

Copyright ...

... provided that the following conditions are met:
   *  Foo
      bar.
   *  Baz
      bee.
   *  Bop
      bow.
 
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" ...

This causes the error ../LICENSE.txt:7: ERROR: Unexpected indentation. (which refers to the * FOO line). This is because the include directive in license.rst is going to parse LICENSE.txt as if it were a .rst file (from what I understand).

I can add :literal: or :code: in license.rst to fix the error:

License
=======

.. include:: ../LICENSE.txt
    :literal:

but this drastically changes the look of the generated website, which I'd have to ask approval of from our client, which is a bit of a headache.

I have already used suppress_warnings = ["etoc.toctree"] to suppress a warning, but the Unexpected indentation doesn't state which warning type it belongs to.

I tried using suppress_warnings = ["etoc.toctree", "Unexpected indentation", "Unexpected indentation.", "ERROR: Unexpected indentation", "ERROR: Unexpected indentation."], but the mentions of suppress_warnings in the codebase don't seem to indicate such usage of suppress_warnings being possible.

I found this Sphinx GitHub issue comment asking for the same feature, but the comment was left in 2020, so I'm curious whether changes were made that have now made it possible.

So, is there a way to just suppress this warning, or maybe just all warnings from this specific file? Thanks.


Solution

  • This error message is from the Docutils rST parser. The included file is no valid reStructuredText.

    Workarounds: