我有这样的Flask网络服务:
from flask import Flask, jsonify
app = Flask(__name__)
@app.route('/api/ping')
def ping():
"""Check if service is alive.
.. :quickref: Ping; Get pong response
"""
return jsonify({'status': 'pong!'})
if __name__ == '__main__':
app.run(host='127.0.0.1', port=8080, debug=True)
我正在使用sphinxcontrib-httpdomain == 1.7.0。我的第一个文档copied from documentation中有以下部分:
Summary
-------
.. qrefflask:: logging_service.main:app
API Details
-----------
.. autoflask:: logging_service.main:app
:undoc-static:
当我在docs文件夹中运行make html
时,出现此错误:
...PROJECT.../docs/logging_service.rst:2: WARNING: Insufficient data supplied (1 row(s)); no data remaining for table body, required by "list-table" directive.
.. list-table::
:widths: 20 45 35
:header-rows: 1
* - Resource
- Operation
- Description
我在这里想念的是什么?
答案 0 :(得分:1)
以上错误通常是由于缺少数据引起的。在这种特定情况下,我建议例如以以下方式重写服务:
from flask import Flask, jsonify
def create_app():
app = Flask(__name__)
@app.route('/api/ping')
def ping():
"""Check if service is alive.
.. :quickref: Ping; Get pong response
"""
return jsonify({'status': 'pong!'})
return app
if __name__ == '__main__':
create_app().run(
host='127.0.0.1',
port=8080,
debug=True
)
并相应地更新.rst文件:
Summary
-------
.. qrefflask:: logging_service:create_app
API Details
-----------
.. autoflask:: logging_service:create_app
:undoc-static:
该示例应该起作用,并希望这将有助于某人理解更改的逻辑。