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.
This error message is from the Docutils rST parser. The included file is no valid reStructuredText.
Workarounds:
The save way is to adress the core of the issue
Alternatively, you may try including the license file as Markdown:
.. include:: LICENSE.txt
:parser: markdown
(This requires a 3rd party Markdown parser).
Docutils allows to configure the report level via the "report-level" configuration setting in a "docutils.conf" configuration file. If nothing else works and you are sure, that the output of the license text is correct and there are no other errors or WARNING-level problems in any file of the project, you may try with
[general]
report_level: 2
in a file docutils.conf
in the project root directory.
Unfortunately, there is no fine-grained report-level system, so this will permantently disable all Docutils messages above level 2 (SEVERE).