From 3143acecd760f14715e38f56193734833c88652d Mon Sep 17 00:00:00 2001 From: Patrice Chalin Date: Fri, 7 Mar 2025 13:00:52 -0500 Subject: [PATCH] [infra] Factor include partial from shortcode --- .../docs/languages/_includes/index-intro.md | 24 +++++++++++ layouts/partials/include.md | 37 +++++++++++++++++ .../shortcodes/docs/languages/index-intro2.md | 24 +++++++++++ layouts/shortcodes/include.html | 40 +++++++++---------- 4 files changed, 104 insertions(+), 21 deletions(-) create mode 100644 content/en/docs/languages/_includes/index-intro.md create mode 100644 layouts/partials/include.md create mode 100644 layouts/shortcodes/docs/languages/index-intro2.md diff --git a/content/en/docs/languages/_includes/index-intro.md b/content/en/docs/languages/_includes/index-intro.md new file mode 100644 index 000000000000..52a7b6936ff2 --- /dev/null +++ b/content/en/docs/languages/_includes/index-intro.md @@ -0,0 +1,24 @@ +--- +--- + +This is the OpenTelemetry {{ $name }} documentation. OpenTelemetry is an +observability framework -- an API, SDK, and tools that are designed to aid in +the generation and collection of application telemetry data such as metrics, +logs, and traces. This documentation is designed to help you understand how to +get started using OpenTelemetry {{ $name }}. + +## Status and Releases + +The current status of the major functional components for OpenTelemetry +{{ $name }} is as follows: + +| Traces | Metrics | Logs | +| ------------------- | -------------------- | ----------------- | +| {{ $tracesStatus }} | {{ $metricsStatus }} | {{ $logsStatus }} | + +For releases, including the [latest release][], see [Releases]. {{ $.Inner }} + +[latest release]: + +[Releases]: + diff --git a/layouts/partials/include.md b/layouts/partials/include.md new file mode 100644 index 000000000000..d7abf07b54c9 --- /dev/null +++ b/layouts/partials/include.md @@ -0,0 +1,37 @@ +{{/* + +This partial implements the core functionality of the 'include.html' shortcode, +allowing reuse across other shortcodes and partials. + +This partial expects the following arguments -- beyond those used for the +include functionality: + +- `_dot`: the '.' context of the page or shortcode invoking this partial +- `_path`: the path to the file to be included + +*/ -}} + +{{ $path := ._path -}} +{{ $args := . -}} +{{ $page := partial "func/find-include.html" (dict "path" $path "page" ._dot.Page) -}} +{{ with $page -}} + {{ $content := .RenderShortcodes -}} + {{ range $_k, $v := $args -}} + {{ $k := string $_k -}} + {{ if not (hasPrefix $k "_") -}} + {{ $regex := printf "\\{\\{\\s*\\$%s\\s*\\}\\}" $k -}} + {{ $content = replaceRE $regex $v $content -}} + {{ end -}} + {{ end -}} + {{ $content -}} +{{ else -}} + {{ $msg := printf + "Can't include '%s': file not found in page or ancestor contexts of page %s." + $path .Page.Path -}} + {{ warnf $msg -}} + +
+
INTERNAL SITE ERROR
+ {{ $msg }} +
+{{ end -}} diff --git a/layouts/shortcodes/docs/languages/index-intro2.md b/layouts/shortcodes/docs/languages/index-intro2.md new file mode 100644 index 000000000000..ad03c8399958 --- /dev/null +++ b/layouts/shortcodes/docs/languages/index-intro2.md @@ -0,0 +1,24 @@ +{{ $prettier_ignore := ` + + +` -}} +{{ $lang := .Get 0 -}} +{{ $data := index $.Site.Data.instrumentation $lang }} +{{ $name := $data.name -}} + +{{ $tracesStatus := partial "docs/get-signal-status.html" (dict "lang" $lang "signal" "traces") -}} +{{ $metricsStatus := partial "docs/get-signal-status.html" (dict "lang" $lang "signal" "metrics") -}} +{{ $logsStatus := partial "docs/get-signal-status.html" (dict "lang" $lang "signal" "logs") -}} + +{{ $args := dict + "_dot" . + "_path" "index-intro.md" + "name" $name + "lang" $lang + "tracesStatus" $tracesStatus + "metricsStatus" $metricsStatus + "logsStatus" $logsStatus + ".Inner" .Inner +-}} + +{{ partial "include.md" $args -}} diff --git a/layouts/shortcodes/include.html b/layouts/shortcodes/include.html index 225669b3fb75..1514d9a9cc57 100644 --- a/layouts/shortcodes/include.html +++ b/layouts/shortcodes/include.html @@ -1,24 +1,22 @@ -{{/* Use to include Markdown snippets. Note that the included content can have -calls to shortcodes. */ -}} +{{/* -{{ $path := .Get (cond .IsNamedParams "file" 0) -}} -{{ $args := .Params -}} -{{ $page := partial "func/find-include.html" (dict "path" $path "page" .Page) -}} -{{ with $page -}} - {{ $content := .RenderShortcodes -}} - {{ range $k, $v := $args -}} - {{ $regex := printf "\\{\\{\\s*\\$%s\\s*\\}\\}" (string $k) -}} - {{ $content = replaceRE $regex $v $content -}} - {{ end -}} - {{ $content -}} -{{ else -}} - {{ $msg := printf - "Can't include '%s': file not found in page or ancestor contexts of page %s." - $path .Page.Path -}} - {{ warnf $msg -}} +Use to include markdown snippets. Note that the included content can have calls +to shortcodes. Arguments to this shortcode can be named or positional. + +The first argument (optionally named "file") is mandatory, it is the path to the +file to include. The path is relative to the content directory. Search will be +done in '_includes' folders unless the argument starts with a dot or slash. + +The value of other positional or named arguments will be used to replace +occurrences of '{{ $key }}' in the included content, where 'key' is the name of +the argument or its position in the list of positional arguments. -
-
INTERNAL SITE ERROR
- {{ $msg }} -
+*/ -}} + +{{ $path := .Get (cond .IsNamedParams "file" 0) -}} +{{ $args := dict "_dot" . "_path" $path -}} +{{/* Add the positional and named params to our $args map. */ -}} +{{ range $i, $v := .Params -}} + {{ $args = merge $args (dict (string $i) $v) -}} {{ end -}} +{{ partial "include.md" $args -}}