コード例 #1
0
ファイル: test.py プロジェクト: songym2020/eave
 def test_note(self):
     doc = Doc()
     note1 = Note()
     note1.title = 'test note1'
     note1.content = 'This is the **first** test note'
     note2 = Note()
     note2.content = 'This note has no title'
     doc.add_note(note1)
     doc.add_note(note2)
     html = doc.build()
     self.assertIn('test note1', html)
     self.assertIn('This is the <strong>first</strong> test note', html)
     self.assertNotIn('note2', html)
     self.assertIn('This note has no title', html)
コード例 #2
0
ファイル: best_practice.py プロジェクト: taojy123/eave
# 也可以使用 * 方式完全引入
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),
                QP(name='page_size', type='integer', default=10),
            ],
            response_example="""
{
    "page": 1,
    "page_size": 10,
コード例 #3
0
ファイル: speech.py プロジェクト: taojy123/openapi_speech
          version='2020-06-14')

doc.description = """
##### 主讲人: 陶佳元 [tslow.cn](https://tslow.cn)
"""

note = Note(title='先听个段子')
note.content = f"""
#### 说程序员最痛恨的 4 件事情
1. 写注释
2. 写文档
3. 别人不写注释
4. 别人不写文档
<br><br><br>
"""
doc.add_note(note)

note = Note(title='开始今天我们话题,接口文档')
note.content = f"""
- 谁写文档: `后端工程师`
- 写给谁看: `前端工程师`
<br><br>

#### 青铜玩家的文档
{img('api_doc.png', 600)}
<br><br>

#### 其实我们可以有更高一点的追求
{img('snowboard_example.png', 700)}
{img('redoc-demo.png', 800)}
1. 界面美观