wrap_reStructuredText

(function from pyomo.common.formatting)

pyomo.common.formatting.wrap_reStructuredText(docstr, wrapper)[source]

A text wrapper that honors paragraphs and basic reStructuredText markup

This wraps textwrap.fill() to first separate the incoming text by paragraphs before using wrapper to wrap each one. It includes a basic (partial) parser for reStructuredText format to attempt to avoid wrapping structural elements like section headings, bullet / enumerated lists, and tables.

Parameters:
  • docstr (str) – The incoming string to parse and wrap

  • wrapper (textwrap.TextWrap) – The configured TextWrap object to use for wrapping paragraphs. While the object will be reconfigured within this function, it will be restored to its original state upon exit.