Skip to content

Commit 04d93c7

Browse files
Fix dogfooding: remove MkDocsYMLManager from ZensicalToolSpec config spec
When an existing mkdocs.yml has content, the first_content resolution picks it over the empty zensical.toml, so config is never written to zensical.toml. This causes `zensical serve` to fail with "Missing required setting: site_name". Fix: Zensical only manages zensical.toml. Each tool manages its own config files independently. Agent-Logs-Url: https://github.com/usethis-python/usethis-python/sessions/a9aad48e-e19c-485f-8ad9-7894a746e1b1 Co-authored-by: nathanjmcdougall <[email protected]>
1 parent 2d8bca6 commit 04d93c7

2 files changed

Lines changed: 8 additions & 16 deletions

File tree

src/usethis/_tool/impl/spec/zensical.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
from typing_extensions import override
99

10-
from usethis._config_file import MkDocsYMLManager, ZensicalTOMLManager
10+
from usethis._config_file import ZensicalTOMLManager
1111
from usethis._integrations.project.name import get_project_name
1212
from usethis._tool.base import ToolMeta, ToolSpec
1313
from usethis._tool.config import ConfigEntry, ConfigItem, ConfigSpec
@@ -46,7 +46,6 @@ def config_spec(self) -> ConfigSpec:
4646
return ConfigSpec.from_flat(
4747
file_managers=[
4848
ZensicalTOMLManager(),
49-
MkDocsYMLManager(),
5049
],
5150
resolution="first_content",
5251
config_items=[
@@ -57,10 +56,6 @@ def config_spec(self) -> ConfigSpec:
5756
keys=["project", "site_name"],
5857
get_value=lambda: get_project_name(),
5958
),
60-
Path("mkdocs.yml"): ConfigEntry(
61-
keys=["site_name"],
62-
get_value=lambda: get_project_name(),
63-
),
6459
},
6560
),
6661
ConfigItem(
@@ -70,10 +65,6 @@ def config_spec(self) -> ConfigSpec:
7065
keys=["project", "nav"],
7166
get_value=lambda: [{"Home": "index.md"}],
7267
),
73-
Path("mkdocs.yml"): ConfigEntry(
74-
keys=["nav"],
75-
get_value=lambda: [{"Home": "index.md"}],
76-
),
7768
},
7869
),
7970
],

tests/usethis/_core/test_core_tool.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4237,9 +4237,9 @@ def test_how_to_use(
42374237
"""
42384238
)
42394239

4240-
class TestMkDocsYMLFallback:
4240+
class TestMkDocsYMLPresent:
42414241
@pytest.mark.usefixtures("_vary_network_conn")
4242-
def test_uses_mkdocs_yml_if_present(self, tmp_path: Path):
4242+
def test_writes_zensical_toml_even_if_mkdocs_yml_present(self, tmp_path: Path):
42434243
# Arrange
42444244
(tmp_path / "pyproject.toml").write_text("""\
42454245
[project]
@@ -4251,7 +4251,8 @@ def test_uses_mkdocs_yml_if_present(self, tmp_path: Path):
42514251
with change_cwd(tmp_path), files_manager():
42524252
use_zensical()
42534253

4254-
# Assert - config should stay in mkdocs.yml since it already has content
4255-
assert (tmp_path / "mkdocs.yml").exists()
4256-
contents = (tmp_path / "mkdocs.yml").read_text()
4257-
assert "site_name: existing-site" in contents
4254+
# Assert - config should be written to zensical.toml regardless of mkdocs.yml
4255+
assert (tmp_path / "zensical.toml").exists()
4256+
contents = (tmp_path / "zensical.toml").read_text()
4257+
assert "[project]" in contents
4258+
assert 'site_name = "my-project"' in contents

0 commit comments

Comments
 (0)