kythe.io@v0.0.68-0.20240422202219-7225dbc01741/kythe/docs/schema/example-dot.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 verifies and formats a single Kythe example, which is expected
    19  # to be piped in on standard input from example.sh.
    20  #
    21  # The script assumes its working directory is the schema output directory and
    22  # requires the following environment variables:
    23  #   TMP
    24  #   LANGUAGE
    25  #   LABEL
    26  #   CXX_INDEXER_BIN
    27  #   VERIFIER_BIN
    28  #   SHASUM_TOOL
    29  
    30  RAW_EXAMPLE="$TMP/raw.dot"
    31  cat > "${RAW_EXAMPLE}"
    32  EXAMPLE_ID="$($SHASUM_TOOL "${RAW_EXAMPLE}" | cut -c 1-64)"
    33  dot -Tsvg -o "${EXAMPLE_ID}.svg" "${RAW_EXAMPLE}"
    34  echo "<div>"
    35  cat "${EXAMPLE_ID}.svg"
    36  echo "</div>"
    37  # echo "(<a href=\"${EXAMPLE_ID}.svg\" target=\"_blank\">${LANGUAGE}</a>)"