Adds Docs support to Flask.
Project description
Flask-Docs v0.1.4
Adds Docs support to Flask.
Features
- Automatic generation of markdown documents
- Support Flask-RESTful
- Support for generating offline documents
- Support flask.views.MethodView
Usage
Here is an example:
from flask import Flask
from flask_docs import ApiDoc
app = Flask(__name__)
# Using CDN
# app.config['API_DOC_CDN'] = True
# Disable document pages
# app.config['API_DOC_ENABLE'] = False
# Api Document needs to be displayed
app.config['API_DOC_MEMBER'] = ['api', 'platform']
# Restful API documents to be excluded
app.config['RESTFUL_API_DOC_EXCLUDE'] = []
ApiDoc(app)
How to add markdown documents to the code:
@@@
# Write your markdown document here
@@@
Run in /docs/api
Api and document pages
@api.route('/add_data', methods=['POST'])
def add_data():
"""Add some data
Add some data in this routing
Args:
pass
Returns:
pass
"""
return jsonify({'api': 'add data'})
@api.route('/del_data', methods=['POST'])
def del_data():
"""Del some data
@@@
#### args
| args | nullable | type | remark |
|--------|--------|--------|--------|
| title | false | string | blog title |
| name | true | string | person's name |
#### return
- ##### json
> {"msg": "success", "code": 200}
@@@
"""
return jsonify({'api': 'del data'})
@platform.route('/get_something', methods=['GET'])
def get_something():
"""
@@@
#### example
```
import requests
url='http://127.0.0.1:5000/api/get_something'
try:
print requests.get(url).text
except:
pass
```
@@@
"""
return jsonify({'platform': 'get something'})
Flask-RESTful Api and document pages
from flask_restful import Resource, Api
class TodoList(Resource):
"""Manage todolist"""
def post(self):
"""Submission of data
Args:
pass
Returns:
pass
"""
return {'todos': 'post todolist'}
def get(self):
"""
@@@
#### args
| args | nullable | type | remark |
|--------|--------|--------|--------|
| id | false | int | todo id |
#### return
- ##### json
> {...}
@@@
"""
return {'todos': 'get todolist'}
restful_api.add_resource(TodoList, '/todolist')
flask.views.MethodView Api
For the time being, only url_rule with the same class name are supported
from flask.views import MethodView
class TodoList(MethodView):
"""Manage todolist"""
def put(self):
"""Change the data
"""
return jsonify({'todos': 'put todolist'})
def delete(self):
"""Delete the data
"""
return jsonify({'todos': 'delete todolist'})
app.add_url_rule('/todolist/', view_func=TodoList.as_view('todolist'))
Examples
Installation
pip3 install Flask-Docs
Reference
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Flask-Docs-Cat-0.1.4.tar.gz
(369.1 kB
view details)
File details
Details for the file Flask-Docs-Cat-0.1.4.tar.gz
.
File metadata
- Download URL: Flask-Docs-Cat-0.1.4.tar.gz
- Upload date:
- Size: 369.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.3rc1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
26a21a41ecf5589c45c58032c0ca679f5f2454f2899ee43fa9e73a274b1d3cc0
|
|
MD5 |
128e359fe817c7634c2fe1cb53b94bd7
|
|
BLAKE2b-256 |
99788793f8d21c38bf8dd5e95d4b84cd79eb3903dd2b9540a5a78e26eda3c2c1
|