从模板生成程序集和模块ascidoc文件的脚本。
newdoc的Python项目详细描述
#自述:newdoc脚本
此脚本用于在Asciidoc中编写Red Hat或Fedora文档时生成空模块和程序集文件。生成的文件遵循模块化文档计划设置的模板准则:<;https://redhat-documentation.github.io/modular-docs/>;。
该脚本现在与Python3(用于Fedora和社区发行版)和Python2.7(用于RHEL7和MacOS)兼容。
它还没有在windows上测试过。
##如何安装脚本?
要在fedora上安装newdoc,请使用copr包存储库:<;https://copr.fedorainfracloud.org/coprs/mareksu/newdoc/>;。请看那里的说明。
在包含python 3的linux发行版上,使用pip包管理器,版本3:
^{tt1}$
在RHEL 7、CentOS 7或MacOS上,使用软件包管理器,版本2:
^{tt2}$
##如何添加新模块?
在模块所在的目录中,使用newdoc脚本创建一个新文件:
^{tt3}$
The script also accepts the –concept and –reference options. You can use these short forms instead: -p, -c, and -r.
用文档重写模板中的信息。
##如何添加新程序集?
在程序集所在的目录中,使用newdoc脚本创建新文件:
^{tt4}$
You can use the short form of the option instead: newdoc -a “Achieving thing”.
用文档重写模板中的信息。
Add AsciiDoc include statements to include modules. See [Include Files](https://asciidoctor.org/docs/asciidoc-syntax-quick-reference/#include-files) in the AsciiDoc Syntax Quick Reference.
##配置
newdoc允许您配置其行为的多个方面:
- 程序集和模块的自定义模板,
- 从标题转换ID时如何大写,
- 什么符号用于替换ids中的空格。
这些选项可以在newdoc.ini配置文件中设置,该文件位于:
- 在Fedora、RHEL和其他Linux发行版上,在~/.config/newdoc/newdoc.ini
- 在macos上,在~/library/preferences/newdoc/newdoc.ini中
配置文件不会自动创建:如果要设置自定义选项,请使用纯文本编辑器创建它。
文件必须始终以[newdoc]标题开头。此回购协议中的示例配置位于examples/newdoc.ini。
###自定义模板
在配置文件中,可以为每个模块类型设置自定义asciidoc模板文件的路径。选项是:
- 装配模板
- 概念模板
- 过程模板
- 参考模板
例如,要将自定义模板用于参考模块,请使用:
` reference_template = ~/.config/newdoc/my-reference-template.adoc `
newdoc使用pythonstring.template库对模板执行替换。替换以下字符串:
- ${module\u title}输入模块的标题
- ${module\u id}和生成的模块id
- ${file name}和生成的模块文件名
有关模板语法的详细信息,请参见:<;https://docs.python.org/3/library/string.html#template-strings>;
###id替换
配置文件中的id\u case选项控制字母大小写应如何从标题更改为id:
- id_case = lowercase: All letters in the ID will be lower-case
- id_case = capitalize: The first letter will be upper-case, the rest lower-case
- id_case = preserve: Keep the capitalization as entered in the title
单词分隔符选项允许您选择用于替换id中空格的符号(或字符串)。默认值为破折号:
^{tt6}$
##注释
- 如果您希望生成不带解释性注释的文件,请在创建文档时添加–no comments或-c选项。
##其他资源
- [模块化文档参考指南](https://redhat-documentation.github.io/modular-docs/)
- [Asciidoc标记Red Hat文档的快速参考](https://redhat-documentation.github.io/asciidoc-markup-conventions/)