From cb2668bc57fb205fbd44b77695d36d019a7e1054 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Sat, 23 May 2026 23:58:50 +0300 Subject: docs(internal/perc): fix misleading comments in perc.go - ParsingStrategy: clarify that (nil, false, nil) means input not matched, not that an error occurred. Errors only happen when the pattern matches but value parsing fails. - ParseCalculation: remove mention of "formatting options" since callers get raw values and the Format() method, not configurable formatting. --- internal/perc/perc.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/internal/perc/perc.go b/internal/perc/perc.go index 63a171e..4f5056f 100644 --- a/internal/perc/perc.go +++ b/internal/perc/perc.go @@ -51,7 +51,8 @@ func (c *Calculation) Format() string { } // ParsingStrategy represents a parsing function that attempts to parse input. -// Returns a Calculation if handled, or error if not. +// Returns (calc, true, nil) on success, (nil, true, err) if the pattern matched +// but value parsing failed, or (nil, false, nil) if the input did not match. type ParsingStrategy func(input string) (*Calculation, bool, error) // strategyRegistry maintains a registry of parsing strategies. @@ -108,7 +109,7 @@ func Parse(input string) (string, error) { // ParseCalculation parses a percentage calculation input string and returns the Calculation object. // It handles formats like "20% of 150", "30 is what % of 150", and "30 is 20% of what". -// This provides callers with more flexibility to access raw values and formatting options. +// This provides callers with access to the raw values and calculation type. func ParseCalculation(input string) (*Calculation, error) { input = strings.ToLower(strings.TrimSpace(input)) input = strings.ReplaceAll(input, "what is ", "") -- cgit v1.2.3