跳转到主要内容

一个用于从 requirement.txt 生成 rst/markdown 以显示 Python 包依赖项的 Sphinx 扩展

项目描述

sphinxcontrib-requirements-txt

readthedocs pre-commit.ci status github/workflow codecov

github/downloads github/downloads/latest github/issues github/issues-closed github/issues-pr github/issues-pr-closed github/discussions github/milestones github/forks github/stars github/watchers github/contributors github/commit-activity github/last-commit github/release-date

github/license github/languages github/languages/top github/directory-file-count github/code-size github/repo-size github/v

pypi/status pypi/v pypi/downloads pypi/format pypi/implementation pypi/pyversions

一个用于从 requirement.txt 生成 rst/markdown 以显示 Python 包依赖项的 Sphinx 扩展。

使用方法

以 MyST 为例。rst 类似。

requirement.txt:

# To complete package names, a cache is needed.
# Every time you change template, the cache must be regenerated.
#
# ```shell
# $ pkgbuild-language-server --print-config cache
# /home/wzy/.cache/pacman.json
# ```

pyalpm
# See <https://wiki.archlinux.org.cn/title/Namcap>.
git+git://gitlab.archlinux.org/pacman/namcap

docs/conf.py:

# ...
extensions = [
    "myst_parser",
    "sphinxcontrib.requirements_txt",
]
# ...

docs/index.md:

```{requirements} ../requirements.txt
```

然后

cd docs && sphinx-build . _build/html
cd -
xdg-open docs/_build/html/index.html

生成的 markdown 将被插入并渲染。您可以看到

screenshot

自定义

```{requirements} /the/path/of/requirements.txt
---
title: Dependence
template: /the/path/of/template.j2
---
```
  • /the/path/of/requirements.txt 可以是一个 glob 表达式。
  • title 可以包含 {title},它将被转换为 requirement 文件的基本名称。例如,requirements/dev.txt 将转换为 dev
  • template 是一个 jinja2 文件。参见 jinja2 语法示例

替代方案

查看 readthedocs 了解更多信息。

项目详情


下载文件

下载适合您平台的文件。如果您不确定选择哪个,请了解有关 安装包 的更多信息。

源代码分发

sphinxcontrib-requirements-txt-0.0.4.tar.gz (25.6 kB 查看哈希值)

上传时间 源代码

构建分发

sphinxcontrib_requirements_txt-0.0.4-py3-none-any.whl (18.9 kB 查看哈希值)

上传时间 Python 3

支持