-
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.
Added a "Background" section explaining how the module came to be.
- Loading branch information
Showing
2 changed files
with
88 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# This Source Code Form is subject to the terms of the Mozilla Public | ||
# License, v. 2.0. If a copy of the MPL was not distributed with this | ||
# file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
# | ||
# jsdoc wrapper used by the "jsdoc" package.json script | ||
# | ||
# Removes the existing destination directory if it exists, runs JSDoc, and emits | ||
# the relative path to the generated index.html file. | ||
# | ||
# Prompts the user to install JSDoc if not present. It's not a package.json | ||
# devDependency because it seems that many folks browse JSDoc in their IDE | ||
# without needing to generate the HTML version. | ||
|
||
if ! command -v jsdoc > /dev/null; then | ||
echo \"Run 'pnpm add -g jsdoc' to install JSDoc: https://jsdoc.app\" | ||
exit 1 | ||
fi | ||
|
||
ARGS=() | ||
DESTINATION="" | ||
|
||
# Discover the output directory, since JSDoc doesn't have a setting to emit it. | ||
while [[ "$#" -ne 0 ]]; do | ||
curArg="$1" | ||
shift | ||
ARGS+=("$curArg") | ||
|
||
case "$curArg" in | ||
-c|--configure) | ||
if [[ -z "$DESTINATION" ]]; then | ||
# All bets are off if the destination property contains an escaped '"' or | ||
# there's more than one "destination" property defined. | ||
DESTINATION="$(sed -ne 's/.*"destination": *"\([^"]*\)".*/\1/p' < "$1")" | ||
fi | ||
ARGS+=("$1") | ||
shift | ||
;; | ||
-d|--destination) | ||
DESTINATION="$1" | ||
ARGS+=("$1") | ||
shift | ||
;; | ||
*) | ||
;; | ||
esac | ||
done | ||
|
||
# "out" is the JSDoc default directory. | ||
DESTINATION="${DESTINATION:-out}" | ||
rm -rf "$DESTINATION" | ||
|
||
if jsdoc "${ARGS[@]}"; then | ||
exec find "$DESTINATION" -name index.html -print -quit | ||
fi |