Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[infra] Factor out include partial from shortcode #6494

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions content/en/docs/languages/_includes/index-intro.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
---

This is the OpenTelemetry {{ $name }} documentation. OpenTelemetry is an
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this introduction is how it's been done for ages, but I find "This is" a bit weak, like it points out the obvious. Maybe we could say something like "Welcome to the OpenTelemetry (name) documentation...."?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. Let's tackle that change in a followup PR.

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]:
<https://github.com/open-telemetry/opentelemetry-{{ $lang }}/releases/latest>
[Releases]:
<https://github.com/open-telemetry/opentelemetry-{{ $lang }}/releases>
37 changes: 37 additions & 0 deletions layouts/partials/include.md
Original file line number Diff line number Diff line change
@@ -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 -}}

<div class="alert alert-warning">
<div class="h4 alert-heading">INTERNAL SITE ERROR</div>
{{ $msg }}
</div>
{{ end -}}
24 changes: 24 additions & 0 deletions layouts/shortcodes/docs/languages/index-intro2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{{ $prettier_ignore := `

<!-- 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 -}}
40 changes: 19 additions & 21 deletions layouts/shortcodes/include.html
Original file line number Diff line number Diff line change
@@ -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.

<div class="alert alert-warning">
<div class="h4 alert-heading">INTERNAL SITE ERROR</div>
{{ $msg }}
</div>
*/ -}}

{{ $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 -}}
Loading