Skip to content

Commit c18fb0e

Browse files
authored
restructure spec and include metadata for docs (#118)
Signed-off-by: Michael Beemer <[email protected]>
1 parent 7d4648c commit c18fb0e

File tree

10 files changed

+90
-37
lines changed

10 files changed

+90
-37
lines changed

.markdownlint.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,5 @@ MD033:
66
- details
77
MD024:
88
siblings_only: true
9+
MD025:
10+
front_matter_title: ""

Makefile

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
IS_PYTHON_INSTALLED = $(shell which python >> /dev/null 2>&1; echo $$?)
22
ALL_DOCS := $(shell find . -type f -name '*.md' -not -path './.github/*' -not -path './node_modules/*' | sort)
33

4-
parse: clean _check_python
4+
parse: _check_python
55
@python ./tools/specification_parser/specification_parser.py
66

7-
clean:
8-
@find ./specification -name '*.json' -delete
9-
107
lint: node_modules
118
@python ./tools/specification_parser/lint_json_output.py specification.json
129
./node_modules/.bin/markdownlint --ignore node_modules/ --ignore tools/ **/*.md
@@ -25,13 +22,15 @@ _check_python:
2522
&& echo "" \
2623
&& exit 1; \
2724
fi;
25+
2826
.PHONY: markdown-toc
2927
markdown-toc: node_modules
3028
@if ! npm ls markdown-toc; then npm ci; fi
3129
@for f in $(ALL_DOCS); do \
3230
if grep -q '<!-- tocstop -->' $$f; then \
3331
echo markdown-toc: processing $$f; \
3432
npx --no -- markdown-toc --bullets="-" --no-first-h1 --no-stripHeadingTags -i $$f || exit 1; \
33+
npx --no -- prettier -w $$f; \
3534
else \
3635
echo markdown-toc: no TOC markers, skipping $$f; \
3736
fi; \

specification/README.md

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
1+
---
2+
id: intro
3+
title: Intro
4+
description: An intro to the OpenFeature specification.
5+
sidebar_position: 0
6+
---
7+
18
# OpenFeature Specification
29

310
## Contents
411

512
- [Glossary](./glossary.md)
613
- [Types](./types.md)
7-
- [Evaluation API](./flag-evaluation.md)
8-
- [Providers](./providers.md)
9-
- [Evaluation Context](./evaluation-context.md)
10-
- [Hooks](./hooks.md)
14+
- [Evaluation API](./sections/01-flag-evaluation.md)
15+
- [Providers](./sections//02-providers.md)
16+
- [Evaluation Context](./sections/03-evaluation-context.md)
17+
- [Hooks](./sections/04-hooks.md)
1118

1219
## Conformance
1320

specification/glossary.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
---
2+
title: Glossary
3+
description: A list of terms used within the OpenFeature specification.
4+
sidebar_position: 1
5+
---
6+
17
# Glossary
28

39
This document defines some terms that are used across this specification.
@@ -54,7 +60,7 @@ A developer who is setting up or configuring an application or service to use th
5460

5561
### Provider Author
5662

57-
The maintainer of an API-compliant [provider](./providers.md) which implements the necessary interfaces required for flag evaluation.
63+
The maintainer of an API-compliant [provider](./sections/02-providers.md) which implements the necessary interfaces required for flag evaluation.
5864

5965
### Integration Author
6066

@@ -86,7 +92,7 @@ A source-of-truth for flag values and rules. Flag management systems may include
8692

8793
### Provider
8894

89-
An SDK-compliant implementation which resolves flag values from a particular flag management system, allowing the use of the [Evaluation API](./flag-evaluation.md#flag-evaluation) as an abstraction for the system in question.
95+
An SDK-compliant implementation which resolves flag values from a particular flag management system, allowing the use of the [Evaluation API](./sections/01-flag-evaluation.md#flag-evaluation) as an abstraction for the system in question.
9096

9197
### Integration
9298

specification/flag-evaluation.md renamed to specification/sections/01-flag-evaluation.md

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
1+
---
2+
title: Flag Evaluation API
3+
description: The specification that defines the developer facing feature flag evaluation API.
4+
toc_max_heading_level: 4
5+
---
6+
17
# Flag Evaluation API
28

3-
**Status**: [Experimental](./README.md#document-statuses)
9+
**Status**: [Experimental](../README.md#document-statuses)
410

511
## Overview
612

7-
The `evaluation API` allows for the evaluation of feature flag values, independent of any flag control plane or vendor. In the absence of a [provider](./providers.md) the `evaluation API` uses the "No-op provider", which simply returns the supplied default flag value.
13+
The `evaluation API` allows for the evaluation of feature flag values, independent of any flag control plane or vendor. In the absence of a [provider](./02-providers.md) the `evaluation API` uses the "No-op provider", which simply returns the supplied default flag value.
814

915
### API Initialization and Configuration
1016

@@ -23,7 +29,7 @@ It's important that multiple instances of the `API` not be active, so that state
2329
OpenFeature.setProvider(new MyProvider());
2430
```
2531

26-
See [provider](./providers.md) for details.
32+
See [provider](./02-providers.md) for details.
2733

2834
#### Requirement 1.1.3
2935

@@ -34,7 +40,7 @@ See [provider](./providers.md) for details.
3440
OpenFeature.addHooks([new MyHook()]);
3541
```
3642

37-
See [hooks](./hooks.md) for details.
43+
See [hooks](./04-hooks.md) for details.
3844

3945
#### Requirement 1.1.4
4046

@@ -45,7 +51,7 @@ See [hooks](./hooks.md) for details.
4551
OpenFeature.getProviderMetadata();
4652
```
4753

48-
See [provider](./providers.md) for details.
54+
See [provider](./02-providers.md) for details.
4955

5056
#### Requirement 1.1.5
5157

@@ -79,7 +85,7 @@ Clients may be created in critical code paths, and even per-request in server-si
7985
client.addHooks([new MyHook()]);
8086
```
8187

82-
See [hooks](./hooks.md) for details.
88+
See [hooks](./04-hooks.md) for details.
8389

8490
#### Requirement 1.2.2
8591

@@ -109,7 +115,7 @@ number myNumber = client.getNumberValue('number-flag', 75);
109115
MyStruct myStruct = client.getObjectValue<MyStruct>('structured-flag', { text: 'N/A', percentage: 75 }, evaluationContext, options);
110116
```
111117

112-
See [evaluation context](./evaluation-context.md) for details.
118+
See [evaluation context](./03-evaluation-context.md) for details.
113119

114120
##### Condition 1.3.2
115121

@@ -126,7 +132,7 @@ GetIntValue(flag string, defaultValue int64, evalCtx EvaluationContext, options
126132
GetFloatValue(flag string, defaultValue float64, evalCtx EvaluationContext, options ...EvaluationOption) (float64, error)
127133
```
128134

129-
See [types](./types.md) for details.
135+
See [types](../types.md) for details.
130136

131137
##### Requirement 1.3.3
132138

@@ -211,12 +217,12 @@ It's recommended to provide non-blocking mechanisms for flag evaluation, particu
211217

212218
> The `evaluation options` structure's `hooks` field denotes an ordered collection of hooks that the client **MUST** execute for the respective flag evaluation, in addition to those already configured.
213219
214-
See [hooks](./hooks.md) for details.
220+
See [hooks](./04-hooks.md) for details.
215221

216222
#### Context Transformation
217223

218224
##### Requirement 1.6.1
219225

220226
> The `client` **SHOULD** transform the `evaluation context` using the `provider's` `context transformer` function if one is defined, before passing the result of the transformation to the provider's flag resolution functions.
221227
222-
See [context transformation](./providers.md#context-transformation) for details.
228+
See [context transformation](./02-providers.md#context-transformation) for details.

specification/providers.md renamed to specification/sections/02-providers.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
1+
---
2+
title: Provider
3+
description: The specification that defines the responsibilities and behaviors of a provider.
4+
toc_max_heading_level: 4
5+
---
6+
17
# Provider
28

39
## Overview
410

511
The `provider` API defines interfaces that Provider Authors can use to abstract a particular flag management system, thus enabling the use of the `evaluation API` by Application Authors.
612

7-
Providers are the "translator" between the flag evaluation calls made in application code, and the flag management system that stores flags and in some cases evaluates flags. At a minimum, providers should implement some basic evaluation methods which return flag values of the expected type. In addition, providers may transform the [evaluation context](evaluation-context.md) appropriately in order to be used in dynamic evaluation of their associated flag management system, provide insight into why evaluation proceeded the way it did, and expose configuration options for their associated flag management system. Hypothetical provider implementations might wrap a vendor SDK, embed an REST client, or read flags from a local file.
13+
Providers are the "translator" between the flag evaluation calls made in application code, and the flag management system that stores flags and in some cases evaluates flags. At a minimum, providers should implement some basic evaluation methods which return flag values of the expected type. In addition, providers may transform the [evaluation context](./03-evaluation-context.md) appropriately in order to be used in dynamic evaluation of their associated flag management system, provide insight into why evaluation proceeded the way it did, and expose configuration options for their associated flag management system. Hypothetical provider implementations might wrap a vendor SDK, embed an REST client, or read flags from a local file.
814

9-
![Provider](./assets/images/provider.png)
15+
![Provider](../assets/images/provider.png)
1016

1117
### Feature Provider Interface
1218

@@ -31,7 +37,7 @@ provider.getMetadata().getName(); // "my-custom-provider"
3137
resolveBooleanValue(flagKey, defaultValue, context, options);
3238
```
3339

34-
see: [flag resolution structure](./types.md#flag-resolution), [flag value resolution](./glossary.md#flag-value-resolution)
40+
see: [flag resolution structure](../types.md#flag-resolution), [flag value resolution](../glossary.md#flag-value-resolution)
3541

3642
##### Condition 2.3
3743

@@ -109,7 +115,7 @@ ResolutionDetails<MyStruct> resolveStructureValue(string flagKey, MyStruct defau
109115

110116
Feature flag management systems often define structures representing arbitrary contextual data pertaining to the runtime, user, or application. The context transformer defines a simple interface to transform the OpenFeature `evaluation context` to such a structure, mapping values appropriately.
111117

112-
See [evaluation context](./evaluation-context.md).
118+
See [evaluation context](./03-evaluation-context.md).
113119

114120
##### Requirement 2.10
115121

@@ -130,7 +136,7 @@ class MyProvider implements Provider {
130136
}
131137
```
132138

133-
See [evaluation context](./evaluation-context.md), [flag evaluation](./flag-evaluation.md#flag-evaluation).
139+
See [evaluation context](./03-evaluation-context.md), [flag evaluation](./01-flag-evaluation.md#flag-evaluation).
134140

135141
##### Condition 2.11
136142

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,24 @@
1+
---
2+
title: Evaluation Context
3+
description: The specification that defines the structure and expectations of evaluation context.
4+
toc_max_heading_level: 4
5+
---
6+
17
# Evaluation Context
28

3-
**Status**: [Experimental](./README.md#document-statuses)
9+
**Status**: [Experimental](../README.md#document-statuses)
410

511
## Overview
612

713
The `evaluation context` provides ambient information for the purposes of flag evaluation. Contextual data may be used as the basis for targeting, including rule-based evaluation, overrides for specific subjects, or fractional flag evaluation.
814

9-
The context might contain information about the end-user, the application, the host, or any other ambient data that might be useful in flag evaluation. For example, a flag system might define rules that return a specific value based on the user's email address, locale, or the time of day. The context provides this information. The context can be optionally provided at evaluation, and mutated in [before hooks](./hooks.md).
15+
The context might contain information about the end-user, the application, the host, or any other ambient data that might be useful in flag evaluation. For example, a flag system might define rules that return a specific value based on the user's email address, locale, or the time of day. The context provides this information. The context can be optionally provided at evaluation, and mutated in [before hooks](./04-hooks.md).
1016

1117
### Fields
1218

1319
NOTE: Field casing is not specified, and should be chosen in accordance with language idioms.
1420

15-
see: [types](./types.md)
21+
see: [types](../types.md)
1622

1723
#### Requirement 3.1
1824

@@ -24,4 +30,4 @@ The targeting key uniquely identifies the subject (end-user, or client service)
2430

2531
> The evaluation context **MUST** support the inclusion of custom fields, having keys of type `string`, and values of type `boolean | string | number | datetime | structure`.
2632
27-
see: [structure](./types.md#structure), [datetime](./types.md#datetime)
33+
see: [structure](../types.md#structure), [datetime](../types.md#datetime)

specification/hooks.md renamed to specification/sections/04-hooks.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
---
2+
title: Hooks
3+
description: The specification that defines the expectations and life cycle of hooks.
4+
toc_max_heading_level: 4
5+
---
6+
17
# Hooks
28

39
## Overview
@@ -11,13 +17,13 @@ Hooks add their logic at any of four specific stages of flag evaluation:
1117
- `error`, immediately after an unsuccessful during flag evaluation
1218
- `finally` unconditionally after flag evaluation
1319

14-
![Flag evaluation life cycle](./assets/images/life-cycle.png)
20+
![Flag evaluation life cycle](../assets/images/life-cycle.png)
1521

16-
Hooks can be configured to run globally (impacting all flag evaluations), per client, or per flag evaluation invocation. Some example use-cases for hook include adding additional data to the [evaluation context](./evaluation-context.md), performing validation on the received flag value, providing data to telemetric tools, and logging errors.
22+
Hooks can be configured to run globally (impacting all flag evaluations), per client, or per flag evaluation invocation. Some example use-cases for hook include adding additional data to the [evaluation context](./03-evaluation-context.md), performing validation on the received flag value, providing data to telemetric tools, and logging errors.
1723

1824
### Definitions
1925

20-
**Hook**: Application author/integrator-supplied logic that is called by the OpenFeature framework at a specific stage. **Stage**: An explicit portion of the flag evaluation lifecycle. e.g. `before` being "before the [resolution](./glossary.md#resolving-flag-values) is run. **Invocation**: A single call to evaluate a flag. `client.getBooleanValue(..)` is an invocation. **API**: The global API singleton.
26+
**Hook**: Application author/integrator-supplied logic that is called by the OpenFeature framework at a specific stage. **Stage**: An explicit portion of the flag evaluation lifecycle. e.g. `before` being "before the [resolution](../glossary.md#resolving-flag-values) is run. **Invocation**: A single call to evaluate a flag. `client.getBooleanValue(..)` is an invocation. **API**: The global API singleton.
2127

2228
### Hook context
2329

@@ -157,7 +163,7 @@ In languages with try/catch semantics, this means that exceptions thrown in `err
157163

158164
Before hooks can impact evaluation by various means, such as mutating the `evaluation context`. Therefore, an error in the `before` hooks is considered abnormal execution, and the default should be returned.
159165

160-
### [Flag evaluation options](./types.md#evaluation-options)
166+
### [Flag evaluation options](../types.md#evaluation-options)
161167

162168
Usage might look something like:
163169

@@ -168,7 +174,7 @@ val = client.get_boolean_value('my-key', False, evaluation_options={
168174
})
169175
```
170176

171-
See: [Flag evaluation options](./flag-evaluation.md#)
177+
See: [Flag evaluation options](./01-flag-evaluation.md#)
172178

173179
#### Requirement 4.5.1
174180

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"position": 3,
3+
"label": "Sections",
4+
"collapsible": false,
5+
"link": {
6+
"type": "generated-index",
7+
"title": "Specification Sections"
8+
}
9+
}

specification/types.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
---
2+
title: Types and Data Structures
3+
description: A description of types and data structures used within the OpenFeature specification.
4+
sidebar_position: 2
5+
---
6+
17
# Types and Data Structures
28

39
## Overview
@@ -26,7 +32,7 @@ A language primitive for representing a date and time, including timezone inform
2632

2733
### Evaluation Details
2834

29-
A structure representing the result of the [flag evaluation process](./glossary.md#evaluating-flag-values), and made available in the [detailed flag resolution functions](./flag-evaluation.md#detailed-flag-evaluation), containing the following fields:
35+
A structure representing the result of the [flag evaluation process](./glossary.md#evaluating-flag-values), and made available in the [detailed flag resolution functions](./sections/01-flag-evaluation.md#detailed-flag-evaluation), containing the following fields:
3036

3137
- flag key (string, required)
3238
- value (boolean | string | number | structure, required)
@@ -43,10 +49,10 @@ A structure which contains a subset of the fields defined in the `evaluation det
4349
- reason (string, optional)
4450
- variant (string, optional)
4551

46-
\*NOTE: The `resolution details` structure is not exposed to the Application Author. It defines the data which Provider Authors must return when resolving the value of flags.
52+
> NOTE: The `resolution details` structure is not exposed to the Application Author. It defines the data which Provider Authors must return when resolving the value of flags.
4753
4854
### Evaluation Options
4955

5056
A structure containing the following fields:
5157

52-
- hooks (one or more [hooks](./hooks.md), optional)
58+
- hooks (one or more [hooks](./sections/04-hooks.md), optional)

0 commit comments

Comments
 (0)