https://github.com/mkdocs/get-deps
An extra command for MkDocs that infers required PyPI packages from `plugins` in mkdocs.yml
https://github.com/mkdocs/get-deps
Last synced: 6 months ago
JSON representation
An extra command for MkDocs that infers required PyPI packages from `plugins` in mkdocs.yml
- Host: GitHub
- URL: https://github.com/mkdocs/get-deps
- Owner: mkdocs
- License: mit
- Created: 2023-11-19T15:50:28.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2024-02-11T18:55:11.000Z (about 2 years ago)
- Last Synced: 2025-02-04T07:37:12.356Z (about 1 year ago)
- Language: Python
- Size: 26.4 KB
- Stars: 1
- Watchers: 4
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE.md
Awesome Lists containing this project
README
# mkdocs-get-deps
**An extra command for [MkDocs][] that infers required PyPI packages from `plugins` in mkdocs.yml.**
[](https://pypi.org/project/mkdocs-get-deps/)
[](https://github.com/mkdocs/get-deps/blob/master/LICENSE.md)
[](https://github.com/mkdocs/get-deps/actions?query=event%3Apush+branch%3Amaster)
Installation:Alternatively through MkDocs itself:
```bash
pip install mkdocs-get-deps
```
```bash
pip install mkdocs
```
This command guesses the Python dependencies that a MkDocs site requires in order to build. It simply prints the PyPI packages that need to be installed. In the terminal it can be combined directly with a `pip install` command, as per the last example below:
Usage:Alternatively through MkDocs itself:
```bash
# Print dependencies of the current project
mkdocs-get-deps
# Save them into a file
mkdocs-get-deps > requirements.txt
# Install dependencies on the fly
pip install $(mkdocs-get-deps)
```
```bash
mkdocs get-deps
mkdocs get-deps > requirements.txt
pip install -r requirements.txt
pip install $(mkdocs get-deps)
```
The idea is that right after running this command, you can directly follow it up with `mkdocs build` and it will almost always "just work", without needing to think which dependencies to install.
The way it works is by scanning [`mkdocs.yml`] for `themes:`, `plugins:`, `markdown_extensions:` items and doing a reverse lookup based on a large list of known projects (catalog, see below).
Of course, you're encouraged to use a "virtualenv" with such a command. Also note that for environments that require stability (for example CI) directly installing deps in this way is not a very reliable approach as it precludes dependency pinning.
The command allows overriding which config file is used (instead of `mkdocs.yml` in the current directory) as well as which catalog of projects is used (instead of downloading it from the default location). See [`mkdocs get-deps --help`](https://www.mkdocs.org/user-guide/cli/#mkdocs-get-deps).
## MkDocs' official catalog of plugins
Check out and add all your general-purpose plugins, themes and extensions there, so that they can be looked up through `mkdocs get-deps`.
[MkDocs]: https://www.mkdocs.org/
[`mkdocs.yml`]: https://www.mkdocs.org/user-guide/configuration/