Skip to content

Commit

Permalink
Report usage-based warnings as user-facing messages
Browse files Browse the repository at this point in the history
The other warnings are developer-facing and should indeed remain as DeprecationWarning.
  • Loading branch information
oprypin committed Aug 16, 2022
1 parent 252b9c6 commit c812912
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
12 changes: 7 additions & 5 deletions src/mkdocstrings/extension.py
Expand Up @@ -21,10 +21,10 @@
option_x: etc
```
"""
import functools
import re
from collections import ChainMap
from typing import Any, MutableSequence, Tuple
from warnings import warn
from xml.etree.ElementTree import Element

import yaml
Expand Down Expand Up @@ -182,10 +182,7 @@ def _process_block(
options = ChainMap(local_options, deprecated_local_options, global_options, deprecated_global_options)

if deprecated_global_options or deprecated_local_options:
warn(
"'selection' and 'rendering' are deprecated and merged into a single 'options' YAML key",
DeprecationWarning,
)
self._warn_about_options_key()

if heading_level:
options = ChainMap(options, {"heading_level": heading_level}) # like setdefault
Expand Down Expand Up @@ -216,6 +213,11 @@ def _process_block(

return rendered, handler, data

@staticmethod
@functools.lru_cache(maxsize=None)
def _warn_about_options_key():
log.info("'selection' and 'rendering' are deprecated and merged into a single 'options' YAML key")


class _PostProcessor(Treeprocessor):
def run(self, root: Element):
Expand Down
11 changes: 6 additions & 5 deletions src/mkdocstrings/plugin.py
Expand Up @@ -126,11 +126,6 @@ def on_serve(self, server: LiveReloadServer, builder: Callable, **kwargs: Any):
**kwargs: Additional arguments passed by MkDocs.
"""
if self.config["watch"]:
warn(
"mkdocstrings' watch feature is deprecated in favor of MkDocs' watch feature, "
"see https://www.mkdocs.org/user-guide/configuration/#watch.",
DeprecationWarning,
)
for element in self.config["watch"]:
log.debug(f"Adding directory '{element}' to watcher")
server.watch(element, builder)
Expand Down Expand Up @@ -205,6 +200,12 @@ def on_config(self, config: Config, **kwargs: Any) -> Config: # noqa: W0613 (un
self._inv_futures.append(future)
inv_loader.shutdown(wait=False)

if self.config["watch"]:
log.info(
"mkdocstrings' watch feature is deprecated in favor of MkDocs' watch feature, "
"see https://www.mkdocs.org/user-guide/configuration/#watch",
)

return config

@property
Expand Down

0 comments on commit c812912

Please sign in to comment.