Merge pull request #362 from channelcat/read-the-docs

Added basic readthedocs support
This commit is contained in:
Eli Uriegas 2017-01-29 15:34:58 -06:00 committed by GitHub
commit 894b434875
21 changed files with 94 additions and 88 deletions

View File

@ -45,10 +45,8 @@ Hello World Example
from sanic import Sanic from sanic import Sanic
from sanic.response import json from sanic.response import json
app = Sanic() app = Sanic()
@app.route("/") @app.route("/")
async def test(request): async def test(request):
return json({"hello": "world"}) return json({"hello": "world"})
@ -56,21 +54,6 @@ Hello World Example
if __name__ == "__main__": if __name__ == "__main__":
app.run(host="0.0.0.0", port=8000) app.run(host="0.0.0.0", port=8000)
SSL Example
-----------
Optionally pass in an SSLContext:
.. code:: python
import ssl
certificate = "/path/to/certificate"
keyfile = "/path/to/keyfile"
context = ssl.create_default_context(purpose=ssl.Purpose.CLIENT_AUTH)
context.load_cert_chain(certificate, keyfile=keyfile)
app.run(host="0.0.0.0", port=8443, ssl=context)
Installation Installation
------------ ------------
@ -79,12 +62,14 @@ Installation
Documentation Documentation
------------- -------------
Documentation can be found in the ``docs`` directory. `Documentation on Readthedocs <http://sanic.readthedocs.io/>`_.
.. |Join the chat at https://gitter.im/sanic-python/Lobby| image:: https://badges.gitter.im/sanic-python/Lobby.svg .. |Join the chat at https://gitter.im/sanic-python/Lobby| image:: https://badges.gitter.im/sanic-python/Lobby.svg
:target: https://gitter.im/sanic-python/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge :target: https://gitter.im/sanic-python/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge
.. |Build Status| image:: https://travis-ci.org/channelcat/sanic.svg?branch=master .. |Build Status| image:: https://travis-ci.org/channelcat/sanic.svg?branch=master
:target: https://travis-ci.org/channelcat/sanic :target: https://travis-ci.org/channelcat/sanic
.. |Documentation| image:: https://readthedocs.org/projects/sanic/badge/?version=latest
:target: http://sanic.readthedocs.io/en/latest/?badge=latest
.. |PyPI| image:: https://img.shields.io/pypi/v/sanic.svg .. |PyPI| image:: https://img.shields.io/pypi/v/sanic.svg
:target: https://pypi.python.org/pypi/sanic/ :target: https://pypi.python.org/pypi/sanic/
.. |PyPI version| image:: https://img.shields.io/pypi/pyversions/sanic.svg .. |PyPI version| image:: https://img.shields.io/pypi/pyversions/sanic.svg

20
docs/Makefile Normal file
View File

@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#
# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = sphinx-build
SPHINXPROJ = Sanic
SOURCEDIR = .
BUILDDIR = _build
# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
.PHONY: help Makefile
# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

View File

@ -75,7 +75,7 @@ todo_include_todos = False
# The theme to use for HTML and HTML Help pages. See the documentation for # The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes. # a list of builtin themes.
html_theme = 'alabaster' html_theme = 'sphinx_rtd_theme'
# Add any paths that contain custom static files (such as style sheets) here, # Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files, # relative to this directory. They are copied after the builtin static files,
@ -153,3 +153,7 @@ epub_copyright = copyright
epub_exclude_files = ['search.html'] epub_exclude_files = ['search.html']
# -- Custom Settings -------------------------------------------------------
suppress_warnings = ['image.nonlocal_uri']

View File

@ -6,21 +6,23 @@ Guides
.. toctree:: .. toctree::
:maxdepth: 2 :maxdepth: 2
sanic/getting_started
sanic/routing
sanic/request_data
sanic/static_files
sanic/exceptions
sanic/middleware
sanic/blueprints
sanic/config
sanic/cookies
sanic/class_based_views
sanic/custom_protocol
sanic/ssl
sanic/testing
sanic/deploying
sanic/extensions
sanic/contributing
getting_started getting_started
routing
request_data
deploying
static_files
middleware
exceptions
blueprints
class_based_views
config
cookies
custom_protocol
testing
extensions
contributing
Module Documentation Module Documentation
@ -28,7 +30,5 @@ Module Documentation
.. toctree:: .. toctree::
Module Reference <_api/sanic>
* :ref:`genindex` * :ref:`genindex`
* :ref:`search` * :ref:`search`

36
docs/make.bat Normal file
View File

@ -0,0 +1,36 @@
@ECHO OFF
pushd %~dp0
REM Command file for Sphinx documentation
if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=.
set BUILDDIR=_build
set SPHINXPROJ=Sanic
if "%1" == "" goto help
%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
echo.
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
echo.installed, then set the SPHINXBUILD environment variable to point
echo.to the full path of the 'sphinx-build' executable. Alternatively you
echo.may add the Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.http://sphinx-doc.org/
exit /b 1
)
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS%
goto end
:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS%
:end
popd

View File

@ -158,7 +158,3 @@ app.blueprint(blueprint_v2)
app.run(host='0.0.0.0', port=8000, debug=True) app.run(host='0.0.0.0', port=8000, debug=True)
``` ```
**Previous:** [Exceptions](exceptions.md)
**Next:** [Class-based views](class_based_views.md)

View File

@ -106,7 +106,3 @@ view.add(['POST', 'PUT'], lambda request: text('I am a post/put method'))
# Use the new view to handle requests to the base URL # Use the new view to handle requests to the base URL
app.add_route(view, '/') app.add_route(view, '/')
``` ```
**Previous:** [Blueprints](blueprints.md)
**Next:** [Cookies](cookies.md)

View File

@ -31,5 +31,3 @@ One of the main goals of Sanic is speed. Code that lowers the performance of
Sanic without significant gains in usability, security, or features may not be Sanic without significant gains in usability, security, or features may not be
merged. Please don't let this intimidate you! If you have any concerns about an merged. Please don't let this intimidate you! If you have any concerns about an
idea, open an issue for discussion and help. idea, open an issue for discussion and help.
**Previous:** [Sanic extensions](extensions.md)

View File

@ -73,7 +73,3 @@ parameters available:
HTTPS. HTTPS.
- `httponly` (boolean): Specifies whether the cookie cannot be read by - `httponly` (boolean): Specifies whether the cookie cannot be read by
Javascript. Javascript.
**Previous:** [Class-based views](class_based_views.md)
**Next:** [Custom protocols](custom_protocol.md)

View File

@ -70,7 +70,3 @@ async def response(request):
app.run(host='0.0.0.0', port=8000, protocol=CustomHttpProtocol) app.run(host='0.0.0.0', port=8000, protocol=CustomHttpProtocol)
``` ```
**Previous:** [Cookies](cookies.md)
**Next:** [Testing](testing.md)

View File

@ -53,7 +53,3 @@ directly run by the interpreter.
if __name__ == '__main__': if __name__ == '__main__':
app.run(host='0.0.0.0', port=1337, workers=4) app.run(host='0.0.0.0', port=1337, workers=4)
``` ```
**Previous:** [Request Data](request_data.md)
**Next:** [Static Files](static_files.md)

View File

@ -43,7 +43,3 @@ Some of the most useful exceptions are presented below:
usually occurs if there is an exception raised in user code. usually occurs if there is an exception raised in user code.
See the `sanic.exceptions` module for the full list of exceptions to throw. See the `sanic.exceptions` module for the full list of exceptions to throw.
**Previous:** [Middleware](middleware.md)
**Next:** [Blueprints](blueprints.md)

View File

@ -1,4 +1,4 @@
# Sanic Extensions # Extensions
A list of Sanic extensions created by the community. A list of Sanic extensions created by the community.
@ -6,7 +6,3 @@ A list of Sanic extensions created by the community.
Allows using redis, memcache or an in memory store. Allows using redis, memcache or an in memory store.
- [CORS](https://github.com/ashleysommer/sanic-cors): A port of flask-cors. - [CORS](https://github.com/ashleysommer/sanic-cors): A port of flask-cors.
- [Jinja2](https://github.com/lixxu/sanic-jinja2): Support for Jinja2 template. - [Jinja2](https://github.com/lixxu/sanic-jinja2): Support for Jinja2 template.
**Previous:** [Testing](testing.md)
**Next:** [Contributing](contributing.md)

View File

@ -25,5 +25,3 @@ syntax, so earlier versions of python won't work.
the message *Hello world!*. the message *Hello world!*.
You now have a working Sanic server! You now have a working Sanic server!
**Next:** [Routing](routing.md)

View File

@ -64,7 +64,3 @@ async def halt_request(request):
async def halt_response(request, response): async def halt_response(request, response):
return text('I halted the response') return text('I halted the response')
``` ```
**Previous:** [Static Files](static_files.md)
**Next:** [Exceptions](exceptions.md)

View File

@ -89,7 +89,3 @@ args.get('titles') # => 'Post 1'
args.getlist('titles') # => ['Post 1', 'Post 2'] args.getlist('titles') # => ['Post 1', 'Post 2']
``` ```
**Previous:** [Routing](routing.md)
**Next:** [Deploying](deploying.md)

View File

@ -105,7 +105,3 @@ app.add_route(handler1, '/test')
app.add_route(handler2, '/folder/<name>') app.add_route(handler2, '/folder/<name>')
app.add_route(person_handler2, '/person/<name:[A-z]>', methods=['GET']) app.add_route(person_handler2, '/person/<name:[A-z]>', methods=['GET'])
``` ```
**Previous:** [Getting Started](getting_started.md)
**Next:** [Request Data](request_data.md)

12
docs/sanic/ssl.rst Normal file
View File

@ -0,0 +1,12 @@
SSL Example
-----------
Optionally pass in an SSLContext:
.. code:: python
import ssl
context = ssl.create_default_context(purpose=ssl.Purpose.CLIENT_AUTH)
context.load_cert_chain("/path/to/cert", keyfile="/path/to/keyfile")
app.run(host="0.0.0.0", port=8443, ssl=context)

View File

@ -17,7 +17,3 @@ app.static('/the_best.png', '/home/ubuntu/test.png')
app.run(host="0.0.0.0", port=8000) app.run(host="0.0.0.0", port=8000)
``` ```
**Previous:** [Deploying](deploying.md)
**Next:** [Middleware](middleware.md)

View File

@ -49,7 +49,3 @@ def test_endpoint_challenge():
# Assert that the server responds with the challenge string # Assert that the server responds with the challenge string
assert response.text == request_data['challenge'] assert response.text == request_data['challenge']
``` ```
**Previous:** [Custom protocols](custom_protocol.md)
**Next:** [Sanic extensions](extensions.md)

View File

@ -13,5 +13,6 @@ falcon
tornado tornado
aiofiles aiofiles
sphinx sphinx
sphinx_rtd_theme
recommonmark recommonmark
beautifulsoup4 beautifulsoup4