-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Enum replacement in API First step / PoC for fixing #608 Starting with metrics filters only; other enums should follow * simplify sed for docgen * Complete using new enum types * Generic transform: use same pattern as network transform
- Loading branch information
Showing
42 changed files
with
705 additions
and
679 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
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
Large diffs are not rendered by default.
Oops, something went wrong.
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,14 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -eou pipefail | ||
|
||
md_file="./docs/api.md" | ||
|
||
grep "placeholder @" "$md_file" | while read line; do | ||
type=$(echo "$line" | sed -r 's/^placeholder @(.*):(.*)@/\1/') | ||
indent=$(echo "$line" | sed -r 's/^placeholder @(.*):(.*)@/\2/') | ||
repl=$(go doc -all -short -C pkg/api $type | grep "${type} =" | sed -r "s/^.*\"(.*)\".*\/\/ (.*)/$(printf "%${indent}s")\1: \2/") | ||
awk -v inject="${repl}" "/placeholder @$type:$indent@/{print inject;next}1" $md_file > "$md_file.tmp" | ||
rm $md_file | ||
mv "$md_file.tmp" $md_file | ||
done |
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
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 |
---|---|---|
@@ -1,14 +1,13 @@ | ||
package api | ||
|
||
type Decoder struct { | ||
Type string `yaml:"type" json:"type" enum:"DecoderEnum" doc:"one of the following:"` | ||
Type DecoderEnum `yaml:"type" json:"type" doc:"(enum) one of the following:"` | ||
} | ||
|
||
type DecoderEnum struct { | ||
JSON string `yaml:"json" json:"json" doc:"JSON decoder"` | ||
Protobuf string `yaml:"protobuf" json:"protobuf" doc:"Protobuf decoder"` | ||
} | ||
type DecoderEnum string | ||
|
||
func DecoderName(decoder string) string { | ||
return GetEnumName(DecoderEnum{}, decoder) | ||
} | ||
const ( | ||
// For doc generation, enum definitions must match format `Constant Type = "value" // doc` | ||
DecoderJSON DecoderEnum = "json" // JSON decoder | ||
DecoderProtobuf DecoderEnum = "protobuf" // Protobuf decoder | ||
) |
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.