From 16a29b016f354e7da84b75f7ceaa249ed00880ff Mon Sep 17 00:00:00 2001 From: "Vipul Gupta (@vipulgupta2048)" Date: Mon, 18 Nov 2024 21:16:56 +0530 Subject: [PATCH 1/2] patch: Create versioned docs for Python SDK Signed-off-by: Vipul Gupta (@vipulgupta2048) --- .cspell/balena-words.txt | 1 + .gitignore | 6 +++++- config/navigation.txt | 2 +- config/redirects.txt | 8 ++++++-- pages/reference/sdk/python-sdk.md | 14 ++++++++++++++ templates/balena-sdk-python.html | 8 ++++++++ tools/build.sh | 3 +++ tools/fetch-external.sh | 2 +- 8 files changed, 39 insertions(+), 5 deletions(-) create mode 100644 pages/reference/sdk/python-sdk.md create mode 100644 templates/balena-sdk-python.html diff --git a/.cspell/balena-words.txt b/.cspell/balena-words.txt index f45656de8..6ac414256 100644 --- a/.cspell/balena-words.txt +++ b/.cspell/balena-words.txt @@ -8,6 +8,7 @@ balenacli balenahup balenalib balenasdk +balenasdkpython balenista balenistas Barys diff --git a/.gitignore b/.gitignore index ca4ea799c..641c7a7ca 100644 --- a/.gitignore +++ b/.gitignore @@ -15,7 +15,7 @@ tmp # Ignore external docs that are pulled via tools/fetch-external.sh # pages/reference/sdk/node-sdk.md -pages/reference/sdk/python-sdk.md +# pages/reference/sdk/python-sdk.md pages/reference/supervisor/supervisor-api.md pages/reference/supervisor/upgrade-policy.md @@ -50,6 +50,10 @@ shared/balena-cli-versions/ config/dictionaries/balenasdk.json shared/balena-sdk-versions/ +# Ignore dynamic Python SDK version docs +config/dictionaries/balenasdkpython.json +shared/balena-sdk-python-versions/ + # Ignore dynamic assets generated for Getting Started static/img/device/** config/dictionaries/device.json diff --git a/config/navigation.txt b/config/navigation.txt index 2a3ee4598..be4ca64a0 100644 --- a/config/navigation.txt +++ b/config/navigation.txt @@ -152,7 +152,7 @@ Reference CLI[/reference/balena-cli/$balenacli] SDKs Node.js SDK[/reference/sdk/node-sdk/$balenasdk] - Python SDK[/reference/sdk/python-sdk] + Python SDK[/reference/sdk/python-sdk/$balenasdkpython] Deprecation Policy[/reference/sdk/deprecation-policy] Diagnostics diff --git a/config/redirects.txt b/config/redirects.txt index 3b76b9946..9782879bb 100644 --- a/config/redirects.txt +++ b/config/redirects.txt @@ -196,8 +196,8 @@ /tools/cli /reference/balena-cli/latest/ /tools/sdk/ /reference/sdk/node-sdk/latest/ /tools/sdk /reference/sdk/node-sdk/latest/ -/tools/python-sdk/ /reference/sdk/python-sdk/ -/tools/python-sdk /reference/sdk/python-sdk/ +/tools/python-sdk/ /reference/sdk/python-sdk/latest/ +/tools/python-sdk /reference/sdk/python-sdk/latest/ /runtime/resin-base-images/ /reference/base-images/balena-base-images/ /runtime/resin-base-images /reference/base-images/balena-base-images/ /configuration/custom-docker-base-images/ /reference/base-images/customer-docker-base-images/ @@ -274,6 +274,10 @@ /reference/sdk/node-sdk/ /reference/sdk/node-sdk/latest/ /reference/sdk/node-sdk /reference/sdk/node-sdk/latest/ +# Versioned Python.js SDK docs +/reference/sdk/python-sdk/ /reference/sdk/python-sdk/latest/ +/reference/sdk/python-sdk /reference/sdk/python-sdk/latest/ + # Important: keep dynamic redirect below the static redirects # https://developers.cloudflare.com/pages/platform/redirects/ diff --git a/pages/reference/sdk/python-sdk.md b/pages/reference/sdk/python-sdk.md new file mode 100644 index 000000000..a77c4fd4d --- /dev/null +++ b/pages/reference/sdk/python-sdk.md @@ -0,0 +1,14 @@ +--- +title: balena Python SDK Documentation + +layout: balena-sdk-python.html + +dynamic: + variables: [ $balenasdkpython ] + ref: $original_ref/$balenasdkpython + $switch_text: balena SDK version $balenasdkpython +--- + +# Balena Python SDK {{ $balenasdkpython.version }} Documentation + +{{import "balena-sdk-python-versions"}} diff --git a/templates/balena-sdk-python.html b/templates/balena-sdk-python.html new file mode 100644 index 000000000..a05b70b2b --- /dev/null +++ b/templates/balena-sdk-python.html @@ -0,0 +1,8 @@ +{% extends "default.html" %} + +{% block dynamicSwitchCustom %} +

+

+{% endblock %} + +
diff --git a/tools/build.sh b/tools/build.sh index df254a4ba..7205b583f 100755 --- a/tools/build.sh +++ b/tools/build.sh @@ -16,6 +16,9 @@ node ./tools/versioning.js https://github.com/balena-io/balena-cli/blob/master/d # Generate versioned balena-sdk docs node ./tools/versioning.js https://github.com/balena-io/balena-sdk/blob/master/DOCUMENTATION.md +# Generate versioned balena-python-sdk docs +node ./tools/versioning.js https://github.com/balena-io/balena-sdk-python/blob/master/DOCUMENTATION.md + # Generate Masterclasses Dynamically ./tools/build-masterclass.sh diff --git a/tools/fetch-external.sh b/tools/fetch-external.sh index 6e0d126ce..ddd8edc15 100755 --- a/tools/fetch-external.sh +++ b/tools/fetch-external.sh @@ -100,7 +100,7 @@ cd shared/sdk/ && { } & # get latest python SDK docs -curl --fail --show-error -o pages/reference/sdk/python-sdk.md -L https://github.com/balena-io/balena-sdk-python/raw/master/DOCUMENTATION.md & +# curl --fail --show-error -o pages/reference/sdk/python-sdk.md -L https://github.com/balena-io/balena-sdk-python/raw/master/DOCUMENTATION.md & # get latest base images ref docs cd pages/reference/base-images/ && { From d5939a134110925b2943d35421724d398f110c64 Mon Sep 17 00:00:00 2001 From: "Vipul Gupta (@vipulgupta2048)" Date: Thu, 21 Nov 2024 19:25:33 +0530 Subject: [PATCH 2/2] Differentiate same name config files Signed-off-by: Vipul Gupta (@vipulgupta2048) --- .cspell/balena-words.txt | 4 ++-- .gitignore | 4 ++-- config/navigation.txt | 4 ++-- pages/reference/sdk/node-sdk.md | 8 ++++---- pages/reference/sdk/python-sdk.md | 8 ++++---- tools/versioning.js | 15 +++++++++++++-- 6 files changed, 27 insertions(+), 16 deletions(-) diff --git a/.cspell/balena-words.txt b/.cspell/balena-words.txt index 6ac414256..ee5bef0b6 100644 --- a/.cspell/balena-words.txt +++ b/.cspell/balena-words.txt @@ -7,8 +7,6 @@ balena-builder balenacli balenahup balenalib -balenasdk -balenasdkpython balenista balenistas Barys @@ -30,8 +28,10 @@ metalsmith model multicontainer Nicky +nodesdk openbalena private-contracts +pythonsdk resinio Rulemotion SBVR diff --git a/.gitignore b/.gitignore index 641c7a7ca..de40e8df4 100644 --- a/.gitignore +++ b/.gitignore @@ -47,11 +47,11 @@ config/dictionaries/balenacli.json shared/balena-cli-versions/ # Ignore dynamic balena-SDK version docs -config/dictionaries/balenasdk.json +config/dictionaries/nodesdk.json shared/balena-sdk-versions/ # Ignore dynamic Python SDK version docs -config/dictionaries/balenasdkpython.json +config/dictionaries/pythonsdk.json shared/balena-sdk-python-versions/ # Ignore dynamic assets generated for Getting Started diff --git a/config/navigation.txt b/config/navigation.txt index be4ca64a0..fb492cc2e 100644 --- a/config/navigation.txt +++ b/config/navigation.txt @@ -151,8 +151,8 @@ Reference CLI[/reference/balena-cli/$balenacli] SDKs - Node.js SDK[/reference/sdk/node-sdk/$balenasdk] - Python SDK[/reference/sdk/python-sdk/$balenasdkpython] + Node.js SDK[/reference/sdk/node-sdk/$nodesdk] + Python SDK[/reference/sdk/python-sdk/$pythonsdk] Deprecation Policy[/reference/sdk/deprecation-policy] Diagnostics diff --git a/pages/reference/sdk/node-sdk.md b/pages/reference/sdk/node-sdk.md index f7e779a5f..f76a10585 100644 --- a/pages/reference/sdk/node-sdk.md +++ b/pages/reference/sdk/node-sdk.md @@ -4,11 +4,11 @@ title: balena Node.js SDK Documentation layout: balena-sdk.html dynamic: - variables: [ $balenasdk ] - ref: $original_ref/$balenasdk - $switch_text: balena SDK version $balenasdk + variables: [ $nodesdk ] + ref: $original_ref/$nodesdk + $switch_text: balena SDK version $nodesdk --- -# Balena Node.js SDK {{ $balenasdk.version }} Documentation +# Balena Node.js SDK {{ $nodesdk.version }} Documentation {{import "balena-sdk-versions"}} diff --git a/pages/reference/sdk/python-sdk.md b/pages/reference/sdk/python-sdk.md index a77c4fd4d..3d89e4f9b 100644 --- a/pages/reference/sdk/python-sdk.md +++ b/pages/reference/sdk/python-sdk.md @@ -4,11 +4,11 @@ title: balena Python SDK Documentation layout: balena-sdk-python.html dynamic: - variables: [ $balenasdkpython ] - ref: $original_ref/$balenasdkpython - $switch_text: balena SDK version $balenasdkpython + variables: [ $pythonsdk ] + ref: $original_ref/$pythonsdk + $switch_text: balena SDK version $pythonsdk --- -# Balena Python SDK {{ $balenasdkpython.version }} Documentation +# Balena Python SDK {{ $pythonsdk.version }} Documentation {{import "balena-sdk-python-versions"}} diff --git a/tools/versioning.js b/tools/versioning.js index 1bb875471..0590734cb 100644 --- a/tools/versioning.js +++ b/tools/versioning.js @@ -251,9 +251,20 @@ async function main() { process.exit(1); } + const versionsConfigFileTemplate = { + "balenasdk": "nodesdk", + "balenasdkpython": "pythonsdk", + } + // Parse repository details const { owner, name: repoName, filepath } = parseGithubUrl(repoUrl); - const versionsConfigFile = `./config/dictionaries/${repoName.replaceAll(/-/g, "")}.json` + + // Create versioned config file - Doxx doesn't allow dashes in the config file name + const versionsFileName = repoName.replaceAll(/-/g, "") + // Doxx treats config files with common names as same, so balenasdk and balenasdkpython config files needs to be named differently + const versionsConfigFile = versionsConfigFileTemplate[versionsFileName] ? versionsConfigFileTemplate[versionsFileName] : versionsFileName + const versionsConfigFilePath = `./config/dictionaries/${versionsConfigFile}.json` + const versionedDocsFolder = path.join(__dirname, `../shared/${repoName}-versions`) console.log(`Started versioning ${repoName} docs`) @@ -263,7 +274,7 @@ async function main() { const tagVersions = await fetchGitHubTags(owner, repoName); // Write versions configuration - await fsPromises.writeFile(versionsConfigFile, JSON.stringify(tagVersions, null, 2)); + await fsPromises.writeFile(versionsConfigFilePath, JSON.stringify(tagVersions, null, 2)); if (fs.existsSync(versionedDocsFolder)) { await fsPromises.rm(versionedDocsFolder, { recursive: true }); }