Skip to content

Commit 3c38c33

Browse files
authored
[infra] Factor out include partial from shortcode (open-telemetry#6494)
1 parent bacce67 commit 3c38c33

File tree

4 files changed

+104
-21
lines changed

4 files changed

+104
-21
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
---
3+
4+
This is the OpenTelemetry {{ $name }} documentation. OpenTelemetry is an
5+
observability framework -- an API, SDK, and tools that are designed to aid in
6+
the generation and collection of application telemetry data such as metrics,
7+
logs, and traces. This documentation is designed to help you understand how to
8+
get started using OpenTelemetry {{ $name }}.
9+
10+
## Status and Releases
11+
12+
The current status of the major functional components for OpenTelemetry
13+
{{ $name }} is as follows:
14+
15+
| Traces | Metrics | Logs |
16+
| ------------------- | -------------------- | ----------------- |
17+
| {{ $tracesStatus }} | {{ $metricsStatus }} | {{ $logsStatus }} |
18+
19+
For releases, including the [latest release][], see [Releases]. {{ $.Inner }}
20+
21+
[latest release]:
22+
<https://github.com/open-telemetry/opentelemetry-{{ $lang }}/releases/latest>
23+
[Releases]:
24+
<https://github.com/open-telemetry/opentelemetry-{{ $lang }}/releases>

layouts/partials/include.md

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{{/*
2+
3+
This partial implements the core functionality of the 'include.html' shortcode,
4+
allowing reuse across other shortcodes and partials.
5+
6+
This partial expects the following arguments -- beyond those used for the
7+
include functionality:
8+
9+
- `_dot`: the '.' context of the page or shortcode invoking this partial
10+
- `_path`: the path to the file to be included
11+
12+
*/ -}}
13+
14+
{{ $path := ._path -}}
15+
{{ $args := . -}}
16+
{{ $page := partial "func/find-include.html" (dict "path" $path "page" ._dot.Page) -}}
17+
{{ with $page -}}
18+
{{ $content := .RenderShortcodes -}}
19+
{{ range $_k, $v := $args -}}
20+
{{ $k := string $_k -}}
21+
{{ if not (hasPrefix $k "_") -}}
22+
{{ $regex := printf "\\{\\{\\s*\\$%s\\s*\\}\\}" $k -}}
23+
{{ $content = replaceRE $regex $v $content -}}
24+
{{ end -}}
25+
{{ end -}}
26+
{{ $content -}}
27+
{{ else -}}
28+
{{ $msg := printf
29+
"Can't include '%s': file not found in page or ancestor contexts of page %s."
30+
$path .Page.Path -}}
31+
{{ warnf $msg -}}
32+
33+
<div class="alert alert-warning">
34+
<div class="h4 alert-heading">INTERNAL SITE ERROR</div>
35+
{{ $msg }}
36+
</div>
37+
{{ end -}}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{{ $prettier_ignore := `
2+
3+
<!-- prettier-ignore -->
4+
` -}}
5+
{{ $lang := .Get 0 -}}
6+
{{ $data := index $.Site.Data.instrumentation $lang }}
7+
{{ $name := $data.name -}}
8+
9+
{{ $tracesStatus := partial "docs/get-signal-status.html" (dict "lang" $lang "signal" "traces") -}}
10+
{{ $metricsStatus := partial "docs/get-signal-status.html" (dict "lang" $lang "signal" "metrics") -}}
11+
{{ $logsStatus := partial "docs/get-signal-status.html" (dict "lang" $lang "signal" "logs") -}}
12+
13+
{{ $args := dict
14+
"_dot" .
15+
"_path" "index-intro.md"
16+
"name" $name
17+
"lang" $lang
18+
"tracesStatus" $tracesStatus
19+
"metricsStatus" $metricsStatus
20+
"logsStatus" $logsStatus
21+
".Inner" .Inner
22+
-}}
23+
24+
{{ partial "include.md" $args -}}

layouts/shortcodes/include.html

+19-21
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,22 @@
1-
{{/* Use to include Markdown snippets. Note that the included content can have
2-
calls to shortcodes. */ -}}
1+
{{/*
32

4-
{{ $path := .Get (cond .IsNamedParams "file" 0) -}}
5-
{{ $args := .Params -}}
6-
{{ $page := partial "func/find-include.html" (dict "path" $path "page" .Page) -}}
7-
{{ with $page -}}
8-
{{ $content := .RenderShortcodes -}}
9-
{{ range $k, $v := $args -}}
10-
{{ $regex := printf "\\{\\{\\s*\\$%s\\s*\\}\\}" (string $k) -}}
11-
{{ $content = replaceRE $regex $v $content -}}
12-
{{ end -}}
13-
{{ $content -}}
14-
{{ else -}}
15-
{{ $msg := printf
16-
"Can't include '%s': file not found in page or ancestor contexts of page %s."
17-
$path .Page.Path -}}
18-
{{ warnf $msg -}}
3+
Use to include markdown snippets. Note that the included content can have calls
4+
to shortcodes. Arguments to this shortcode can be named or positional.
5+
6+
The first argument (optionally named "file") is mandatory, it is the path to the
7+
file to include. The path is relative to the content directory. Search will be
8+
done in '_includes' folders unless the argument starts with a dot or slash.
9+
10+
The value of other positional or named arguments will be used to replace
11+
occurrences of '{{ $key }}' in the included content, where 'key' is the name of
12+
the argument or its position in the list of positional arguments.
1913

20-
<div class="alert alert-warning">
21-
<div class="h4 alert-heading">INTERNAL SITE ERROR</div>
22-
{{ $msg }}
23-
</div>
14+
*/ -}}
15+
16+
{{ $path := .Get (cond .IsNamedParams "file" 0) -}}
17+
{{ $args := dict "_dot" . "_path" $path -}}
18+
{{/* Add the positional and named params to our $args map. */ -}}
19+
{{ range $i, $v := .Params -}}
20+
{{ $args = merge $args (dict (string $i) $v) -}}
2421
{{ end -}}
22+
{{ partial "include.md" $args -}}

0 commit comments

Comments
 (0)