Skip to content

Fix README API documentation to match actual implementation#30

Merged
massiveio merged 2 commits intomasterfrom
copilot/fix-readme-api-discrepancies
Nov 7, 2025
Merged

Fix README API documentation to match actual implementation#30
massiveio merged 2 commits intomasterfrom
copilot/fix-readme-api-discrepancies

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Nov 7, 2025

README.md referenced non-existent API methods (Product(), Route(), Tool(), DimensionWithWeight(), InitializeDefaultDimensions()) that differ from the actual implementation.

Changes

API Method Corrections

  • Dimension specification: Replace Product(), Route(), Tool() with Dimension(name, value, matchType)
  • Weight override: Replace DimensionWithWeight() with ManualWeight(weight)
  • Dimension configuration: Update NewDimensionConfig() signature from (name, index, required, weight) to (name, index, required) + .SetWeight(matchType, weight)
  • Bulk weights: Remove default weight parameter from NewDimensionConfigWithWeights()

Example (Before → After)

// Before (incorrect)
engine.InitializeDefaultDimensions()
rule := matcher.NewRule("rule").
    Product("ProductA", matcher.MatchTypeEqual, 10.0).
    DimensionWithWeight("env", "prod", matcher.MatchTypeEqual, 5.0).
    Build()

// After (correct)
engine.AddDimension(matcher.NewDimensionConfig("product", 0, true).
    SetWeight(matcher.MatchTypeEqual, 10.0))
rule := matcher.NewRule("rule").
    Dimension("product", "ProductA", matcher.MatchTypeEqual).
    Dimension("env", "prod", matcher.MatchTypeEqual).
    ManualWeight(15.0).  // Override calculated weight
    Build()

All code examples throughout README updated to match actual API in api.go and types.go.

Original prompt

There are differences between README.md and the actual API, you can refer to index.html for actual usage.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: cloorc <13597105+cloorc@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix discrepancies between README.md and actual API Fix README API documentation to match actual implementation Nov 7, 2025
Copilot AI requested a review from cloorc November 7, 2025 09:43
@cloorc cloorc marked this pull request as ready for review November 7, 2025 12:46
Copilot AI review requested due to automatic review settings November 7, 2025 12:46
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR updates the README.md documentation to reflect API changes in the matcher library's dimension configuration and weight management system. The changes replace the old constructor-based weight configuration with a builder pattern approach.

Key Changes:

  • Updated all code examples to use NewDimensionConfig().SetWeight() builder pattern instead of passing weights as constructor parameters
  • Replaced DimensionWithWeight() method with Dimension() + ManualWeight() for explicit weight control
  • Changed default weight for unconfigured dimensions from 1.0 to 0.0

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@massiveio massiveio merged commit 2a7ffff into master Nov 7, 2025
8 checks passed
@massiveio massiveio deleted the copilot/fix-readme-api-discrepancies branch November 7, 2025 12:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants