Skip to content

Commit

Permalink
Adds an option to render briefs and notes of semconv / attributes gro…
Browse files Browse the repository at this point in the history
…ups in markdown

Signed-off-by: Alexander Wert <[email protected]>
  • Loading branch information
AlexanderWert committed Oct 12, 2023
1 parent 370e8f4 commit 53d3ac8
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ def __init__(self):
self.is_remove_constraint = False
self.is_metric_table = False
self.is_omit_requirement_level = False
self.is_render_group_brief = False
self.is_render_group_note = False
self.group_key = ""
self.enums = []
self.notes = []
Expand Down Expand Up @@ -77,6 +79,8 @@ class MarkdownRenderer:
"remove_constraints",
"metric_table",
"omit_requirement_level",
"render_group_brief",
"render_group_note",
]

prelude = "<!-- semconv {} -->\n"
Expand Down Expand Up @@ -206,6 +210,12 @@ def write_table_header(self, output: io.StringIO):
def to_markdown_attribute_table(
self, semconv: BaseSemanticConvention, output: io.StringIO
):
if self.render_ctx.is_render_group_brief:
output.write(semconv.brief + "\n\n")

if self.render_ctx.is_render_group_note:
output.write(semconv.note + "\n\n")

attr_to_print = []
for attr in semconv.attributes_and_templates:
if self.render_ctx.group_key is not None:
Expand Down Expand Up @@ -518,6 +528,12 @@ def _render_group(self, semconv, parameters, output):
self.render_ctx.is_omit_requirement_level = (
"omit_requirement_level" in parameters
)
self.render_ctx.is_render_group_brief = (
"render_group_brief" in parameters
)
self.render_ctx.is_render_group_note = (
"render_group_note" in parameters
)

if self.render_ctx.is_metric_table:
self.to_markdown_metric_table(semconv, output)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ groups:
- id: attributes
prefix: "foo"
type: attribute_group
brief: Attribute group
brief: Attribute group brief.
attributes:
- id: bar
type: string
Expand All @@ -16,6 +16,7 @@ groups:
extends: attributes
prefix: "foo"
brief: Derived attribute group
note: This is a groupt note.
attributes:
- id: qux
type: int
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,19 @@
| `foo.bar` | string | Attribute 1 | `baz` | Recommended: if available |
| `foo.qux` | int | Attribute 2 | `42` | Conditionally Required: if available |
<!-- endsemconv -->

<!-- semconv attributes(render_group_brief) -->
Attribute group brief.

| Attribute | Type | Description | Examples | Requirement Level |
|---|---|---|---|---|
| `foo.bar` | string | Attribute 1 | `baz` | Recommended: if available |
<!-- endsemconv -->

<!-- semconv derived_attributes(render_group_note) -->
This is a groupt note.

| Attribute | Type | Description | Examples | Requirement Level |
|---|---|---|---|---|
| `foo.qux` | int | Attribute 2 | `42` | Conditionally Required: if available |
<!-- endsemconv -->
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,9 @@

<!-- semconv span_attribute_group -->
<!-- endsemconv -->

<!-- semconv attributes(render_group_brief) -->
<!-- endsemconv -->

<!-- semconv derived_attributes(render_group_note) -->
<!-- endsemconv -->

0 comments on commit 53d3ac8

Please sign in to comment.