Skip to content

Commit c2a6155

Browse files
Merge pull request #3107 from balena-io/vipulgupta2048/version-python
Create versioned docs for Python SDK
2 parents e038ddb + d5939a1 commit c2a6155

File tree

10 files changed

+59
-14
lines changed

10 files changed

+59
-14
lines changed

.cspell/balena-words.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ balena-builder
77
balenacli
88
balenahup
99
balenalib
10-
balenasdk
1110
balenista
1211
balenistas
1312
Barys
@@ -29,8 +28,10 @@ metalsmith
2928
model
3029
multicontainer
3130
Nicky
31+
nodesdk
3232
openbalena
3333
private-contracts
34+
pythonsdk
3435
resinio
3536
Rulemotion
3637
SBVR

.gitignore

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ tmp
1515

1616
# Ignore external docs that are pulled via tools/fetch-external.sh
1717
# pages/reference/sdk/node-sdk.md
18-
pages/reference/sdk/python-sdk.md
18+
# pages/reference/sdk/python-sdk.md
1919

2020
pages/reference/supervisor/supervisor-api.md
2121
pages/reference/supervisor/upgrade-policy.md
@@ -47,9 +47,13 @@ config/dictionaries/balenacli.json
4747
shared/balena-cli-versions/
4848

4949
# Ignore dynamic balena-SDK version docs
50-
config/dictionaries/balenasdk.json
50+
config/dictionaries/nodesdk.json
5151
shared/balena-sdk-versions/
5252

53+
# Ignore dynamic Python SDK version docs
54+
config/dictionaries/pythonsdk.json
55+
shared/balena-sdk-python-versions/
56+
5357
# Ignore dynamic assets generated for Getting Started
5458
static/img/device/**
5559
config/dictionaries/device.json

config/navigation.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,8 @@ Reference
151151

152152
CLI[/reference/balena-cli/$balenacli]
153153
SDKs
154-
Node.js SDK[/reference/sdk/node-sdk/$balenasdk]
155-
Python SDK[/reference/sdk/python-sdk]
154+
Node.js SDK[/reference/sdk/node-sdk/$nodesdk]
155+
Python SDK[/reference/sdk/python-sdk/$pythonsdk]
156156
Deprecation Policy[/reference/sdk/deprecation-policy]
157157

158158
Diagnostics

config/redirects.txt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,8 @@
196196
/tools/cli /reference/balena-cli/latest/
197197
/tools/sdk/ /reference/sdk/node-sdk/latest/
198198
/tools/sdk /reference/sdk/node-sdk/latest/
199-
/tools/python-sdk/ /reference/sdk/python-sdk/
200-
/tools/python-sdk /reference/sdk/python-sdk/
199+
/tools/python-sdk/ /reference/sdk/python-sdk/latest/
200+
/tools/python-sdk /reference/sdk/python-sdk/latest/
201201
/runtime/resin-base-images/ /reference/base-images/balena-base-images/
202202
/runtime/resin-base-images /reference/base-images/balena-base-images/
203203
/configuration/custom-docker-base-images/ /reference/base-images/customer-docker-base-images/
@@ -274,6 +274,10 @@
274274
/reference/sdk/node-sdk/ /reference/sdk/node-sdk/latest/
275275
/reference/sdk/node-sdk /reference/sdk/node-sdk/latest/
276276

277+
# Versioned Python.js SDK docs
278+
/reference/sdk/python-sdk/ /reference/sdk/python-sdk/latest/
279+
/reference/sdk/python-sdk /reference/sdk/python-sdk/latest/
280+
277281
# Important: keep dynamic redirect below the static redirects
278282
# https://developers.cloudflare.com/pages/platform/redirects/
279283

pages/reference/sdk/node-sdk.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ title: balena Node.js SDK Documentation
44
layout: balena-sdk.html
55

66
dynamic:
7-
variables: [ $balenasdk ]
8-
ref: $original_ref/$balenasdk
9-
$switch_text: balena SDK version $balenasdk
7+
variables: [ $nodesdk ]
8+
ref: $original_ref/$nodesdk
9+
$switch_text: balena SDK version $nodesdk
1010
---
1111

12-
# Balena Node.js SDK {{ $balenasdk.version }} Documentation
12+
# Balena Node.js SDK {{ $nodesdk.version }} Documentation
1313

1414
{{import "balena-sdk-versions"}}

pages/reference/sdk/python-sdk.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
title: balena Python SDK Documentation
3+
4+
layout: balena-sdk-python.html
5+
6+
dynamic:
7+
variables: [ $pythonsdk ]
8+
ref: $original_ref/$pythonsdk
9+
$switch_text: balena SDK version $pythonsdk
10+
---
11+
12+
# Balena Python SDK {{ $pythonsdk.version }} Documentation
13+
14+
{{import "balena-sdk-python-versions"}}

templates/balena-sdk-python.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{% extends "default.html" %}
2+
3+
{% block dynamicSwitchCustom %}
4+
<p class="dynamic-switch__append">
5+
</p>
6+
{% endblock %}
7+
8+
<div id="output"></div>

tools/build.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ node ./tools/versioning.js https://github.com/balena-io/balena-cli/blob/master/d
1616
# Generate versioned balena-sdk docs
1717
node ./tools/versioning.js https://github.com/balena-io/balena-sdk/blob/master/DOCUMENTATION.md
1818

19+
# Generate versioned balena-python-sdk docs
20+
node ./tools/versioning.js https://github.com/balena-io/balena-sdk-python/blob/master/DOCUMENTATION.md
21+
1922
# Generate Masterclasses Dynamically
2023
./tools/build-masterclass.sh
2124

tools/fetch-external.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ cd shared/sdk/ && {
100100
} &
101101

102102
# get latest python SDK docs
103-
curl --fail --show-error -o pages/reference/sdk/python-sdk.md -L https://github.com/balena-io/balena-sdk-python/raw/master/DOCUMENTATION.md &
103+
# curl --fail --show-error -o pages/reference/sdk/python-sdk.md -L https://github.com/balena-io/balena-sdk-python/raw/master/DOCUMENTATION.md &
104104

105105
# get latest base images ref docs
106106
cd pages/reference/base-images/ && {

tools/versioning.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,9 +251,20 @@ async function main() {
251251
process.exit(1);
252252
}
253253

254+
const versionsConfigFileTemplate = {
255+
"balenasdk": "nodesdk",
256+
"balenasdkpython": "pythonsdk",
257+
}
258+
254259
// Parse repository details
255260
const { owner, name: repoName, filepath } = parseGithubUrl(repoUrl);
256-
const versionsConfigFile = `./config/dictionaries/${repoName.replaceAll(/-/g, "")}.json`
261+
262+
// Create versioned config file - Doxx doesn't allow dashes in the config file name
263+
const versionsFileName = repoName.replaceAll(/-/g, "")
264+
// Doxx treats config files with common names as same, so balenasdk and balenasdkpython config files needs to be named differently
265+
const versionsConfigFile = versionsConfigFileTemplate[versionsFileName] ? versionsConfigFileTemplate[versionsFileName] : versionsFileName
266+
const versionsConfigFilePath = `./config/dictionaries/${versionsConfigFile}.json`
267+
257268
const versionedDocsFolder = path.join(__dirname, `../shared/${repoName}-versions`)
258269

259270
console.log(`Started versioning ${repoName} docs`)
@@ -263,7 +274,7 @@ async function main() {
263274
const tagVersions = await fetchGitHubTags(owner, repoName);
264275

265276
// Write versions configuration
266-
await fsPromises.writeFile(versionsConfigFile, JSON.stringify(tagVersions, null, 2));
277+
await fsPromises.writeFile(versionsConfigFilePath, JSON.stringify(tagVersions, null, 2));
267278
if (fs.existsSync(versionedDocsFolder)) {
268279
await fsPromises.rm(versionedDocsFolder, { recursive: true });
269280
}

0 commit comments

Comments
 (0)