Skip to content

🟡 rich

🟢 Documented

examples/rich-markdown.py

import rich
from documented import Documented


class MyMessage(Documented):
    """
    # This is a Markdown formatted message.

    * _One_,
    * *Two*,
    * `Three`

    and **more** features of Markdown

    > are supported.
    """


rich.print(MyMessage())

python

┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
                    This is a Markdown formatted message.                     
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛

  One,                                                                         
  Two,                                                                         
  Three                                                                        

and more features of Markdown                                                   

 are supported.                                                              

This will render the docstring as Markdown in the console.

🟡 DocumentedError

See related thread

textualize/rich#2619

  • 🙁 I haven't found a way to integrate rich with documented directly, to render beautiful exceptions with console markup or Markdown text in them right in the traceback.

  • 🙂 However, this can always be done manually:

    • except the error,
    • and rich.print() it.