0

Consider the following doc-string for docopt:

Usage:
    foo [options]
    foo [options] <input.yaml>

Options:
    -h, --help
        Show help.

when formatting with Sphinx the options are formatted very nicely (bold options, with regular, indented, description).

However, the usage is formatted poorly: everything is on a single line. My question: how can I format such that there is at least the line-break between the different use-cases, but in such a way that docopt is not broken? In particular, the following Sphinx solutions break docopt:

Usage:
|    foo [options]
|    foo [options] <input.yaml>
Usage:
    foo [options]

    foo [options] <input.yaml>
mzjn
  • 48,958
  • 13
  • 128
  • 248
Tom de Geus
  • 5,625
  • 2
  • 33
  • 77
  • I think "Options" looks OK because it is interpreted as an option list (https://docutils.sourceforge.io/docs/ref/rst/restructuredtext.html#option-lists). But the "Usage" part is not recognized as an option list or any other special reST construct. – mzjn Feb 12 '21 at 14:15
  • @mzjn Thanks. Indeed. But how can I do its such that it is reST interpretable as well as docopt interpretable ? – Tom de Geus Feb 12 '21 at 14:38
  • I don't know. This issue seems related: https://github.com/docopt/docopt/issues/210 – mzjn Feb 14 '21 at 08:49
  • @mzjn The issue is indeed related. However, it seems without real solution. The `.. literalinclude` is not an option as I use `.. automodule::`. A suggestion implies putting `Usage::`, which does not work unless a newline is put which is however not accepted by doctopt... – Tom de Geus Feb 14 '21 at 14:39

0 Answers0