python38moduledocs是什么_Python modeldocs包_程序模块 - PyPI - Python中文网

用法

首先,用json创建一个配置文件,比如(可选的“include”):{

"name": "My Documentation",

"version": "1.0.0",

"title": "My Documentation Title",

"description": "This documents my data models",

"include": [

"mymodule",

"tests/myfile.py"

]

}

将其另存为当前目录中的modeldocs.json。

然后简单地运行它,它将递归地从当前目录中搜索所有modeldocs:$ modeldocs

或者,通过命令行指定查找位置和文件:$ modeldocs --include mymodule myfile.py

或者向自定义配置传递一个路径,该路径可以指定一个“include”配置变量:$ modeldocs --config my_model_docs.json

此外,还可以指定自定义输出目录(默认“docs”):$ modeldocs --output mydocs

使用–help/-h查看有关参数的信息:$ modeldocs --help

格式很简单。它遵循与apidocs非常相似的格式(请查看上面的github链接),例如:class Motorcycle(MongoCollection):

'''

@modelGroup Vehicles

@modelTitle Motorcycle

@modelDescription This represents a motorcycle and all its data.

@modelField {String} name the motorcycle name

@modelField {Number} year the year it was made

@modelField {Datetime} purchased_at the datetime it was purchased

@modelField {String="red","green","blue"} color the color of the motorcycle, with specified possible values.

@modelField {String} [owner] the owner of the vehicle (optional due to brackets)

@modelField {Number} [wheels=2] the number of wheels (default 2 as specified)

@modelExample {json} Motorcycle Example

{

"name": "yamaha v-star 650",

"year": 2002,

...

}

'''

pass

就这些。只需将上面这样的doc字符串添加到所有类中,它就会递归地发现它们。

并将文档生成到“docs”目录中。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值