Skip to content

Add optional markdown for docstrings #127

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from Dec 20, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion rest_framework_docs/templates/rest_framework_docs/home.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{% extends "rest_framework_docs/docs.html" %}
{% load drfdocs_filters %}

{% block apps_menu %}
{% regroup endpoints by name_parent as endpoints_grouped %}
Expand Down Expand Up @@ -56,7 +57,7 @@ <h4 class="panel-title title">
<div id="{{ endpoint.path|slugify }}" class="panel-collapse collapse" role="tabpanel">
<div class="panel-body">
{% if endpoint.docstring %}
<p class="lead">{{ endpoint.docstring }}</p>
<p class="lead">{{ endpoint.docstring|markdown }}</p>
{% endif %}

{% if endpoint.errors %}
Expand Down
Empty file.
12 changes: 12 additions & 0 deletions rest_framework_docs/templatetags/drfdocs_filters.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from django import template
from django.template.defaultfilters import stringfilter
from rest_framework.utils.formatting import markup_description


register = template.Library()


@register.filter(name='markdown')
@stringfilter
def markdown(value):
return markup_description(value)