出于文档目的将文件包含到rst

rst-include的Python项目详细描述


rst_include

pypi status巨蟒version许可证维护

build statuscodecov status更好的代码可维护性snyk security

由于您不能将文件包含到github和pypi上的rst文件中,因此可以使用此软件替换这些导入。

这意味着您可以在本地编写rst文档(例如使用pycharm)并在其中使用 这个。。include:将其他rst文件或代码段包含到文档中的选项。 然后,您可以运行此软件来创建一个可以在github或pypi上查看的单片readme.rst

您可能还包括来自Jupyter笔记本的文本/代码(抱歉,目前没有图片,但这样做并不困难)

这有许多优点,如:

  • 不要重复,创建标准块以包含在文档中
  • 将代码文件中经过测试的代码片段包含到文档中,以避免未经测试或过时的文档
  • 包括其他RST文件
  • 非常简单的用法,在travis构建时抛出退出代码以检测文档中的错误
  • 命令行或编程接口,您甚至可以在travis.yml中使用它
  • 命令行界面支持shellscript、cmd、pipes、config文件

这个自述文件也是用rst_include创建的,您可以查看./docs/自述模板.rst, 例如build_docs.sh、build_docs.cmd和build_docs.py。(它们都做同样的事,只是版本不同)

yml在每次运行时都会构建文档,因此您可以确保没有错误。 rst_include仅适用于python>;3.6

100%代码覆盖率 ,mypy静态类型检查,在 Linux、OSX、Windows和Wine下测试 ,自动每日生成和监视


  • rst include parameters
  • 需求
  • 确认
  • 贡献
  • 报告问题
  • 拉取请求
  • 行为准则
  • 许可证
  • 更改日志

    安装和升级

    源代码:

    # normal install
    python setup.py install
    # test without installing
    python setup.py test

    VIA PIP最新版本:

    # latest Release from pypi
    # under Linux You have to use sudo, or it will not be installed as a commandline application
    # [sudo] means, that the command "sudo" is optional for Linux if You want to use it from bash commandline
    [sudo] pip3 install rst_include
    
    # test without installing
    [sudo] pip3 install rst_include --install-option test

    VIA PIP最新开发版本:

    # upgrade all dependencies regardless of version number (PREFERRED)
    [sudo] pip3 install --upgrade https://github.com/bitranox/rst_include/archive/master.zip --upgrade-strategy eager
    # normal install
    [sudo] pip3 install --upgrade https://github.com/bitranox/rst_include/archive/master.zip
    # test without installing
    [sudo] pip3 install https://github.com/bitranox/rst_include/archive/master.zip --install-option test

    via requirements.txt:

    # Insert following line in Your requirements.txt:
    # for the latest Release:
    rst_include
    # for the latest Development Version :
    https://github.com/bitranox/rst_include/archive/master.zip
    
    # to install and upgrade all modules mentioned in requirements.txt:
    [sudo] pip3 install --upgrade -r /<path>/requirements.txt
    

    通过Python:

    # for the latest Release[sudo]python3-mpipinstallupgraderst_include# for the latest Development Version[sudo]python3-mpipinstallupgradehttps://github.com/bitranox/rst_include/archive/master.zip

    基本用法

    由于在当前的python解释器中将rst_include注册为控制台脚本命令,因此必须使用命令"rst_include"(而不是"rst_include.py")

    • 发出命令:
    # issue command on shell or windows commandline
    $> rst_include [OPTIONS]# or, if python/bin is not in Your python path :
    # on Windows
    $> c:\python37\scripts\rst_include [OPTIONS]# on Linux/oSX
    $> /python37/bin/rst_include [OPTIONS]# issue command with python interpreter
    $> python -m rst_include [OPTIONS]
    • 获取帮助:
    # get help on shell or windows commandline
    $> rst_include -h
    
    usage: rst_include [-h]{include,replace} ...
    
    Process .rst File Includes
    
    positional arguments:
      {include,replace}
        include          include rst includes
        replace          string replace
    
    optional arguments:
      -h, --help         show this help message and exit
    
    check the documentation on github
    
    # get help on shell or windows commandline for include
    $> rst_include include -h
    
    # normal install
    python setup.py install
    # test without installing
    python setup.py test
    0
    # normal install
    python setup.py install
    # test without installing
    python setup.py test
    1
    # normal install
    python setup.py install
    # test without installing
    python setup.py test
    2
    • 替换source.rst中的include语句并通过命令行参数将其保存到target.rst:
    # normal install
    python setup.py install
    # test without installing
    python setup.py test
    3
    • 通过config.py:
    • 替换多个文件上的include语句
    # normal install
    python setup.py install
    # test without installing
    python setup.py test
    4

    配置文件的结构:

    文件按给定顺序处理,这样您甚至可以实现嵌套。包含::块。

    您还可以指定源文件和目标文件的编码

    # normal install
    python setup.py install
    # test without installing
    python setup.py test
    5

    另外,您可以轻松替换(也可以多行)文本字符串:

    # normal install
    python setup.py install
    # test without installing
    python setup.py test
    6

    Linux下的管道:

    # normal install
    python setup.py install
    # test without installing
    python setup.py test
    7
  • 欢迎加入QQ群-->: 979659372 Python中文网_新手群

    推荐PyPI第三方库


    热门话题
    java如何使用URLhttp://localhost:8080/appcontext/METAINF/index.html?   Google应用程序引擎Java错误   java此GUI在设置BoxLayout后不显示任何内容   setParameter情况下的java临时类型(字符串名称、对象值)   Rijndael 256加密与Java&Bouncy Castle   java如何检查字符串是否为空?   java InvalidDataAccessResourceUsageException:无法提取结果集   AWTGLCanvas正在隐藏java JToggleButton工具提示   使用PDFBox的java格式数字   java Datainputstream和readUTF数据丢失   在java中使用axiomapi解码XJWT断言   为什么Java和PHP的相同代码不起作用?   JavaGoogleSigin错误,代码工作真实设备工作良好,但不工作模拟器获得错误ApiException 12500,谢谢,我也是新的   java通过使用JNA将void**参数作为char[]获取函数的结果   java如何使用泛型树集创建比较器?   未正确解析java简单文本文件   在java中将字符串转换为MyString对象类型   java Spring继承不起作用