-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add doc gen, move schema path, add tests, fix react gen (#68)
## This PR - moves JSON schema to a dedicated directory - added schema validation tests - fixed React code gen (and tests) - automate CLI doc generation - Loosen JSON schema - ~~Rename default value~~ ### Related Issues Fixes #66 ### Notes It's a big PR that I could break into smaller changes if necessary. --------- Signed-off-by: Michael Beemer <[email protected]> Signed-off-by: Michael Beemer <[email protected]>
- Loading branch information
Showing
22 changed files
with
441 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
|
||
.PHONY: test | ||
test: | ||
@echo "Running tests..." | ||
go test -v ./... | ||
@echo "Tests passed successfully!" | ||
|
||
generate-docs: | ||
@echo "Generating documentation..." | ||
go run ./docs/generate-commands.go | ||
@echo "Documentation generated successfully!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package cmd | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/spf13/cobra/doc" | ||
) | ||
|
||
// GenerateDoc generates cobra docs of the cmd | ||
func GenerateDoc(path string) error { | ||
linkHandler := func(name string) string { | ||
return name | ||
} | ||
|
||
filePrepender := func(filename string) string { | ||
return "<!-- markdownlint-disable-file -->\n<!-- WARNING: THIS DOC IS AUTO-GENERATED. DO NOT EDIT! -->\n" | ||
} | ||
|
||
if err := doc.GenMarkdownTreeCustom(rootCmd, path, filePrepender, linkHandler); err != nil { | ||
return fmt.Errorf("error generating docs: %w", err) | ||
} | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<!-- markdownlint-disable-file --> | ||
<!-- WARNING: THIS DOC IS AUTO-GENERATED. DO NOT EDIT! --> | ||
## openfeature | ||
|
||
CLI for OpenFeature. | ||
|
||
### Synopsis | ||
|
||
CLI for OpenFeature related functionalities. | ||
|
||
### Options | ||
|
||
``` | ||
-h, --help help for openfeature | ||
``` | ||
|
||
### SEE ALSO | ||
|
||
* [openfeature generate](openfeature_generate.md) - Code generation for flag accessors for OpenFeature. | ||
* [openfeature version](openfeature_version.md) - Print the version number of the OpenFeature CLI | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<!-- markdownlint-disable-file --> | ||
<!-- WARNING: THIS DOC IS AUTO-GENERATED. DO NOT EDIT! --> | ||
## openfeature generate | ||
|
||
Code generation for flag accessors for OpenFeature. | ||
|
||
### Synopsis | ||
|
||
Code generation for flag accessors for OpenFeature. | ||
|
||
### Options | ||
|
||
``` | ||
--flag_manifest_path string Path to the flag manifest. | ||
-h, --help help for generate | ||
--output_path string Output path for the codegen | ||
``` | ||
|
||
### SEE ALSO | ||
|
||
* [openfeature](openfeature.md) - CLI for OpenFeature. | ||
* [openfeature generate go](openfeature_generate_go.md) - Generate Golang flag accessors for OpenFeature. | ||
* [openfeature generate react](openfeature_generate_react.md) - Generate typesafe React Hooks. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<!-- markdownlint-disable-file --> | ||
<!-- WARNING: THIS DOC IS AUTO-GENERATED. DO NOT EDIT! --> | ||
## openfeature generate go | ||
|
||
Generate Golang flag accessors for OpenFeature. | ||
|
||
### Synopsis | ||
|
||
Generate Golang flag accessors for OpenFeature. | ||
|
||
``` | ||
openfeature generate go [flags] | ||
``` | ||
|
||
### Options | ||
|
||
``` | ||
-h, --help help for go | ||
--package_name string Name of the Go package to be generated. | ||
``` | ||
|
||
### Options inherited from parent commands | ||
|
||
``` | ||
--flag_manifest_path string Path to the flag manifest. | ||
--output_path string Output path for the codegen | ||
``` | ||
|
||
### SEE ALSO | ||
|
||
* [openfeature generate](openfeature_generate.md) - Code generation for flag accessors for OpenFeature. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<!-- markdownlint-disable-file --> | ||
<!-- WARNING: THIS DOC IS AUTO-GENERATED. DO NOT EDIT! --> | ||
## openfeature generate react | ||
|
||
Generate typesafe React Hooks. | ||
|
||
### Synopsis | ||
|
||
Generate typesafe React Hooks compatible with the OpenFeature React SDK. | ||
|
||
``` | ||
openfeature generate react [flags] | ||
``` | ||
|
||
### Options | ||
|
||
``` | ||
-h, --help help for react | ||
``` | ||
|
||
### Options inherited from parent commands | ||
|
||
``` | ||
--flag_manifest_path string Path to the flag manifest. | ||
--output_path string Output path for the codegen | ||
``` | ||
|
||
### SEE ALSO | ||
|
||
* [openfeature generate](openfeature_generate.md) - Code generation for flag accessors for OpenFeature. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<!-- markdownlint-disable-file --> | ||
<!-- WARNING: THIS DOC IS AUTO-GENERATED. DO NOT EDIT! --> | ||
## openfeature version | ||
|
||
Print the version number of the OpenFeature CLI | ||
|
||
``` | ||
openfeature version [flags] | ||
``` | ||
|
||
### Options | ||
|
||
``` | ||
-h, --help help for version | ||
``` | ||
|
||
### SEE ALSO | ||
|
||
* [openfeature](openfeature.md) - CLI for OpenFeature. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package main | ||
|
||
import ( | ||
"log" | ||
|
||
"github.com/open-feature/cli/cmd" | ||
) | ||
|
||
const docPath = "./docs/commands" | ||
|
||
// GenerateDoc generates cobra docs of the cmd | ||
func main() { | ||
if err := cmd.GenerateDoc(docPath); err != nil { | ||
log.Fatal(err) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.