Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New get-deps command: infer PyPI dependencies from mkdocs.yml #3205

Merged
merged 6 commits into from Jun 9, 2023

Conversation

oprypin
Copy link
Contributor

@oprypin oprypin commented May 1, 2023

The user story is that the following command should let you "just build" any MkDocs site:

pip install $(mkdocs get-deps) && mkdocs build

This cross-references 2 files:

  • mkdocs.yml - theme, plugins, markdown_extensions
  • projects.yaml - a registry of all popular MkDocs-related projects and which entry points they provide - downloaded on the fly

-and prints the names of Python packages from PyPI that need to be installed to build the current MkDocs project


Thanks @pawamoy for inspiration and starting https://github.com/pawamoy/best-of-mkdocs

The user story is that the following command should let you "just build" any MkDocs site:

    pip install $(mkdocs get-deps) && mkdocs build

This cross-references 2 files:

* mkdocs.yml - `theme`, `plugins`, `markdown_extensions`
* projects.yaml - a registry of all popular MkDocs-related projects and which entry points they provide - downloaded on the fly

-and prints the names of Python packages from PyPI that need to be installed to build the current MkDocs project
@pawamoy
Copy link
Sponsor Contributor

pawamoy commented May 1, 2023

Thank you @oprypin, that's a great addition!

Copy link
Sponsor Contributor

@pawamoy pawamoy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing n in "dependencies" (first commit summary)

"""Get names of plugins/extensions from the config - in either a list of dicts or a dict."""

def dig(cfg, keys: str):
"""Receives a string such 'foo.bar' and returns `cfg['foo']['bar']`, or `NotFound`.
Copy link
Sponsor Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"""Receives a string such 'foo.bar' and returns `cfg['foo']['bar']`, or `NotFound`.
"""Receives a string such as 'foo.bar' and returns `cfg['foo']['bar']`, or `NotFound`.

@oprypin oprypin changed the title New get-deps command: infer PyPI depedencies from mkdocs.yml New get-deps command: infer PyPI dependencies from mkdocs.yml Jun 6, 2023
@oprypin
Copy link
Contributor Author

oprypin commented Jun 6, 2023

Missing n in "dependencies" (first commit summary)

Welp, that's staying that way, that commit is very old 🥲

@pawamoy
Copy link
Sponsor Contributor

pawamoy commented Jun 6, 2023

Let plugins declare their own optional dependencies
This is inferred from particular config keys
The current known plugin in need of this is mkdocstrings (handlers)

It means I can add an extra_dependencies key for mkdocstrings in the catalog, listing my extra/optional deps?

@oprypin
Copy link
Contributor Author

oprypin commented Jun 6, 2023

Yes and it's already there

https://github.com/mkdocs/catalog/blob/269c3bfb3ff9e0bb9a7b588e52e227206c914c69/projects.yaml#L258

Or did you have something else in mind?

@pawamoy
Copy link
Sponsor Contributor

pawamoy commented Jun 6, 2023

Nice! No no, just asking.

What do the keys mean in:

  extra_dependencies:
    plugins.mkdocstrings.handlers.crystal: mkdocstrings-crystal
    plugins.mkdocstrings.handlers.python: mkdocstrings-python

plugins to differentiate from... themes or extensions I suppose? The rest (mkdocstrings.handlers.python) is arbitrary?

@pawamoy
Copy link
Sponsor Contributor

pawamoy commented Jun 6, 2023

Ah, I think I got it, it's the keys in mkdocs.yml 👍

This is inferred from particular config keys

The current known plugin in need of this is mkdocstrings (handlers)
@oprypin oprypin merged commit f2d14c5 into master Jun 9, 2023
30 checks passed
@oprypin oprypin deleted the getdeps branch June 9, 2023 18:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants