-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
chalin
merged 1 commit into
open-telemetry:main
from
chalin:chalin-im-rw-includes-refactoring-2025-03-07
Mar 7, 2025
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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]: | ||
<https://github.com/open-telemetry/opentelemetry-{{ $lang }}/releases/latest> | ||
[Releases]: | ||
<https://github.com/open-telemetry/opentelemetry-{{ $lang }}/releases> |
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,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 -}} |
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,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 -}} |
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,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 -}} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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...."?
There was a problem hiding this comment.
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.