Documentation Rendering

Render an extension’s documentation, written in reStructuredText, as HTML.

An extension documents itself in its package’s module docstring, and optionally in more pages in its package’s docs/ directory (.rst or .md). They are rendered when the extension is installed, and shown in the admin console.

Documentation comes from the extension’s author, so it is rendered safely: raw HTML, file inclusion and remote images are disabled, and Markdown’s raw HTML is escaped.

smarter.apps.llmtool.extension.docs.render_markdown(text)[source]

Render Markdown as an HTML fragment, with any raw HTML escaped.

Parameters:

text (str) – The Markdown.

Return type:

str

Returns:

The HTML.

smarter.apps.llmtool.extension.docs.render_page(filename, text)[source]

Render one documentation page, by its file extension.

Parameters:
  • filename (str) – e.g. usage.rst or usage.md.

  • text (str) – The page’s text.

Return type:

str

Returns:

The HTML.

smarter.apps.llmtool.extension.docs.render_rst(text)[source]

Render reStructuredText as an HTML fragment.

Parameters:

text (str) – The reStructuredText.

Return type:

str

Returns:

The HTML body, or the text in a <pre> if it cannot be rendered.