lib.publisher

Docutils Publisher fors for Django Docutils.

django_docutils.lib.publisher.publish_parts_from_doctree(document, destination_path=None, writer=None, writer_name='pseudoxml', settings=None, settings_spec=None, settings_overrides=None, config_section=None, enable_exit_status=False)
function[source]

Render docutils doctree into docutils parts.

Parameters:
Return type:

dict[str, str]

django_docutils.lib.publisher.publish_toc_from_doctree(doctree, writer=None)
function[source]

Publish table of contents from docutils doctree.

Parameters:
  • doctree (document)

  • writer (Writer | None)

Return type:

str | None

django_docutils.lib.publisher.publish_doctree(source, settings_overrides={})
function[source]

Split off ability to get doctree (a.k.a. document).

It’s valuable to be able to run transforms to alter and most importantly, extract data like post abstracts.

Parameters:
  • source (str or bytes) – RST content

  • settings_overrides (dict) – Settings overrides for docutils

Returns:

document/doctree for reStructuredText content

Return type:

docutils.nodes.document

class django_docutils.lib.publisher.PublishHtmlDocTreeKwargs

Bases: TypedDict

Keyword arguments accepted by publish_html_from_source.

django_docutils.lib.publisher.publish_html_from_source(source, **kwargs)
function[source]

Return HTML from reStructuredText source string.

Parameters:
Return type:

str | None

django_docutils.lib.publisher.publish_html_from_doctree(doctree, show_title=True, toc_only=False)
function[source]

Return HTML from reStructuredText document (doctree).

Parameters:
  • value (str) – Contents from template being placed into node

  • show_title (bool) – Show top level title

  • toc_only (bool) – Special flag: return show TOC, used for sidebars

  • doctree (document)

Returns:

HTML from reStructuredText document (doctree)

Return type:

str or None