脏模型的sphinx扩展
dirty-models-sphinx的Python项目详细描述
脏模型Sphinx扩展
Sphinx脏模型的扩展
关于
Sphinx帮助开发人员编写 使用Dirty Models的应用程序。
功能
- 用实型描述每个字段。
- 在Dirty Models上定义的所有字段类型都有文档记录。
- 使用前缀(在字段前面使用#:的文档注释)或
每个字段的后缀(字段后的多行文档字符串)文档。
- 文档read only字段。
- 记录每个字段的默认值。
- 这些字段上的文档日期时间格式。
- 能够在模型签名中设置前缀文本。
- 能够在字段签名中设置前缀文本。
- 能够将字段类型记录为注释或字段指令。
- 能够将模型添加到toctree。
- 能够将模型属性添加到toctree。
更改日志
0.4.1版
- 修复安装。
0.4.0版
- 在timefield和datetimefield上记录默认时区。
- 在DateTimeField上记录强制时区。
- 小修小修。
- 修复嵌套类。
- 文档枚举字段。
0.3.0版
- 添加了将模型添加到toctree的选项。
- 添加了将模型属性添加到toctree的选项。
- 添加了设置前缀模型签名的选项。
- 添加了设置前缀模型字段签名的选项。
- 添加了使用字段类型作为批注的选项。
- 已将字段添加到索引。
- 已将默认值标签更改为Default value。
问题
- 当模型属性位于toctree中时,LaTex手动文档类生成器失败。 这是因为它使用相同的ids创建了一个伪节,并在创建toctree后删除。 因此,乳胶构建器在尝试创建链接时找不到引用。
安装
只需使用pip即可安装:
$ pip install dirty-models-sphinx
并添加到项目的Sphinx扩展。
警告
autodoc需要扩展(包含在sphinx中)。
conf.py文件:
extensions=['sphinx.ext.autodoc','dirty_models_sphinx']
配置
可以使用conf.py文件中的配置修改Dirty Models Sphinx extension行为。
dirty_model_add_classes_to_toc
If it is ^{tt13}$ Dirty Models classes will be added to table of content. Default: ^{tt13}$.
dirty_model_add_attributes_to_toc
If it is ^{tt13}$ Dirty Models class attributes will be added to table of content, only if classes were added. Default: ^{tt13}$.
dirty_model_class_标签
It defines a prefix text for Dirty Model class signatures. It is possible to use ^{tt17}$ in order to avoid prefix. Default: ^{tt18}$.
dirty_model_property_标签
It defines a prefix text for Dirty Model class field signatures. It is possible to use ^{tt17}$ in order to avoid prefix. Default: ^{tt20}$.
dirty_model_field_type_as_annotation
If it is ^{tt13}$ field type will be shown as annotation to attribute. Otherwise, if it is ^{tt22}$, field type will be shown as field directive. Default: ^{tt13}$.
使用量
只需使用常规的自动文档管理器:
..automodule:: models :members::show-inheritance:
未来
- 文档Dirty Validators。
- 文档基本验证。