Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
django-rest-framework
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
django-rest-framework
Commits
ed38371c
Commit
ed38371c
authored
Aug 15, 2017
by
Woile
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix docs multiple nested and multiple methods
parent
31106356
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
2 deletions
+25
-2
rest_framework/templates/rest_framework/docs/document.html
+1
-1
rest_framework/templates/rest_framework/docs/sidebar.html
+1
-1
rest_framework/templatetags/rest_framework.py
+23
-0
No files found.
rest_framework/templates/rest_framework/docs/document.html
View file @
ed38371c
...
...
@@ -20,7 +20,7 @@
</a></h2>
{% endif %}
{% for link_key, link in section
.
links|items %}
{% for link_key, link in section
|schema_
links|items %}
{% include "rest_framework/docs/link.html" %}
{% endfor %}
{% endfor %}
...
...
rest_framework/templates/rest_framework/docs/sidebar.html
View file @
ed38371c
...
...
@@ -10,7 +10,7 @@
<li
data-toggle=
"collapse"
data-target=
"#{{ section_key }}-dropdown"
class=
"collapsed"
>
<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>
<ul
class=
"sub-menu {% if section_key %}collapse{% endif %}"
id=
"{{ section_key }}-dropdown"
>
{% for link_key, link in section
.
links|items %}
{% for link_key, link in section
|schema_
links|items %}
<li><a
href=
"#{{ section_key }}-{{ link_key }}"
>
{{ link.title|default:link_key }}
</a></li>
{% endfor %}
</ul>
...
...
rest_framework/templatetags/rest_framework.py
View file @
ed38371c
...
...
@@ -245,6 +245,29 @@ def items(value):
@register.filter
def
schema_links
(
section
,
sec_key
=
None
):
"""
Recursively find every link in a schema, even nested.
"""
NESTED_FORMAT
=
'
%
s >
%
s'
links
=
section
.
links
if
section
.
data
:
data
=
section
.
data
.
items
()
for
sub_section_key
,
sub_section
in
data
:
new_links
=
schema_links
(
sub_section
,
sec_key
=
sub_section_key
)
links
.
update
(
new_links
)
if
sec_key
is
not
None
:
new_links
=
OrderedDict
()
for
link_key
,
link
in
links
.
items
():
new_key
=
NESTED_FORMAT
%
(
sec_key
,
link_key
)
new_links
.
update
({
new_key
:
link
})
return
new_links
return
links
@register.filter
def
add_nested_class
(
value
):
if
isinstance
(
value
,
dict
):
return
'class=nested'
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment