From f0e65d263767935a47cfa39ab89d538daee1e770 Mon Sep 17 00:00:00 2001 From: Aleksey Zhukov Date: Tue, 23 May 2017 18:22:02 +0300 Subject: [PATCH] Nested docs: use lists for paths instead of strings This way we don't need to do any string manipulation (split_keys is gone), and snippet code generation should be more flexible. --- .../docs/_recursive_document.html | 15 +++++------ .../rest_framework/docs/_recursive_menu.html | 16 +++++------- .../rest_framework/docs/document.html | 4 +-- .../rest_framework/docs/interact.html | 2 +- .../rest_framework/docs/langs/javascript.html | 2 +- .../rest_framework/docs/langs/python.html | 2 +- .../rest_framework/docs/langs/shell.html | 2 +- .../templates/rest_framework/docs/link.html | 6 +++-- .../rest_framework/docs/sidebar.html | 2 +- rest_framework/templatetags/rest_framework.py | 25 ++++++++----------- tests/interactive_doc/test_recursive_url.py | 6 ++--- 11 files changed, 38 insertions(+), 44 deletions(-) diff --git a/rest_framework/templates/rest_framework/docs/_recursive_document.html b/rest_framework/templates/rest_framework/docs/_recursive_document.html index d1596b454..fcdbf5c80 100644 --- a/rest_framework/templates/rest_framework/docs/_recursive_document.html +++ b/rest_framework/templates/rest_framework/docs/_recursive_document.html @@ -1,15 +1,16 @@ {% load rest_framework %} {% for section_key, section in items %} -{% if section_key %} - {{ section_key }} - -{% endif %} + {% if section_key %} + + {{ section_key }} + + + {% endif %} {% if section.links|items %} {% for link_key, link in section.links|items %} - {% include "rest_framework/docs/link.html" with prefix=prefix level=level|add:1%} + {% include "rest_framework/docs/link.html" with path=path %} {% endfor %} {% endif %} - {% include 'rest_framework/docs/_recursive_document.html' with items=section.data|items prefix=prefix|add:section_key|add:'/' level=level|add:1 %} + {% include 'rest_framework/docs/_recursive_document.html' with items=section.data|items path=path|list_add:section_key level=level|add:1 %} {% endfor %} - diff --git a/rest_framework/templates/rest_framework/docs/_recursive_menu.html b/rest_framework/templates/rest_framework/docs/_recursive_menu.html index 82775dd02..bb86a87c5 100644 --- a/rest_framework/templates/rest_framework/docs/_recursive_menu.html +++ b/rest_framework/templates/rest_framework/docs/_recursive_menu.html @@ -1,22 +1,18 @@ {% load rest_framework %} {% if items %} -