【问题标题】:Extracting blocks of text from RST documents,files by :ref:?从 RST 文档中提取文本块,文件由 :ref:?
【发布时间】:2021-12-27 09:34:50
【问题描述】:

我有一个 rst 文件 SWAP.rst,我需要提取一些特定数据并放入字典中。

文件如下所示:

:baseID: SWAP_DF

The current used for the force ...

.. requirement::SWAT_FD_AR_Force.432
   :c_This_is_a: functional
   :c_Release: AR_V2.RC
   :c_Maturity: accepted
   :c_Implementation: implemented

   text text text text
   tables

.. comment:: SDASD.471
   :c_This_is_a: functional
   :c_Release: adm_28.1
   :c_Implementation: implemented

   text tables etc

.. requirement:: SWAT_FD_AR_Force.231
   :c_This_is_a: non-functional
   :c_Release: AP_V1_RD1
   :c_Maturity: accepted
   :c_Implementation: implemented

   text, tables ,etc

我需要提取所有需求部分并使用 python、docutils 放入字典

【问题讨论】:

  • 如果您想要一个更好的答案,您需要说明您遇到的具体问题,以及您的 work in progress 代码示例。

标签: python restructuredtext docutils


【解决方案1】:

对于commentrequirement 指令,您必须使用implement Directive classes,以便您可以将第一个文档翻译成文档树,然后您可以将其翻译成所需的字典形式。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-06-15
    • 1970-01-01
    • 1970-01-01
    • 2017-10-22
    • 2015-11-04
    • 2020-01-29
    • 1970-01-01
    相关资源
    最近更新 更多