add auto-doc support

This commit is contained in:
Yun Xu
2017-07-01 23:46:34 -07:00
parent fd5faeb5dd
commit 3fff685c44
6 changed files with 42 additions and 1 deletions

View File

@@ -13,6 +13,9 @@ import sys
# Add support for Markdown documentation using Recommonmark
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
# autogenerate documentation from docstrings
root_directory = os.path.dirname(os.getcwd())
@@ -140,3 +143,13 @@ epub_exclude_files = ['search.html']
# -- Custom Settings -------------------------------------------------------
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)

View File

@@ -117,3 +117,11 @@ args.get('titles') # => 'Post 1'
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
```

View File

@@ -110,3 +110,11 @@ def handle_request(request):
status=200
)
```
## Full API Reference
```eval_rst
.. automodule:: sanic.response
:members: json, text, raw, html, file, file_stream, stream, redirect
```

View File

@@ -214,4 +214,3 @@ and `recv` methods to send and receive data respectively.
WebSocket support requires the [websockets](https://github.com/aaugustin/websockets)
package by Aymeric Augustin.