Skip to content

Commit 9c18c38

Browse files
nanuxbedrdaeman
authored andcommitted
1 parent 7b0689a commit 9c18c38

File tree

10 files changed

+58
-27
lines changed

10 files changed

+58
-27
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{% for section_key, section in items %}
2+
{% if section_key %}
3+
<h{{level}} id="{{prefix}}-{{ section_key }}" class="coredocs-section-title">{{ section_key }} <a href="#{{ section_key }}"><i class="fa fa-link" aria-hidden="true"></i>
4+
</a></h{{level}}>
5+
{% endif %}
6+
7+
{% if section.links.items %}
8+
{% for link_key, link in section.links.items %}
9+
{% include "rest_framework/docs/link.html" with prefix=prefix level=level|add:1%}
10+
{% endfor %}
11+
{% else %}
12+
{% include 'rest_framework/docs/_recursive_document.html' with items=section.items prefix=prefix|add:section_key|add:'/' level=level|add:1 %}
13+
{% endif %}
14+
{% endfor %}
15+
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<ul id="{% if prefix %}{{prefix}}-dropdown{% else %}menu-content{% endif %}" class="menu-content collapse out">
2+
{% for section_key, section in items %}
3+
<li data-toggle="collapse" data-target="#{{prefix}}{{ section_key }}-dropdown" class="collapsed">
4+
<a><i class="fa fa-dot-circle-o fa-lg"></i> {% if prefix %}{{prefix}}/{% endif %}{% if section_key %}{{ section_key }}{% else %}API Endpoints{% endif %} <span class="arrow"></span></a>
5+
</li>
6+
{% if section.links.items %}
7+
<ul class="sub-menu {% if section_key %}collapse{% endif %}" id="{{prefix}}{{ section_key }}-dropdown">
8+
{% for link_key, link in section.links.items %}
9+
<li><a href="#{{prefix}}-{{ section_key }}-{{ link_key }}">{{ link.title|default:link_key }}</a></li>
10+
{% endfor %}
11+
</ul>
12+
{% else %}
13+
{% include 'rest_framework/docs/_recursive_menu.html' with items=section.items prefix=prefix|add:section_key %}
14+
{% endif %}
15+
{% endfor %}
16+
</ul>
17+

rest_framework/templates/rest_framework/docs/document.html

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,7 @@ <h1>{{ document.title }}</h1>
1414
</div>
1515
</div>
1616

17-
{% for section_key, section in document.data|items %}
18-
{% if section_key %}
19-
<h2 id="{{ section_key }}" class="coredocs-section-title">{{ section_key }} <a href="#{{ section_key }}"><i class="fa fa-link" aria-hidden="true"></i>
20-
</a></h2>
21-
{% endif %}
22-
23-
{% for link_key, link in section.links|items %}
24-
{% include "rest_framework/docs/link.html" %}
25-
{% endfor %}
26-
{% endfor %}
17+
{% include 'rest_framework/docs/_recursive_document.html' with items=document.data|items level=2 %}
2718

2819
{% for link_key, link in document.links|items %}
2920
{% include "rest_framework/docs/link.html" %}

rest_framework/templates/rest_framework/docs/interact.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ <h3 class="modal-title"><i class="fa fa-exchange"></i> {{ link.title|default:lin
1616

1717
</div>
1818

19-
<form data-key='["{{ section_key }}", "{{ link_key }}"]' class="api-interaction">
19+
<form data-key='[{{ prefix|split_keys }} "{{ section_key }}", "{{ link_key }}"]' class="api-interaction">
2020
<div class="modal-body">
2121
<div class="row">
2222
<div class="col-lg-6 request">

rest_framework/templates/rest_framework/docs/langs/javascript.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
var client = new coreapi.Client()
77

88
// Interact with the API endpoint
9-
var action = [{% if section_key %}"{{ section_key }}", {% endif %}"{{ link_key }}"]
9+
var action = [{% if prefix %}{{ prefix|split_keys }} {% endif %}{% if section_key %}"{{ section_key }}", {% endif %}"{{ link_key }}"]
1010
{% if link.fields %}var params = {
1111
{% for field in link.fields %} {{ field.name }}: ...{% if not loop.last %},{% endif %}
1212
{% endfor %}}

rest_framework/templates/rest_framework/docs/langs/python.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
schema = client.get("{{ document.url }}"{% if schema_format %}, format="{{ schema_format }}"{% endif %})
77

88
# Interact with the API endpoint
9-
action = [{% if section_key %}"{{ section_key }}", {% endif %}"{{ link_key }}"]
9+
action = [{% if prefix %}{{ prefix|split_keys }} {% endif %}{% if section_key %}"{{ section_key }}", {% endif %}"{{ link_key }}"]
1010
{% if link.fields %}params = {
1111
{% for field in link.fields %} "{{ field.name }}": ...{% if not loop.last %},{% endif %}
1212
{% endfor %}}

rest_framework/templates/rest_framework/docs/langs/shell.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
$ coreapi get {{ document.url }}{% if schema_format %} --format {{ schema_format }}{% endif %}
44

55
# Interact with the API endpoint
6-
$ coreapi action {% if section_key %}{{ section_key }} {% endif %}{{ link_key }}{% for field in link.fields %} -p {{ field.name }}=...{% endfor %}{% endcode %}</code></pre>
6+
$ coreapi action {% if prefix %}{{ prefix|split_keys:'cmd' }} {% endif %}{% if section_key %}{{ section_key }} {% endif %}{{ link_key }}{% for field in link.fields %} -p {{ field.name }}=...{% endfor %}{% endcode %}</code></pre>

rest_framework/templates/rest_framework/docs/link.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<i class="fa fa-exchange"></i> Interact
1111
</button>
1212

13-
<h3 id="{{ section_key }}-{{ link_key }}" class="coredocs-link-title">{{ link.title|default:link_key }} <a href="#{{ section_key }}-{{ link_key }}"><i class="fa fa-link" aria-hidden="true"></i>
13+
<h3 id="{{prefix}}-{{ section_key }}-{{ link_key }}" class="coredocs-link-title">{{ link.title|default:link_key }} <a href="#{{prefix}}-{{ section_key }}-{{ link_key }}"><i class="fa fa-link" aria-hidden="true"></i>
1414
</a></h3>
1515

1616
<div class="meta">

rest_framework/templates/rest_framework/docs/sidebar.html

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,7 @@ <h3 class="brand"><a href="#">{{ document.title }}</a></h3>
44

55
<i class="fa fa-bars fa-2x toggle-btn" data-toggle="collapse" data-target="#menu-content"></i>
66
<div class="menu-list">
7-
<ul id="menu-content" class="menu-content collapse out">
8-
{% for section_key, section in document.data|items %}
9-
<li data-toggle="collapse" data-target="#{{ section_key }}-dropdown" class="collapsed">
10-
<a><i class="fa fa-dot-circle-o fa-lg"></i> {% if section_key %}{{ section_key }}{% else %}API Endpoints{% endif %} <span class="arrow"></span></a>
11-
</li>
12-
<ul class="sub-menu {% if section_key %}collapse{% endif %}" id="{{ section_key }}-dropdown">
13-
{% for link_key, link in section.links|items %}
14-
<li><a href="#{{ section_key }}-{{ link_key }}">{{ link.title|default:link_key }}</a></li>
15-
{% endfor %}
16-
</ul>
17-
{% endfor %}
18-
</ul>
7+
{% include 'rest_framework/docs/_recursive_menu.html' with items=document.data|items %}
198

209
<ul class="menu-list menu-list-bottom">
2110
<li data-toggle="collapse" data-target="#auth-control" class="collapsed">

rest_framework/templatetags/rest_framework.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,3 +362,22 @@ def break_long_headers(header):
362362
if len(header) > 160 and ',' in header:
363363
header = mark_safe('<br> ' + ', <br>'.join(header.split(',')))
364364
return header
365+
366+
367+
@register.filter
368+
def split_keys(keys, cmd_type='script'):
369+
if not keys:
370+
return ''
371+
372+
if cmd_type == 'script':
373+
joiner = ', '
374+
wrapper = '"'
375+
else:
376+
joiner = ' '
377+
wrapper = ''
378+
379+
return joiner.join([
380+
'{wrapper}{k}{wrapper}'.format(k=k, wrapper=wrapper)
381+
if k != '' else ''
382+
for k in keys.split('/')
383+
])

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy