restructuredText 文档字符串到 .md 文件

问题描述

我有一个 Python 项目,我使用 restructuredText 来注释/记录我的每个类/函数。这是我的文档字符串示例:

"""
Updates the contacts birth date in batch
:param nb_contacts: nb_contacts: number of contacts to update
:param batch_size: size of the batch
:param context: airflow context
:return: true if update is successful
"""

我想从我的代码生成 .md 文件。反正有办法吗?

解决方法

Sphinx 可能就是您要找的,另外还可以将生成的文档发布到您可能已经熟悉的 ReadTheDocs

任何 .rst 文件都可以使用 pandoc 严格转换为 .md(或任何其他格式),您可以在其中执行以下操作:

pandoc -f page.rst -t page.md

,

从 reStructuredText 生成 Markdown 似乎是一种不常见的组合。您会在 Markdown output for Sphinx based documentation

上找到与您类似的问题