chore(deps): update dependency mkdocs to v1.4.0 (main) #91

Merged
decentral1se merged 1 commits from renovate/main-mkdocs-1.x into main 2022-10-02 22:09:21 +00:00
Member

This PR contains the following updates:

Package Update Change
mkdocs (source) minor ==1.3.1 -> ==1.4.0

Release Notes

mkdocs/mkdocs

v1.4.0

Compare Source

Feature upgrades

Hooks (#​2978)

The new hooks: config allows you to add plugin-like event handlers from local Python files, without needing to set up and install an actual plugin.

See documentation.

edit_uri flexibility (#​2927)

There is a new edit_uri_template: config.
It works like edit_uri but more generally covers ways to construct an edit URL.
See documentation.

Additionally, the edit_uri functionality will now fully work even if repo_url is omitted (#​2928)

Upgrades for plugin developers

NOTE: This release has big changes to the implementation of plugins and their configs. But, the intention is to have zero breaking changes in all reasonably common use cases. Or at the very least if a code fix is required, there should always be a way to stay compatible with older MkDocs versions. Please report if this release breaks something.

Customize event order for plugin event handlers (#​2973)

Plugins can now choose to set a priority value for their event handlers. This can override the old behavior where for each event type, the handlers are called in the order that their plugins appear in the plugins config.

If this is set, events with higher priority are called first. Events without a chosen priority get a default of 0. Events that have the same priority are ordered as they appear in the config.

Recommended priority values: 100 "first", 50 "early", 0 "default", -50 "late", -100 "last".
As different plugins discover more precise relations to each other, the values should be further tweaked.

See documentation.

New events that persist across builds in mkdocs serve (#​2972)

The new events are on_startup and on_shutdown. They run at the very beginning and very end of an mkdocs invocation.
on_startup also receives information on how mkdocs was invoked (e.g. serve --dirtyreload).

See documentation.

Replace File.src_path to not deal with backslashes (#​2930)

The property src_path uses backslashes on Windows, which doesn't make sense as it's a virtual path.
To not make a breaking change, there's no change to how this property is used, but now you should:

  • Use File.src_uri instead of File.src_path
  • and File.dest_uri instead of File.dest_path.

These consistently use forward slashes, and are now the definitive source that MkDocs itself uses.

See source code.

As a related tip: you should also stop using os.path.* or pathlib.Path() to deal with these paths, and instead use posixpath.* or pathlib.PurePosixPath()

MkDocs is type-annotated, ready for use with mypy (#​2941, #​2970)
Type annotations for event handler methods (#​2931)

MkDocs' plugin event methods now have type annotations. You might have been adding annotations to events already, but now they will be validated to match the original.

See source code and documentation.

One big update is that now you should annotate method parameters more specifically as config: defaults.MkDocsConfig instead of config: base.Config. This not only makes it clear that it is the main config of MkDocs itself, but also provides type-safe access through attributes of the object (see next section).

See source code and documentation.

Rework ConfigOption schemas as class-based (#​2962)

When developing a plugin, the settings that it accepts used to be specified in the config_scheme variable on the plugin class.
This approach is now soft-deprecated, and instead you should specify the config in a sub-class of base.Config.

Old example:

from mkdocs import plugins
from mkdocs.config import base, config_options

class MyPlugin(plugins.BasePlugin):
    config_scheme = (
        ('foo', config_options.Type(int)),
        ('bar', config_options.Type(str, default='')),
    )

    def on_page_markdown(self, markdown: str, *, config: base.Config, **kwargs):
        if self.config['foo'] < 5:
            if config['site_url'].startswith('http:'):
                return markdown + self.config['baz']

This code snippet actually has many mistakes but it will pass all type checks and silently run and even succeed in some cases.

So, on to the new equivalent example, changed to new-style schema and attribute-based access:
(Complaints from "mypy" added inline)

from mkdocs import plugins
from mkdocs.config import base, config_options as c

class MyPluginConfig(base.Config):
    foo = c.Optional(c.Type(int))
    bar = c.Type(str, default='')

class MyPlugin(plugins.BasePlugin[MyPluginConfig]):
    def on_page_markdown(self, markdown: str, *, config: base.MkDocsConfig, **kwargs):
        if self.config.foo < 5:  # Error, `foo` might be `None`, need to check first.
            if config.site_url.startswith('http:'):  # Error, MkDocs' `site_url` also might be `None`.
                return markdown + self.config.baz  # Error, no such attribute `baz`!

This lets you notice the errors from a static type checker before running the code and fix them as such:

class MyPlugin(plugins.BasePlugin[MyPluginConfig]):
    def on_page_markdown(self, markdown: str, *, config: base.MkDocsConfig, **kwargs):
        if self.config.foo is not None and self.config.foo < 5:  # OK, `int < int` is valid.
            if (config.site_url or '').startswith('http:'):  # OK, `str.startswith(str)` is valid.
                return markdown + self.config.bar  # OK, `str + str` is valid.

See documentation.

Also notice that we had to explicitly mark the config attribute foo as Optional.
The new-style config has all attributes marked as required by default, and specifying required=False or required=True is not allowed!

New: config_options.Optional (#​2962)

Wrapping something into Optional is conceptually similar to "I want the default to be None" -- and you have to express it like that, because writing default=None doesn't actually work.

Breaking change: the method BaseConfigOption.is_required() was removed. Use .required instead. (#​2938)
And even the required property should be mostly unused now.
For class-based configs, there's a new definition for whether an option is "required":

  • It has no default, and
  • It is not wrapped into config_options.Optional.
New: config_options.ListOfItems (#​2938)

Defines a list of items that each must adhere to the same constraint. Kind of like a validated Type(list)

Examples how to express a list of integers (with from mkdocs.config import config_options as c):

Description | Code entry
----------- | ----------
Required to specify | foo = c.ListOfItems(c.Type(int))
Optional, default is [] | foo = c.ListOfItems(c.Type(int), default=[])
Optional, default is None | foo = c.Optional(c.ListOfItems(c.Type(int)))

See more examples in documentation.

Updated: config_options.SubConfig (#​2807)

SubConfig used to silently ignore all validation of its config options. Now you should pass validate=True to it or just use new class-based configs where this became the default.

So, it can be used to validate a nested sub-dict with all keys pre-defined and value types strictly validated.

See examples in documentation.

Other changes to config options

URL's default is now None instead of ''. This can still be checked for truthiness in the same way - if config.some_url: (#​2962)

FilesystemObject is no longer abstract and can be used directly, standing for "file or directory" with optional existence checking (#​2938)

Bug fixes:

  • Fix SubConfig, ConfigItems, MarkdownExtensions to not leak values across different instances (#​2916, #​2290)
  • SubConfig raises the correct kind of validation error without a stack trace (#​2938)
  • Fix dot-separated redirect in config_options.Deprecated(moved_to) (#​2963)

Tweaked logic for handling ConfigOption.default (#​2938)

Deprecated config option classes: ConfigItems (#​2983), OptionallyRequired (#​2962), RepoURL (#​2927)

Theme updates

  • Styles of admonitions in "MkDocs" theme (#​2981):

    • Update colors to increase contrast
    • Apply admonition styles also to <details> tag, to support Markdown extensions that provide it (pymdownx.details, callouts)
  • Built-in themes now also support these languages:

Future compatibility

  • extra_css: and extra_javascript: warn if a backslash \ is passed to them. (#​2930, #​2984)

  • Show DeprecationWarnings as INFO messages. (#​2907)

    If any plugin or extension that you use relies on deprecated functionality of other libraries, it is at risk of breaking in the near future. Plugin developers should address these in a timely manner.

  • Avoid a dependency on importlib_metadata starting from Python 3.10 (#​2959)

  • Drop support for Python 3.6 (#​2948)

Incompatible changes to public APIs
  • mkdocs.utils:
    • create_media_urls and normalize_url warn if a backslash \ is passed to them. (#​2930)
    • is_markdown_file stops accepting case-insensitive variants such as .MD, which is how MkDocs build was already operating. (#​2912)
    • Hard-deprecated: modified_time, reduce_list, get_html_path, get_url_path, is_html_file, is_template_file. (#​2912)

Miscellaneous

  • If a plugin adds paths to watch in LiveReloadServer, it can now unwatch them. (#​2777)

  • Bugfix (regression in 1.2): Support listening on an IPv6 address in mkdocs serve. (#​2951)

Other small improvements; see commit log.


Configuration

📅 Schedule: At any time (no schedule defined).

🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

♻️ Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 Ignore: Close this PR and you won't be reminded about this update again.


  • If you want to rebase/retry this PR, click this checkbox.

This PR has been generated by Renovate Bot.

This PR contains the following updates: | Package | Update | Change | |---|---|---| | [mkdocs](https://www.mkdocs.org) ([source](https://github.com/mkdocs/mkdocs)) | minor | `==1.3.1` -> `==1.4.0` | --- ### Release Notes <details> <summary>mkdocs/mkdocs</summary> ### [`v1.4.0`](https://github.com/mkdocs/mkdocs/releases/1.4.0) [Compare Source](https://github.com/mkdocs/mkdocs/compare/1.3.1...1.4.0) #### Feature upgrades ##### Hooks ([#&#8203;2978](https://github.com/mkdocs/mkdocs/issues/2978)) The new `hooks:` config allows you to add plugin-like event handlers from local Python files, without needing to set up and install an actual plugin. See [**documentation**](https://www.mkdocs.org/user-guide/configuration/#hooks). ##### `edit_uri` flexibility ([#&#8203;2927](https://github.com/mkdocs/mkdocs/issues/2927)) There is a new `edit_uri_template:` config.\ It works like `edit_uri` but more generally covers ways to construct an edit URL.\ See [**documentation**](https://www.mkdocs.org/user-guide/configuration/#edit_uri_template). Additionally, the `edit_uri` functionality will now fully work even if `repo_url` is omitted ([#&#8203;2928](https://github.com/mkdocs/mkdocs/issues/2928)) #### Upgrades for plugin developers NOTE: This release has big changes to the implementation of plugins and their configs. But, the intention is to have zero breaking changes in all reasonably common use cases. Or at the very least if a code fix is required, there should always be a way to stay compatible with older MkDocs versions. Please report if this release breaks something. ##### Customize event order for plugin event handlers ([#&#8203;2973](https://github.com/mkdocs/mkdocs/issues/2973)) Plugins can now choose to set a priority value for their event handlers. This can override the old behavior where for each event type, the handlers are called in the order that their plugins appear in the [`plugins` config](https://www.mkdocs.org/user-guide/configuration/#plugins). If this is set, events with higher priority are called first. Events without a chosen priority get a default of 0. Events that have the same priority are ordered as they appear in the config. Recommended priority values: `100` "first", `50` "early", `0` "default", `-50` "late", `-100` "last".\ As different plugins discover more precise relations to each other, the values should be further tweaked. See [**documentation**](https://www.mkdocs.org/dev-guide/plugins/#event-priorities). ##### New events that persist across builds in `mkdocs serve` ([#&#8203;2972](https://github.com/mkdocs/mkdocs/issues/2972)) The new events are `on_startup` and `on_shutdown`. They run at the very beginning and very end of an `mkdocs` invocation.\ `on_startup` also receives information on how `mkdocs` was invoked (e.g. `serve` `--dirtyreload`). See [**documentation**](https://www.mkdocs.org/dev-guide/plugins/#events). ##### Replace `File.src_path` to not deal with backslashes ([#&#8203;2930](https://github.com/mkdocs/mkdocs/issues/2930)) The property `src_path` uses backslashes on Windows, which doesn't make sense as it's a virtual path.\ To not make a breaking change, there's no change to how *this* property is used, but now you should: - Use **`File.src_uri`** instead of `File.src_path` - and **`File.dest_uri`** instead of `File.dest_path`. These consistently use forward slashes, and are now the definitive source that MkDocs itself uses. See [source code](https://github.com/mkdocs/mkdocs/blob/1.4.0/mkdocs/structure/files.py#L151). As a related tip: you should also stop using `os.path.*` or `pathlib.Path()` to deal with these paths, and instead use `posixpath.*` or `pathlib.PurePosixPath()` ##### MkDocs is type-annotated, ready for use with [mypy](https://mypy.readthedocs.io/) ([#&#8203;2941](https://github.com/mkdocs/mkdocs/issues/2941), [#&#8203;2970](https://github.com/mkdocs/mkdocs/issues/2970)) ##### Type annotations for event handler methods ([#&#8203;2931](https://github.com/mkdocs/mkdocs/issues/2931)) MkDocs' plugin event methods now have type annotations. You might have been adding annotations to events already, but now they will be validated to match the original. See [source code](https://github.com/mkdocs/mkdocs/blob/1.4.0/mkdocs/plugins.py#L165) and [documentation](https://www.mkdocs.org/dev-guide/plugins/#events). One big update is that now you should annotate method parameters more specifically as `config: defaults.MkDocsConfig` instead of `config: base.Config`. This not only makes it clear that it is the [main config of MkDocs itself](https://github.com/mkdocs/mkdocs/blob/1.4.0/mkdocs/config/defaults.py), but also provides type-safe access through attributes of the object (see next section). See [source code](https://github.com/mkdocs/mkdocs/blob/1.4.0/mkdocs/config/defaults.py) and [documentation](https://www.mkdocs.org/dev-guide/plugins/#on_event_name). ##### Rework ConfigOption schemas as class-based ([#&#8203;2962](https://github.com/mkdocs/mkdocs/issues/2962)) When developing a plugin, the settings that it accepts used to be specified in the `config_scheme` variable on the plugin class.\ This approach is now soft-deprecated, and instead you should specify the config in a sub-class of `base.Config`. Old example: ```python from mkdocs import plugins from mkdocs.config import base, config_options class MyPlugin(plugins.BasePlugin): config_scheme = ( ('foo', config_options.Type(int)), ('bar', config_options.Type(str, default='')), ) def on_page_markdown(self, markdown: str, *, config: base.Config, **kwargs): if self.config['foo'] < 5: if config['site_url'].startswith('http:'): return markdown + self.config['baz'] ``` This code snippet actually has many mistakes but it will pass all type checks and silently run and even succeed in some cases. So, on to the new equivalent example, changed to new-style schema and attribute-based access:\ (Complaints from "mypy" added inline) ```python from mkdocs import plugins from mkdocs.config import base, config_options as c class MyPluginConfig(base.Config): foo = c.Optional(c.Type(int)) bar = c.Type(str, default='') class MyPlugin(plugins.BasePlugin[MyPluginConfig]): def on_page_markdown(self, markdown: str, *, config: base.MkDocsConfig, **kwargs): if self.config.foo < 5: # Error, `foo` might be `None`, need to check first. if config.site_url.startswith('http:'): # Error, MkDocs' `site_url` also might be `None`. return markdown + self.config.baz # Error, no such attribute `baz`! ``` This lets you notice the errors from a static type checker before running the code and fix them as such: ```python class MyPlugin(plugins.BasePlugin[MyPluginConfig]): def on_page_markdown(self, markdown: str, *, config: base.MkDocsConfig, **kwargs): if self.config.foo is not None and self.config.foo < 5: # OK, `int < int` is valid. if (config.site_url or '').startswith('http:'): # OK, `str.startswith(str)` is valid. return markdown + self.config.bar # OK, `str + str` is valid. ``` See [**documentation**](https://www.mkdocs.org/dev-guide/plugins/#config_scheme). Also notice that we had to explicitly mark the config attribute `foo` as `Optional`.\ The new-style config has all attributes marked as required by default, and specifying `required=False` or `required=True` is not allowed! ##### New: `config_options.Optional` ([#&#8203;2962](https://github.com/mkdocs/mkdocs/issues/2962)) Wrapping something into `Optional` is conceptually similar to "I want the default to be `None`" -- and you *have* to express it like that, because writing `default=None` doesn't actually work. Breaking change: the method `BaseConfigOption.is_required()` was removed. Use `.required` instead. ([#&#8203;2938](https://github.com/mkdocs/mkdocs/issues/2938))\ And even the `required` property should be mostly unused now.\ For class-based configs, there's a new definition for whether an option is "required": - It has no default, and - It is not wrapped into `config_options.Optional`. ##### New: `config_options.ListOfItems` ([#&#8203;2938](https://github.com/mkdocs/mkdocs/issues/2938)) Defines a list of items that each must adhere to the same constraint. Kind of like a validated `Type(list)` Examples how to express a list of integers (with `from mkdocs.config import config_options as c`): Description | Code entry \----------- | ---------- Required to specify | `foo = c.ListOfItems(c.Type(int))` Optional, default is \[] | `foo = c.ListOfItems(c.Type(int), default=[])` Optional, default is None | `foo = c.Optional(c.ListOfItems(c.Type(int)))` See more [examples in **documentation**](https://www.mkdocs.org/dev-guide/plugins/#examples-of-config-definitions). ##### Updated: `config_options.SubConfig` ([#&#8203;2807](https://github.com/mkdocs/mkdocs/issues/2807)) `SubConfig` used to silently ignore all validation of its config options. Now you should pass `validate=True` to it or just use new class-based configs where this became the default. So, it can be used to validate a nested sub-dict with all keys pre-defined and value types strictly validated. See [examples in **documentation**](https://www.mkdocs.org/dev-guide/plugins/#examples-of-config-definitions). ##### Other changes to config options `URL`'s default is now `None` instead of `''`. This can still be checked for truthiness in the same way - `if config.some_url:` ([#&#8203;2962](https://github.com/mkdocs/mkdocs/issues/2962)) `FilesystemObject` is no longer abstract and can be used directly, standing for "file or directory" with optional existence checking ([#&#8203;2938](https://github.com/mkdocs/mkdocs/issues/2938)) Bug fixes: - Fix `SubConfig`, `ConfigItems`, `MarkdownExtensions` to not leak values across different instances ([#&#8203;2916](https://github.com/mkdocs/mkdocs/issues/2916), [#&#8203;2290](https://github.com/mkdocs/mkdocs/issues/2290)) - `SubConfig` raises the correct kind of validation error without a stack trace ([#&#8203;2938](https://github.com/mkdocs/mkdocs/issues/2938)) - Fix dot-separated redirect in `config_options.Deprecated(moved_to)` ([#&#8203;2963](https://github.com/mkdocs/mkdocs/issues/2963)) Tweaked logic for handling `ConfigOption.default` ([#&#8203;2938](https://github.com/mkdocs/mkdocs/issues/2938)) Deprecated config option classes: `ConfigItems` ([#&#8203;2983](https://github.com/mkdocs/mkdocs/issues/2983)), `OptionallyRequired` ([#&#8203;2962](https://github.com/mkdocs/mkdocs/issues/2962)), `RepoURL` ([#&#8203;2927](https://github.com/mkdocs/mkdocs/issues/2927)) #### Theme updates - Styles of admonitions in "MkDocs" theme ([#&#8203;2981](https://github.com/mkdocs/mkdocs/issues/2981)): - Update colors to increase contrast - Apply admonition styles also to `<details>` tag, to support Markdown extensions that provide it ([pymdownx.details](https://facelessuser.github.io/pymdown-extensions/extensions/details/), [callouts](https://oprypin.github.io/markdown-callouts/#collapsible-blocks)) - Built-in themes now also support these languages: - Russian ([#&#8203;2976](https://github.com/mkdocs/mkdocs/issues/2976)) - Turkish (Turkey) ([#&#8203;2946](https://github.com/mkdocs/mkdocs/issues/2946)) - Ukrainian ([#&#8203;2980](https://github.com/mkdocs/mkdocs/issues/2980)) #### Future compatibility - `extra_css:` and `extra_javascript:` warn if a backslash `\` is passed to them. ([#&#8203;2930](https://github.com/mkdocs/mkdocs/issues/2930), [#&#8203;2984](https://github.com/mkdocs/mkdocs/issues/2984)) - Show `DeprecationWarning`s as INFO messages. ([#&#8203;2907](https://github.com/mkdocs/mkdocs/issues/2907)) If any plugin or extension that you use relies on deprecated functionality of other libraries, it is at risk of breaking in the near future. Plugin developers should address these in a timely manner. - Avoid a dependency on `importlib_metadata` starting from Python 3.10 ([#&#8203;2959](https://github.com/mkdocs/mkdocs/issues/2959)) - Drop support for Python 3.6 ([#&#8203;2948](https://github.com/mkdocs/mkdocs/issues/2948)) ##### Incompatible changes to public APIs - `mkdocs.utils`: - `create_media_urls` and `normalize_url` warn if a backslash `\` is passed to them. ([#&#8203;2930](https://github.com/mkdocs/mkdocs/issues/2930)) - `is_markdown_file` stops accepting case-insensitive variants such as `.MD`, which is how MkDocs build was already operating. ([#&#8203;2912](https://github.com/mkdocs/mkdocs/issues/2912)) - Hard-deprecated: `modified_time`, `reduce_list`, `get_html_path`, `get_url_path`, `is_html_file`, `is_template_file`. ([#&#8203;2912](https://github.com/mkdocs/mkdocs/issues/2912)) #### Miscellaneous - If a plugin adds paths to `watch` in `LiveReloadServer`, it can now `unwatch` them. ([#&#8203;2777](https://github.com/mkdocs/mkdocs/issues/2777)) - Bugfix (regression in 1.2): Support listening on an IPv6 address in `mkdocs serve`. ([#&#8203;2951](https://github.com/mkdocs/mkdocs/issues/2951)) Other small improvements; see [commit log](https://github.com/mkdocs/mkdocs/compare/1.3.1...1.4.0). </details> --- ### Configuration :date: **Schedule**: At any time (no schedule defined). :vertical_traffic_light: **Automerge**: Disabled by config. Please merge this manually once you are satisfied. :recycle: **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. :no_bell: **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, click this checkbox. --- This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
renovate-bot added 1 commit 2022-09-28 07:01:59 +00:00
continuous-integration/drone/push Build is passing Details
34a69e3a3b
chore(deps): update dependency mkdocs to v1.4.0
decentral1se merged commit 34a69e3a3b into main 2022-10-02 22:09:21 +00:00
Sign in to join this conversation.
No reviewers
No Label
No Milestone
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: coop-cloud/docs.coopcloud.tech#91
No description provided.