From b38d91c76f877ad7fd415453aeaadb1006fe0e78 Mon Sep 17 00:00:00 2001 From: "qwen.ai[bot]" Date: Wed, 12 Aug 2026 14:49:31 +0000 Subject: [PATCH] docs: add docstrings to _fmt and _block functions in compare.py --- src/netsleuth/compare.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/netsleuth/compare.py b/src/netsleuth/compare.py index 3d8b297..f5519df 100644 --- a/src/netsleuth/compare.py +++ b/src/netsleuth/compare.py @@ -139,12 +139,32 @@ def diff_reports(before: dict, after: dict) -> ReportDiff: def _fmt(value: Any) -> str: + """Format a value for display in markdown tables. + + Args: + value: The value to format (can be None, int, float, or str). + + Returns: + An em-dash (—) for None values, a compact numeric format for + int/float values, or the string representation for other types. + """ if value is None: return "—" return f"{value:g}" if isinstance(value, (int, float)) else str(value) def _block(title: str, changes: list[Change]) -> list[str]: + """Render a section of changes as markdown lines. + + Args: + title: Section heading (e.g., "Identity", "Latency", "Speed"). + changes: List of Change objects describing what changed. + + Returns: + A list of markdown lines forming the section. If there are no + changes, returns a heading with "No change." message. Otherwise + returns a markdown table with Field/Before/After/Delta columns. + """ if not changes: return [f"### {title}", "", "No change.", ""] return (