diff --git a/requirements.txt b/requirements.txt index f449bbb..337cfb1 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,3 +3,5 @@ djangorestframework==3.3.2 coverage==4.0.3 flake8==2.5.1 mkdocs==0.15.3 +django-markwhat==1.5 +docutils==0.12 \ No newline at end of file diff --git a/rest_framework_docs/templates/rest_framework_docs/home.html b/rest_framework_docs/templates/rest_framework_docs/home.html index e13e5a5..28f512d 100644 --- a/rest_framework_docs/templates/rest_framework_docs/home.html +++ b/rest_framework_docs/templates/rest_framework_docs/home.html @@ -1,6 +1,8 @@ {% extends "rest_framework_docs/docs.html" %} {% load drfdocs_filters %} +{% load markdown %} + {% block apps_menu %} {% regroup endpoints by name_parent as endpoints_grouped %}
{{ endpoint.docstring|markdown:'safe' }}
{{ endpoint.docstring|markdown }}
{% endif %} diff --git a/rest_framework_docs/templatetags/markdown.py b/rest_framework_docs/templatetags/markdown.py new file mode 100644 index 0000000..3efd94d --- /dev/null +++ b/rest_framework_docs/templatetags/markdown.py @@ -0,0 +1,14 @@ +""" +Defining a custom template tag as a wrapper around the markup template tag provided by the +django-markwhat library. This prevents the need for users to have to install django-markwhat into their +INSTALLED_APPS. +""" +from django import template +from django_markwhat.templatetags.markup import markdown as markdown_filter + +register = template.Library() + + +@register.filter(is_safe=True) +def markdown(value, args=''): + return markdown_filter(value, args)