# Path: mkdocs/config/base.py
# class Config(UserDict):
#     """
#     MkDocs Configuration dict
# 
#     This is a fairly simple extension of a standard dictionary. It adds methods
#     for running validation on the structure and contents.
#     """
# 
#     def __init__(self, schema, config_file_path=None):
#         """
#         The schema is a Python dict which maps the config name to a validator.
#         """
# 
#         self._schema = schema
#         self._schema_keys = set(dict(schema).keys())
#         # Ensure config_file_path is a Unicode string
#         if config_file_path is not None and not isinstance(config_file_path, str):
#             try:
#                 # Assume config_file_path is encoded with the file system encoding.
#                 config_file_path = config_file_path.decode(encoding=sys.getfilesystemencoding())
#             except UnicodeDecodeError:
#                 raise ValidationError("config_file_path is not a Unicode string.")
#         self.config_file_path = config_file_path
#         self.data = {}
# 
#         self.user_configs = []
#         self.set_defaults()
# 
#     def set_defaults(self):
#         """
#         Set the base config by going through each validator and getting the
#         default if it has one.
#         """
# 
#         for key, config_option in self._schema:
#             self[key] = config_option.default
# 
#     def _validate(self):
# 
#         failed, warnings = [], []
# 
#         for key, config_option in self._schema:
#             try:
#                 value = self.get(key)
#                 self[key] = config_option.validate(value)
#                 warnings.extend([(key, w) for w in config_option.warnings])
#                 config_option.reset_warnings()
#             except ValidationError as e:
#                 failed.append((key, e))
# 
#         for key in (set(self.keys()) - self._schema_keys):
#             warnings.append((
#                 key, f"Unrecognised configuration name: {key}"
#             ))
# 
#         return failed, warnings
# 
#     def _pre_validate(self):
# 
#         failed, warnings = [], []
# 
#         for key, config_option in self._schema:
#             try:
#                 config_option.pre_validation(self, key_name=key)
#                 warnings.extend([(key, w) for w in config_option.warnings])
#                 config_option.reset_warnings()
#             except ValidationError as e:
#                 failed.append((key, e))
# 
#         return failed, warnings
# 
#     def _post_validate(self):
# 
#         failed, warnings = [], []
# 
#         for key, config_option in self._schema:
#             try:
#                 config_option.post_validation(self, key_name=key)
#                 warnings.extend([(key, w) for w in config_option.warnings])
#                 config_option.reset_warnings()
#             except ValidationError as e:
#                 failed.append((key, e))
# 
#         return failed, warnings
# 
#     def validate(self):
# 
#         failed, warnings = self._pre_validate()
# 
#         run_failed, run_warnings = self._validate()
# 
#         failed.extend(run_failed)
#         warnings.extend(run_warnings)
# 
#         # Only run the post validation steps if there are no failures, warnings
#         # are okay.
#         if len(failed) == 0:
#             post_failed, post_warnings = self._post_validate()
#             failed.extend(post_failed)
#             warnings.extend(post_warnings)
# 
#         return failed, warnings
# 
#     def load_dict(self, patch):
#         """ Load config options from a dictionary. """
# 
#         if not isinstance(patch, dict):
#             raise exceptions.ConfigurationError(
#                 "The configuration is invalid. The expected type was a key "
#                 "value mapping (a python dict) but we got an object of type: "
#                 f"{type(patch)}")
# 
#         self.user_configs.append(patch)
#         self.data.update(patch)
# 
#     def load_file(self, config_file):
#         """ Load config options from the open file descriptor of a YAML file. """
#         try:
#             return self.load_dict(utils.yaml_load(config_file))
#         except YAMLError as e:
#             # MkDocs knows and understands ConfigurationErrors
#             raise exceptions.ConfigurationError(
#                 f"MkDocs encountered an error parsing the configuration file: {e}"
#             )


import logging
import importlib_metadata
from collections import OrderedDict
from mkdocs.config.base import Config

def get_plugins():
    """ Return a dict of all installed Plugins as {name: EntryPoint}. """

    plugins = importlib_metadata.entry_points(group='mkdocs.plugins')

    # Allow third-party plugins to override core plugins
    pluginmap = {}
    for plugin in plugins:
        if plugin.name in pluginmap and plugin.value.startswith("mkdocs.contrib."):
            continue

        pluginmap[plugin.name] = plugin

    return pluginmap


class BasePlugin:
    """
    Plugin base class.

    All plugins should subclass this class.
    """

    config_scheme = ()
    config = {}

    def load_config(self, options, config_file_path=None):
        """ Load config from a dict of options. Returns a tuple of (errors, warnings)."""


# Path: mkdocs/config/base.py
# class Config(UserDict):
#     """
#     MkDocs Configuration dict
# 
#     This is a fairly simple extension of a standard dictionary. It adds methods
#     for running validation on the structure and contents.
#     """
# 
#     def __init__(self, schema, config_file_path=None):
#         """
#         The schema is a Python dict which maps the config name to a validator.
#         """
# 
#         self._schema = schema
#         self._schema_keys = set(dict(schema).keys())
#         # Ensure config_file_path is a Unicode string
#         if config_file_path is not None and not isinstance(config_file_path, str):
#             try:
#                 # Assume config_file_path is encoded with the file system encoding.
#                 config_file_path = config_file_path.decode(encoding=sys.getfilesystemencoding())
#             except UnicodeDecodeError:
#                 raise ValidationError("config_file_path is not a Unicode string.")
#         self.config_file_path = config_file_path
#         self.data = {}
# 
#         self.user_configs = []
#         self.set_defaults()
# 
#     def set_defaults(self):
#         """
#         Set the base config by going through each validator and getting the
#         default if it has one.
#         """
# 
#         for key, config_option in self._schema:
#             self[key] = config_option.default
# 
#     def _validate(self):
# 
#         failed, warnings = [], []
# 
#         for key, config_option in self._schema:
#             try:
#                 value = self.get(key)
#                 self[key] = config_option.validate(value)
#                 warnings.extend([(key, w) for w in config_option.warnings])
#                 config_option.reset_warnings()
#             except ValidationError as e:
#                 failed.append((key, e))
# 
#         for key in (set(self.keys()) - self._schema_keys):
#             warnings.append((
#                 key, f"Unrecognised configuration name: {key}"
#             ))
# 
#         return failed, warnings
# 
#     def _pre_validate(self):
# 
#         failed, warnings = [], []
# 
#         for key, config_option in self._schema:
#             try:
#                 config_option.pre_validation(self, key_name=key)
#                 warnings.extend([(key, w) for w in config_option.warnings])
#                 config_option.reset_warnings()
#             except ValidationError as e:
#                 failed.append((key, e))
# 
#         return failed, warnings
# 
#     def _post_validate(self):
# 
#         failed, warnings = [], []
# 
#         for key, config_option in self._schema:
#             try:
#                 config_option.post_validation(self, key_name=key)
#                 warnings.extend([(key, w) for w in config_option.warnings])
#                 config_option.reset_warnings()
#             except ValidationError as e:
#                 failed.append((key, e))
# 
#         return failed, warnings
# 
#     def validate(self):
# 
#         failed, warnings = self._pre_validate()
# 
#         run_failed, run_warnings = self._validate()
# 
#         failed.extend(run_failed)
#         warnings.extend(run_warnings)
# 
#         # Only run the post validation steps if there are no failures, warnings
#         # are okay.
#         if len(failed) == 0:
#             post_failed, post_warnings = self._post_validate()
#             failed.extend(post_failed)
#             warnings.extend(post_warnings)
# 
#         return failed, warnings
# 
#     def load_dict(self, patch):
#         """ Load config options from a dictionary. """
# 
#         if not isinstance(patch, dict):
#             raise exceptions.ConfigurationError(
#                 "The configuration is invalid. The expected type was a key "
#                 "value mapping (a python dict) but we got an object of type: "
#                 f"{type(patch)}")
# 
#         self.user_configs.append(patch)
#         self.data.update(patch)
# 
#     def load_file(self, config_file):
#         """ Load config options from the open file descriptor of a YAML file. """
#         try:
#             return self.load_dict(utils.yaml_load(config_file))
#         except YAMLError as e:
#             # MkDocs knows and understands ConfigurationErrors
#             raise exceptions.ConfigurationError(
#                 f"MkDocs encountered an error parsing the configuration file: {e}"
#             )


# Path: mkdocs/plugins.py
import logging
import importlib_metadata
from collections import OrderedDict
from mkdocs.config.base import Config


def get_plugins():
    """ Return a dict of all installed Plugins as {name: EntryPoint}. """

    plugins = importlib_metadata.entry_points(group='mkdocs.plugins')

    # Allow third-party plugins to override core plugins
    pluginmap = {}
    for plugin in plugins:
        if plugin.name in pluginmap and plugin.value.startswith("mkdocs.contrib."):
            continue

        pluginmap[plugin.name] = plugin

    return pluginmap


class BasePlugin:
    """
    Plugin base class.

    All plugins should subclass this class.
    """

    config_scheme = ()
    config = {}

    def load_config(self, options, config_file_path=None):
        """ Load config from a dict of options. Returns a tuple of (errors, warnings)."""


        self.config = Config(schema=self.config_scheme, config_file_path=config_file_path)