Skip to content

Resolve sphinx documentation build warnings #711

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 2, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -14,10 +14,14 @@
# serve to show the default.

import datetime
import sys
import os
import shlex
import sys

import django
from sphinx.ext.apidoc import main

from rest_framework_json_api import VERSION

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
@@ -27,8 +31,7 @@
django.setup()

# Auto-generate API documentation.
from sphinx.ext.apidoc import main
main(['-o', 'apidoc', '-f', '-e', '-T', '-M', '../rest_framework_json_api'])
main(['-o', '_build/apidoc', '-f', '-e', '-T', '-M', '../rest_framework_json_api'])

# -- General configuration ------------------------------------------------

@@ -38,17 +41,13 @@
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = ['sphinx.ext.autodoc']
extensions = ['sphinx.ext.autodoc', 'recommonmark']
autodoc_member_order = 'bysource'
autodoc_inherit_docstrings = False

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']

from recommonmark.parser import CommonMarkParser
source_parsers = {
'.md': CommonMarkParser,
}
# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
# source_suffix = ['.rst', '.md']
@@ -71,7 +70,6 @@
# built documents.
#
# The short X.Y version.
from rest_framework_json_api import VERSION
version = VERSION
# The full version, including alpha/beta/rc tags.
release = VERSION
@@ -91,7 +89,7 @@

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
exclude_patterns = ['_build']
exclude_patterns = ['_build', 'pull_request_template.md']

# The reST default role (used for this markup: `text`) to use for all
# documents.
27 changes: 12 additions & 15 deletions rest_framework_json_api/renderers.py
Original file line number Diff line number Diff line change
@@ -26,24 +26,21 @@ class JSONRenderer(renderers.JSONRenderer):
Render a JSON response per the JSON API spec:
.. code:: json
.. code-block:: json
{
"data": [{
"type": "companies",
"id": 1,
"attributes": {
"name": "Mozilla",
"slug": "mozilla",
"date-created": "2014-03-13 16:33:37"
}
}, {
"type": "companies",
"id": 2,
...
}]
"data": [
{
"type": "companies",
"id": 1,
"attributes": {
"name": "Mozilla",
"slug": "mozilla",
"date-created": "2014-03-13 16:33:37"
}
}
]
}
"""

media_type = 'application/vnd.api+json'
23 changes: 12 additions & 11 deletions rest_framework_json_api/views.py
Original file line number Diff line number Diff line change
@@ -37,19 +37,20 @@ class PreloadIncludesMixin(object):
__all__ can be used to specify a prefetch which should be done regardless of the include
.. code:: python
# When MyViewSet is called with ?include=author it will prefetch author and authorbio
class MyViewSet(viewsets.ModelViewSet):
queryset = Book.objects.all()
prefetch_for_includes = {
'__all__': [],
'category.section': ['category']
}
select_for_includes = {
'__all__': [],
'author': ['author', 'author__authorbio'],
}
# When MyViewSet is called with ?include=author it will prefetch author and authorbio
class MyViewSet(viewsets.ModelViewSet):
queryset = Book.objects.all()
prefetch_for_includes = {
'__all__': [],
'category.section': ['category']
}
select_for_includes = {
'__all__': [],
'author': ['author', 'author__authorbio'],
}
"""

def get_select_related(self, include):