@@ -4825,41 +4825,43 @@ def makeExtension( # noqa: N802
48254825 We only support this function being used by Zensical.
48264826 Consider this function private API.
48274827 """
4828- mdx, mdx_config = _split_configs(markdown_extensions or [])
4829- tool_config = _ToolConfig(config_file_path=config_file_path)
4830-
4831- autorefs = AutorefsPlugin()
4832- autorefs.config = AutorefsConfig()
4833- autorefs.config.resolve_closest = True
4834- autorefs.config.link_titles = "auto"
4835- autorefs.config.strip_title_tags = "auto"
4836- autorefs.scan_toc = True
4837- autorefs._link_titles = "external"
4838- autorefs._strip_title_tags = False
4839-
4840- mdx.append(AutorefsExtension(autorefs))
4841-
4842- handlers_instance = Handlers(
4843- theme="material",
4844- default=default_handler or _default_config["default_handler"],
4845- inventory_project=inventory_project or "Project",
4846- inventory_version=inventory_version or "0.0.0",
4847- handlers_config=handlers or _default_config["handlers"],
4848- custom_templates=custom_templates or _default_config["custom_templates"],
4849- mdx=mdx,
4850- mdx_config=mdx_config,
4851- locale=locale or _default_config["locale"],
4852- tool_config=tool_config,
4853- )
4828+ global _AUTOREFS # noqa: PLW0603
4829+ if _AUTOREFS is None:
4830+ _AUTOREFS = AutorefsPlugin()
4831+ _AUTOREFS.config = AutorefsConfig()
4832+ _AUTOREFS.config.resolve_closest = True
4833+ _AUTOREFS.config.link_titles = "auto"
4834+ _AUTOREFS.config.strip_title_tags = "auto"
4835+ _AUTOREFS.scan_toc = True
4836+ _AUTOREFS._link_titles = "external"
4837+ _AUTOREFS._strip_title_tags = False
4838+
4839+ global _HANDLERS # noqa: PLW0603
4840+ if _HANDLERS is None:
4841+ mdx, mdx_config = _split_configs(markdown_extensions or [])
4842+ tool_config = _ToolConfig(config_file_path=config_file_path)
4843+ mdx.append(AutorefsExtension(_AUTOREFS))
4844+ _HANDLERS = Handlers(
4845+ theme="material",
4846+ default=default_handler or _default_config["default_handler"],
4847+ inventory_project=inventory_project or "Project",
4848+ inventory_version=inventory_version or "0.0.0",
4849+ handlers_config=handlers or _default_config["handlers"],
4850+ custom_templates=custom_templates or _default_config["custom_templates"],
4851+ mdx=mdx,
4852+ mdx_config=mdx_config,
4853+ locale=locale or _default_config["locale"],
4854+ tool_config=tool_config,
4855+ )
48544856
4855- handlers_instance ._download_inventories()
4856- register = autorefs .register_url
4857- for identifier, url in handlers_instance ._yield_inventory_items():
4858- register(identifier, url)
4857+ _HANDLERS ._download_inventories()
4858+ register = _AUTOREFS .register_url
4859+ for identifier, url in _HANDLERS ._yield_inventory_items():
4860+ register(identifier, url)
48594861
48604862 return MkdocstringsExtension(
4861- handlers=handlers_instance ,
4862- autorefs=autorefs ,
4863+ handlers=_HANDLERS ,
4864+ autorefs=_AUTOREFS ,
48634865 autorefs_extension=True,
48644866 )
48654867```
0 commit comments