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
69cbafc6
Commit
69cbafc6
authored
Mar 28, 2013
by
Tom Christie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add search and next/prev
parent
d2435385
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
116 additions
and
1 deletions
+116
-1
docs/css/default.css
+11
-0
docs/template.html
+31
-0
mkdocs.py
+74
-1
No files found.
docs/css/default.css
View file @
69cbafc6
...
...
@@ -277,3 +277,14 @@ footer a {
footer
a
:hover
{
color
:
gray
;
}
.btn-inverse
{
background-image
:
-webkit-gradient
(
linear
,
0
0
,
0
100%
,
from
(
#606060
),
to
(
#404040
))
!important
;
background-image
:
-webkit-linear-gradient
(
top
,
#606060
,
#404040
)
!important
;
}
.modal-open
.modal
,
.btn
:focus
{
outline
:
none
;}
@media
(
max-width
:
650px
)
{
.repo-link.btn-inverse
{
display
:
none
;}
}
docs/template.html
View file @
69cbafc6
...
...
@@ -41,6 +41,9 @@
<div
class=
"navbar-inner"
>
<div
class=
"container-fluid"
>
<a
class=
"repo-link btn btn-primary btn-small"
href=
"https://github.com/tomchristie/django-rest-framework/tree/master"
>
GitHub
</a>
<a
class=
"repo-link btn btn-inverse btn-small {{ next_url_disabled }}"
href=
"{{ next_url }}"
>
Next
<i
class=
"icon-arrow-right icon-white"
></i></a>
<a
class=
"repo-link btn btn-inverse btn-small {{ prev_url_disabled }}"
href=
"{{ prev_url }}"
><i
class=
"icon-arrow-left icon-white"
></i>
Previous
</a>
<a
class=
"repo-link btn btn-inverse btn-small"
href=
"#searchModal"
data-toggle=
"modal"
><i
class=
"icon-search icon-white"
></i>
Search
</a>
<a
class=
"btn btn-navbar"
data-toggle=
"collapse"
data-target=
".nav-collapse"
>
<span
class=
"icon-bar"
></span>
<span
class=
"icon-bar"
></span>
...
...
@@ -118,6 +121,34 @@
<div
class=
"body-content"
>
<div
class=
"container-fluid"
>
<!-- Search Modal -->
<div
id=
"searchModal"
class=
"modal hide fade"
tabindex=
"-1"
role=
"dialog"
aria-labelledby=
"myModalLabel"
aria-hidden=
"true"
>
<div
class=
"modal-header"
>
<button
type=
"button"
class=
"close"
data-dismiss=
"modal"
aria-hidden=
"true"
>
×
</button>
<h3
id=
"myModalLabel"
>
Documentation search
</h3>
</div>
<div
class=
"modal-body"
>
<!-- Custom google search -->
<script>
(
function
()
{
var
cx
=
'015016005043623903336:rxraeohqk6w'
;
var
gcse
=
document
.
createElement
(
'script'
);
gcse
.
type
=
'text/javascript'
;
gcse
.
async
=
true
;
gcse
.
src
=
(
document
.
location
.
protocol
==
'https:'
?
'https:'
:
'http:'
)
+
'//www.google.com/cse/cse.js?cx='
+
cx
;
var
s
=
document
.
getElementsByTagName
(
'script'
)[
0
];
s
.
parentNode
.
insertBefore
(
gcse
,
s
);
})();
</script>
<gcse:search></gcse:search>
</div>
<div
class=
"modal-footer"
>
<button
class=
"btn"
data-dismiss=
"modal"
aria-hidden=
"true"
>
Close
</button>
</div>
</div>
<div
class=
"row-fluid"
>
<div
class=
"span3"
>
...
...
mkdocs.py
View file @
69cbafc6
...
...
@@ -37,6 +37,60 @@ page = open(os.path.join(docs_dir, 'template.html'), 'r').read()
# 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'
,
'api-guide/requests.md'
,
'api-guide/responses.md'
,
'api-guide/views.md'
,
'api-guide/generic-views.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/settings.md'
,
'topics/ajax-csrf-cors.md'
,
'topics/browser-enhancements.md'
,
'topics/browsable-api.md'
,
'topics/rest-hypermedia-hateoas.md'
,
'topics/contributing.md'
,
'topics/rest-framework-2-announcement.md'
,
'topics/2.2-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
>
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
)
...
...
@@ -46,6 +100,7 @@ for (dirpath, dirnames, filenames) in os.walk(docs_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
:
...
...
@@ -78,16 +133,34 @@ for (dirpath, dirnames, filenames) in os.walk(docs_dir):
toc
+=
template
+
'
\n
'
if
filename
==
'index.md'
:
main_title
=
'Django REST framework -
APIs made easy
'
main_title
=
'Django REST framework -
Web Browseable APIs
'
else
:
main_title
=
'Django REST framework - '
+
main_title
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
])
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'<pre><code>:::bash'
,
r'<pre class="prettyprint lang-bsh">'
,
output
)
output
=
re
.
sub
(
r'<pre>'
,
r'<pre class="prettyprint lang-py">'
,
output
)
...
...
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