add auto-doc support
This commit is contained in:
parent
fd5faeb5dd
commit
3fff685c44
13
docs/conf.py
13
docs/conf.py
|
@ -13,6 +13,9 @@ import sys
|
||||||
# Add support for Markdown documentation using Recommonmark
|
# Add support for Markdown documentation using Recommonmark
|
||||||
from recommonmark.parser import CommonMarkParser
|
from recommonmark.parser import CommonMarkParser
|
||||||
|
|
||||||
|
# Add support for auto-doc
|
||||||
|
from recommonmark.transform import AutoStructify
|
||||||
|
|
||||||
# Ensure that sanic is present in the path, to allow sphinx-apidoc to
|
# Ensure that sanic is present in the path, to allow sphinx-apidoc to
|
||||||
# autogenerate documentation from docstrings
|
# autogenerate documentation from docstrings
|
||||||
root_directory = os.path.dirname(os.getcwd())
|
root_directory = os.path.dirname(os.getcwd())
|
||||||
|
@ -140,3 +143,13 @@ epub_exclude_files = ['search.html']
|
||||||
# -- Custom Settings -------------------------------------------------------
|
# -- Custom Settings -------------------------------------------------------
|
||||||
|
|
||||||
suppress_warnings = ['image.nonlocal_uri']
|
suppress_warnings = ['image.nonlocal_uri']
|
||||||
|
|
||||||
|
|
||||||
|
# app setup hook
|
||||||
|
def setup(app):
|
||||||
|
app.add_config_value('recommonmark_config', {
|
||||||
|
'auto_toc_tree_section': 'Contents',
|
||||||
|
'enable_eval_rst': True,
|
||||||
|
'enable_auto_doc_ref': True,
|
||||||
|
}, True)
|
||||||
|
app.add_transform(AutoStructify)
|
||||||
|
|
|
@ -117,3 +117,11 @@ args.get('titles') # => 'Post 1'
|
||||||
|
|
||||||
args.getlist('titles') # => ['Post 1', 'Post 2']
|
args.getlist('titles') # => ['Post 1', 'Post 2']
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
## Full API Reference
|
||||||
|
|
||||||
|
```eval_rst
|
||||||
|
.. autoclass:: sanic.request.Request
|
||||||
|
:members: json, token, form, files, args, raw_args, cookies, ip, scheme, host, content_type, path, query_string, url
|
||||||
|
```
|
|
@ -110,3 +110,11 @@ def handle_request(request):
|
||||||
status=200
|
status=200
|
||||||
)
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
## Full API Reference
|
||||||
|
|
||||||
|
```eval_rst
|
||||||
|
.. automodule:: sanic.response
|
||||||
|
:members: json, text, raw, html, file, file_stream, stream, redirect
|
||||||
|
```
|
|
@ -214,4 +214,3 @@ and `recv` methods to send and receive data respectively.
|
||||||
|
|
||||||
WebSocket support requires the [websockets](https://github.com/aaugustin/websockets)
|
WebSocket support requires the [websockets](https://github.com/aaugustin/websockets)
|
||||||
package by Aymeric Augustin.
|
package by Aymeric Augustin.
|
||||||
|
|
||||||
|
|
|
@ -237,6 +237,7 @@ def json(body, status=200, headers=None,
|
||||||
content_type="application/json", **kwargs):
|
content_type="application/json", **kwargs):
|
||||||
"""
|
"""
|
||||||
Returns response object with body in json format.
|
Returns response object with body in json format.
|
||||||
|
|
||||||
:param body: Response data to be serialized.
|
:param body: Response data to be serialized.
|
||||||
:param status: Response code.
|
:param status: Response code.
|
||||||
:param headers: Custom Headers.
|
:param headers: Custom Headers.
|
||||||
|
@ -250,6 +251,7 @@ def text(body, status=200, headers=None,
|
||||||
content_type="text/plain; charset=utf-8"):
|
content_type="text/plain; charset=utf-8"):
|
||||||
"""
|
"""
|
||||||
Returns response object with body in text format.
|
Returns response object with body in text format.
|
||||||
|
|
||||||
:param body: Response data to be encoded.
|
:param body: Response data to be encoded.
|
||||||
:param status: Response code.
|
:param status: Response code.
|
||||||
:param headers: Custom Headers.
|
:param headers: Custom Headers.
|
||||||
|
@ -264,6 +266,7 @@ def raw(body, status=200, headers=None,
|
||||||
content_type="application/octet-stream"):
|
content_type="application/octet-stream"):
|
||||||
"""
|
"""
|
||||||
Returns response object without encoding the body.
|
Returns response object without encoding the body.
|
||||||
|
|
||||||
:param body: Response data.
|
:param body: Response data.
|
||||||
:param status: Response code.
|
:param status: Response code.
|
||||||
:param headers: Custom Headers.
|
:param headers: Custom Headers.
|
||||||
|
@ -276,6 +279,7 @@ def raw(body, status=200, headers=None,
|
||||||
def html(body, status=200, headers=None):
|
def html(body, status=200, headers=None):
|
||||||
"""
|
"""
|
||||||
Returns response object with body in html format.
|
Returns response object with body in html format.
|
||||||
|
|
||||||
:param body: Response data to be encoded.
|
:param body: Response data to be encoded.
|
||||||
:param status: Response code.
|
:param status: Response code.
|
||||||
:param headers: Custom Headers.
|
:param headers: Custom Headers.
|
||||||
|
|
|
@ -99,7 +99,16 @@ class Router:
|
||||||
return name, _type, pattern
|
return name, _type, pattern
|
||||||
|
|
||||||
def add(self, uri, methods, handler, host=None, strict_slashes=False):
|
def add(self, uri, methods, handler, host=None, strict_slashes=False):
|
||||||
|
"""Add a handler to the route list
|
||||||
|
|
||||||
|
:param uri: path to match
|
||||||
|
:param methods: sequence of accepted method names. If none are
|
||||||
|
provided, any method is allowed
|
||||||
|
:param handler: request handler function.
|
||||||
|
When executed, it should provide a response object.
|
||||||
|
:param strict_slashes: strict to trailing slash
|
||||||
|
:return: Nothing
|
||||||
|
"""
|
||||||
# add regular version
|
# add regular version
|
||||||
self._add(uri, methods, handler, host)
|
self._add(uri, methods, handler, host)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user