mirror of
https://github.com/django-components/django-components.git
synced 2025-07-13 20:04:59 +00:00
docs: Move docs-folder to root (#816)
* Move docs-folder form src to root * Avoid mkdocs package / module name clash * Update location of docs & add Windows compatibility * Update requirements-docs * Update generated file to current state
This commit is contained in:
parent
cdc830fca3
commit
594c0689ba
68 changed files with 116 additions and 108 deletions
|
@ -1,49 +0,0 @@
|
|||
"""Utilities for interacting with MkDocs configuration."""
|
||||
|
||||
from functools import lru_cache
|
||||
from importlib import import_module
|
||||
from pathlib import Path
|
||||
from typing import Dict, List, Optional, Union
|
||||
|
||||
import griffe
|
||||
import yaml # type: ignore[import-untyped]
|
||||
|
||||
|
||||
@lru_cache()
|
||||
def load_config() -> Dict:
|
||||
mkdocs_config_str = Path("mkdocs.yml").read_text()
|
||||
# NOTE: Use BaseLoader to avoid resolving tags like `!ENV`
|
||||
# See https://stackoverflow.com/questions/45966633/yaml-error-could-not-determine-a-constructor-for-the-tag
|
||||
mkdocs_config = yaml.load(mkdocs_config_str, yaml.BaseLoader)
|
||||
return mkdocs_config
|
||||
|
||||
|
||||
@lru_cache()
|
||||
def find_plugin(name: str) -> Optional[Dict]:
|
||||
config = load_config()
|
||||
plugins: List[Union[str, Dict[str, Dict]]] = config.get("plugins", [])
|
||||
if not plugins:
|
||||
return None
|
||||
|
||||
for plugin in plugins:
|
||||
if isinstance(plugin, str):
|
||||
plugin = {plugin: {}}
|
||||
plugin_name, plugin_conf = list(plugin.items())[0]
|
||||
if plugin_name == name:
|
||||
return plugin_conf
|
||||
|
||||
return None
|
||||
|
||||
|
||||
def get_mkdocstrings_plugin_handler_options() -> Optional[Dict]:
|
||||
plugin = find_plugin("mkdocstrings")
|
||||
if plugin is None:
|
||||
return None
|
||||
|
||||
return plugin.get("handlers", {}).get("python", {}).get("options", {})
|
||||
|
||||
|
||||
def import_object(obj: griffe.Object):
|
||||
module = import_module(obj.module.path)
|
||||
runtime_obj = getattr(module, obj.name)
|
||||
return runtime_obj
|
Loading…
Add table
Add a link
Reference in a new issue