Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added 'API reference' section to generated model examples

git-svn-id: http://code.djangoproject.com/svn/django/trunk@352 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit b7643d009eea7547b7f65b20c27369bb223290fd 1 parent 7b6c472
@adrianholovaty adrianholovaty authored
Showing with 16 additions and 0 deletions.
  1. +16 −0 tests/builddocs.py
View
16 tests/builddocs.py
@@ -17,6 +17,15 @@
<h2>Model source code</h2>
<pre class="literal-block">{{ model_source }}</pre>
+<h2>API reference</h2>
+
+{% for model in models %}
+<h3>{{ model.name }} objects have the following methods:</h3>
+<ul>
+{% for method in model.methods %}<li><span class="pre">{{ method }}()</span></li>
+{% endfor %}</ul>
+{% endfor %}
+
<h2>Sample API usage</h2>
<pre class="literal-block">{{ api_usage }}</pre>
</div>
@@ -46,6 +55,13 @@ def make_docs_from_model_tests(output_dir):
model_source = model_source.replace('API_TESTS = ', '')
model_source = model_source.strip()
+ models = []
+ for m in mod._MODELS:
+ models.append({
+ 'name': m._meta.object_name,
+ 'methods': [method for method in dir(m) if not method.startswith('_')],
+ })
+
# Run this through the template system.
t = template.Template(MODEL_DOC_TEMPLATE)
c = template.Context(locals())
Please sign in to comment.
Something went wrong with that request. Please try again.