Skip to content

Commit

Permalink
fix: correctly build config
Browse files Browse the repository at this point in the history
  • Loading branch information
phil65 committed Nov 2, 2024
1 parent f40ce13 commit 3c0dc35
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions mkdocs_mknodes/builders/configbuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,26 @@ def add_config_file(self, path: str | os.PathLike[str]):
cfg = mkdocsconfigfile.MkDocsConfigFile(path)
self.configs.append(cfg)

def build_mkdocs_config(self, **kwargs: Any) -> MkDocsConfig:
def build_mkdocs_config(
self, site_dir: str | os.PathLike[str] | None = None, **kwargs: Any
) -> MkDocsConfig:
cfg = self.configs[0]
cfg = {**cfg, **kwargs}
text = yamltools.dump_yaml(cfg)
buffer = io.StringIO(text)
buffer.name = self.configs[0].path
config = load_config(buffer, **kwargs)
for plugin in config["plugins"]:
if site_dir:
cfg["site_dir"] = site_dir
for plugin in cfg["plugins"]:
if "mknodes" in plugin:
if self.repo_path is not None:
plugin["mknodes"]["repo_path"] = self.repo_path
if self.build_fn is not None:
plugin["mknodes"]["build_fn"] = self.build_fn
if self.clone_depth is not None:
plugin["mknodes"]["clone_depth"] = self.clone_depth
# cfg = {**cfg, **kwargs}
text = yamltools.dump_yaml(dict(cfg))
buffer = io.StringIO(text)
buffer.name = cfg.path
config = load_config(buffer, **kwargs)

for k, v in config.items():
logger.debug("%s: %s", k, v)
return config

0 comments on commit 3c0dc35

Please sign in to comment.