def test_doc(self): doc = Doc(title='Test Api Document', version='v2') doc.host = 'http://www.apitest.com' doc.description = """ this is a test document - test1 - test2 """ html = doc.build() self.assertIn('<h1>Test Api Document</h1>', html) self.assertIn('<li>Version: <code>v2</code></li>', html) self.assertIn('<li>Host: <code>http://www.apitest.com</code></li>', html) self.assertIn('<li>test1</li>', html) self.assertIn('<li>test2</li>', html)
# ======= Basic Usage ======== # 第1步,引入 eave 包内组件 from eave import Doc, Note, Api, PP, QP, BP # 也可以使用 * 方式完全引入 from eave import * # 第2步,创建一个 doc 对象,并指定文档的标题和接口调用地址 doc = Doc(title='My Api Document', host='www.myapi.com') # 第3步,如果需要的话,为文档添加描述信息,描述信息会出现在标题下方(支持 markdown 语法) doc.description = """ the content of description is **markdown** format 1. one point 2. two point 3. three point """ # 第4步,如果需要的话,为文档添加一些详细的说明,这些内容会出现在接口目录的下方(支持 markdown 语法) doc.add_note(title="note title", content="the content of note is also **markdown** format") # 第5步,添加一个接口,使用 url method params 等参数进行描述 doc.add_api(title='Get all orders of shop', url='/shop/<id>/orders/', method='GET', description='Get all orders of shop, shop admin login required', params=[ PP(name='id', description='the id of shop'), QP(name='page', type='integer', default=1),