Skip to content

Commit

Permalink
Status page: use shortcode to automatically get statuses from spec (#959
Browse files Browse the repository at this point in the history
)
  • Loading branch information
chalin authored Dec 1, 2021
1 parent bfec42d commit e8b6cb6
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 8 deletions.
16 changes: 8 additions & 8 deletions content/en/status/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ Checking the current status for each client in the README of its [github repo](h

#### Tracing

- **API:** stable
- **SDK:** stable
- **Protocol:** stable
- {{% spec_status "API" "trace/api" "Status" %}}
- {{% spec_status "SDK" "trace/sdk" "Status" %}}
- {{% spec_status "Protocol" "protocol/otlp" "Tracing" %}}
- **Collector:** experimental
- Notes:
- The tracing specification is now completely stable, and covered by long term support.
Expand All @@ -60,9 +60,9 @@ Checking the current status for each client in the README of its [github repo](h

#### [Metrics][]

- **API:** feature-freeze
- **SDK:** experimental
- **Protocol:** stable
- {{% spec_status "API" "metrics/api" "Status" %}}
- {{% spec_status "SDK" "metrics/sdk" "Status" %}}
- {{% spec_status "Protocol" "protocol/otlp" "Metrics" %}}
- **Collector:** experimental
- Notes:
- OpenTelemetry Metrics is currently under active development.
Expand All @@ -75,7 +75,7 @@ Checking the current status for each client in the README of its [github repo](h

#### Baggage

- **API:** stable
- {{% spec_status "API" "baggage/api" "Status" %}}
- **SDK:** stable
- **Protocol:** N/A
- **Collector:** N/A
Expand All @@ -87,7 +87,7 @@ Checking the current status for each client in the README of its [github repo](h

- **API:** draft
- **SDK:** draft
- **Protocol:** experimental
- {{% spec_status "Protocol" "protocol/otlp" "Logs" %}}
- **Collector:** experimental
- Notes:
- OpenTelemetry Logging is currently under active development.
Expand Down
36 changes: 36 additions & 0 deletions layouts/shortcodes/spec_status.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{{ $err := "spec_status shortcode error" -}}
{{ $label := .Get 0 -}}
{{ $pageRef := .Get 1 -}}
{{ if not (hasPrefix $pageRef "/") -}}
{{ $pageRef = printf "/docs/reference/specification/%s" $pageRef -}}
{{ end -}}
{{ $page := .Site.GetPage $pageRef -}}
{{ if not $page -}}
{{ errorf "spec_status: Can't find page at '%s'." $pageRef -}}
{{ end -}}

{{ $_match := .Get 2 | default "Status" -}}
{{ $matchThis := printf ".*%s.*" $_match -}}

{{ $statusLine := "" -}}
{{ with findRE $matchThis $page.Content -}}
{{/* Note that content is in HTML. */ -}}
{{ $statusLine = index . 0 -}}
{{ else -}}
{{ errorf "%s: page '%s' does not contain a line matching '%s'." $err $pageRef $_match -}}
{{ end -}}

{{ $status := "" -}}
{{/* Valid statuses, as taken from:
- https://opentelemetry.io/docs/reference/specification/document-status/
- https://github.com/open-telemetry/opentelemetry-proto#maturity-level
*/ -}}
{{ $statusValueRE := "(?i:experimental|stable|deprecated|removed|mixed|feature.freeze|alpha|beta)" -}}
{{ $statusRE := printf "%s(,\\s*%s)*" $statusValueRE $statusValueRE -}}
{{ with findRE $statusRE $statusLine -}}
{{ $status = index . 0 -}}
{{ else -}}
{{ errorf "%s: '%s' value did not match one of '%s' in file '%s': matched line is '%s'" $err $_match $statusValueRE $pageRef $statusLine -}}
{{ end -}}

**[{{ $label }}]({{ $page.RelPermalink }}):** {{ lower $status -}}

0 comments on commit e8b6cb6

Please sign in to comment.