A sphinx extension to generate a rst/markdown to display the dependencies of
a python package from requirement.txt.
Take MyST as an example. rst is similar.
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/title/Namcap>.
git+git://gitlab.archlinux.org/pacman/namcap
docs/conf.py:
# ...
extensions = [
"myst_parser",
"sphinxcontrib.requirements_txt",
]
# ...docs/index.md:
```{requirements} ../requirements.txt
```Then:
cd docs && sphinx-build . _build/html
cd -
xdg-open docs/_build/html/index.htmlA generated markdown will be inserted and rendered. You see:
```{requirements} /the/path/of/requirements.txt
---
title: Dependence
template: /the/path/of/template.j2
---
```/the/path/of/requirements.txtcan be a glob expression.titlecan contain{title}, which will be converted to the base name of requirement file. Such asrequirements/dev.txtwill be converted todev.templateis a jinja2 file. See jinja2 syntax and examples.
