|
From: Guenter M. <mi...@us...> - 2020-12-07 07:20:55
|
On 2020-12-06, Gökçe Aydos wrote:
> [-- Type: text/plain, Encoding: quoted-printable --]
> On 06/12/2020 20:34, Alan G. Isaac wrote:
>> Why copy/paste at all when you can just ``include`` code?
> Thanks, that is a good idea for longer code Alan!
> My case is different. For example in one document I have about 50 code
> blocks, which are about 2 to 8 lines long. Creating 50 files for this
> purpose would be very inconvenient.
> When I copy code from the rendered version then it's no problem, but
> copying from the rst source is very error-prone due to the indentation,
> e.g.,:
> code:: sh
> cat > file <<EOF
> 4spaces here instead of 2
> and EOF does not work
> EOF
When working with reStructuredText, I find myself using the "rectangualar
blocks" feature of my text editor a lot.
However, your example looks a lot like a use case for `PyLit`_, where you
can convert easily in both directions between a "text" and "code" version
of a document, e.g.,
text::
# Options for HTML output
# -----------------------
#
# The style sheet to use for HTML and HTML Help pages. A file of that name
# must exist either in Sphinx' static/ path, or in one of the custom paths
# given in html_static_path::
html_style = 'pylit-sphinx.css'
# html_style = 'sphinxdoc.css'
# Options to the theme, like a sidebar that is visible even when
# scrolling (TODO: how to get this to work (maybe just update Spinx)?)::
#html_theme_options = {'stickysidebar': 'true'}
# The name for this set of Sphinx documents. If None, it defaults to
# "<project> v<release> documentation". ::
html_title = "PyLit"
# A shorter title for the navigation bar. Default is the same as html_title.
# ::
html_short_title = "Home"
code::
Options for HTML output
-----------------------
The style sheet to use for HTML and HTML Help pages. A file of that name
must exist either in Sphinx' static/ path, or in one of the custom paths
given in html_static_path::
html_style = 'pylit-sphinx.css'
# html_style = 'sphinxdoc.css'
Options to the theme, like a sidebar that is visible even when
scrolling (TODO: how to get this to work (maybe just update Spinx)?)::
#html_theme_options = {'stickysidebar': 'true'}
The name for this set of Sphinx documents. If None, it defaults to
"<project> v<release> documentation". ::
html_title = "PyLit"
A shorter title for the navigation bar. Default is the same as html_title.
::
html_short_title = "Home"
Günter
.. _Pylit: https://pypi.org/project/pylit/
|