lib.views

Django view machinery for rendering docutils content as HTML.

class django_docutils.lib.views.TitleMixin[source]

Bases: ContextMixin

ContextMixin that capitalizes title and subtitle.

title = None
subtitle = None
get_context_data(**kwargs)[source]

django_docutils.lib.text.smart_title() on title and subtitle.

Return type:

Dict[str, Any]

class django_docutils.lib.views.TemplateTitleView(**kwargs)[source]

Bases: TemplateView, TitleMixin

Combination of Template and Title mixin.

title = None
subtitle = None
get_context_data(**kwargs)[source]

Return context data.

Return type:

Dict[str, Any]

class django_docutils.lib.views.RSTMixin[source]

Bases: object

Django Class-based view mixin for reStructuredText.

request: HttpRequest
raw_content

Raw reStructuredText content.

doctree

Return docutils doctree of RST content (pre-HTML).

sidebar

Return table of contents sidebar of RST content as HTML.

content

Return reStructuredText content as HTML.

get_base_template()[source]

TODO: move this out of RSTMixin, it is AMP related, not RST.

Return type:

str

class django_docutils.lib.views.RSTRawView(**kwargs)[source]

Bases: TemplateTitleView

Send pure reStructuredText to template.

Requires template tags to process it.

{% load django_docutils %}
{% block content %}
  <div id="content_wrapper" class="content docutils-html fixed-toc-content">
    {% restructuredtext content show_title=False %}
  </div>
{% endblock content %}

{% block sidebar %}
  {% restructuredtext content toc_only=True %}
{% endblock sidebar %}
template_name = 'rst/raw.html'
file_path: Union[str, PathLike[str], None] = None
title = None
get_context_data(**kwargs)[source]

Merge content to context data.

Return type:

Dict[str, Any]

class django_docutils.lib.views.RSTView(**kwargs)[source]

Bases: RSTRawView, RSTMixin

RestructuredText Django View.

template_name = 'rst/base.html'
file_path: Union[str, PathLike[str], None] = None
title = None
raw_content

Raw reStructuredText data.

get_context_data(**kwargs)[source]

Merge content and sidebar to context data.

Return type:

Dict[str, Any]