From 94401b43d2a1be81304ddcd91e3a97e7d2a42c4c Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Tue, 9 Oct 2012 13:50:26 +0100 Subject: Flesh out quickstart guide and make some style tweaks --- docs/images/quickstart.png | Bin 0 -> 39050 bytes docs/tutorial/quickstart.md | 39 +++++++++++++++++++++ mkdocs.py | 25 ++++++++----- .../static/rest_framework/css/default.css | 4 +++ rest_framework/templates/rest_framework/base.html | 10 +++--- 5 files changed, 63 insertions(+), 15 deletions(-) create mode 100644 docs/images/quickstart.png diff --git a/docs/images/quickstart.png b/docs/images/quickstart.png new file mode 100644 index 00000000..5006d60f Binary files /dev/null and b/docs/images/quickstart.png differ diff --git a/docs/tutorial/quickstart.md b/docs/tutorial/quickstart.md index 62338160..cf5933ad 100644 --- a/docs/tutorial/quickstart.md +++ b/docs/tutorial/quickstart.md @@ -131,3 +131,42 @@ We'd also like to set a few global settings. We'd like to turn on pagination, a } Okay, that's us done. + +--- + +## Testing our API + +We can now access our API, both from the command-line, using tools like `curl`... + + bash: curl -H 'Accept: application/json; indent=4' -u admin:password http://127.0.0.1:8000/users/ + { + "count": 2, + "next": null, + "previous": null, + "results": [ + { + "email": "admin@example.com", + "groups": [], + "url": "http://127.0.0.1:8000/users/1/", + "username": "admin" + }, + { + "email": "tom@example.com", + "groups": [], + "url": "http://127.0.0.1:8000/users/2/", + "username": "tom" + } + ] + } + +Or directly through the browser... + +![Quick start image][image] + +Great, that was easy! + +If you want to get a more in depth understanding of how REST framework fits together head on over to [the tutorial][tutorial], or start browsing the [API guide][guide]. + +[image]: ../images/quickstart.png +[tutorial]: 1-serialization.md +[guide]: ../#api-guide \ No newline at end of file diff --git a/mkdocs.py b/mkdocs.py index 8ccd75e5..dc29d40b 100755 --- a/mkdocs.py +++ b/mkdocs.py @@ -37,12 +37,25 @@ for static in ['css', 'js', 'img']: shutil.copytree(source, target) 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: - if not filename.endswith('.md'): + path = os.path.join(dirpath, filename) + + if filename.endswith('.png'): + output_path = os.path.join(build_dir, filename) + shutil.copy(path, output_path) + continue + elif not filename.endswith('.md'): continue + output_path = os.path.join(build_dir, filename[:-3] + '.html') + toc = '' - text = open(os.path.join(dirpath, filename), 'r').read().decode('utf-8') + text = open(path, 'r').read().decode('utf-8') for line in text.splitlines(): if line.startswith('# '): title = line[2:].strip() @@ -60,16 +73,10 @@ for (dirpath, dirnames, filenames) in os.walk(docs_dir): content = markdown.markdown(text, ['headerid']) - relative_dir = dirpath.replace(docs_dir, '').lstrip(os.path.sep) - build_dir = os.path.join(html_dir, relative_dir) - build_file = os.path.join(build_dir, filename[:-3] + '.html') - - if not os.path.exists(build_dir): - os.makedirs(build_dir) output = page.replace('{{ content }}', content).replace('{{ toc }}', toc).replace('{{ base_url }}', base_url).replace('{{ suffix }}', suffix).replace('{{ index }}', index) output = output.replace('{{ page_id }}', filename[:-3]) 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(build_file, 'w').write(output.encode('utf-8'))
+        open(output_path, 'w').write(output.encode('utf-8'))
diff --git a/rest_framework/static/rest_framework/css/default.css b/rest_framework/static/rest_framework/css/default.css
index 4d61ac8f..739b9300 100644
--- a/rest_framework/static/rest_framework/css/default.css
+++ b/rest_framework/static/rest_framework/css/default.css
@@ -19,6 +19,10 @@ h2, h3 {
     padding-right: 0.25em;
 }
 
+.version {
+  font-size: 70%;
+}
+
 .format-option {
     font-family: Menlo, Consolas, "Andale Mono", "Lucida Console", monospace;
 }
diff --git a/rest_framework/templates/rest_framework/base.html b/rest_framework/templates/rest_framework/base.html
index d26cb8f4..5ac6ef67 100644
--- a/rest_framework/templates/rest_framework/base.html
+++ b/rest_framework/templates/rest_framework/base.html
@@ -39,7 +39,7 @@
                         {% if user.is_authenticated %}