forked from zalando/restful-api-guidelines
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: generate rules information json in travis build (zalando#446)
- Loading branch information
1 parent
f871fff
commit a5e606e
Showing
3 changed files
with
13 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/usr/bin/env bash | ||
# This script generates a JSON with information about the guideline rules. | ||
|
||
build_dir=${1:-output} | ||
|
||
grep -Pzoh "(?s)\[(#[0-9]+)\]\n[=]+\s+.*?\n" chapters/* | \ | ||
sed '$!N;s/\n/ /' | tr -d "[]{}\000"| sed '/^\s*$/d' | \ | ||
sort | perl -pi -e 'chomp if eof' | \ | ||
jq -Rs '{rules: split("\n") }' | \ | ||
jq '{rules: .rules | map(. | {id: split(" == ")[0], title: split(" == ")[1]})}' \ | ||
> ${build_dir}/rules |