Skip to content

Commit 2a59175

Browse files
committed
docs(config[save_config_yaml_with_items]) add NumPy docstring with doctest
why: Function had only a one-line summary with no Parameters, Returns, or Examples section despite the project requiring full NumPy docstrings and working doctests on all public functions. what: - Add description explaining why this differs from save_config_yaml (preserves duplicate top-level keys via ordered pairs) - Add Parameters and Returns sections per NumPy docstring standard - Add Examples section with duplicate-section round-trip doctest
1 parent a81abb0 commit 2a59175

1 file changed

Lines changed: 28 additions & 1 deletion

File tree

src/vcspull/config.py

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -882,7 +882,34 @@ def save_config_yaml_with_items(
882882
config_file_path: pathlib.Path,
883883
items: list[tuple[str, t.Any]],
884884
) -> None:
885-
"""Persist configuration data while preserving duplicate top-level sections."""
885+
"""Persist configuration data while preserving duplicate top-level sections.
886+
887+
Unlike :func:`save_config_yaml`, which loses duplicate keys when given a
888+
plain ``dict``, this function accepts ordered ``(label, data)`` pairs so
889+
that two workspace-root entries with the same key are each serialised as a
890+
separate YAML block.
891+
892+
Parameters
893+
----------
894+
config_file_path : pathlib.Path
895+
Destination config file (may be a symlink; the real target is updated).
896+
items : list of tuple[str, Any]
897+
Ordered ``(section_label, section_data)`` pairs. Each pair becomes one
898+
YAML document block in the output.
899+
900+
Examples
901+
--------
902+
>>> import pathlib, tempfile
903+
>>> with tempfile.TemporaryDirectory() as tmp:
904+
... p = pathlib.Path(tmp) / "cfg.yaml"
905+
... save_config_yaml_with_items(p, [
906+
... ("~/code/", {"flask": "git+https://github.com/pallets/flask.git"}),
907+
... ("~/code/", {"django": "git+https://github.com/django/django.git"}),
908+
... ])
909+
... content = p.read_text(encoding="utf-8")
910+
... "flask" in content and "django" in content
911+
True
912+
"""
886913
documents: list[str] = []
887914

888915
for label, section in items:

0 commit comments

Comments
 (0)