Skip to content

Commit e68c275

Browse files
authored
Merge pull request linode#45 from leslitagordita/local-api-docs-build
[New] Add way to build the api docs site from a local spec file
2 parents a4aa0d8 + 9aa7dea commit e68c275

File tree

3 files changed

+26
-9
lines changed

3 files changed

+26
-9
lines changed

develop.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
3+
bash ./getDependencies.sh ${1}
4+
gatsby develop;

getDependencies.sh

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,37 @@
11
BLUE='\033[0;34m'
22
NC='\033[0m' # No Color
33

4+
SPEC_FILE=""
5+
if [ -n ${1} ]; then
6+
SPEC_FILE=${1}
7+
echo $([ -f $SPEC_FILE ])
8+
fi
9+
410
echo
5-
echo "${BLUE}Fetching base theme${NC}"
11+
printf "${BLUE}Fetching base theme${NC}\n"
612
if
713
cd linode-hugo-theme; then
814
git pull origin development; else
915
git clone https://github.com/linode/linode-hugo-theme.git;
1016
fi
1117

12-
echo
13-
echo "${BLUE}Fetching API specs${NC}"
14-
cd -
15-
curl https://raw.githubusercontent.com/linode/linode-api-docs/master/openapi.yaml > static/api/docs/v4/openapi.yaml
18+
if [ -f "$SPEC_FILE" ]; then
19+
echo
20+
printf "${BLUE}Using local spec file at: ${SPEC_FILE}${NC}\n"
21+
cat $SPEC_FILE > static/api/docs/v4/openapi.yaml;
22+
else
23+
echo
24+
printf "${BLUE}Fetching API specs${NC}\n"
25+
cd -
26+
curl https://raw.githubusercontent.com/linode/linode-api-docs/master/openapi.yaml > static/api/docs/v4/openapi.yaml;
27+
fi
28+
1629

1730
echo
18-
echo "${BLUE}Removing faulty data${NC}"
31+
printf "${BLUE}Removing faulty data${NC}\n"
1932
sed -i.bak '/backgroundColor:/d' static/api/docs/v4/openapi.yaml
2033
rm static/api/docs/v4/openapi.yaml.bak
2134

2235
echo
23-
echo "${BLUE}Converting YAML to JSON${NC}"
24-
./node_modules/yamljs/bin/yaml2json static/api/docs/v4/openapi.yaml > static/api/docs/v4/spec.json
36+
printf "${BLUE}Converting YAML to JSON${NC}\n"
37+
node_modules/yamljs/bin/yaml2json static/api/docs/v4/openapi.yaml > static/api/docs/v4/spec.json

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
],
5151
"scripts": {
5252
"build": "./getDependencies.sh && gatsby build && node search/buildIndex.js",
53-
"develop": "./getDependencies.sh && gatsby develop",
53+
"develop": "./develop.sh",
5454
"start": "npm run develop",
5555
"serve": "gatsby serve",
5656
"test": "echo \"Write tests! -> https://gatsby.app/unit-testing\""

0 commit comments

Comments
 (0)