Skip to content

Commit

Permalink
Added 'API reference' section to generated model examples
Browse files Browse the repository at this point in the history
git-svn-id: http://code.djangoproject.com/svn/django/trunk@352 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information
adrianholovaty committed Jul 29, 2005
1 parent 7b6c472 commit b7643d0
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions tests/builddocs.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@
<h2>Model source code</h2> <h2>Model source code</h2>
<pre class="literal-block">{{ model_source }}</pre> <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> <h2>Sample API usage</h2>
<pre class="literal-block">{{ api_usage }}</pre> <pre class="literal-block">{{ api_usage }}</pre>
</div> </div>
Expand Down Expand Up @@ -46,6 +55,13 @@ def make_docs_from_model_tests(output_dir):
model_source = model_source.replace('API_TESTS = ', '') model_source = model_source.replace('API_TESTS = ', '')
model_source = model_source.strip() 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. # Run this through the template system.
t = template.Template(MODEL_DOC_TEMPLATE) t = template.Template(MODEL_DOC_TEMPLATE)
c = template.Context(locals()) c = template.Context(locals())
Expand Down

0 comments on commit b7643d0

Please sign in to comment.