While developing a Python package I am working on a Sphinx documentation with a ReadTheDocs theme which I will later publish on my GitHub Pages.
My problem is that I would like to include the content of another (plaintext) file into a .rst
file but have the lines wrapped.
I found a very similar question already asked and answered.
How to wrap a long literal block in reStructuredText?
I have tried out the accepted answer but it does not work for me... or maybe I am doing it wrong...
I was following this article.
Being explicit:
I have the following section in the conf.py
:
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
html_css_files = [
'custom.css',
]
And I added custom.css
under _static
which contains 3 lines:
pre {
white-space: pre-wrap;
}
The problem emerges when I try to include an MIT license text (which is in a LICENSE file in the root of the repository) into one of the .rst
files:
.. literalinclude:: ../../LICENSE
:language: text
I would like to get an effect like here:
https://snakemake.readthedocs.io/en/stable/project_info/license.html
However, in my case the text is not wrapped and there is a horizontal scroll bar at the bottom of the text block, like in the screenshot below:
It must be possible somehow since snakemake developers achieved it for their docs, I just don't know - how(?)
Reply to Steve's comment below:
I don't think my code was applied - I inspected the source behind the built web page and the only element with pre
is:
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>Copyright 2021 ***
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
</pre></div>
On top of the source the only css
loading are:
<link rel="stylesheet" href="../_static/css/theme.css" type="text/css" />
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
So my file is not there too...