我正在尝试使用 sphinx autodoc 为我的 python 项目生成文档。我似乎无法在此代码中保留文档字符串:
class aps_sio():
def __init__(self, server, port, mav, is_sim=False):
########## ASYNC IO INITIALIZATION ##########
# creates a new Async Socket IO Server
#sio = socketio.AsyncServer()
self.server = server
self.port = port
self.sio = socketio.AsyncServer(async_mode='aiohttp')
self.mav = mav
# Creates a new Aiohttp Web Application
self.app = web.Application()
# Binds our Socket.IO server to our Web App
# instance
self.sio.attach(self.app)
#############################################
# Note: these decorated functions are created at initialization time, thus are indented with __init__
@self.sio.on('connect')
async def on_connect(sid, environ):
"""Event handler for an socket.io connection. Logs the connection and adds the SID to the sid_list
:param sid: The unique socket ID of the requesting connection
:type sid: string
:param environ: Enviroment object for the requesting connection
:type environ: Enviroment Object
"""
self.sid_list.append(sid)
self.logger.log_aps('%s - Socket Connected, SID: %s IP: %s' % (time.time(), sid, environ['REMOTE_ADDR']))
if __name__ == "__main__":
sio1 = aps_sio("localhost",8005, mav1)
我不知道如何使用类似functool.wraps
这个问题中接受的答案之类的东西:
Python decorator handling docstrings
我将如何保存函数文档字符串?
谢谢