aboutsummaryrefslogtreecommitdiffstats
path: root/build/buildjsdocs.sh
blob: e40ecd7242b93548ed3bf96d7b99fc54f031755f (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
32
33
34
35
36
37
38
39
40
#!/usr/bin/env bash
#
# SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
# SPDX-FileCopyrightText: 2014-2015 ownCloud, Inc.
# SPDX-License-Identifier: AGPL-3.0-only
#
# Run JS tests
#
NPM="$(which npm 2>/dev/null)"
OUTPUT_DIR="jsdocs"

JS_FILES="../core/js/*.js ../core/js/**/*.js ../apps/*/js/*.js"

if test -z "$NPM"
then
	echo 'Node JS >= 0.8 is required to build the documentation' >&2
	exit 1
fi

# update/install test packages
$NPM install --prefix . --link jsdoc || exit 3

JSDOC_BIN="$(which jsdoc 2>/dev/null)"

# If not installed globally, try local version
if test -z "$JSDOC_BIN"
then
	JSDOC_BIN="./node_modules/jsdoc/jsdoc.js"
fi

if test -z "$JSDOC_BIN"
then
	echo 'jsdoc executable not found' >&2
	exit 2
fi

mkdir -p "$OUTPUT_DIR"

NODE_PATH="./node_modules" $JSDOC_BIN -d "$OUTPUT_DIR" $JS_FILES