This commit is contained in:
Sina 2025-04-08 16:18:52 +02:00 committed by GitHub
commit 938b7af316
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
21 changed files with 5990 additions and 7538 deletions

2
.gitignore vendored
View File

@ -18,3 +18,5 @@ coverage.*
!.github
!.gitignore
!.pre-commit-config.yaml
venv/

View File

@ -30,4 +30,4 @@ repos:
rev: v2.2.6
hooks:
- id: codespell
exclude: locale|kickstarter-announcement.md|coreapi-0.1.1.js
exclude: locale|kickstarter-announcement.md|coreapi-0.1.1.js|docs_theme/package-lock.json

2
docs_theme/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
node_modules/
dist/

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,455 +0,0 @@
/* Set the body padding-top when above 980px to push the content down from
below the navbar, which is fixed at >980px screen widths. */
pre {
font-size: 12px;
}
.dropdown .dropdown-menu {
display: none;
overflow-y: auto;
}
.dropdown.open .dropdown-menu {
display: block;
}
@media (max-width: 480px) {
.repo-link {
display: none;
}
}
/* Header link to GitHub */
.repo-link {
float: right;
margin-right: 10px;
margin-top: 9px;
}
body.index-page #main-content p.badges {
padding-bottom: 1px;
}
/* GitHub 'Star' badge */
body.index-page #main-content iframe.github-star-button {
float: right;
margin-top: -12px;
margin-right: -15px;
}
/* CI and PyPI badge */
body.index-page #main-content img.status-badge {
float: right;
margin-right: 8px;
margin-top: -11px;
margin-bottom: 0px;
}
/* Github source file badges */
a.github {
float: right;
margin-top: -12px;
margin-right: 12px;
}
a.github:hover {
text-decoration: none;
}
/* */
body hr {
border-top: 1px dotted #A30000;
}
/* Force TOC text to not overrun */
#table-of-contents {
overflow: hidden;
margin: 0 0 20px 0;
}
/* Code blocks should scroll horizontally */
pre {
overflow: auto;
word-wrap: normal;
white-space: pre;
}
code, pre {
font-family: Consolas,Menlo,Monaco,Lucida Console,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier New,monospace,sans-serif;
font-size: 13px;
}
/* Preserve the spacing of the navbar across different screen sizes. */
.navbar-inner {
/*padding: 5px 0;*/
}
@media (max-width: 979px) {
.navbar .brand {
margin-left: 0;
padding-left: 0;
}
.navbar-inner .container-fluid {
padding-left: 15px;
}
}
.nav-list li.main {
font-weight: bold;
}
.nav-list a {
overflow: hidden;
}
.nav-list > li > a {
padding: 2px 15px 3px;
}
/* Set the table of contents to static so it flows back into the content when
viewed on tablets and smaller. */
@media (max-width: 767px) {
#table-of-contents {
position: static;
}
}
/* When the page is in two-column layout, give the main content some room
to breath on the left. */
@media (min-width: 768px) {
#main-content {
padding-left: 1em;
}
}
/* Cutesy quote styling */
blockquote {
font-family: Georgia, serif;
font-size: 18px;
font-style: italic;
margin: 0.25em 0;
padding: 0.25em 40px;
line-height: 1.45;
position: relative;
color: #383838;
border-left: none;
}
blockquote:before {
display: block;
content: "\201C";
font-size: 80px;
position: absolute;
left: -10px;
top: -20px;
color: #7a7a7a;
}
blockquote p:last-child {
color: #999999;
font-size: 14px;
display: block;
margin-top: 5px;
}
/*=== dabapps bootstrap styles ====*/
html{
width:100%;
background: none;
}
body, .navbar .navbar-inner .container-fluid{
max-width: 1150px;
margin: 0 auto;
}
/* Replacement for `body { background-attachment: fixed; }`, which
has performance issues when scrolling on large displays. */
body::before {
content: ' ';
position: fixed;
width: 100%;
height: 100%;
top: 0;
left: 0;
background-color: #f8f8f8;
background: url(../img/grid.png) repeat-x;
will-change: transform;
z-index: -1;
}
#main-content h1:first-of-type {
margin-top: 0
}
#main-content h1, #main-content h2 {
font-weight: 300;
margin-top: 20px
}
#main-content h3, #main-content h4, #main-content h5 {
font-weight: 300;
margin-top: 15px
}
#main-content img {
display: block;
margin: 40px auto;
}
/* custom navigation styles */
.navbar .navbar-inner{
background: #2C2C2C;
color: white;
border: none;
border-top: 5px solid #A30000;
}
.navbar .navbar-inner .nav li, .navbar .navbar-inner .nav li a, .navbar .navbar-inner .brand{
color: white;
}
.nav-list > .active > a, .navbar .navbar-inner .nav li a:hover {
background:#212121;
color:white;
}
.navbar .navbar-inner .dropdown-menu li a, .navbar .navbar-inner .dropdown-menu li{
color: #A30000;
}
.dropdown-menu .active > a,
.dropdown-menu .active > a:hover {
background-image: none;
}
.navbar-inverse .nav .dropdown .active > a,
.navbar-inverse .nav .dropdown .active > a:hover,
.navbar-inverse .nav .dropdown .active > a:focus {
background-color: #eeeeee;
}
.navbar .navbar-inner .dropdown-menu li a:hover{
background: #eeeeee;
color: #c20000;
}
/* custom general page styles */
.hero-unit h2, .hero-unit h1{
color: #A30000;
}
body a{
color: #A30000;
}
body a:hover{
color: #c20000;
}
/* subnavigation styles */
@media (min-width: 767px) {
.sidebar-nav-fixed {
position:fixed;
width:19%;
max-width: 240px;
}
.navbar {
position: fixed;
}
.navbar .navbar-inner .container-fluid{
max-width: 1110px;
}
}
h1 code, h2 code, h3 code, h4 code, h5 code {
color: #333;
}
/* sticky footer and footer */
html, body {
height: 100%;
}
.wrapper {
min-height: 100%;
height: auto !important;
height: 100%;
margin: 0 auto -60px;
}
.body-content{
padding-top: 70px;
padding-bottom: 70px;
}
@media (max-width: 979px) {
.navbar-fixed-top .navbar-inner {
padding: 0px;
}
}
@media (max-width: 767px) {
.body-content{
padding-top: 0px;
}
}
@media (min-width: 768px) {
footer.span12 {
width: 95%;
}
}
footer, .push {
height: 60px; /* .push must be the same height as .footer */
}
footer p {
text-align: center;
color: gray;
border-top: 1px solid #DDD;
padding-top: 10px;
}
footer a {
color: gray;
font-weight: bold;
}
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;}
}
td, th {
padding: 0.25em;
background-color: #f7f7f9;
border-color: #e1e1e8;
}
table {
border-color: white;
margin-bottom: 0.6em;
}
.side-nav {
overflow-y: scroll;
}
ul.sponsor.diamond li a {
float: left;
width: 600px;
height: 20px;
text-align: center;
margin: 10px 70px;
padding: 300px 0 0 0;
background-position: 0 50%;
background-size: 600px auto;
background-repeat: no-repeat;
font-size: 200%;
}
@media (max-width: 1000px) {
ul.sponsor.diamond li a {
float: left;
width: 300px;
height: 20px;
text-align: center;
margin: 10px 40px;
padding: 300px 0 0 0;
background-position: 0 50%;
background-size: 280px auto;
background-repeat: no-repeat;
font-size: 150%;
}
}
ul.sponsor.platinum li a {
float: left;
width: 300px;
height: 20px;
text-align: center;
margin: 10px 40px;
padding: 300px 0 0 0;
background-position: 0 50%;
background-size: 280px auto;
background-repeat: no-repeat;
font-size: 150%;
}
ul.sponsor.gold li a {
float: left;
width: 130px;
height: 20px;
text-align: center;
margin: 10px 30px;
padding: 150px 0 0 0;
background-position: 0 50%;
background-size: 130px auto;
background-repeat: no-repeat;
font-size: 120%;
}
ul.sponsor.silver li a {
float: left;
width: 130px;
height: 20px;
text-align: center;
margin: 10px 30px;
padding: 150px 0 0 0;
background-position: 0 50%;
background-size: 130px auto;
background-repeat: no-repeat;
font-size: 120%;
}
ul.sponsor {
list-style: none;
display: block;
}
#mkdocs_search_modal article p{
word-wrap: break-word;
}
.toclink {
color: #333;
}
.book-cover img {
margin: 0 !important;
display: inline-block !important;
}
/* admonition */
.admonition {
border: .075rem solid #448aff;
border-radius: .2rem;
margin: 1.5625em 0;
padding: 0 .6rem;
}
.admonition-title {
background: #448aff1a;
font-weight: 700;
margin: 0 -.6rem 1em;
padding: 0.4rem 0.6rem;
}

View File

@ -1,30 +0,0 @@
.com { color: #93a1a1; }
.lit { color: #195f91; }
.pun, .opn, .clo { color: #93a1a1; }
.fun { color: #dc322f; }
.str, .atv { color: #D14; }
.kwd, .prettyprint .tag { color: #1e347b; }
.typ, .atn, .dec, .var { color: teal; }
.pln { color: #48484c; }
.prettyprint {
padding: 8px;
background-color: #f7f7f9;
border: 1px solid #e1e1e8;
}
.prettyprint.linenums {
-webkit-box-shadow: inset 40px 0 0 #fbfbfc, inset 41px 0 0 #ececf0;
-moz-box-shadow: inset 40px 0 0 #fbfbfc, inset 41px 0 0 #ececf0;
box-shadow: inset 40px 0 0 #fbfbfc, inset 41px 0 0 #ececf0;
}
/* Specify class=linenums on a pre to get line numbering */
ol.linenums {
margin: 0 0 0 33px; /* IE indents via margin-left */
}
ol.linenums li {
padding-left: 12px;
color: #bebec5;
line-height: 20px;
text-shadow: 0 1px 0 #fff;
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,29 +0,0 @@
var getSearchTerm = function() {
var sPageURL = window.location.search.substring(1);
var sURLVariables = sPageURL.split('&');
for (var i = 0; i < sURLVariables.length; i++) {
var sParameterName = sURLVariables[i].split('=');
if (sParameterName[0] === 'q') {
return sParameterName[1];
}
}
};
$(function() {
var searchTerm = getSearchTerm(),
$searchModal = $('#mkdocs_search_modal'),
$searchQuery = $searchModal.find('#mkdocs-search-query'),
$searchResults = $searchModal.find('#mkdocs-search-results');
$('pre code').parent().addClass('prettyprint well');
if (searchTerm) {
$searchQuery.val(searchTerm);
$searchResults.text('Searching...');
$searchModal.modal();
}
$searchModal.on('shown', function() {
$searchQuery.focus();
});
});

View File

@ -1,171 +1,187 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta charset="utf-8" />
<title>
{% if page.title %}{{ page.title }} - {% endif %}{{ config.site_name }}
</title>
<link href="{{ 'img/favicon.ico'|url }}" rel="icon" type="image/x-icon" />
<link rel="canonical" href="{{ page.canonical_url|url }}" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta
name="description"
content="Django, API, REST{% if page %}, {{ page.title }}{% endif %}"
/>
<meta name="author" content="Tom Christie" />
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<title>{% if page.title %}{{ page.title }} - {% endif %}{{ config.site_name }}</title>
<link href="{{ 'img/favicon.ico'|url }}" rel="icon" type="image/x-icon">
<link rel="canonical" href="{{ page.canonical_url|url }}" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Django, API, REST{% if page %}, {{ page.title }}{% endif %}">
<meta name="author" content="Tom Christie">
<!-- Le styles -->
<link href="{{ 'css/prettify.css'|url }}" rel="stylesheet">
<!-- Le styles -->
<!-- <link href="{{ 'css/prettify.css'|url }}" rel="stylesheet">
<link href="{{ 'css/bootstrap.css'|url }}" rel="stylesheet">
<link href="{{ 'css/bootstrap-responsive.css'|url }}" rel="stylesheet">
<link href="{{ 'css/default.css'|url }}" rel="stylesheet">
<link href="{{ 'css/default.css'|url }}" rel="stylesheet"> -->
<link rel="stylesheet" href="{{ 'dist/main.css'|url }}" />
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-18852272-2']);
_gaq.push(['_trackPageview']);
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(["_setAccount", "UA-18852272-2"]);
_gaq.push(["_trackPageview"]);
(function() {
var ga = document.createElement('script');
ga.type = 'text/javascript';
ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(ga, s);
})();
</script>
(function () {
var ga = document.createElement("script");
ga.type = "text/javascript";
ga.async = true;
ga.src =
("https:" == document.location.protocol
? "https://ssl"
: "http://www") + ".google-analytics.com/ga.js";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(ga, s);
})();
</script>
</head>
<body
onload="prettyPrint()"
class="{% if page and page.is_homepage %}index{% endif %}-page"
>
<div class="wrapper">
{% include "nav.html" %}
<style>
#sidebarInclude img {
margin-bottom: 10px;
}
#sidebarInclude a.promo {
color: black;
}
@media (max-width: 767px) {
div.promo {
display: none;
}
}
</style>
</head>
<body onload="prettyPrint()" class="{% if page and page.is_homepage %}index{% endif %}-page">
<div class="body-content">
<div class="container">
<div class="row">
<div class="col-12 col-md-3">
<div id="table-of-contents">
<ul class="nav flex-column">
{% if page and page.is_homepage %}
<a
href="#"
class="nav-link {% if page and page.is_homepage %} fw-bold {% endif %}"
>Django REST framework</a
>
{% endif %} {% for toc_item in page.toc %}
<a
href="{{ toc_item.url }}"
class="nav-link {% if page and not page.is_homepage %}main{% endif %}"
>{{ toc_item.title }}</a
>
<div class="wrapper">
{% include "nav.html" %}
{% for toc_item in toc_item.children %}
<li>
<a class="nav-link" href="{{ toc_item.url }}"
>{{ toc_item.title }}</a
>
</li>
{% endfor %} {% endfor %}
<div class="body-content">
<div class="container-fluid">
<!-- Search Modal -->
<div id="mkdocs_search_modal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="promo">
{% if page.toc %}
<hr />
{% endif %}
</div>
<div id="sidebarInclude"></div>
</ul>
</div>
</div>
<div id="main-content" class="col-12 col-md-9">
{% block content %} {% if page.meta.source %} {% for filename in
page.meta.source %}
<a
class="github"
href="https://github.com/encode/django-rest-framework/tree/master/rest_framework/{{ filename }}"
>
<span class="label label-info">{{ filename }}</span>
</a>
{% endfor %} {% endif %} {{ page.content }} {% endblock %}
</div>
<!--/span-->
</div>
<!--/row-->
</div>
<!--/.fluid-container-->
</div>
<!--/.body content-->
<div id="push"></div>
</div>
<!--/.wrapper -->
<footer class="col-11 border-top mx-auto">
<p class="text-center py-3 my-0">
Documentation built with <a href="http://www.mkdocs.org/">MkDocs</a>.
</p>
</footer>
<!-- Search Modal Start -->
<div
class="modal fade"
id="mkdocs_search_modal"
tabindex="-1"
aria-labelledby="searchModal"
aria-hidden="true"
>
<div class="modal-dialog modal-dialog-centered modal-dialog-scrollable">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h3 id="myModalLabel">Documentation search</h3>
<h3 class="modal-title fs-5" id="search_modal_label">
Documentation Search
</h3>
<button
type="button"
class="btn-close"
data-bs-dismiss="modal"
aria-label="Close"
></button>
</div>
<div class="modal-body">
<form role="form" autocomplete="off">
<div class="form-group">
<input type="text" name="q" class="form-control" placeholder="Search..." id="mkdocs-search-query">
<input
type="text"
name="q"
class="form-control"
placeholder="Search..."
id="mkdocs-search-query"
/>
</div>
</form>
<div id="mkdocs-search-results"></div>
<div id="mkdocs-search-results" class="mt-3"></div>
</div>
<div class="modal-footer">
<button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
<button
type="button"
class="btn btn-secondary"
data-bs-dismiss="modal"
>
Close
</button>
</div>
</div>
</div>
</div>
<!-- Modal End -->
<div class="row-fluid">
<div class="span3">
<div id="table-of-contents">
<ul class="nav nav-list side-nav well sidebar-nav-fixed">
{% if page and page.is_homepage %}
<li class="main">
<a href="#">Django REST framework</a>
</li>
{% endif %}
{% for toc_item in page.toc %}
<li class="{% if page and not page.is_homepage %}main{% endif %}">
<a href="{{ toc_item.url }}">{{ toc_item.title }}</a>
</li>
{% for toc_item in toc_item.children %}
<li>
<a href="{{ toc_item.url }}">{{ toc_item.title }}</a>
</li>
{% endfor %}
{% endfor %}
<div class="promo">
{% if page.toc %}<hr/>{% endif %}
<div id="sidebarInclude">
</div>
</ul>
</div>
</div>
<div id="main-content" class="span9">
{% block content %}
{% if page.meta.source %}
{% for filename in page.meta.source %}
<a class="github" href="https://github.com/encode/django-rest-framework/tree/master/rest_framework/{{ filename }}">
<span class="label label-info">{{ filename }}</span>
</a>
{% endfor %}
{% endif %}
{{ page.content }}
{% endblock %}
</div> <!--/span-->
</div> <!--/row-->
</div> <!--/.fluid-container-->
</div> <!--/.body content-->
<div id="push"></div>
</div> <!--/.wrapper -->
<footer class="span12">
<p>Documentation built with <a href="http://www.mkdocs.org/">MkDocs</a>.
</p>
</footer>
<!-- Le javascript
<!-- Le javascript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script async src="https://fund.django-rest-framework.org/sidebar_include.js"></script>
<!-- Placed at the end of the document so the pages load faster -->
<!-- <script async src="https://fund.django-rest-framework.org/sidebar_include.js"></script>
<script src="{{ 'js/jquery-1.8.1-min.js'|url }}"></script>
<script src="{{ 'js/prettify-1.0.js'|url }}"></script>
<script src="{{ 'js/bootstrap-2.1.1-min.js'|url }}"></script>
<script src="{{ 'js/theme.js'|url }}"></script>
<script src="{{ 'js/theme.js'|url }}"></script> -->
<script>var base_url = '{{ base_url }}';</script>
{% for path in config.extra_javascript %}
<script src="{{ path|url }}" defer></script>
{% endfor %}
<script>
var base_url = "{{ base_url }}";
</script>
<script>
var shiftWindow = function() {
scrollBy(0, -50)
};
if (location.hash) shiftWindow();
window.addEventListener("hashchange", shiftWindow);
$('.dropdown-menu').on('click touchstart', function(event) {
event.stopPropagation();
});
// Dynamically force sidenav/dropdown to no higher than browser window
$('.side-nav, .dropdown-menu').css('max-height', window.innerHeight - 130);
$(function() {
$(window).resize(function() {
$('.side-nav, .dropdown-menu').css('max-height', window.innerHeight - 130);
});
});
</script>
</body>
<script src="{{ 'dist/main.js'|url }}"></script>
{% for path in config.extra_javascript %}
<script src="{{ path|url }}" defer></script>
{% endfor %}
</body>
</html>

View File

@ -1,46 +1,187 @@
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="navbar-inner">
<div class="container-fluid">
<a class="repo-link btn btn-primary btn-small" href="https://github.com/encode/django-rest-framework/tree/master">GitHub</a>
<a class="repo-link btn btn-inverse btn-small {% if not page.next_page %}disabled{% endif %}" rel="next" {% if page.next_page %}href="{{ page.next_page.url|url }}"{% endif %}>
Next <i class="icon-arrow-right icon-white"></i>
</a>
<a class="repo-link btn btn-inverse btn-small {% if not page.previous_page %}disabled{% endif %}" rel="prev" {% if page.previous_page %}href="{{ page.previous_page.url|url }}"{% endif %}>
<i class="icon-arrow-left icon-white"></i> Previous
</a>
<a id="search_modal_show" class="repo-link btn btn-inverse btn-small" href="#mkdocs_search_modal" data-toggle="modal" data-target="#mkdocs_search_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>
<span class="icon-bar"></span>
</a>
<a class="brand" href="https://www.django-rest-framework.org/">Django REST framework</a>
<div class="nav-collapse collapse">
{% if nav|length>1 %}
<!-- Main navigation -->
<ul class="nav navbar-nav">
{% for nav_item in nav %} {% if nav_item.children %}
<li class="dropdown{% if nav_item.active %} active{% endif %}">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">{{ nav_item.title }} <b class="caret"></b></a>
<ul class="dropdown-menu">
{% for nav_item in nav_item.children %}
<li {% if nav_item.active %}class="active" {% endif %}>
<a href="{{ nav_item.url|url }}">{{ nav_item.title }}</a>
</li>
{% endfor %}
</ul>
</li>
{% else %}
<li {% if nav_item.active %}class="active" {% endif %}>
<a href="{{ nav_item.url|url }}">{{ nav_item.title }}</a>
</li>
{% endif %} {% endfor %}
<!-- New Navbar -->
<nav class="navbar navbar-expand-lg bg-body-tertiary fixed-top">
<div class="container">
<a class="navbar-brand" href="https://www.django-rest-framework.org/">
<span class="d-none d-md-block">Django REST Framework</span>
<span class="d-block d-md-none">DRF</span>
</a>
</ul>
{% endif %}
</div>
<!--/.nav-collapse -->
<div class="d-flex gap-2 order-lg-5 justify-self-end ms-auto">
<button
type="button"
id="search_modal_show"
class="btn btn-sm btn-secondary d-flex align-items-center gap-1"
href="#mkdocs_search_modal"
data-bs-toggle="modal"
data-bs-target="#mkdocs_search_modal"
>
<svg
xmlns="http://www.w3.org/2000/svg"
width="16"
height="16"
fill="currentColor"
class="bi bi-search"
viewBox="0 0 16 16"
>
<path
d="M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001q.044.06.098.115l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85a1 1 0 0 0-.115-.1zM12 6.5a5.5 5.5 0 1 1-11 0 5.5 5.5 0 0 1 11 0"
/>
</svg>
</div>
<span class="d-none d-md-block">Search</span>
</button>
<!-- prettier-ignore -->
<a
{% if page.previous_page %}href="{{ page.previous_page.url|url }}"{% endif %}
{% if not page.previous_page %}disabled{% endif %}
class="btn btn-sm btn-secondary align-items-center gap-1 d-flex"
>
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-arrow-left" viewBox="0 0 16 16">
<path fill-rule="evenodd" d="M15 8a.5.5 0 0 0-.5-.5H2.707l3.147-3.146a.5.5 0 1 0-.708-.708l-4 4a.5.5 0 0 0 0 .708l4 4a.5.5 0 0 0 .708-.708L2.707 8.5H14.5A.5.5 0 0 0 15 8"/>
</svg>
<span class="d-none d-md-block">Previous</span>
</a>
<!-- prettier-ignore -->
<a
{% if page.next_page %}href="{{ page.next_page.url|url }}"{% endif %}
{% if not page.next_page %}disabled{% endif %}
class="btn btn-sm btn-secondary align-items-center gap-1 d-flex"
>
<span class="d-none d-md-block">Next</span>
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-arrow-right" viewBox="0 0 16 16">
<path fill-rule="evenodd" d="M1 8a.5.5 0 0 1 .5-.5h11.793l-3.147-3.146a.5.5 0 0 1 .708-.708l4 4a.5.5 0 0 1 0 .708l-4 4a.5.5 0 0 1-.708-.708L13.293 8.5H1.5A.5.5 0 0 1 1 8"/>
</svg>
</a>
<!-- prettier-ignore -->
<a
class="btn btn-primary btn-sm align-items-center gap-1 d-none d-sm-flex"
href="https://github.com/encode/django-rest-framework/tree/master"
>
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-github" viewBox="0 0 16 16">
<path d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27s1.36.09 2 .27c1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.01 8.01 0 0 0 16 8c0-4.42-3.58-8-8-8"/>
</svg>
<span class="d-none d-md-block">Github</span>
</a
>
<div class="dropdown">
<button
class="btn dropdown-toggle d-flex align-items-center"
type="button"
data-bs-toggle="dropdown"
aria-expanded="false"
id="bd-theme"
>
<div class="theme-icon-active"></div>
</button>
<ul class="dropdown-menu" aria-labelledby="bd-theme-text">
<li>
<button class="dropdown-item" href="#" data-bs-theme-value="dark">
<svg
xmlns="http://www.w3.org/2000/svg"
width="16"
height="16"
fill="currentColor"
class="bi bi-moon-fill"
viewBox="0 0 16 16"
>
<path
d="M6 .278a.77.77 0 0 1 .08.858 7.2 7.2 0 0 0-.878 3.46c0 4.021 3.278 7.277 7.318 7.277q.792-.001 1.533-.16a.79.79 0 0 1 .81.316.73.73 0 0 1-.031.893A8.35 8.35 0 0 1 8.344 16C3.734 16 0 12.286 0 7.71 0 4.266 2.114 1.312 5.124.06A.75.75 0 0 1 6 .278"
/>
</svg>
<span>Dark</span>
</button>
</li>
<li>
<button class="dropdown-item" href="#" data-bs-theme-value="light">
<svg
xmlns="http://www.w3.org/2000/svg"
width="16"
height="16"
fill="currentColor"
class="bi bi-brightness-high-fill"
viewBox="0 0 16 16"
>
<path
d="M12 8a4 4 0 1 1-8 0 4 4 0 0 1 8 0M8 0a.5.5 0 0 1 .5.5v2a.5.5 0 0 1-1 0v-2A.5.5 0 0 1 8 0m0 13a.5.5 0 0 1 .5.5v2a.5.5 0 0 1-1 0v-2A.5.5 0 0 1 8 13m8-5a.5.5 0 0 1-.5.5h-2a.5.5 0 0 1 0-1h2a.5.5 0 0 1 .5.5M3 8a.5.5 0 0 1-.5.5h-2a.5.5 0 0 1 0-1h2A.5.5 0 0 1 3 8m10.657-5.657a.5.5 0 0 1 0 .707l-1.414 1.415a.5.5 0 1 1-.707-.708l1.414-1.414a.5.5 0 0 1 .707 0m-9.193 9.193a.5.5 0 0 1 0 .707L3.05 13.657a.5.5 0 0 1-.707-.707l1.414-1.414a.5.5 0 0 1 .707 0m9.193 2.121a.5.5 0 0 1-.707 0l-1.414-1.414a.5.5 0 0 1 .707-.707l1.414 1.414a.5.5 0 0 1 0 .707M4.464 4.465a.5.5 0 0 1-.707 0L2.343 3.05a.5.5 0 1 1 .707-.707l1.414 1.414a.5.5 0 0 1 0 .708"
/>
</svg>
<span> Light </span>
</button>
</li>
<li>
<button class="dropdown-item" href="#" data-bs-theme-value="auto">
<svg
xmlns="http://www.w3.org/2000/svg"
width="16"
height="16"
fill="currentColor"
class="bi bi-circle-half"
viewBox="0 0 16 16"
>
<path
d="M8 15A7 7 0 1 0 8 1zm0 1A8 8 0 1 1 8 0a8 8 0 0 1 0 16"
/>
</svg>
<span>Auto</span>
</button>
</li>
</ul>
</div>
</div>
<button
class="navbar-toggler"
type="button"
data-bs-toggle="collapse"
data-bs-target="#navbarSupportedContent"
aria-controls="navbarSupportedContent"
aria-expanded="false"
aria-label="Toggle navigation"
>
<span class="navbar-toggler-icon"></span>
</button>
<!-- Main navigation -->
<div class="collapse navbar-collapse" id="navbarSupportedContent">
{% if nav|length>1 %}
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
{% for nav_item in nav %} {% if nav_item.children %}
<li class="nav-item dropdown">
<a
class="nav-link dropdown-toggle"
href="#"
role="button"
data-bs-toggle="dropdown"
aria-expanded="false"
>
{{ nav_item.title }}
</a>
<ul class="dropdown-menu">
{% for nav_item in nav_item.children %}
<li>
<!-- prettier-ignore -->
<a {% if nav_item.active %} class="dropdown-item active" {% else %} class="dropdown-item" {% endif %}
href="{{ nav_item.url|url }}">{{ nav_item.title }}</a>
</li>
{% endfor %}
</ul>
</li>
{% else %}
<li class="nav-item">
<!-- prettier-ignore -->
<a {% if nav_item.active %} class="nav-link active" {% else %} class="nav-link" {% endif %}
aria-current="page" href="{{ nav_item.url|url }}">{{ nav_item.title }}</a>
</li>
{% endif %} {% endfor %}
</ul>
{% endif %}
</div>
</div>
</nav>

5233
docs_theme/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

30
docs_theme/package.json Normal file
View File

@ -0,0 +1,30 @@
{
"name": "drf_docs_theme",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"build": "webpack build",
"build:production": "webpack build --mode=production",
"build:watch": "webpack build --watch"
},
"author": "",
"license": "ISC",
"dependencies": {
"@popperjs/core": "^2.11.8",
"bootstrap": "^5.3.3"
},
"devDependencies": {
"autoprefixer": "^10.4.19",
"css-loader": "^7.1.1",
"html-webpack-plugin": "^5.6.0",
"mini-css-extract-plugin": "^2.9.0",
"postcss-loader": "^8.1.1",
"sass": "^1.77.1",
"sass-loader": "^14.2.1",
"style-loader": "^4.0.0",
"webpack": "^5.91.0",
"webpack-cli": "^5.1.4",
"webpack-dev-server": "^5.0.4"
}
}

106
docs_theme/src/js/main.js Normal file
View File

@ -0,0 +1,106 @@
// import "../../node_modules/bootstrap/js/dist/alert";
import "../../node_modules/bootstrap/js/dist/button";
// import "../../node_modules/bootstrap/js/dist/carousel";
import "../../node_modules/bootstrap/js/dist/collapse";
import "../../node_modules/bootstrap/js/dist/dropdown";
import "../../node_modules/bootstrap/js/dist//modal";
// import "../../node_modules/bootstrap/js/dist/offcanvas";
// import "../../node_modules/bootstrap/js/dist/popover";
// import "../../node_modules/bootstrap/js/dist/scrollspy";
// import "../../node_modules/bootstrap/js/dist/tab";
// import "../../node_modules/bootstrap/js/dist/toast";
// import "../../node_modules/bootstrap/js/dist/tooltip";
import "./prettify-1.0.js";
import "../scss/main.scss";
function setupPrettify() {
const codeBlocks = document.querySelectorAll("pre code");
codeBlocks.forEach((block) => {
block.parentElement.classList.add("prettyprint", "well");
});
}
setupPrettify();
const getStoredTheme = () => localStorage.getItem("theme");
const setStoredTheme = (theme) => localStorage.setItem("theme", theme);
const getPreferredTheme = () => {
const storedTheme = getStoredTheme();
if (storedTheme) {
return storedTheme;
}
return window.matchMedia("(prefers-color-scheme: dark)").matches
? "dark"
: "light";
};
const setTheme = (theme) => {
if (theme === "auto") {
document.documentElement.setAttribute(
"data-bs-theme",
window.matchMedia("(prefers-color-scheme: dark)").matches
? "dark"
: "light"
);
} else {
document.documentElement.setAttribute("data-bs-theme", theme);
}
};
setTheme(getPreferredTheme());
const showActiveTheme = (theme, focus = false) => {
const themeSwitcher = document.querySelector("#bd-theme");
if (!themeSwitcher) {
return;
}
const activeThemeIcon = document.querySelector(".theme-icon-active");
const btnToActive = document.querySelector(
`[data-bs-theme-value="${theme}"]`
);
const svgOfActiveBtn = btnToActive.querySelector("svg").cloneNode(true);
document.querySelectorAll("[data-bs-theme-value]").forEach((element) => {
element.classList.remove("active");
element.setAttribute("aria-pressed", "false");
});
btnToActive.classList.add("active");
btnToActive.setAttribute("aria-pressed", "true");
activeThemeIcon.innerHTML = null;
activeThemeIcon.appendChild(svgOfActiveBtn);
const themeSwitcherLabel = `Toggle Theme (${btnToActive.dataset.bsThemeValue})`;
themeSwitcher.setAttribute("aria-label", themeSwitcherLabel);
if (focus) {
themeSwitcher.focus();
}
};
window
.matchMedia("(prefers-color-scheme: dark)")
.addEventListener("change", () => {
const storedTheme = getStoredTheme();
if (storedTheme !== "light" && storedTheme !== "dark") {
setTheme(getPreferredTheme());
}
});
window.addEventListener("DOMContentLoaded", () => {
showActiveTheme(getPreferredTheme());
document.querySelectorAll("[data-bs-theme-value]").forEach((toggle) => {
toggle.addEventListener("click", () => {
const theme = toggle.getAttribute("data-bs-theme-value");
setStoredTheme(theme);
setTheme(theme);
showActiveTheme(theme, true);
});
});
});

View File

@ -25,4 +25,4 @@ I,J,v],hashComments:!0,cStyleComments:!0,multiLineStrings:!0,regexLiterals:!0}),
hashComments:3,cStyleComments:!0,multilineStrings:!0,tripleQuotedStrings:!0,regexLiterals:!0}),["coffee"]);k(x([],[["str",/^[\S\s]+/]]),["regex"]);window.prettyPrintOne=function(a,m,e){var h=document.createElement("PRE");h.innerHTML=a;e&&D(h,e);E({g:m,i:e,h:h});return h.innerHTML};window.prettyPrint=function(a){function m(){for(var e=window.PR_SHOULD_USE_CONTINUATION?l.now()+250:Infinity;p<h.length&&l.now()<e;p++){var n=h[p],k=n.className;if(k.indexOf("prettyprint")>=0){var k=k.match(g),f,b;if(b=
!k){b=n;for(var o=void 0,c=b.firstChild;c;c=c.nextSibling)var i=c.nodeType,o=i===1?o?b:c:i===3?N.test(c.nodeValue)?b:o:o;b=(f=o===b?void 0:o)&&"CODE"===f.tagName}b&&(k=f.className.match(g));k&&(k=k[1]);b=!1;for(o=n.parentNode;o;o=o.parentNode)if((o.tagName==="pre"||o.tagName==="code"||o.tagName==="xmp")&&o.className&&o.className.indexOf("prettyprint")>=0){b=!0;break}b||((b=(b=n.className.match(/\blinenums\b(?::(\d+))?/))?b[1]&&b[1].length?+b[1]:!0:!1)&&D(n,b),d={g:k,h:n,i:b},E(d))}}p<h.length?setTimeout(m,
250):a&&a()}for(var e=[document.getElementsByTagName("pre"),document.getElementsByTagName("code"),document.getElementsByTagName("xmp")],h=[],k=0;k<e.length;++k)for(var t=0,s=e[k].length;t<s;++t)h.push(e[k][t]);var e=q,l=Date;l.now||(l={now:function(){return+new Date}});var p=0,d,g=/\blang(?:uage)?-([\w.]+)(?!\S)/;m()};window.PR={createSimpleLexer:x,registerLangHandler:k,sourceDecorator:u,PR_ATTRIB_NAME:"atn",PR_ATTRIB_VALUE:"atv",PR_COMMENT:"com",PR_DECLARATION:"dec",PR_KEYWORD:"kwd",PR_LITERAL:"lit",
PR_NOCODE:"nocode",PR_PLAIN:"pln",PR_PUNCTUATION:"pun",PR_SOURCE:"src",PR_STRING:"str",PR_TAG:"tag",PR_TYPE:"typ"}})();
PR_NOCODE:"nocode",PR_PLAIN:"pln",PR_PUNCTUATION:"pun",PR_SOURCE:"src",PR_STRING:"str",PR_TAG:"tag",PR_TYPE:"typ"}})();

View File

@ -0,0 +1,72 @@
a {
text-decoration: none;
&:hover,
&:active {
text-decoration: underline;
}
}
pre.prettyprint {
margin-bottom: 20px;
}
code {
@extend .rounded;
}
pre {
@extend .bg-body-tertiary;
@extend .rounded;
}
pre code {
border: none;
}
img {
@extend .img-fluid;
}
.nav-link {
padding: 2px 15px 3px;
}
.body-content {
padding-top: 70px;
padding-bottom: 70px;
}
.badges {
display: flex;
align-items: center;
justify-content: end;
gap: 8px;
}
.toclink {
color: #333;
}
#table-of-contents {
@extend .rounded;
padding: 0.5rem;
margin-bottom: 1rem;
}
.headerlink {
display: none;
}
.promo {
@extend .d-none;
@extend .d-md-block;
}
[data-bs-theme="dark"] .promo li a {
color: white !important;
}
[data-bs-theme="dark"] [src="img/logo.png"] {
filter: invert(1) brightness(1.5) contrast(1.2);
}

View File

@ -0,0 +1,61 @@
// Bootstrap Variables
// General Styles
$font-family-base: "Helvetica Neue", Helvetica, Arial, sans-serif;
$font-size-base: 1rem * 0.875;
// Navbar Styles
$navbar-padding-y: 0.5rem;
$navbar-nav-link-padding-x: 1rem;
$code-color: #d14;
// Configuration
@import "../../node_modules/bootstrap/scss/functions";
@import "../../node_modules/bootstrap/scss/variables";
@import "../../node_modules/bootstrap/scss/variables-dark";
@import "../../node_modules/bootstrap/scss/maps";
@import "../../node_modules/bootstrap/scss/mixins";
@import "../../node_modules/bootstrap/scss/utilities";
// Layout & components
@import "../../node_modules/bootstrap/scss/root";
@import "../../node_modules/bootstrap/scss/reboot";
@import "../../node_modules/bootstrap/scss/type";
@import "../../node_modules/bootstrap/scss/images";
@import "../../node_modules/bootstrap/scss/containers";
@import "../../node_modules/bootstrap/scss/grid";
// @import "../../node_modules/bootstrap/scss/tables";
// @import "../../node_modules/bootstrap/scss/forms";
@import "../../node_modules/bootstrap/scss/buttons";
@import "../../node_modules/bootstrap/scss/transitions";
@import "../../node_modules/bootstrap/scss/dropdown";
// @import "../../node_modules/bootstrap/scss/button-group";
@import "../../node_modules/bootstrap/scss/nav";
@import "../../node_modules/bootstrap/scss/navbar";
// @import "../../node_modules/bootstrap/scss/card";
@import "../../node_modules/bootstrap/scss/accordion";
@import "../../node_modules/bootstrap/scss/breadcrumb";
@import "../../node_modules/bootstrap/scss/pagination";
// @import "../../node_modules/bootstrap/scss/badge";
// @import "../../node_modules/bootstrap/scss/alert";
// @import "../../node_modules/bootstrap/scss/progress";
// @import "../../node_modules/bootstrap/scss/list-group";
@import "../../node_modules/bootstrap/scss/close";
// @import "../../node_modules/bootstrap/scss/toasts";
@import "../../node_modules/bootstrap/scss/modal";
// @import "../../node_modules/bootstrap/scss/tooltip";
// @import "../../node_modules/bootstrap/scss/popover";
// @import "../../node_modules/bootstrap/scss/carousel";
// @import "../../node_modules/bootstrap/scss/spinners";
// @import "../../node_modules/bootstrap/scss/offcanvas";
// @import "../../node_modules/bootstrap/scss/placeholders";
// Helpers
@import "../../node_modules/bootstrap/scss/helpers";
// Utilities
@import "../../node_modules/bootstrap/scss/utilities/api";
@import "./prettify.scss";
@import "./custom.scss";

View File

@ -0,0 +1,89 @@
.com {
color: #93a1a1;
}
.lit {
color: #195f91;
}
.pun,
.opn,
.clo {
color: #93a1a1;
}
.fun {
color: #dc322f;
}
.str,
.atv {
color: #d14;
}
.kwd,
.prettyprint .tag {
color: #1e347b;
}
.typ,
.atn,
.dec,
.var {
color: teal;
}
.pln {
color: #48484c;
}
.prettyprint {
padding: 20px;
}
.prettyprint.linenums {
box-shadow: inset 40px 0 0 #fbfbfc, inset 41px 0 0 #ececf0;
}
[data-bs-theme="dark"] {
.com {
color: #9ea0a0;
}
.lit {
color: #4d90fe;
}
.pun,
.opn,
.clo {
color: #9ea0a0;
}
.fun {
color: #fe6160;
}
.str,
.atv {
color: #fea832;
}
.kwd,
.prettyprint .tag {
color: #4d69a8;
}
.typ,
.atn,
.dec,
.var {
color: #38a1a1;
}
.pln {
color: #c8c8cc;
}
}
/* Specify class=linenums on a pre to get line numbering */
ol.linenums {
margin: 0 0 0 33px; /* IE indents via margin-left */
}
ol.linenums li {
padding-left: 12px;
color: #bebec5;
line-height: 20px;
text-shadow: 0 1px 0 #fff;
}

View File

@ -0,0 +1,51 @@
"use strict";
const path = require("path");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const autoprefixer = require("autoprefixer");
const miniCssExtractPlugin = require("mini-css-extract-plugin");
module.exports = {
mode: "development",
entry: "./src/js/main.js",
output: {
filename: "main.js",
path: path.resolve(__dirname, "dist"),
},
devServer: {
static: path.resolve(__dirname, "dist"),
port: 8080,
hot: true,
},
plugins: [new miniCssExtractPlugin()],
module: {
rules: [
{
test: /\.(scss)$/,
use: [
{
// Adds CSS to the DOM by injecting a `<style>` tag
loader: miniCssExtractPlugin.loader,
},
{
// Interprets `@import` and `url()` like `import/require()` and will resolve them
loader: "css-loader",
},
{
// Loader for webpack to process CSS with PostCSS
loader: "postcss-loader",
options: {
postcssOptions: {
plugins: [autoprefixer],
},
},
},
{
// Loads a SASS/SCSS file and compiles it to CSS
loader: "sass-loader",
},
],
},
],
},
};

View File

@ -7,11 +7,15 @@ repo_url: https://github.com/encode/django-rest-framework
theme:
name: mkdocs
custom_dir: docs_theme
watch:
- docs_theme
markdown_extensions:
- admonition
- toc:
anchorlink: True
# anchorlink: True
permalink: True
nav:
- Home: 'index.md'