Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fixes #5405 -- Support restructured text in model docstrings #484

Closed
wants to merge 2 commits into from

2 participants

Commits on Oct 31, 2012
  1. @tricoder42

    Fixes #5405

    tricoder42 authored
  2. @tricoder42
This page is out of date. Refresh to see the latest.
View
10 django/contrib/admindocs/templates/admin_doc/model_detail.html
@@ -22,12 +22,12 @@
{% block content %}
<div id="content-main">
-<h1>{{ summary }}</h1>
-
-{% if description %}
- <p>{% filter linebreaksbr %}{% trans description %}{% endfilter %}</p>
-{% endif %}
+<h1>{{ name }}</h1>
+<h2>{% trans "Description" %}</h2>
+{% if summary %}<strong>{% trans summary %}</strong>{% endif %}
+{% if description %}<p>{% trans description %}</p>{% endif %}
+<h2>{{ heading }}</h2>
<div class="module">
<table class="model">
<thead>
View
2  django/contrib/admindocs/templates/admin_doc/view_detail.html
@@ -15,7 +15,7 @@
<h1>{{ name }}</h1>
-<h2 class="subhead">{{ summary|striptags }}</h2>
+<h2 class="subhead">{{ summary }}</h2>
{{ body }}
View
14 django/contrib/admindocs/views.py
@@ -196,6 +196,14 @@ def model_detail(request, app_label, model_name):
opts = model._meta
+ title, description, metadata = utils.parse_docstring(model.__doc__)
+ if title:
+ title = utils.parse_rst(title, 'model', _('model:') + model_name)
+ if description:
+ description = utils.parse_rst(description, 'model', _('model:') + model_name)
+ for key in metadata:
+ metadata[key] = utils.parse_rst(metadata[key], 'model', _('model:') + model_name)
+
# Gather fields/field descriptions.
fields = []
for field in opts.fields:
@@ -266,8 +274,10 @@ def model_detail(request, app_label, model_name):
return render_to_response('admin_doc/model_detail.html', {
'root_path': urlresolvers.reverse('admin:index'),
'name': '%s.%s' % (opts.app_label, opts.object_name),
- 'summary': _("Fields on %s objects") % opts.object_name,
- 'description': model.__doc__,
+ 'heading': _("Fields on %s objects") % opts.object_name,
+ 'summary': title,
+ 'description': description,
+ 'meta': metadata,
'fields': fields,
}, context_instance=RequestContext(request))
Something went wrong with that request. Please try again.