summaryrefslogtreecommitdiffstats
path: root/js/src/doc/lib/make-watermark.sh
blob: a39ff5436a9c0b5dc722b016f13d4f381e5f879c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/env bash

# Generate an HTML watermark for the given file. Claim the text was
# generated from SOURCE.
#
# Usage:
#
#   make-watermark.sh FILE SOURCE

set -eu

# Include the watermark as visible text in the page, as suggested in bug 990662.

echo '<h4>Source Metadata</h4>'
echo '<dl>'
echo '    <dt>Generated from file:<dt>'
echo "    <dd>$2</dd>"
echo '    <dt>Watermark:</dt>'
echo "    <dd id='watermark'>sha256:$(cat "$1" | shasum -a 256 | sed 's/ .*$//')</dd>"

# If we have Mercurial changeset ID, include it.
if [ "${JS_DOC_HG_IDENTIFY:+set}" = set ]; then
    # If the changeset ID has a '+' on the end (indicating local
    # modifications), omit that from the link.
    cat <<EOF
    <dt>Changeset:</dt>
    <dd><a href="https://hg.mozilla.org/mozilla-central/rev/${JS_DOC_HG_IDENTIFY%+}">${JS_DOC_HG_IDENTIFY}</a></dd>
EOF
fi

echo '</dl>'