@@ -413,47 +413,47 @@ def _split_configs(markdown_extensions: list[str | dict]) -> tuple[list[str], di
413413 return mdx , mdx_config
414414
415415
416+ class _ToolConfig :
417+ def __init__ (self , config_file_path : str | None = None ) -> None :
418+ self .config_file_path = config_file_path
419+
420+
416421def makeExtension ( # noqa: N802
417- * args : Any , # noqa: ARG001
418- ** kwargs : Any ,
422+ * ,
423+ default_handler : str | None = None ,
424+ inventory_project : str | None = None ,
425+ inventory_version : str | None = None ,
426+ handlers : dict [str , dict ] | None = None ,
427+ custom_templates : str | None = None ,
428+ markdown_extensions : list [str | dict ] | None = None ,
429+ locale : str | None = None ,
430+ config_file_path : str | None = None ,
419431) -> MkdocstringsExtension :
420- """Create the extension instance."""
421- from zensical .config import _yaml_load # noqa: PLC0415
422-
423- with open ("mkdocs.yml" , encoding = "utf-8" ) as f :
424- mkdocs_config = _yaml_load (f )
425-
426- mkdocstrings_config = mkdocs_config .get ("plugins" , None )
427- if isinstance (mkdocstrings_config , dict ):
428- mkdocstrings_config = mkdocstrings_config .get ("mkdocstrings" , {})
429- elif isinstance (mkdocstrings_config , list ):
430- for plugin in mkdocstrings_config :
431- if isinstance (plugin , dict ) and "mkdocstrings" in plugin :
432- mkdocstrings_config = plugin ["mkdocstrings" ]
433- break
434- else :
435- mkdocstrings_config = _default_config
436- else :
437- mkdocstrings_config = _default_config
432+ """Create the extension instance.
438433
439- mdx , mdx_config = _split_configs (mkdocs_config .get ("markdown_extensions" , []))
434+ We only support this function being used by Zensical.
435+ Consider this function private API.
436+ """
437+ mdx , mdx_config = _split_configs (markdown_extensions or [])
438+ tool_config = _ToolConfig (config_file_path = config_file_path )
440439
441- handlers = Handlers (
440+ handlers_instance = Handlers (
442441 theme = "material" ,
443- default = mkdocstrings_config .get ("default_handler" , _default_config ["default_handler" ]),
444- inventory_project = mkdocs_config .get ("site_name" , "Project" ),
445- handlers_config = mkdocstrings_config .get ("handlers" , _default_config ["handlers" ]),
446- custom_templates = mkdocstrings_config .get ("custom_templates" , _default_config ["custom_templates" ]),
442+ default = default_handler or _default_config ["default_handler" ],
443+ inventory_project = inventory_project or "Project" ,
444+ inventory_version = inventory_version or "0.0.0" ,
445+ handlers_config = handlers or _default_config ["handlers" ],
446+ custom_templates = custom_templates or _default_config ["custom_templates" ],
447447 mdx = mdx ,
448448 mdx_config = mdx_config ,
449- locale = mkdocstrings_config . get ( " locale" , _default_config ["locale" ]) ,
450- tool_config = mkdocs_config ,
449+ locale = locale or _default_config ["locale" ],
450+ tool_config = tool_config ,
451451 )
452452
453- handlers ._download_inventories ()
453+ handlers_instance ._download_inventories ()
454454
455455 autorefs = AutorefsPlugin ()
456456 autorefs .config = AutorefsConfig ()
457457 autorefs .scan_toc = False
458458
459- return MkdocstringsExtension (handlers = handlers , autorefs = autorefs , ** kwargs )
459+ return MkdocstringsExtension (handlers = handlers_instance , autorefs = autorefs )
0 commit comments