open-feature / spec

OpenFeature specification
https://openfeature.dev
Apache License 2.0
755 stars 36 forks source link

feat: Inline comment support for spec repos #261

Closed justinabrahms closed 5 months ago

justinabrahms commented 5 months ago

This PR

This should allow someone to mark specifications as done based on inline comments, rather than having to hand-roll regexes.

How to test

set this in your .specrc (example is for go)

[spec]
file_extension=go
inline_comment_prefix=//

then edit code by adding lines like:

import (
    "errors"
    "fmt"
    "sync"

    "github.com/go-logr/logr"
    "github.com/open-feature/go-sdk/openfeature/internal"
    "golang.org/x/exp/maps"
)

//  spec:5.3.5:If the provider emits an event, the value of the client's provider status MUST be updated accordingly.:end

// spec:5.3.4.3:If the provider's on context changed function terminates
// abnormally, and no other invocations have yet to terminate, associated
// PROVIDER_ERROR handlers MUST run.:end

// evaluationAPI wraps OpenFeature evaluation API functionalities
type evaluationAPI struct {
    defaultProvider FeatureProvider
    namedProviders  map[string]FeatureProvider

and run python /path/to/spec/tools/repo_parser/spec_finder.py --code-directory .

then validate those don't show up in the remaining complaints.