From 3a648b9f0b0aa9a955065b96ea1a03376816ec00 Mon Sep 17 00:00:00 2001 From: Dougal Matthews Date: Thu, 9 Oct 2014 10:14:04 +0100 Subject: Migrate documentation to MkDocs proper --- .gitignore | 1 + docs/404.html | 201 ------------------------------------------ docs/template.html | 239 ------------------------------------------------- docs/theme/404.html | 201 ++++++++++++++++++++++++++++++++++++++++++ docs/theme/base.html | 244 +++++++++++++++++++++++++++++++++++++++++++++++++++ mkdocs.py | 203 ------------------------------------------ mkdocs.yml | 55 ++++++++++++ 7 files changed, 501 insertions(+), 643 deletions(-) delete mode 100644 docs/404.html delete mode 100644 docs/template.html create mode 100644 docs/theme/404.html create mode 100644 docs/theme/base.html delete mode 100755 mkdocs.py create mode 100644 mkdocs.yml diff --git a/.gitignore b/.gitignore index ae73f837..9e17827b 100644 --- a/.gitignore +++ b/.gitignore @@ -18,3 +18,4 @@ local/ !.gitignore !.travis.yml +site/ diff --git a/docs/404.html b/docs/404.html deleted file mode 100644 index 864247e7..00000000 --- a/docs/404.html +++ /dev/null @@ -1,201 +0,0 @@ - - - - - Django REST framework - 404 - Page not found - - - - - - - - - - - - - - - - - - - -
- - - -
-
- - - - -
-
-

404

-

Page not found

-

Try the homepage, or search the documentation.

-
-
-
-
- -
-
- - - - - - - - - - diff --git a/docs/template.html b/docs/template.html deleted file mode 100644 index f36cffc6..00000000 --- a/docs/template.html +++ /dev/null @@ -1,239 +0,0 @@ - - - - - {{ title }} - - - - - - - - - - - - - - - - - - - - -
- - - -
-
- - - - -
- -
- -
- - -
-
- -
- {{ content }} -
-
-
-
- -
-
- - - - - - - - - - - diff --git a/docs/theme/404.html b/docs/theme/404.html new file mode 100644 index 00000000..864247e7 --- /dev/null +++ b/docs/theme/404.html @@ -0,0 +1,201 @@ + + + + + Django REST framework - 404 - Page not found + + + + + + + + + + + + + + + + + + + +
+ + + +
+
+ + + + +
+
+

404

+

Page not found

+

Try the homepage, or search the documentation.

+
+
+
+
+ +
+
+ + + + + + + + + + diff --git a/docs/theme/base.html b/docs/theme/base.html new file mode 100644 index 00000000..45e19cf3 --- /dev/null +++ b/docs/theme/base.html @@ -0,0 +1,244 @@ + + + + + {{ title }} + + + + + + + + + + + + + + + + + + + + +
+ + + +
+
+ + + + +
+ +
+ +
+ + +
+
+ +
+ {{ content }} +
+
+
+
+ +
+
+ + + + + + + + + + + diff --git a/mkdocs.py b/mkdocs.py deleted file mode 100755 index 3787d792..00000000 --- a/mkdocs.py +++ /dev/null @@ -1,203 +0,0 @@ -#!/usr/bin/env python - -import markdown -import os -import re -import shutil -import sys - -root_dir = os.path.abspath(os.path.dirname(__file__)) -docs_dir = os.path.join(root_dir, 'docs') -html_dir = os.path.join(root_dir, 'html') - -local = not '--deploy' in sys.argv -preview = '-p' in sys.argv - -if local: - base_url = 'file://%s/' % os.path.normpath(os.path.join(os.getcwd(), html_dir)) - suffix = '.html' - index = 'index.html' -else: - base_url = 'http://www.django-rest-framework.org' - suffix = '' - index = '' - - -main_header = '
  • {{ title }}
  • ' -sub_header = '
  • {{ title }}
  • ' -code_label = r'\1' - -page = open(os.path.join(docs_dir, 'template.html'), 'r').read() - -# Copy static files -# for static in ['css', 'js', 'img']: -# source = os.path.join(docs_dir, 'static', static) -# target = os.path.join(html_dir, static) -# if os.path.exists(target): -# shutil.rmtree(target) -# shutil.copytree(source, target) - - -# Hacky, but what the hell, it'll do the job -path_list = [ - 'index.md', - 'tutorial/quickstart.md', - 'tutorial/1-serialization.md', - 'tutorial/2-requests-and-responses.md', - 'tutorial/3-class-based-views.md', - 'tutorial/4-authentication-and-permissions.md', - 'tutorial/5-relationships-and-hyperlinked-apis.md', - 'tutorial/6-viewsets-and-routers.md', - 'api-guide/requests.md', - 'api-guide/responses.md', - 'api-guide/views.md', - 'api-guide/generic-views.md', - 'api-guide/viewsets.md', - 'api-guide/routers.md', - 'api-guide/parsers.md', - 'api-guide/renderers.md', - 'api-guide/serializers.md', - 'api-guide/fields.md', - 'api-guide/relations.md', - 'api-guide/validators.md', - 'api-guide/authentication.md', - 'api-guide/permissions.md', - 'api-guide/throttling.md', - 'api-guide/filtering.md', - 'api-guide/pagination.md', - 'api-guide/content-negotiation.md', - 'api-guide/format-suffixes.md', - 'api-guide/reverse.md', - 'api-guide/exceptions.md', - 'api-guide/status-codes.md', - 'api-guide/testing.md', - 'api-guide/settings.md', - 'topics/documenting-your-api.md', - 'topics/ajax-csrf-cors.md', - 'topics/browser-enhancements.md', - 'topics/browsable-api.md', - 'topics/rest-hypermedia-hateoas.md', - 'topics/third-party-resources.md', - 'topics/contributing.md', - 'topics/rest-framework-2-announcement.md', - 'topics/2.2-announcement.md', - 'topics/2.3-announcement.md', - 'topics/2.4-announcement.md', - 'topics/release-notes.md', - 'topics/credits.md', -] - -prev_url_map = {} -next_url_map = {} -for idx in range(len(path_list)): - path = path_list[idx] - rel = '../' * path.count('/') - - if idx == 1 and not local: - # Link back to '/', not '/index' - prev_url_map[path] = '/' - elif idx > 0: - prev_url_map[path] = rel + path_list[idx - 1][:-3] + suffix - - if idx < len(path_list) - 1: - next_url_map[path] = rel + path_list[idx + 1][:-3] + suffix - - -for (dirpath, dirnames, filenames) in os.walk(docs_dir): - relative_dir = dirpath.replace(docs_dir, '').lstrip(os.path.sep) - build_dir = os.path.join(html_dir, relative_dir) - - if not os.path.exists(build_dir): - os.makedirs(build_dir) - - for filename in filenames: - path = os.path.join(dirpath, filename) - relative_path = os.path.join(relative_dir, filename) - - if not filename.endswith('.md'): - if relative_dir: - output_path = os.path.join(build_dir, filename) - shutil.copy(path, output_path) - continue - - output_path = os.path.join(build_dir, filename[:-3] + '.html') - - toc = '' - text = open(path, 'r').read().decode('utf-8') - main_title = None - description = 'Django, API, REST' - for line in text.splitlines(): - if line.startswith('# '): - title = line[2:].strip() - template = main_header - description = description + ', ' + title - elif line.startswith('## '): - title = line[3:].strip() - template = sub_header - else: - continue - - if not main_title: - main_title = title - anchor = title.lower().replace(' ', '-').replace(':-', '-').replace("'", '').replace('?', '').replace('.', '') - template = template.replace('{{ title }}', title) - template = template.replace('{{ anchor }}', anchor) - toc += template + '\n' - - if filename == 'index.md': - main_title = 'Django REST framework - Web APIs for Django' - else: - main_title = main_title + ' - Django REST framework' - - if relative_path == 'index.md': - canonical_url = base_url - else: - canonical_url = base_url + '/' + relative_path[:-3] + suffix - prev_url = prev_url_map.get(relative_path) - next_url = next_url_map.get(relative_path) - - content = markdown.markdown(text, ['headerid']) - - output = page.replace('{{ content }}', content).replace('{{ toc }}', toc).replace('{{ base_url }}', base_url).replace('{{ suffix }}', suffix).replace('{{ index }}', index) - output = output.replace('{{ title }}', main_title) - output = output.replace('{{ description }}', description) - output = output.replace('{{ page_id }}', filename[:-3]) - output = output.replace('{{ canonical_url }}', canonical_url) - - if filename =='index.md': - output = output.replace('{{ ad_block }}', """
    - """) - else: - output = output.replace('{{ ad_block }}', '') - - if prev_url: - output = output.replace('{{ prev_url }}', prev_url) - output = output.replace('{{ prev_url_disabled }}', '') - else: - output = output.replace('{{ prev_url }}', '#') - output = output.replace('{{ prev_url_disabled }}', 'disabled') - - if next_url: - output = output.replace('{{ next_url }}', next_url) - output = output.replace('{{ next_url_disabled }}', '') - else: - output = output.replace('{{ next_url }}', '#') - output = output.replace('{{ next_url_disabled }}', 'disabled') - - output = re.sub(r'a href="([^"]*)\.md"', r'a href="\1%s"' % suffix, output) - output = re.sub(r'
    :::bash', r'
    ', output)
    -        output = re.sub(r'
    ', r'
    ', output)
    -        output = re.sub(r'', code_label, output)
    -        open(output_path, 'w').write(output.encode('utf-8'))
    -
    -if preview:
    -    import subprocess
    -
    -    url = 'html/index.html'
    -
    -    try:
    -        subprocess.Popen(["open", url])  # Mac
    -    except OSError:
    -        subprocess.Popen(["xdg-open", url])  # Linux
    -    except:
    -        os.startfile(url)  # Windows
    diff --git a/mkdocs.yml b/mkdocs.yml
    new file mode 100644
    index 00000000..0134679c
    --- /dev/null
    +++ b/mkdocs.yml
    @@ -0,0 +1,55 @@
    +site_name: Django REST frameowkr
    +site_url: http://www.django-rest-framework.org/
    +site_description: Django REST framework - Web APIs for DjangoProject documentation with Markdown.
    +
    +repo_url: https://github.com/tomchristie/django-rest-framework
    +
    +pages:
    + - ['index.md', ]
    + - ['tutorial/quickstart.md', ]
    + - ['tutorial/1-serialization.md', ]
    + - ['tutorial/2-requests-and-responses.md', ]
    + - ['tutorial/3-class-based-views.md', ]
    + - ['tutorial/4-authentication-and-permissions.md', ]
    + - ['tutorial/5-relationships-and-hyperlinked-apis.md', ]
    + - ['tutorial/6-viewsets-and-routers.md', ]
    + - ['api-guide/requests.md', ]
    + - ['api-guide/responses.md', ]
    + - ['api-guide/views.md', ]
    + - ['api-guide/generic-views.md', ]
    + - ['api-guide/viewsets.md', ]
    + - ['api-guide/routers.md', ]
    + - ['api-guide/parsers.md', ]
    + - ['api-guide/renderers.md', ]
    + - ['api-guide/serializers.md', ]
    + - ['api-guide/fields.md', ]
    + - ['api-guide/relations.md', ]
    + - ['api-guide/authentication.md', ]
    + - ['api-guide/permissions.md', ]
    + - ['api-guide/throttling.md', ]
    + - ['api-guide/filtering.md', ]
    + - ['api-guide/pagination.md', ]
    + - ['api-guide/content-negotiation.md', ]
    + - ['api-guide/format-suffixes.md', ]
    + - ['api-guide/reverse.md', ]
    + - ['api-guide/exceptions.md', ]
    + - ['api-guide/status-codes.md', ]
    + - ['api-guide/testing.md', ]
    + - ['api-guide/settings.md', ]
    + - ['topics/documenting-your-api.md', ]
    + - ['topics/ajax-csrf-cors.md', ]
    + - ['topics/browser-enhancements.md', ]
    + - ['topics/browsable-api.md', ]
    + - ['topics/rest-hypermedia-hateoas.md', ]
    + - ['topics/third-party-resources.md', ]
    + - ['topics/contributing.md', ]
    + - ['topics/rest-framework-2-announcement.md', ]
    + - ['topics/2.2-announcement.md', ]
    + - ['topics/2.3-announcement.md', ]
    + - ['topics/2.4-announcement.md', ]
    + - ['topics/release-notes.md', ]
    + - ['topics/credits.md', ]
    +
    +theme_dir: docs/theme
    +copyright: Copyright © 2014, Tom Christie.
    +google_analytics: ['UA-27795084-5', 'mkdocs.org']
    -- 
    cgit v1.2.3
    
    
    From b2762cbb76a2602361fe5a9af6804863127d1c67 Mon Sep 17 00:00:00 2001
    From: Dougal Matthews
    Date: Wed, 22 Oct 2014 21:13:08 +0100
    Subject: Fixed typos in the config and updated Google analytics
    
    ---
     .gitignore | 1 +
     mkdocs.yml | 4 ++--
     2 files changed, 3 insertions(+), 2 deletions(-)
    
    diff --git a/.gitignore b/.gitignore
    index 9e17827b..2341eba0 100644
    --- a/.gitignore
    +++ b/.gitignore
    @@ -18,4 +18,5 @@ local/
     
     !.gitignore
     !.travis.yml
    +
     site/
    diff --git a/mkdocs.yml b/mkdocs.yml
    index 0134679c..8db4efc1 100644
    --- a/mkdocs.yml
    +++ b/mkdocs.yml
    @@ -1,4 +1,4 @@
    -site_name: Django REST frameowkr
    +site_name: Django REST framework
     site_url: http://www.django-rest-framework.org/
     site_description: Django REST framework - Web APIs for DjangoProject documentation with Markdown.
     
    @@ -52,4 +52,4 @@ pages:
     
     theme_dir: docs/theme
     copyright: Copyright © 2014, Tom Christie.
    -google_analytics: ['UA-27795084-5', 'mkdocs.org']
    +google_analytics: ['UA-18852272-2', 'django-rest-framework.org']
    -- 
    cgit v1.2.3
    
    
    From 261c4ce9aff6725a4e069cf45d0f57ec97a27bdb Mon Sep 17 00:00:00 2001
    From: Dougal Matthews
    Date: Wed, 22 Oct 2014 21:13:40 +0100
    Subject: Remove redundant requirements file
    
    ---
     docs/requirements.txt | 1 -
     1 file changed, 1 deletion(-)
     delete mode 100644 docs/requirements.txt
    
    diff --git a/docs/requirements.txt b/docs/requirements.txt
    deleted file mode 100644
    index a91fb978..00000000
    --- a/docs/requirements.txt
    +++ /dev/null
    @@ -1 +0,0 @@
    -markdown>=2.1.0
    -- 
    cgit v1.2.3
    
    
    From ae36a258d7266f73b73a0a722d39ff806d552e1b Mon Sep 17 00:00:00 2001
    From: Dougal Matthews
    Date: Wed, 22 Oct 2014 21:21:59 +0100
    Subject: Add the kickstarter annoucement to the TOC
    
    ---
     mkdocs.yml | 1 +
     1 file changed, 1 insertion(+)
    
    diff --git a/mkdocs.yml b/mkdocs.yml
    index 8db4efc1..cfaaed42 100644
    --- a/mkdocs.yml
    +++ b/mkdocs.yml
    @@ -47,6 +47,7 @@ pages:
      - ['topics/2.2-announcement.md', ]
      - ['topics/2.3-announcement.md', ]
      - ['topics/2.4-announcement.md', ]
    + - ['topics/kickstarter-announcement.md', ]
      - ['topics/release-notes.md', ]
      - ['topics/credits.md', ]
     
    -- 
    cgit v1.2.3
    
    
    From 04abe9830c1b6c0670a49129529e8e8d9e411f2c Mon Sep 17 00:00:00 2001
    From: Dougal Matthews
    Date: Wed, 22 Oct 2014 21:22:16 +0100
    Subject: Add a docs build to the Tox run
    
    ---
     .travis.yml | 1 +
     tox.ini     | 5 +++++
     2 files changed, 6 insertions(+)
    
    diff --git a/.travis.yml b/.travis.yml
    index 9dd587be..6191e7e2 100644
    --- a/.travis.yml
    +++ b/.travis.yml
    @@ -4,6 +4,7 @@ sudo: false
     
     env:
         - TOX_ENV=py27-flake8
    +    - TOX_ENV=py27-docs
         - TOX_ENV=py34-django17
         - TOX_ENV=py33-django17
         - TOX_ENV=py32-django17
    diff --git a/tox.ini b/tox.ini
    index a7200a3f..6b680813 100644
    --- a/tox.ini
    +++ b/tox.ini
    @@ -29,3 +29,8 @@ deps =
            pytest==2.5.2
            flake8==2.2.2
     commands = ./runtests.py --lintonly
    +
    +[testenv:py27-docs]
    +deps =
    +       mkdocs>=0.11.1
    +commands = mkdocs build
    -- 
    cgit v1.2.3
    
    
    From 84d9c4b46eacda54b31a3779c623554758f4dccc Mon Sep 17 00:00:00 2001
    From: Dougal Matthews
    Date: Wed, 22 Oct 2014 21:36:11 +0100
    Subject: Change site_dir to html to match mkdocs.py
    
    ---
     CONTRIBUTING.md             | 8 ++++----
     docs/topics/contributing.md | 8 ++++----
     mkdocs.yml                  | 1 +
     3 files changed, 9 insertions(+), 8 deletions(-)
    
    diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
    index 1b199534..ff82c954 100644
    --- a/CONTRIBUTING.md
    +++ b/CONTRIBUTING.md
    @@ -101,15 +101,15 @@ There are many great markdown editors that make working with the documentation r
     
     ## Building the documentation
     
    -To build the documentation, simply run the `mkdocs.py` script.
    +To build the documentation, simply install MkDocs with `pip install mkdocs` and then run the following command.
     
    -    ./mkdocs.py
    +    mkdocs build
     
     This will build the html output into the `html` directory.
     
    -You can build the documentation and open a preview in a browser window by using the `-p` flag.
    +You can build the documentation and open a preview in a browser window by using the `serve` command.
     
    -    ./mkdocs.py -p
    +    mkdocs serve
     
     ## Language style
     
    diff --git a/docs/topics/contributing.md b/docs/topics/contributing.md
    index 52f6e287..5809af65 100644
    --- a/docs/topics/contributing.md
    +++ b/docs/topics/contributing.md
    @@ -135,15 +135,15 @@ There are many great Markdown editors that make working with the documentation r
     
     ## Building the documentation
     
    -To build the documentation, simply run the `mkdocs.py` script.
    +To build the documentation, simply install MkDocs with `pip install mkdocs` and then run the following command.
     
    -    ./mkdocs.py
    +    mkdocs build
     
     This will build the html output into the `html` directory.
     
    -You can build the documentation and open a preview in a browser window by using the `-p` flag.
    +You can build the documentation and open a preview in a browser window by using the `serve` command.
     
    -    ./mkdocs.py -p
    +    mkdocs serve
     
     ## Language style
     
    diff --git a/mkdocs.yml b/mkdocs.yml
    index cfaaed42..e2c3abe8 100644
    --- a/mkdocs.yml
    +++ b/mkdocs.yml
    @@ -51,6 +51,7 @@ pages:
      - ['topics/release-notes.md', ]
      - ['topics/credits.md', ]
     
    +site_dir: html
     theme_dir: docs/theme
     copyright: Copyright © 2014, Tom Christie.
     google_analytics: ['UA-18852272-2', 'django-rest-framework.org']
    -- 
    cgit v1.2.3
    
    
    From 792c0c291f2cbe3c51de9e43cfee35c121e13687 Mon Sep 17 00:00:00 2001
    From: Dougal Matthews
    Date: Thu, 23 Oct 2014 08:11:24 +0100
    Subject: Remove the site ignore which isn't needed as we will use the html
     output directory as before
    
    ---
     .gitignore | 2 --
     1 file changed, 2 deletions(-)
    
    diff --git a/.gitignore b/.gitignore
    index 2341eba0..ae73f837 100644
    --- a/.gitignore
    +++ b/.gitignore
    @@ -18,5 +18,3 @@ local/
     
     !.gitignore
     !.travis.yml
    -
    -site/
    -- 
    cgit v1.2.3
    
    
    From 2ddef2d3263b2187fd502e42eaaecc3a4f0ad2b2 Mon Sep 17 00:00:00 2001
    From: Dougal Matthews
    Date: Thu, 23 Oct 2014 14:10:23 +0100
    Subject: Drop simply from the mkdocs install lines
    
    It is still simple tho', honest ;)
    ---
     CONTRIBUTING.md             | 2 +-
     docs/topics/contributing.md | 2 +-
     2 files changed, 2 insertions(+), 2 deletions(-)
    
    diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
    index ff82c954..69802995 100644
    --- a/CONTRIBUTING.md
    +++ b/CONTRIBUTING.md
    @@ -101,7 +101,7 @@ There are many great markdown editors that make working with the documentation r
     
     ## Building the documentation
     
    -To build the documentation, simply install MkDocs with `pip install mkdocs` and then run the following command.
    +To build the documentation, install MkDocs with `pip install mkdocs` and then run the following command.
     
         mkdocs build
     
    diff --git a/docs/topics/contributing.md b/docs/topics/contributing.md
    index 5809af65..c7991a0f 100644
    --- a/docs/topics/contributing.md
    +++ b/docs/topics/contributing.md
    @@ -135,7 +135,7 @@ There are many great Markdown editors that make working with the documentation r
     
     ## Building the documentation
     
    -To build the documentation, simply install MkDocs with `pip install mkdocs` and then run the following command.
    +To build the documentation, install MkDocs with `pip install mkdocs` and then run the following command.
     
         mkdocs build
     
    -- 
    cgit v1.2.3
    
    
    From d6b203f013890cc25f5454696805bc85c1ca2482 Mon Sep 17 00:00:00 2001
    From: José Padilla
    Date: Tue, 28 Oct 2014 17:40:29 -0400
    Subject: Use page_title instead of title in docs theme
    
    ---
     docs/theme/base.html | 2 +-
     1 file changed, 1 insertion(+), 1 deletion(-)
    
    diff --git a/docs/theme/base.html b/docs/theme/base.html
    index 45e19cf3..943a60e4 100644
    --- a/docs/theme/base.html
    +++ b/docs/theme/base.html
    @@ -2,7 +2,7 @@
     
     
         
    -    {{ title }}
    +    {{ page_title }}
         
         
         
    -- 
    cgit v1.2.3
    
    
    From 18712a5cbcbb25d935b93baac589cacfe1cbb754 Mon Sep 17 00:00:00 2001
    From: Dougal Matthews
    Date: Wed, 29 Oct 2014 20:54:20 +0000
    Subject: Fix the Navigation style
    
    ---
     docs/theme/base.html | 7 ++-----
     1 file changed, 2 insertions(+), 5 deletions(-)
    
    diff --git a/docs/theme/base.html b/docs/theme/base.html
    index 943a60e4..e5ad4377 100644
    --- a/docs/theme/base.html
    +++ b/docs/theme/base.html
    @@ -188,15 +188,12 @@ a.fusion-poweredby {
                 
    +
    -- cgit v1.2.3 From 49a493f61f4d5b4447d139d189d78995e65231b2 Mon Sep 17 00:00:00 2001 From: Dougal Matthews Date: Wed, 29 Oct 2014 20:54:31 +0000 Subject: Bring back the promo section --- docs/theme/base.html | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/theme/base.html b/docs/theme/base.html index e5ad4377..7ca7de14 100644 --- a/docs/theme/base.html +++ b/docs/theme/base.html @@ -191,7 +191,8 @@ a.fusion-poweredby {
  • {{ toc_item.title }}
  • {% endfor %}
    - {{ ad_block }} +
    +
    -- cgit v1.2.3 From 3c49b9fe4648d6fb291f0d34bf2e9ef4b72d45be Mon Sep 17 00:00:00 2001 From: Dougal Matthews Date: Wed, 29 Oct 2014 21:03:00 +0000 Subject: Add next and previous page. --- docs/theme/base.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/theme/base.html b/docs/theme/base.html index 7ca7de14..0f876cc1 100644 --- a/docs/theme/base.html +++ b/docs/theme/base.html @@ -57,8 +57,8 @@ a.fusion-poweredby {
    - {% include "content.html" %} + {% if meta.source %} + {% for filename in meta.source %} + + {{ filename }} + + {% endfor %} + {% endif %} + + {{ content }}
    -- cgit v1.2.3 From 3bfc82068b068defee470910a850757e4c12df3b Mon Sep 17 00:00:00 2001 From: José Padilla Date: Fri, 31 Oct 2014 11:38:27 -0400 Subject: Update tabbing and cleanup theme templates --- docs_theme/404.html | 211 ++++++++++++++++++++++------------------- docs_theme/base.html | 259 +++++++++++++++++++++++++++------------------------ docs_theme/nav.html | 51 +++++----- 3 files changed, 274 insertions(+), 247 deletions(-) diff --git a/docs_theme/404.html b/docs_theme/404.html index 864247e7..44993e37 100644 --- a/docs_theme/404.html +++ b/docs_theme/404.html @@ -1,50 +1,54 @@ - - - Django REST framework - 404 - Page not found - - - - - - - - - - - - - - - - - - + + + + + Django REST framework - 404 - Page not found + + + + + + + + + + + + + + + + + + + + + + + + + + + -
    - +
    + + - - - - - - + + + + - // Dynamically force sidenav to no higher than browser window - $('.side-nav').css('max-height', window.innerHeight - 130); - - $(function(){ - $(window).resize(function(){ - $('.side-nav').css('max-height', window.innerHeight - 130); - }); - }); - - + diff --git a/docs_theme/base.html b/docs_theme/base.html index 67290df6..544e2188 100644 --- a/docs_theme/base.html +++ b/docs_theme/base.html @@ -1,56 +1,62 @@ - - - {{ page_title }} - - - - - - - - - - - - - - - - - - - {# TODO: This is a bit of a hack. We don't want to refer to the file specifically. #} - + + + + + {{ page_title }} + + + + + + + + + + + + + + + + + + + +{# TODO: This is a bit of a hack. We don't want to refer to the file specifically. #} + +
    @@ -59,32 +65,34 @@ a.fusion-poweredby {
    - - + +
    @@ -98,18 +106,16 @@ a.fusion-poweredby {
    @@ -127,42 +133,51 @@ a.fusion-poweredby { {% endif %} {{ content }} -
    -
    -
    -
    - -
    -
    + + + + + + + + +
    + + - - - - - - - + + + + + - // Dynamically force sidenav to no higher than browser window - $('.side-nav').css('max-height', window.innerHeight - 130); - - $(function(){ - $(window).resize(function(){ - $('.side-nav').css('max-height', window.innerHeight - 130); - }); - }); - - + diff --git a/docs_theme/nav.html b/docs_theme/nav.html index a7a72d68..87e197b3 100644 --- a/docs_theme/nav.html +++ b/docs_theme/nav.html @@ -1,11 +1,10 @@ - -- cgit v1.2.3 From 06683b86b2b15153df52fe481b5c4eeb489a80cf Mon Sep 17 00:00:00 2001 From: José Padilla Date: Fri, 31 Oct 2014 13:02:11 -0400 Subject: Use single quotes for consistency Conflicts: mkdocs.yml --- mkdocs.yml | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/mkdocs.yml b/mkdocs.yml index 2d1886a0..c70de982 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -13,30 +13,30 @@ pages: - ['tutorial/4-authentication-and-permissions.md', ] - ['tutorial/5-relationships-and-hyperlinked-apis.md', ] - ['tutorial/6-viewsets-and-routers.md', ] - - ['api-guide/requests.md', "API Guide", ] - - ['api-guide/responses.md', "API Guide", ] - - ['api-guide/views.md', "API Guide", ] - - ['api-guide/generic-views.md', "API Guide", ] - - ['api-guide/viewsets.md', "API Guide", ] - - ['api-guide/routers.md', "API Guide", ] - - ['api-guide/parsers.md', "API Guide", ] - - ['api-guide/renderers.md', "API Guide", ] - - ['api-guide/serializers.md', "API Guide", ] - - ['api-guide/fields.md', "API Guide", ] - - ['api-guide/relations.md', "API Guide", ] - - ['api-guide/validators.md', "API Guide", ] - - ['api-guide/authentication.md', "API Guide", ] - - ['api-guide/permissions.md', "API Guide", ] - - ['api-guide/throttling.md', "API Guide", ] - - ['api-guide/filtering.md', "API Guide", ] - - ['api-guide/pagination.md', "API Guide", ] - - ['api-guide/content-negotiation.md', "API Guide", ] - - ['api-guide/format-suffixes.md', "API Guide", ] - - ['api-guide/reverse.md', "API Guide", ] - - ['api-guide/exceptions.md', "API Guide", ] - - ['api-guide/status-codes.md', "API Guide", ] - - ['api-guide/testing.md', "API Guide", ] - - ['api-guide/settings.md', "API Guide", ] + - ['api-guide/requests.md', 'API Guide', ] + - ['api-guide/responses.md', 'API Guide', ] + - ['api-guide/views.md', 'API Guide', ] + - ['api-guide/generic-views.md', 'API Guide', ] + - ['api-guide/viewsets.md', 'API Guide', ] + - ['api-guide/routers.md', 'API Guide', ] + - ['api-guide/parsers.md', 'API Guide', ] + - ['api-guide/renderers.md', 'API Guide', ] + - ['api-guide/serializers.md', 'API Guide', ] + - ['api-guide/fields.md', 'API Guide', ] + - ['api-guide/relations.md', 'API Guide', ] + - ['api-guide/validators.md', 'API Guide', ] + - ['api-guide/authentication.md', 'API Guide', ] + - ['api-guide/permissions.md', 'API Guide', ] + - ['api-guide/throttling.md', 'API Guide', ] + - ['api-guide/filtering.md', 'API Guide', ] + - ['api-guide/pagination.md', 'API Guide', ] + - ['api-guide/content-negotiation.md', 'API Guide', ] + - ['api-guide/format-suffixes.md', 'API Guide', ] + - ['api-guide/reverse.md', 'API Guide', ] + - ['api-guide/exceptions.md', 'API Guide', ] + - ['api-guide/status-codes.md', 'API Guide', ] + - ['api-guide/testing.md', 'API Guide', ] + - ['api-guide/settings.md', 'API Guide', ] - ['topics/documenting-your-api.md', ] - ['topics/ajax-csrf-cors.md', ] - ['topics/browser-enhancements.md', ] -- cgit v1.2.3 From 200e0b17daecd07de6d1f9926a430d29b3ee948f Mon Sep 17 00:00:00 2001 From: José Padilla Date: Fri, 31 Oct 2014 13:03:39 -0400 Subject: Clean up extra white space --- docs/topics/2.2-announcement.md | 8 ++++---- docs/topics/2.3-announcement.md | 8 ++++---- docs/topics/documenting-your-api.md | 8 ++++---- docs/topics/kickstarter-announcement.md | 2 +- docs/topics/release-notes.md | 2 +- docs/topics/rest-framework-2-announcement.md | 4 ++-- docs/topics/writable-nested-serializers.md | 10 +++++----- docs/tutorial/1-serialization.md | 2 +- 8 files changed, 22 insertions(+), 22 deletions(-) diff --git a/docs/topics/2.2-announcement.md b/docs/topics/2.2-announcement.md index a997c782..1df52cff 100644 --- a/docs/topics/2.2-announcement.md +++ b/docs/topics/2.2-announcement.md @@ -42,7 +42,7 @@ The 2.2 release makes a few changes to the API, in order to make it more consist The `ManyRelatedField()` style is being deprecated in favor of a new `RelatedField(many=True)` syntax. -For example, if a user is associated with multiple questions, which we want to represent using a primary key relationship, we might use something like the following: +For example, if a user is associated with multiple questions, which we want to represent using a primary key relationship, we might use something like the following: class UserSerializer(serializers.HyperlinkedModelSerializer): questions = serializers.PrimaryKeyRelatedField(many=True) @@ -58,10 +58,10 @@ The change also applies to serializers. If you have a nested serializer, you sh class Meta: model = Track fields = ('name', 'duration') - + class AlbumSerializer(serializer.ModelSerializer): tracks = TrackSerializer(many=True) - + class Meta: model = Album fields = ('album_name', 'artist', 'tracks') @@ -87,7 +87,7 @@ For example, is a user account has an optional foreign key to a company, that yo This is in line both with the rest of the serializer fields API, and with Django's `Form` and `ModelForm` API. -Using `required` throughout the serializers API means you won't need to consider if a particular field should take `blank` or `null` arguments instead of `required`, and also means there will be more consistent behavior for how fields are treated when they are not present in the incoming data. +Using `required` throughout the serializers API means you won't need to consider if a particular field should take `blank` or `null` arguments instead of `required`, and also means there will be more consistent behavior for how fields are treated when they are not present in the incoming data. The `null=True` argument will continue to function, and will imply `required=False`, but will raise a `PendingDeprecationWarning`. diff --git a/docs/topics/2.3-announcement.md b/docs/topics/2.3-announcement.md index 7c800afa..9c9f3e9f 100644 --- a/docs/topics/2.3-announcement.md +++ b/docs/topics/2.3-announcement.md @@ -27,7 +27,7 @@ As an example of just how simple REST framework APIs can now be, here's an API w class GroupViewSet(viewsets.ModelViewSet): model = Group - + # Routers provide an easy way of automatically determining the URL conf router = routers.DefaultRouter() router.register(r'users', UserViewSet) @@ -197,13 +197,13 @@ Usage of the old-style attributes continues to be supported, but will raise a `P For most cases APIs using model fields will behave as previously, however if you are using a custom renderer, not provided by REST framework, then you may now need to add support for rendering `Decimal` instances to your renderer implementation. -## ModelSerializers and reverse relationships +## ModelSerializers and reverse relationships The support for adding reverse relationships to the `fields` option on a `ModelSerializer` class means that the `get_related_field` and `get_nested_field` method signatures have now changed. In the unlikely event that you're providing a custom serializer class, and implementing these methods you should note the new call signature for both methods is now `(self, model_field, related_model, to_many)`. For reverse relationships `model_field` will be `None`. -The old-style signature will continue to function but will raise a `PendingDeprecationWarning`. +The old-style signature will continue to function but will raise a `PendingDeprecationWarning`. ## View names and descriptions @@ -211,7 +211,7 @@ The mechanics of how the names and descriptions used in the browseable API are g If you've been customizing this behavior, for example perhaps to use `rst` markup for the browseable API, then you'll need to take a look at the implementation to see what updates you need to make. -Note that the relevant methods have always been private APIs, and the docstrings called them out as intended to be deprecated. +Note that the relevant methods have always been private APIs, and the docstrings called them out as intended to be deprecated. --- diff --git a/docs/topics/documenting-your-api.md b/docs/topics/documenting-your-api.md index e20f9712..d65e251f 100644 --- a/docs/topics/documenting-your-api.md +++ b/docs/topics/documenting-your-api.md @@ -54,7 +54,7 @@ The title that is used in the browsable API is generated from the view class nam For example, the view `UserListView`, will be named `User List` when presented in the browsable API. -When working with viewsets, an appropriate suffix is appended to each generated view. For example, the view set `UserViewSet` will generate views named `User List` and `User Instance`. +When working with viewsets, an appropriate suffix is appended to each generated view. For example, the view set `UserViewSet` will generate views named `User List` and `User Instance`. #### Setting the description @@ -65,9 +65,9 @@ If the python `markdown` library is installed, then [markdown syntax][markdown] class AccountListView(views.APIView): """ Returns a list of all **active** accounts in the system. - + For more details on how accounts are activated please [see here][ref]. - + [ref]: http://example.com/activating-accounts """ @@ -84,7 +84,7 @@ You can modify the response behavior to `OPTIONS` requests by overriding the `me def metadata(self, request): """ Don't include the view description in OPTIONS responses. - """ + """ data = super(ExampleView, self).metadata(request) data.pop('description') return data diff --git a/docs/topics/kickstarter-announcement.md b/docs/topics/kickstarter-announcement.md index 7d1f6d0e..e8bad95b 100644 --- a/docs/topics/kickstarter-announcement.md +++ b/docs/topics/kickstarter-announcement.md @@ -160,4 +160,4 @@ The following individuals made a significant financial contribution to the devel ### Supporters -There were also almost 300 further individuals choosing to help fund the project at other levels or choosing to give anonymously. Again, thank you, thank you, thank you! \ No newline at end of file +There were also almost 300 further individuals choosing to help fund the project at other levels or choosing to give anonymously. Again, thank you, thank you, thank you! diff --git a/docs/topics/release-notes.md b/docs/topics/release-notes.md index 88780c3f..9fca949a 100644 --- a/docs/topics/release-notes.md +++ b/docs/topics/release-notes.md @@ -63,7 +63,7 @@ You can determine your currently installed version using `pip freeze`: * Bugfix: Fix migration in `authtoken` application. * Bugfix: Allow selection of integer keys in nested choices. * Bugfix: Return `None` instead of `'None'` in `CharField` with `allow_none=True`. -* Bugfix: Ensure custom model fields map to equivelent serializer fields more reliably. +* Bugfix: Ensure custom model fields map to equivelent serializer fields more reliably. * Bugfix: `DjangoFilterBackend` no longer quietly changes queryset ordering. ### 2.4.2 diff --git a/docs/topics/rest-framework-2-announcement.md b/docs/topics/rest-framework-2-announcement.md index f1060d90..a7746932 100644 --- a/docs/topics/rest-framework-2-announcement.md +++ b/docs/topics/rest-framework-2-announcement.md @@ -8,7 +8,7 @@ What it is, and why you should care. --- -**Announcement:** REST framework 2 released - Tue 30th Oct 2012 +**Announcement:** REST framework 2 released - Tue 30th Oct 2012 --- @@ -37,7 +37,7 @@ REST framework 2 includes a totally re-worked serialization engine, that was ini * A declarative serialization API, that mirrors Django's `Forms`/`ModelForms` API. * Structural concerns are decoupled from encoding concerns. * Able to support rendering and parsing to many formats, including both machine-readable representations and HTML forms. -* Validation that can be mapped to obvious and comprehensive error responses. +* Validation that can be mapped to obvious and comprehensive error responses. * Serializers that support both nested, flat, and partially-nested representations. * Relationships that can be expressed as primary keys, hyperlinks, slug fields, and other custom representations. diff --git a/docs/topics/writable-nested-serializers.md b/docs/topics/writable-nested-serializers.md index abc6a82f..ed614bd2 100644 --- a/docs/topics/writable-nested-serializers.md +++ b/docs/topics/writable-nested-serializers.md @@ -8,7 +8,7 @@ Although flat data structures serve to properly delineate between the individual Nested data structures are easy enough to work with if they're read-only - simply nest your serializer classes and you're good to go. However, there are a few more subtleties to using writable nested serializers, due to the dependencies between the various model instances, and the need to save or delete multiple instances in a single action. -## One-to-many data structures +## One-to-many data structures *Example of a **read-only** nested serializer. Nothing complex to worry about here.* @@ -16,10 +16,10 @@ Nested data structures are easy enough to work with if they're read-only - simpl class Meta: model = ToDoItem fields = ('text', 'is_completed') - + class ToDoListSerializer(serializers.ModelSerializer): items = ToDoItemSerializer(many=True, read_only=True) - + class Meta: model = ToDoList fields = ('title', 'items') @@ -31,7 +31,7 @@ Some example output from our serializer. 'items': { {'text': 'Compile playlist', 'is_completed': True}, {'text': 'Send invites', 'is_completed': False}, - {'text': 'Clean house', 'is_completed': False} + {'text': 'Clean house', 'is_completed': False} } } @@ -44,4 +44,4 @@ Let's take a look at updating our nested one-to-many data structure. ### Making PATCH requests -[cite]: http://jsonapi.org/format/#url-based-json-api \ No newline at end of file +[cite]: http://jsonapi.org/format/#url-based-json-api diff --git a/docs/tutorial/1-serialization.md b/docs/tutorial/1-serialization.md index db5b9ea7..f9027b68 100644 --- a/docs/tutorial/1-serialization.md +++ b/docs/tutorial/1-serialization.md @@ -134,7 +134,7 @@ A serializer class is very similar to a Django `Form` class, and includes simila The field flags can also control how the serializer should be displayed in certain circumstances, such as when rendering to HTML. The `style={'type': 'textarea'}` flag above is equivelent to using `widget=widgets.Textarea` on a Django `Form` class. This is particularly useful for controlling how the browsable API should be displayed, as we'll see later in the tutorial. -We can actually also save ourselves some time by using the `ModelSerializer` class, as we'll see later, but for now we'll keep our serializer definition explicit. +We can actually also save ourselves some time by using the `ModelSerializer` class, as we'll see later, but for now we'll keep our serializer definition explicit. ## Working with Serializers -- cgit v1.2.3 From b8aa7e0c34dc839a47b679aa2402d0f1b98704a0 Mon Sep 17 00:00:00 2001 From: Dougal Matthews Date: Tue, 18 Nov 2014 17:16:54 +0000 Subject: Fix previous and next links --- docs_theme/nav.html | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/docs_theme/nav.html b/docs_theme/nav.html index 87e197b3..0f3b9871 100644 --- a/docs_theme/nav.html +++ b/docs_theme/nav.html @@ -2,8 +2,12 @@