26
26
my $otlpSpecVers = $versions {' otlp:' };
27
27
my $semconvVers = $versions {' semconv:' };
28
28
my %patchMsgCount ;
29
- my $openRelref = ' {{% relref' ;
30
29
31
30
sub printTitleAndFrontMatter () {
32
31
print " ---\n " ;
119
118
120
119
# # Semconv
121
120
122
- if ($ARGV =~ / \/ semconv/ ) {
121
+ if ($ARGV =~ / ^tmp \/ semconv/ ) {
123
122
my $otel_spec_event_deprecation = ' (opentelemetry-specification/blob/main/specification/logs)/event-(api|sdk).md' ;
124
123
if (/ $otel_spec_event_deprecation / ) {
125
124
# Cf. https://github.com/open-telemetry/opentelemetry-specification/pull/4359
@@ -131,13 +130,6 @@ ($$)
131
130
s | (\] :\s *)/docs/| $1 $specBasePath /semconv/| ;
132
131
133
132
s |\( (/model/.*?)\) | ($semconvSpecRepoUrl /tree/v$semconvVers /$1 )| g ;
134
-
135
- # TODO: drop after fix of https://github.com/open-telemetry/semantic-conventions/pull/1316
136
- s | #instrument-advice\b | #instrument-advisory-parameters| g ;
137
-
138
- # TODO: drop after fix of https://github.com/open-telemetry/semantic-conventions/issues/1313
139
- s | (/database/database-spans\. md)#batch-operations| $1 | g ;
140
- s | (/messaging/messaging-spans\. md)#common-messaging-operations| $1 | g ;
141
133
}
142
134
143
135
153
145
154
146
s |\( https://github.com/open-telemetry/opentelemetry-specification\) | ($specBasePath /otel/)| ;
155
147
s | (\]\( )/specification/| $1 $specBasePath /otel/)| ;
156
- s |\.\. /semantic_conventions/README.md| $semConvRef | if $ARGV =~ / overview/ ;
157
148
s |\.\. /specification/(.*?\) )| ../otel/$1 | g if $ARGV =~ / otel\/ specification/ ;
158
149
159
150
# Match markdown inline links or link definitions to OTel spec pages: "[...](URL)" or "[...]: URL"
@@ -172,93 +163,15 @@ ($$)
172
163
s | (\]\( )([^)]+\. png\) )| $1 ../$2 | g if $ARGV =~ / \b tmp\/ semconv\/ docs\/ general\/ attributes/ ;
173
164
s | (\]\( )([^)]+\. png\) )| $1 ../$2 | g if $ARGV =~ / \b tmp\/ semconv\/ docs\/ http\/ http-spans/ ;
174
165
175
- # Handle links containing `README.md`
176
-
177
166
# Rewrite paths that are outside of the spec folders as external links:
178
-
179
167
s |\.\.\/ README.md| $otelSpecRepoUrl /| g if $ARGV =~ / specification._index/ ;
180
- s |\.\.\/ README.md| .. | if $ARGV =~ / specification\/ library-guidelines.md/ ;
168
+ s |\.\.\/ README.md| /docs/specs/otel/ | if $ARGV =~ / specification\/ library-guidelines.md/ ;
181
169
182
170
s | (\.\.\/ )+(experimental\/ [^)]+)| $otelSpecRepoUrl /tree/v$otelSpecVers /$2 | g ;
183
171
s | (\.\.\/ )+(supplementary-guidelines\/ compatibility\/ [^)]+)| $otelSpecRepoUrl /tree/v$otelSpecVers /$2 | g ;
184
172
185
173
s |\.\. /((?:examples/)?README\. md)| $otlpSpecRepoUrl /tree/v$otlpSpecVers /$1 | g if $ARGV =~ / ^tmp\/ otlp/ ;
186
174
187
- # Replace `README.md` by `_index.md` in markdown links:
188
- s {
189
- # An inline markdown link, just before the URL: `](` like in `[docs](/docs)`
190
- (
191
- \]\(
192
- )
193
-
194
- # Match any local path. In the `[^...]` exclude group we have:
195
- # - `:` so as to exclude external links, which use `:` after a protocol specifier
196
- # - `)` prevents us from gobbling up past the end of the inline link
197
-
198
- ([^:\) ]*)
199
- README\. md
200
- ([^)]*) # Any anchor specifier
201
- (\) ) # The end of the inline link
202
- } { $1 $openRelref "$2_index.md$3 " \%\}\} $4 } gx ;
203
-
204
- # Replace `README.md` by `_index.md` in markdown link definitions:
205
- s {
206
- # A markdown link definition, just before the URL: `]:`, like in `[docs]: /docs`
207
- (
208
- \] :\s *
209
- )
210
-
211
- # Match any local path. In the `[^...]` exclude group we have:
212
- # - `:` so as to exclude external links, which use `:` after a protocol specifier
213
- # - A space should prevent us from gobbling up beyond the end of a link def
214
-
215
- ([^: ]*)
216
- README\. md
217
- ([^)]*) # Any anchor specifier
218
- (\n )$ # End of the link definition
219
- } { $1 $openRelref "$2_index.md$3 " \%\}\} $4 } gx ;
220
-
221
- # Rewrite inline links
222
- if ($ARGV =~ / \b tmp\/ opamp/ ) {
223
- s |\]\( ([^:\) ]*?)\. md((#.*?)?)\) | ]($1 /$2 )| g ;
224
- } else {
225
- # Generally rewrite markdown links as {{% relref "..." %}} expressions,
226
- # since that gets Hugo to resolve the links. We can't use the raw path since
227
- # some need a `../` prefix to resolve. We let Hugo handle that.
228
- s {
229
- # Match markdown link `](` just before the URL
230
- (\]\( )
231
-
232
- # Match the link path:
233
- (
234
- # Match paths upto but excluding `.md`. The character exclusions are as follows:
235
- #
236
- # - `:` ensures the URL is a path, not an external link, which has a protocol followe by `:`
237
- # - `)` so we don't overrun the end of the markdown link, which ends with `)`
238
- # - `{` or `}` so that the path doesn't contain Hugo {{...}}
239
-
240
- [^:\)\{\} ]*?
241
-
242
- \. md
243
-
244
- # Match optional anchor of the form `#some-id`
245
- (?:
246
- \# .*?
247
- )?
248
- )
249
- # Closing parenthesis of markdown link
250
- \)
251
- } { $1 $openRelref "$2 " \%\}\}\) } gx ;
252
- }
253
-
254
- # Rewrite link defs to local pages such as the following:
255
- #
256
- # [specification]: overview.md
257
- # [faas]: some-path/faas-spans.md (FaaS trace conventions)
258
- #
259
- # The subregex `[:\s]+` excludes external URLs (because they contain a colon after the protocol)
260
- s | ^(\[ [^\] ]+\] :\s *)([^:\s ]+)(\s *(\( .*\) )?)$| $1 \{ {% relref "$2 " %}}$3 | g ;
261
-
262
175
# Make website-local page references local:
263
176
s | https://opentelemetry.io/| /| g ;
264
177
0 commit comments