-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Pull and extract Go and Java examples (#7446)
* Include required query arguments in curl examples * Pull and extract Go examples * use prebuild * Revert "use prebuild" This reverts commit 6ba1ddb. * Include make and gawk in build image * Fix permissions * touch Makefile.config * Respect existing files * Add Java examples * Hups * Fail on wrong example format Co-authored-by: david.jones <david.jones@datadoghq.com>
- Loading branch information
1 parent
7079c3d
commit a31c31b
Showing
8 changed files
with
174 additions
and
18 deletions.
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
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
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
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
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
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
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,57 @@ | ||
#!/usr/bin/env -S awk -f | ||
# SPDX-License-Identifier: Apache-2.0 OR MIT | ||
# Based on https://codereview.stackexchange.com/questions/194986/print-code-fenced-sections-of-a-markdown-document/195030#195030 | ||
BEGIN { | ||
in_code_block = 0; | ||
tag = ""; | ||
operation_id = ""; | ||
} | ||
|
||
function slug(value) { | ||
head = ""; | ||
tail = value; | ||
while ( match(tail,/[[:upper:]][[:lower:]]/) ) { | ||
tgt = substr(tail,RSTART,1); | ||
if ( substr(tail,RSTART-1,1) ~ /[[:lower:]]/ ) { | ||
tgt = "-" tolower(tgt); | ||
} | ||
head = head substr(tail,1,RSTART-1) tgt; | ||
tail = substr(tail,RSTART+1); | ||
} | ||
return tolower(head) tail; | ||
} | ||
|
||
/^# \\.+Api/ { | ||
tag = slug(substr($2, 2, length($2)-4)); | ||
} | ||
/^## / { | ||
operation_id = $2; | ||
} | ||
/^```go/ { | ||
if (in_code_block == 0) { | ||
in_code_block = 1; | ||
if (out_file) { | ||
close(out_file); | ||
} | ||
system("mkdir -p " output "/" tag); | ||
out_file=output "/" tag "/" operation_id ".go"; | ||
print out_file; | ||
} else { | ||
print "Can't parse " FILENAME > "/dev/stderr" | ||
exit 1 | ||
} | ||
next; | ||
} | ||
/^```/ { | ||
in_code_block = 0; | ||
} | ||
|
||
in_code_block { | ||
# Make sure that the file is newly created | ||
if (in_code_block == 1) { | ||
in_code_block = 2; | ||
print > out_file; | ||
} else { | ||
print >> out_file; | ||
} | ||
} |
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,56 @@ | ||
#!/usr/bin/env -S awk -f | ||
# SPDX-License-Identifier: Apache-2.0 OR MIT | ||
# Based on https://codereview.stackexchange.com/questions/194986/print-code-fenced-sections-of-a-markdown-document/195030#195030 | ||
BEGIN { | ||
in_code_block = 0; | ||
tag = ""; | ||
operation_id = ""; | ||
} | ||
|
||
function slug(value) { | ||
head = ""; | ||
tail = value; | ||
while ( match(tail,/[[:upper:]][[:lower:]]/) ) { | ||
tgt = substr(tail,RSTART,1); | ||
if ( substr(tail,RSTART-1,1) ~ /[[:lower:]]/ ) { | ||
tgt = "-" tolower(tgt); | ||
} | ||
head = head substr(tail,1,RSTART-1) tgt; | ||
tail = substr(tail,RSTART+1); | ||
} | ||
return tolower(head) tail; | ||
} | ||
|
||
/^# .+Api/ { | ||
tag = slug(substr($2, 0, length($2)-3)); | ||
} | ||
/^## / { | ||
operation_id = toupper( substr( $2, 1, 1 ) ) substr( $2, 2 ); | ||
} | ||
/^```java/ { | ||
if (in_code_block == 0) { | ||
in_code_block = 1; | ||
if (out_file) { | ||
close(out_file); | ||
} | ||
system("mkdir -p " output "/" tag); | ||
out_file=output "/" tag "/" operation_id ".java"; | ||
print out_file; | ||
} else { | ||
print "Can't parse " FILENAME > "/dev/stderr" | ||
exit 1 | ||
} | ||
next; | ||
} | ||
/^```/ { | ||
in_code_block = 0; | ||
} | ||
in_code_block { | ||
# Make sure that the file is newly created | ||
if (in_code_block == 1) { | ||
in_code_block = 2; | ||
print > out_file; | ||
} else { | ||
print >> out_file; | ||
} | ||
} |