Skip to content

Commit 34b1890

Browse files
committed
Add better support for enum values, with Xcode tags.
Xcode tag syntax means that you can now click on the link in the docs, and it will take you straight to the enum. This should make it a little bit easier for clients to see what options are available.
1 parent e5bf04e commit 34b1890

File tree

3 files changed

+46
-229
lines changed

3 files changed

+46
-229
lines changed

Scripts/semantic-convention/templates/SemanticAttributes.swift.j2

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import Foundation
2828
public enum {{enum}}: String {
2929

3030
{%- for attribute in attributes | unique(attribute="fqn") %}
31+
{%- set class_name = attribute.fqn | to_camelcase(True) ~ "Values" %}
3132
/**
3233
{{attribute.brief | to_doc_brief}}.
3334
{%- if attribute.examples %}
@@ -52,7 +53,11 @@ public enum {{enum}}: String {
5253
- Warning: Deprecated • {{attribute.deprecated | to_doc_brief}}.
5354
{%- endif %}
5455

56+
{%- if attribute.is_enum %}
57+
- Requires: Value should be one of [`{{enum}}.{{class_name}}`](x-source-tag://otel{{class_name}}) (of type `{{to_swift_return_type(attribute.attr_type|lower)}}`)
58+
{% else %}
5559
- Requires: Value type should be `{{to_swift_return_type(attribute.attr_type|lower)}}`
60+
{% endif -%}
5661
*/
5762
{%- if attribute.deprecated %}
5863
@available(*, deprecated)
@@ -78,6 +83,7 @@ public enum {{enum}}: String {
7883
/**
7984
{{attribute.brief | to_doc_brief}}.
8085
*/
86+
/// - Tag: otel{{class_name}}
8187
{%- if attribute.attr_type.custom_values %}
8288
public struct {{class_name}}: CustomStringConvertible {
8389
{%- for member in attribute.attr_type.members %}
@@ -90,7 +96,8 @@ public enum {{enum}}: String {
9096
/**
9197
swift.
9298
*/
93-
public static let swift = TelemetrySdkLanguageValues("swift"){% endif %}
99+
public static let swift = TelemetrySdkLanguageValues("swift")
100+
{%- endif %}
94101

95102
internal let value: String
96103

0 commit comments

Comments
 (0)