用法
首先,用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”目录中。