summaryrefslogtreecommitdiffstats
path: root/js/src/doc/lib/make-bibliography.sh
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /js/src/doc/lib/make-bibliography.sh
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'js/src/doc/lib/make-bibliography.sh')
-rwxr-xr-xjs/src/doc/lib/make-bibliography.sh81
1 files changed, 81 insertions, 0 deletions
diff --git a/js/src/doc/lib/make-bibliography.sh b/js/src/doc/lib/make-bibliography.sh
new file mode 100755
index 000000000..33068ca9c
--- /dev/null
+++ b/js/src/doc/lib/make-bibliography.sh
@@ -0,0 +1,81 @@
+#!/usr/bin/env bash
+
+# Generate a Markdown bibliography file --- that is, definitions for
+# reference-style link labels --- from a documentation directory's
+# config.sh file.
+#
+# Usage:
+# make-bibliography.sh [--mdn] CONFIG CITING-URL
+#
+# where:
+# - CONFIG is the name of the config.sh file to process; and
+# - CITING-URL is the absolute URL at which the document using these labels
+# will appear. The links we output use URLs relative to CITING-URL to
+# refer to the URLs given in CONFIG.
+#
+# If given the --mdn flag, generate links that are correct for files
+# as they appear in format.sh's OUTPUTDIR, not for publishing on MDN.
+
+set -eu
+
+mdn=false
+
+while true; do
+ case "${1-}" in
+ '--mdn')
+ mdn=true
+ shift
+ ;;
+ *)
+ break
+ ;;
+ esac
+done
+
+lib=$(dirname $0)
+config=$1
+citing=$2
+
+source "$lib/common.sh"
+
+source "$lib/dummy-config.sh"
+
+label() {
+ local label=$1; shift
+ local fragment=
+ case "$1" in
+ '#'*)
+ fragment=$1; shift
+ ;;
+ esac
+ local title=${1:+ \"$1\"}
+
+ citing_prefix=$(dirname "$citing")/
+ if $mdn; then
+ echo "[$label]: $(relative "$citing_prefix" "$BASE_URL$RELATIVE_URL")$fragment$title"
+ else
+ echo "[$label]: ${INPUT_FILE/md/html}$fragment$title"
+ fi
+}
+
+absolute-label() {
+ local label=$1
+ local absolute_url=$2
+ local title=$3
+
+ echo "[$label]: $absolute_url${title:+ \"$title\"}"
+}
+
+resource() {
+ local label=$1 file=$2 absolute_url=$3
+
+ if [ -n "$label" ]; then
+ if $mdn; then
+ echo "[$label]: $absolute_url"
+ else
+ echo "[$label]: $file"
+ fi
+ fi
+}
+
+source "$config"