kythe.io@v0.0.68-0.20240422202219-7225dbc01741/kythe/docs/schema/example-clike.sh (about) 1 #!/bin/bash -e 2 set -o pipefail 3 4 # Copyright 2016 The Kythe Authors. All rights reserved. 5 # 6 # Licensed under the Apache License, Version 2.0 (the "License"); 7 # you may not use this file except in compliance with the License. 8 # You may obtain a copy of the License at 9 # 10 # http://www.apache.org/licenses/LICENSE-2.0 11 # 12 # Unless required by applicable law or agreed to in writing, software 13 # distributed under the License is distributed on an "AS IS" BASIS, 14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 # See the License for the specific language governing permissions and 16 # limitations under the License. 17 18 # This script formats a single Kythe example, which is expected to be piped in 19 # on standard input from example.sh. It will not run the verifier but will 20 # format the example like C++. 21 # 22 # The script assumes its working directory is the schema output directory and 23 # requires the following environment variables: 24 # TMP 25 # LANGUAGE 26 # LABEL 27 28 SRCS="$TMP/example" 29 mkdir "$SRCS" 30 ARGS_FILE="$TMP/args" 31 touch "$ARGS_FILE" 32 33 # The raw filter input will be placed into this file for later syntax 34 # highlighting. 35 RAW_EXAMPLE="$TMP/raw.hcc" 36 cat > "${RAW_EXAMPLE}" 37 38 echo "<div><h5 id=\"_${LABEL}\">${LABEL}" 39 echo " (${LANGUAGE})</h5>" 40 source-highlight --failsafe --output=STDOUT --src-lang cpp -i "$RAW_EXAMPLE" 41 echo "</div>"