Skip to content

Commit 9ee192d

Browse files
committed
[CI] Semconv: mount README.md as _index pages
1 parent 7d6e80a commit 9ee192d

File tree

7 files changed

+149
-29
lines changed

7 files changed

+149
-29
lines changed

hugo.yaml

+61
Original file line numberDiff line numberDiff line change
@@ -263,8 +263,69 @@ module:
263263
target: content/docs/specs/otlp/_index.md
264264
- source: tmp/otlp/docs/img
265265
target: content/docs/specs/otlp/img
266+
# Semconv
267+
# cSpell:ignore cloudevents faas
266268
- source: tmp/semconv/docs
267269
target: content/docs/specs/semconv
270+
excludeFiles: '**/README.md'
271+
# DO NOT EDIT - semconv autogenerated mounts below this point - DO NOT EDIT
272+
- source: tmp/semconv/docs/README.md
273+
target: content/docs/specs/semconv/_index.md
274+
- source: tmp/semconv/docs/attributes-registry/README.md
275+
target: content/docs/specs/semconv/attributes-registry/_index.md
276+
- source: tmp/semconv/docs/azure/README.md
277+
target: content/docs/specs/semconv/azure/_index.md
278+
- source: tmp/semconv/docs/cloud-providers/README.md
279+
target: content/docs/specs/semconv/cloud-providers/_index.md
280+
- source: tmp/semconv/docs/cloudevents/README.md
281+
target: content/docs/specs/semconv/cloudevents/_index.md
282+
- source: tmp/semconv/docs/code/README.md
283+
target: content/docs/specs/semconv/code/_index.md
284+
- source: tmp/semconv/docs/database/README.md
285+
target: content/docs/specs/semconv/database/_index.md
286+
- source: tmp/semconv/docs/dotnet/README.md
287+
target: content/docs/specs/semconv/dotnet/_index.md
288+
- source: tmp/semconv/docs/exceptions/README.md
289+
target: content/docs/specs/semconv/exceptions/_index.md
290+
- source: tmp/semconv/docs/faas/README.md
291+
target: content/docs/specs/semconv/faas/_index.md
292+
- source: tmp/semconv/docs/feature-flags/README.md
293+
target: content/docs/specs/semconv/feature-flags/_index.md
294+
- source: tmp/semconv/docs/gen-ai/README.md
295+
target: content/docs/specs/semconv/gen-ai/_index.md
296+
- source: tmp/semconv/docs/general/README.md
297+
target: content/docs/specs/semconv/general/_index.md
298+
- source: tmp/semconv/docs/hardware/README.md
299+
target: content/docs/specs/semconv/hardware/_index.md
300+
- source: tmp/semconv/docs/http/README.md
301+
target: content/docs/specs/semconv/http/_index.md
302+
- source: tmp/semconv/docs/messaging/README.md
303+
target: content/docs/specs/semconv/messaging/_index.md
304+
- source: tmp/semconv/docs/mobile/README.md
305+
target: content/docs/specs/semconv/mobile/_index.md
306+
- source: tmp/semconv/docs/non-normative/README.md
307+
target: content/docs/specs/semconv/non-normative/_index.md
308+
- source: tmp/semconv/docs/non-normative/compatibility/README.md
309+
target: content/docs/specs/semconv/non-normative/compatibility/_index.md
310+
- source: tmp/semconv/docs/object-stores/README.md
311+
target: content/docs/specs/semconv/object-stores/_index.md
312+
- source: tmp/semconv/docs/resource/README.md
313+
target: content/docs/specs/semconv/resource/_index.md
314+
- source: tmp/semconv/docs/resource/cloud-provider/README.md
315+
target: content/docs/specs/semconv/resource/cloud-provider/_index.md
316+
- source: tmp/semconv/docs/resource/cloud-provider/aws/README.md
317+
target: content/docs/specs/semconv/resource/cloud-provider/aws/_index.md
318+
- source: tmp/semconv/docs/resource/cloud-provider/gcp/README.md
319+
target: content/docs/specs/semconv/resource/cloud-provider/gcp/_index.md
320+
- source: tmp/semconv/docs/rpc/README.md
321+
target: content/docs/specs/semconv/rpc/_index.md
322+
- source: tmp/semconv/docs/runtime/README.md
323+
target: content/docs/specs/semconv/runtime/_index.md
324+
- source: tmp/semconv/docs/system/README.md
325+
target: content/docs/specs/semconv/system/_index.md
326+
- source: tmp/semconv/docs/url/README.md
327+
target: content/docs/specs/semconv/url/_index.md
328+
# DO NOT EDIT - semconv autogenerated mounts above - DO NOT EDIT
268329

269330
## es
270331
- source: content/es

layouts/_default/_markup/render-link.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
{{ with $u.RawQuery -}}{{ $href = printf "%s?%s" $href . -}}{{ end -}}
3434
{{ with $u.Fragment -}}{{ $href = printf "%s#%s" $href . -}}{{ end -}}
3535
{{ else -}}
36-
{{ warnf "File %s: cannot resolve spec link reference '%s'" .Page.File.Filename $url -}}
36+
{{ warnf "File %s: cannot resolve spec link reference '%s' (%s)" .Page.File.Filename $url $path -}}
3737
{{ end -}}
3838
{{ $url = $href -}}
3939
{{ else if hasPrefix $url "/" -}}

scripts/content-modules/adjust-pages.pl

+4-3
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ ()
4646
$frontMatterFromFile =~ s/(title|linkTitle): .*/$& $otlpSpecVers/g;
4747
# TODO: add to spec landing page
4848
$frontMatterFromFile .= "weight: 20\n" if $frontMatterFromFile !~ /^\s*weight/;
49-
} elsif ($ARGV =~ /semconv\/docs\/_index.md$/) {
49+
} elsif ($ARGV =~ /semconv\/docs\/\w+.md$/) {
5050
$title .= " $semconvVers";
5151
$frontMatterFromFile =~ s/linkTitle: .*/$& $semconvVers/;
5252
# $frontMatterFromFile =~ s/body_class: .*/$& td-page--draft/;
@@ -108,6 +108,7 @@ ()
108108
s|Emit Event API|Log API|;
109109
s|(docs/specs/otel/logs/api.md#emit-a)n-event|$1-logrecord|;
110110
s|\[semantic-convention-groups\]|[group-stability]|;
111+
s|\Q../../docs/|../|g; # https://github.com/open-telemetry/semantic-conventions/pull/1843
111112
}
112113

113114
sub getVersFromSubmodule() {
@@ -147,10 +148,10 @@ ()
147148
$frontMatterFromFile = '';
148149
$title = '';
149150
$lineNum = 1;
150-
if (/^<!---? Hugo/) {
151+
if (/^(<!)?--- (# )?Hugo/) {
151152
while(<>) {
152153
$lineNum++;
153-
last if /^-?-->/;
154+
last if /^--->?/;
154155
patchEventAliases();
155156
patchSemConv1_30_0();
156157
$frontMatterFromFile .= $_;

scripts/content-modules/cp-pages.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ rm -Rf $DEST
7878
mkdir -p $DEST
7979
cp -R $SRC/* $DEST/
8080

81-
find $DEST/ -name "README.md" -exec sh -c 'f="{}"; mv -- "$f" "${f%README.md}_index.md"' \;
81+
# find $DEST/ -name "README.md" -exec sh -c 'f="{}"; mv -- "$f" "${f%README.md}_index.md"' \;
8282

8383
# To exclude a file use, e.g.: -not -path '*/specification/_index.md'
8484
FILES=$(find $DEST -name "*.md")

scripts/content-modules/normalize-titles.pl

+50-24
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,35 @@ ($)
4040
return $str;
4141
}
4242

43+
my $properNames = <<'EON';
44+
.NET Core
45+
AI Inference
46+
AWS Lambda
47+
Azure
48+
Cassandra
49+
Cloud Run
50+
Common Language Runtime
51+
Compute Engine
52+
Connect RPC
53+
Cosmos
54+
Elasticsearch
55+
Go
56+
Google
57+
Google Cloud
58+
Kafka
59+
Kestrel
60+
Kubernetes
61+
Microsoft
62+
Node.js
63+
Pub/Sub
64+
Redis
65+
EON
66+
67+
my @properNames =
68+
grep { /\S/ } # drop blank lines
69+
map { s/^\s+|\s+$//gr } # trim whitespace
70+
split(/\n/, $properNames);
71+
4372
sub toSentenceCase($) {
4473
my ($str) = @_;
4574

@@ -50,10 +79,10 @@ ($)
5079
$str =~ s/^([a-z][a-z0-9]*)\b/\u$1/;
5180

5281
# Handle exceptions
53-
$str =~ s/(.NET) (core)/$1 \u$2/;
54-
$str =~ s/(AI) (inference)/$1 \u$2/;
55-
$str =~ s|google cloud|Google Cloud|i;
56-
$str =~ s|pub/sub|Pub/Sub|;
82+
for my $name (@properNames) {
83+
$str =~ s/\b\Q$name\E\b/$name/gi;
84+
}
85+
$str =~ s/Function(.)as.a.Service/Function$1as$1a$1Service/i;
5786

5887
return $str;
5988
}
@@ -70,9 +99,9 @@ ()
7099
if ($title =~ /^OpenTelemetry (Protocol )?(.*)/) {
71100
$linkTitle = $2;
72101
} elsif ($title =~ /^(.*?) Semantic Conventions?$/i) {
73-
$linkTitle = toTitleCase($1);
102+
$linkTitle = $1; # toTitleCase($1);
74103
} elsif ($title =~ /^.*? for (.*)$/i) {
75-
$linkTitle = toTitleCase($1);
104+
$linkTitle = $1; # toTitleCase($1);
76105
}
77106
if ($linkTitle =~ /^Function.as.a.Service$/i) {
78107
$linkTitle = 'FaaS';
@@ -87,24 +116,21 @@ ()
87116
} elsif ($linkTitle =~ /^(Exceptions|Feature Flags) .. (.*)$/i) {
88117
$linkTitle = $2;
89118
}
90-
if ($linkTitle =~ /^(.*) Attributes$/i && $title ne 'General Attributes') {
91-
$linkTitle = $1;
92-
}
93119

94-
$linkTitle = 'Events' if $linkTitle =~ /Mobile Events/;
120+
$linkTitle = 'Events' if $linkTitle =~ /Mobile Events/i;
95121
$linkTitle = 'Connect' if $title =~ /Connect RPC$/i;
96122
$linkTitle = 'HTTP' if $linkTitle =~ /^HTTP Client and Server/i;
97123
$linkTitle = 'SQL' if $title =~ /SQL Databases$/i;
98124
$linkTitle = 'System use cases' if $title =~ /System .*?General Use Cases/i;
99125
$linkTitle = $1 if $title =~ /Gen(?:erative) ?AI (\w+)$/i && $title !~ /Systems$/i;
100126
$linkTitle = $1 if $title =~ /(OpenAI) \w+$/i;
101127

102-
# Missing an `s` in "Semantic Convention"?
103-
if ($title =~ /^Semantic Convention\b/i and $title !~ /Groups$/i) {
104-
$title =~ s/Semantic Convention\b/$&s/ig;
128+
# Missing an `s` in "Semantic convention"?
129+
if ($title =~ /^Semantic convention\b/i and $title !~ /Groups$/i) {
130+
$title =~ s/Semantic convention\b/$&s/ig;
105131
printf STDOUT "> $title -> $linkTitle - added 's' to 'Conventions'\n";
106132
}
107-
$linkTitle =~ s/^(Database|Messaging) Client //;
133+
$linkTitle =~ s/^(Database|Messaging) Client //i;
108134
if ($ARGV =~ /docs\/azure/) {
109135
$linkTitle =~ s/ Resource Logs?//i;
110136
$linkTitle =~ s/Azure //i;
@@ -117,7 +143,7 @@ ()
117143
unless $ARGV =~ /gen-ai-metrics/;
118144
$linkTitle =~ s/ (components|guide|queries|supplementary information|systems|platform)$//i;
119145
$linkTitle =~ s/ \(command line interface\)//i;
120-
$linkTitle =~ s/ resources$//i;
146+
$linkTitle =~ s/ (attributes|resources)$//i;
121147
$linkTitle =~ s/(Process) and process runtime$/$1/i;
122148

123149
$linkTitle = '.NET' if $linkTitle =~ /.net common language runtime/i;
@@ -129,20 +155,20 @@ ()
129155

130156
$frontMatter .= $frontMatterFromFile if $frontMatterFromFile;
131157

132-
if ($linkTitle && $linkTitle ne $title) {
133-
$linkTitle = toSentenceCase($linkTitle); # unless $linkTitle =~ /^gRPC/;
134-
if ($frontMatter !~ /linkTitle: /) {
158+
$linkTitle = toSentenceCase($linkTitle);
159+
if ($linkTitle) {
160+
if ($frontMatter !~ /linkTitle: / && $linkTitle ne $title) {
135161
$frontMatter .= "linkTitle: $linkTitle\n";
136162
} elsif ($frontMatter !~ /^auto_gen:/m) {
137163
$frontMatter =~ s/^(linkTitle: ).*$/$1$linkTitle/m;
138164
}
139165
}
140166

141-
if ($ARGV =~ /docs\/(.*?)(README|_index).md$/) {
142-
$frontMatter .= "path_base_for_github_subdir:\n";
143-
$frontMatter .= " from: tmp/semconv/docs/$1_index.md\n";
144-
$frontMatter .= " to: $1README.md\n";
145-
}
167+
# if ($ARGV =~ /docs\/(.*?)(README|_index).md$/) {
168+
# $frontMatter .= "path_base_for_github_subdir:\n";
169+
# $frontMatter .= " from: tmp/semconv/docs/$1_index.md\n";
170+
# $frontMatter .= " to: $1README.md\n";
171+
# }
146172

147173
return $frontMatter;
148174
}
@@ -157,7 +183,7 @@ ()
157183
}
158184

159185
print $beforeTitle if $beforeTitle;
160-
$title = toTitleCase($title);
186+
$title = toSentenceCase($title);
161187
print "# $title\n"
162188
}
163189

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/usr/bin/perl -w -i
2+
#
3+
# DRAFT script used to normalize semconv doc-page tiles and add Hugo front matter
4+
5+
$^W = 1;
6+
7+
use strict;
8+
use warnings;
9+
use diagnostics;
10+
11+
sub mountEntryFor() {
12+
s|^(./)?docs/||;
13+
my $target = $_;
14+
$target =~ s/README\.md$/_index.md/;
15+
return <<"EOS";
16+
- source: tmp/semconv/docs/$_
17+
target: content/docs/specs/semconv/$target
18+
EOS
19+
}
20+
21+
sub main() {
22+
foreach (@ARGV) {
23+
my $path = "";
24+
print mountEntryFor();
25+
}
26+
}
27+
28+
main();

static/refcache.json

+4
Original file line numberDiff line numberDiff line change
@@ -18687,6 +18687,10 @@
1868718687
"StatusCode": 200,
1868818688
"LastSeen": "2024-10-09T10:19:24.765198+02:00"
1868918689
},
18690+
"https://wikipedia.org/wiki/SQL_syntax#Operators": {
18691+
"StatusCode": 200,
18692+
"LastSeen": "2025-01-28T16:18:59.006111-05:00"
18693+
},
1869018694
"https://wikipedia.org/wiki/Software_testing": {
1869118695
"StatusCode": 200,
1869218696
"LastSeen": "2024-12-04T08:47:02.68804707Z"

0 commit comments

Comments
 (0)