记录jinja2模板文件的简单工具
jinja2rst的Python项目详细描述
Author: | Hartmut Goebel <h.goebel@crazy-compilers.com> |
---|---|
Copyright: | 2015 by Hartmut Goebel |
Licence: | GNU General Public Licence v3 or later (GPLv3+) |
此工具允许您将文档直接写入jinja2 模板文件作为注释。这些评论将转换为 文本和模板代码进入文本块。
这是一种有文化的编程,除了你没有 将代码写入文本,但将文本写入代码。这个区别 允许直接使用模板文件,而无需任何预处理
用法:
jinja2rst [-h] infile outfile positional arguments: infile jinja2-template-file to read (`-` for stdin) outfile rst-file to write (`-` for stdout) optional arguments: -h, --help show this help message and exit
工作原理
此脚本接受以#开头的所有行(和行 只包含一个#)作为文本行。其他一切都会 作为“代码”处理。文本行将删除#。 而“代码”将预先设置空格。
另外,在“代码”块的开头和结尾,行是 根据RestructuredText的要求添加。也在 “code”-块,如果需要,添加::。
示例
您可以在 示例目录您也可以在线查看生成的html https://rawgit.com/htgoebel/jinja2rst/develop/examples/main.html。