CheeseAPI-APIDocumenter


NameCheeseAPI-APIDocumenter JSON
Version 0.0.1 PyPI version JSON
download
home_pageNone
Summary一款基于CheeseAPI的api接口文档管理器。
upload_time2024-05-03 18:36:51
maintainerNone
docs_urlNone
authorNone
requires_pythonNone
licenseNone
keywords api cheeseapi document documenter
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # **CheeseAPI_APIDocumenter**

一款基于[CheeseAPI](https://github.com/CheeseUnknown/CheeseAPI)的API接口文档管理器,在代码中使用装饰器进行文档注册,并构建出API文档。

目前项目仍处于开发阶段,仅支持输出raw源文件以及markdown文档;在未来期望能支持更多类型的文档,以及创建支持APIDocumenter源文件格式的API文档体系。

## **安装**

系统要求:Linux。

Python要求:目前仅保证支持3.11及以上版本的Python,新版本会优先支持Python的最新稳定版本。

```bash
pip install CheeseAPI_APIDocumenter
```

## **使用**

CheeseAPI_APIDocumenter是[CheeseAPI](https://github.com/CheeseUnknown/CheeseAPI)的一款插件,但它并不需要在入口文件中注册。

```python
from CheeseAPI import app, WebsocketServer
from CheeseAPI_APIDocumenter import documenter

app.localModules.append('CheeseAPI_APIDocumenter') # 该行代码可省略

@documenter('注册用户', {
    'body': {
        'type': 'form-data',
        'params': [
            {
                'key': 'username',
                'type': 'str',
                'description': '用户名;长度为5-20。'
            },
            {
                'key': 'password',
                'type': 'str',
                'description': '由sha256一次加密后的密码。'
            },
            {
                'key': 'gender',
                'type': 'str',
                'default': '"UNKNOWN"',
                'description': '支持“MALE”、“FEMALE”和“UNKNOWN”。'
            },
            {
                'key': 'birthDate',
                'type': 'timestamp',
                'required': True,
                'description': '出生日期。'
            }
        ]
    }
}, [
    {
        'status': 201,
        'description': '注册成功',
        'body': {
            'type': 'text',
            'description': '该用户的uuid。'
        }
    },
    {
        'status': 409,
        'description': '该用户名已被注册'
    }
])
@app.route.post('/register')
async def register(**_):
    ...

@documenter('自定义websocket', example = '对于websocket,由于其通讯的灵活性,请在此进行更细节的描述')
@app.route.websocket('/')
class MyWebsocket(WebsocketServer):
    ...

if __name__ == '__main__':
    app.run()
```

在当前目录下执行命令,会自动在`./document/`下生成API文档:

```bash
APIDocumenter
```

生成文档的规则为:

- 每个本地模块会生成一个同模块名的文件,里面包含该模块内的所有受`@documenter`注册的API。

- 非模块内的接口会统一生成在`index`文件内。

- 依赖模块的接口并不会被加载。

更多生成命令选项请查看[Command](https://github.com/CheeseUnknown/CheeseAPI_APIDocumenter/blob/master/document/Command.md)。

## **更多...**

### 1. [**Documenter**](https://github.com/CheeseUnknown/CheeseAPI_APIDocumenter/blob/master/document/Documenter.md)

### 1. [**Command (命令参数)**](https://github.com/CheeseUnknown/CheeseAPI_APIDocumenter/blob/master/document/Command.md)

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "CheeseAPI-APIDocumenter",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "API, CheeseAPI, Document, Documenter",
    "author": null,
    "author_email": "Cheese Unknown <cheese@cheese.ren>",
    "download_url": "https://files.pythonhosted.org/packages/c2/7e/70df925deabb908a13dea3e522a08cd8025c0afb7859e66533b7d574c1c8/cheeseapi_apidocumenter-0.0.1.tar.gz",
    "platform": null,
    "description": "# **CheeseAPI_APIDocumenter**\n\n\u4e00\u6b3e\u57fa\u4e8e[CheeseAPI](https://github.com/CheeseUnknown/CheeseAPI)\u7684API\u63a5\u53e3\u6587\u6863\u7ba1\u7406\u5668\uff0c\u5728\u4ee3\u7801\u4e2d\u4f7f\u7528\u88c5\u9970\u5668\u8fdb\u884c\u6587\u6863\u6ce8\u518c\uff0c\u5e76\u6784\u5efa\u51faAPI\u6587\u6863\u3002\n\n\u76ee\u524d\u9879\u76ee\u4ecd\u5904\u4e8e\u5f00\u53d1\u9636\u6bb5\uff0c\u4ec5\u652f\u6301\u8f93\u51faraw\u6e90\u6587\u4ef6\u4ee5\u53camarkdown\u6587\u6863\uff1b\u5728\u672a\u6765\u671f\u671b\u80fd\u652f\u6301\u66f4\u591a\u7c7b\u578b\u7684\u6587\u6863\uff0c\u4ee5\u53ca\u521b\u5efa\u652f\u6301APIDocumenter\u6e90\u6587\u4ef6\u683c\u5f0f\u7684API\u6587\u6863\u4f53\u7cfb\u3002\n\n## **\u5b89\u88c5**\n\n\u7cfb\u7edf\u8981\u6c42\uff1aLinux\u3002\n\nPython\u8981\u6c42\uff1a\u76ee\u524d\u4ec5\u4fdd\u8bc1\u652f\u63013.11\u53ca\u4ee5\u4e0a\u7248\u672c\u7684Python\uff0c\u65b0\u7248\u672c\u4f1a\u4f18\u5148\u652f\u6301Python\u7684\u6700\u65b0\u7a33\u5b9a\u7248\u672c\u3002\n\n```bash\npip install CheeseAPI_APIDocumenter\n```\n\n## **\u4f7f\u7528**\n\nCheeseAPI_APIDocumenter\u662f[CheeseAPI](https://github.com/CheeseUnknown/CheeseAPI)\u7684\u4e00\u6b3e\u63d2\u4ef6\uff0c\u4f46\u5b83\u5e76\u4e0d\u9700\u8981\u5728\u5165\u53e3\u6587\u4ef6\u4e2d\u6ce8\u518c\u3002\n\n```python\nfrom CheeseAPI import app, WebsocketServer\nfrom CheeseAPI_APIDocumenter import documenter\n\napp.localModules.append('CheeseAPI_APIDocumenter') # \u8be5\u884c\u4ee3\u7801\u53ef\u7701\u7565\n\n@documenter('\u6ce8\u518c\u7528\u6237', {\n    'body': {\n        'type': 'form-data',\n        'params': [\n            {\n                'key': 'username',\n                'type': 'str',\n                'description': '\u7528\u6237\u540d\uff1b\u957f\u5ea6\u4e3a5-20\u3002'\n            },\n            {\n                'key': 'password',\n                'type': 'str',\n                'description': '\u7531sha256\u4e00\u6b21\u52a0\u5bc6\u540e\u7684\u5bc6\u7801\u3002'\n            },\n            {\n                'key': 'gender',\n                'type': 'str',\n                'default': '\"UNKNOWN\"',\n                'description': '\u652f\u6301\u201cMALE\u201d\u3001\u201cFEMALE\u201d\u548c\u201cUNKNOWN\u201d\u3002'\n            },\n            {\n                'key': 'birthDate',\n                'type': 'timestamp',\n                'required': True,\n                'description': '\u51fa\u751f\u65e5\u671f\u3002'\n            }\n        ]\n    }\n}, [\n    {\n        'status': 201,\n        'description': '\u6ce8\u518c\u6210\u529f',\n        'body': {\n            'type': 'text',\n            'description': '\u8be5\u7528\u6237\u7684uuid\u3002'\n        }\n    },\n    {\n        'status': 409,\n        'description': '\u8be5\u7528\u6237\u540d\u5df2\u88ab\u6ce8\u518c'\n    }\n])\n@app.route.post('/register')\nasync def register(**_):\n    ...\n\n@documenter('\u81ea\u5b9a\u4e49websocket', example = '\u5bf9\u4e8ewebsocket\uff0c\u7531\u4e8e\u5176\u901a\u8baf\u7684\u7075\u6d3b\u6027\uff0c\u8bf7\u5728\u6b64\u8fdb\u884c\u66f4\u7ec6\u8282\u7684\u63cf\u8ff0')\n@app.route.websocket('/')\nclass MyWebsocket(WebsocketServer):\n    ...\n\nif __name__ == '__main__':\n    app.run()\n```\n\n\u5728\u5f53\u524d\u76ee\u5f55\u4e0b\u6267\u884c\u547d\u4ee4\uff0c\u4f1a\u81ea\u52a8\u5728`./document/`\u4e0b\u751f\u6210API\u6587\u6863\uff1a\n\n```bash\nAPIDocumenter\n```\n\n\u751f\u6210\u6587\u6863\u7684\u89c4\u5219\u4e3a\uff1a\n\n- \u6bcf\u4e2a\u672c\u5730\u6a21\u5757\u4f1a\u751f\u6210\u4e00\u4e2a\u540c\u6a21\u5757\u540d\u7684\u6587\u4ef6\uff0c\u91cc\u9762\u5305\u542b\u8be5\u6a21\u5757\u5185\u7684\u6240\u6709\u53d7`@documenter`\u6ce8\u518c\u7684API\u3002\n\n- \u975e\u6a21\u5757\u5185\u7684\u63a5\u53e3\u4f1a\u7edf\u4e00\u751f\u6210\u5728`index`\u6587\u4ef6\u5185\u3002\n\n- \u4f9d\u8d56\u6a21\u5757\u7684\u63a5\u53e3\u5e76\u4e0d\u4f1a\u88ab\u52a0\u8f7d\u3002\n\n\u66f4\u591a\u751f\u6210\u547d\u4ee4\u9009\u9879\u8bf7\u67e5\u770b[Command](https://github.com/CheeseUnknown/CheeseAPI_APIDocumenter/blob/master/document/Command.md)\u3002\n\n## **\u66f4\u591a...**\n\n### 1. [**Documenter**](https://github.com/CheeseUnknown/CheeseAPI_APIDocumenter/blob/master/document/Documenter.md)\n\n### 1. [**Command (\u547d\u4ee4\u53c2\u6570)**](https://github.com/CheeseUnknown/CheeseAPI_APIDocumenter/blob/master/document/Command.md)\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "\u4e00\u6b3e\u57fa\u4e8eCheeseAPI\u7684api\u63a5\u53e3\u6587\u6863\u7ba1\u7406\u5668\u3002",
    "version": "0.0.1",
    "project_urls": {
        "Source": "https://github.com/CheeseUnknown/CheeseAPI_APIDocumenter"
    },
    "split_keywords": [
        "api",
        " cheeseapi",
        " document",
        " documenter"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "59a956c64dd980cbc0873288aea9aa502cd2eabb97c9162f17d3d2bb2bd0b80e",
                "md5": "d56afbfa746a1070dbed56242b2c8599",
                "sha256": "d763414ec60366e587aad35046ca9777e753429065e84e184fcc7fb5025a1fa6"
            },
            "downloads": -1,
            "filename": "cheeseapi_apidocumenter-0.0.1-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "d56afbfa746a1070dbed56242b2c8599",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": null,
            "size": 7162,
            "upload_time": "2024-05-03T18:36:49",
            "upload_time_iso_8601": "2024-05-03T18:36:49.664276Z",
            "url": "https://files.pythonhosted.org/packages/59/a9/56c64dd980cbc0873288aea9aa502cd2eabb97c9162f17d3d2bb2bd0b80e/cheeseapi_apidocumenter-0.0.1-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c27e70df925deabb908a13dea3e522a08cd8025c0afb7859e66533b7d574c1c8",
                "md5": "0df0dedff04ea0ccd6e208c3f0e7db17",
                "sha256": "cbd119fd6d01126c54b0828d54041a76ead3fb9c298fe98c52748342b3c6b073"
            },
            "downloads": -1,
            "filename": "cheeseapi_apidocumenter-0.0.1.tar.gz",
            "has_sig": false,
            "md5_digest": "0df0dedff04ea0ccd6e208c3f0e7db17",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 5371,
            "upload_time": "2024-05-03T18:36:51",
            "upload_time_iso_8601": "2024-05-03T18:36:51.909893Z",
            "url": "https://files.pythonhosted.org/packages/c2/7e/70df925deabb908a13dea3e522a08cd8025c0afb7859e66533b7d574c1c8/cheeseapi_apidocumenter-0.0.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-05-03 18:36:51",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "CheeseUnknown",
    "github_project": "CheeseAPI_APIDocumenter",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "cheeseapi-apidocumenter"
}
        
Elapsed time: 0.23396s