forked from pulumi/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_typedoc.sh
executable file
·162 lines (144 loc) · 5.54 KB
/
run_typedoc.sh
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
#!/bin/bash
# Runs typedoc on various Pulumi repos and copies them to
# the /libraries folder.
# NOTE: typedoc needs to be installed globally (see README.md) rather than
# in a local node_modules folder. This is because typedoc does not correctly
# support relative paths within a TypeScript file. (So, you can point it at a folder,
# but if those .ts files use a path like "..\", typedoc will fail to resolve as intended.)
set -o errexit -o pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
TOOL_TYPEDOC="$SCRIPT_DIR/../node_modules/.bin/typedoc"
TOOL_APIDOCGEN="go run ./tools/tscdocgen/*.go"
PULUMI_DOC_TMP=`mktemp -d`
PULUMI_DOC_BASE=./content/docs/reference/pkg/nodejs/pulumi
PULUMI_DOC_DATA_BASE=./data/pkg/nodejs/pulumi
# Set this to 1 to run all generation in parallel.
PARALLEL=0
# Generates API documentation for a given package. The arguments are:
# * $1 - the simple name of the package (e.g., "azure" for the pulumi-azure package)
# * $2 - the package root directory (to run `make ensure` for dependency updates)
# * $3 - the package source directory, relative to the root, optionally empty if the same
# If the PKGS envvar is set, only packages in that list (space delimited) are regenerated.
generate_docs() {
GENPKG=""
if [[ -z "$PKGS" ]]; then
GENPKG=$1
else
for PKG in ${PKGS}; do
if [[ "$PKG" == "$1" ]]; then
GENPKG=$1
fi
done
fi
if [[ ! -z "$GENPKG" ]]; then
echo -e "\033[0;95m$1\033[0m"
echo -e "\033[0;93mGenerating typedocs\033[0m"
# Change to the target directory and rebuild if necessary.
PKGPATH=../$2
pushd $PKGPATH
if [[ -z "$NOBUILD" ]]; then
git clean -xdf
make ensure && make build && make install
fi
if [[ ! -z "$3" ]]; then
PKGPATH=$PKGPATH/$3
cd $3
fi
PKG_REPO_DIR=$2
if [[ ! -z "$3" ]]; then
PKG_REPO_DIR=$PKG_REPO_DIR/$3
fi
# Generate the docs, copy any READMEs, and remember the Git hash.
${TOOL_TYPEDOC} --json "${PULUMI_DOC_TMP}/$1.docs.json" \
--mode modules --includeDeclarations --excludeExternals --excludePrivate
mkdir -p ${PULUMI_DOC_TMP}/readmes
find . -name 'README.md' -exec rsync -R {} ${PULUMI_DOC_TMP}/readmes \;
HEAD_COMMIT=$(git rev-parse HEAD)
# Change back to the origin directory and create the API documents.
popd
echo -e "\033[0;93mGenerating pulumi.com API docs\033[0m"
echo -e ${TOOL_APIDOCGEN} "${PKGPATH}" "$1" "${PULUMI_DOC_TMP}/$1.docs.json" "${PULUMI_DOC_BASE}/$1" "${PULUMI_DOC_DATA_BASE}" "$PKG_REPO_DIR" $HEAD_COMMIT
${TOOL_APIDOCGEN} "${PKGPATH}" "$1" "${PULUMI_DOC_TMP}/$1.docs.json" "${PULUMI_DOC_BASE}/$1" "${PULUMI_DOC_DATA_BASE}" "$PKG_REPO_DIR" $HEAD_COMMIT
fi
}
REPOS=(
"aiven,pulumi-aiven,sdk/nodejs"
"alicloud,pulumi-alicloud,sdk/nodejs"
"akamai,pulumi-akamai,sdk/nodejs"
"auth0,pulumi-auth0,sdk/nodejs"
"aws,pulumi-aws,sdk/nodejs"
"awsx,pulumi-awsx/nodejs/awsx"
"azure,pulumi-azure,sdk/nodejs"
"azure-nextgen,pulumi-azure-nextgen,sdk/nodejs"
"azuread,pulumi-azuread,sdk/nodejs"
"azuredevops,pulumi-azuredevops,sdk/nodejs"
"civo,pulumi-civo,sdk/nodejs"
"cloud,pulumi-cloud/api"
"cloudamqp,pulumi-cloudamqp,sdk/nodejs"
"cloudflare,pulumi-cloudflare,sdk/nodejs"
"consul,pulumi-consul,sdk/nodejs"
"datadog,pulumi-datadog,sdk/nodejs"
"digitalocean,pulumi-digitalocean,sdk/nodejs"
"dnsimple,pulumi-dnsimple,sdk/nodejs"
"docker,pulumi-docker,sdk/nodejs"
"eks,pulumi-eks/nodejs/eks"
"fastly,pulumi-fastly,sdk/nodejs"
"f5bigip,pulumi-f5bigip,sdk/nodejs"
"gcp,pulumi-gcp,sdk/nodejs"
"github,pulumi-github,sdk/nodejs"
"gitlab,pulumi-gitlab,sdk/nodejs"
"hcloud,pulumi-hcloud,sdk/nodejs"
"kafka,pulumi-kafka,sdk/nodejs"
"keycloak,pulumi-keycloak,sdk/nodejs"
"kong,pulumi-kong,sdk/nodejs"
"kubernetes,pulumi-kubernetes,sdk/nodejs"
"kubernetesx,pulumi-kubernetesx/nodejs/kubernetesx"
"linode,pulumi-linode,sdk/nodejs"
"mailgun,pulumi-mailgun,sdk/nodejs"
"mongodbatlas,pulumi-mongodbatlas,sdk/nodejs"
"mysql,pulumi-mysql,sdk/nodejs"
"newrelic,pulumi-newrelic,sdk/nodejs"
"ns1,pulumi-ns1,sdk/nodejs"
"okta,pulumi-okta,sdk/nodejs"
"openstack,pulumi-openstack,sdk/nodejs"
"packet,pulumi-packet,sdk/nodejs"
"pagerduty,pulumi-pagerduty,sdk/nodejs"
"policy,pulumi-policy,sdk/nodejs/policy"
"postgresql,pulumi-postgresql,sdk/nodejs"
"pulumi,pulumi/sdk/nodejs"
"rabbitmq,pulumi-rabbitmq,sdk/nodejs"
"rancher2,pulumi-rancher2,sdk/nodejs"
"random,pulumi-random,sdk/nodejs"
"signalfx,pulumi-signalfx,sdk/nodejs"
"spotinst,pulumi-spotinst,sdk/nodejs"
"terraform,pulumi-terraform,sdk/nodejs"
"tls,pulumi-tls,sdk/nodejs"
"vault,pulumi-vault,sdk/nodejs"
"venafi,pulumi-venafi,sdk/nodejs"
"vsphere,pulumi-vsphere,sdk/nodejs"
"wavefront,pulumi-wavefront,sdk/nodejs"
)
PIDS=()
# run processes and store pids in array
for repo in ${REPOS[*]}
do
IFS=',' read -r -a repo_parts <<< "$repo"
SIMPLE_NAME=${repo_parts[0]}
PACKAGE_NAME=${repo_parts[1]}
ROOT_PATH=${repo_parts[2]}
if [ "$PARALLEL" -eq "1" ]; then
generate_docs $SIMPLE_NAME $PACKAGE_NAME $ROOT_PATH &
PIDS+=($!)
else
generate_docs $SIMPLE_NAME $PACKAGE_NAME $ROOT_PATH
PIDS+=($!)
fi
echo -e $!
done
# wait for all pids
for pid in ${PIDS[*]}
do
echo -e "Waiting on: $pid"
wait $pid
done
echo "Done"