From ed76aaab625d4870c2c2486e3095cab93d4233a5 Mon Sep 17 00:00:00 2001 From: Aryan Bhosale Date: Fri, 29 Mar 2024 15:33:06 +0530 Subject: [PATCH 1/5] docs for bfe3227 commit --- script/docs.ps1 | 47 ++++++++++++++++++++++++++++++++++++ script/env.ps1 | 13 ++-------- script/markdownlint-hook.ps1 | 10 ++++++++ 3 files changed, 59 insertions(+), 11 deletions(-) create mode 100644 script/docs.ps1 create mode 100644 script/markdownlint-hook.ps1 diff --git a/script/docs.ps1 b/script/docs.ps1 new file mode 100644 index 000000000..dd1350eda --- /dev/null +++ b/script/docs.ps1 @@ -0,0 +1,47 @@ +# Get the version +if ($args) { + $Version = $args[0] +} else { + $Version = "development" +} + +# Set environment variables +$env:VERSION = $Version +$env:COMMIT_HASH = (git rev-parse --short HEAD) +$env:MKDOCS_ENABLE_PDF_EXPORT = 1 + +Write-Output "Version: $Version" + +# Remove the site directory if it exists +if (Test-Path "site") { + Remove-Item "site" -Recurse -Force +} + +# Generate and publish documents +Write-Output "Generate and publish documents..." +& mkdocs build --config-file mkdocs.yml --site-dir "site/online/$Version" + +# Copy redirect page +Copy-Item "docs/redirect-page.html" "site/index.html" + +# Checkout webpage-docs branch +git checkout webpage-docs + +# Clean up irrelevant files +if (Test-Path "$Version") { + Remove-Item "$Version" -Recurse -Force +} + +# Move PDF file to top directory +if (Test-Path "site/online/$Version") { + Move-Item "site/online/$Version/pdf/DTaaS-docs.pdf" ".\DTaaS-$Version.pdf" + Move-Item "site/online/$Version" ".\$Version" +} + +# Move index.html to top directory and remove site directory +Move-Item "site/index.html" "." +Remove-Item "site" -Recurse -Force + +# Commit changes +git add . +git commit --no-verify -m "docs for $env:COMMIT_HASH commit" \ No newline at end of file diff --git a/script/env.ps1 b/script/env.ps1 index f9b368438..e913f7a58 100644 --- a/script/env.ps1 +++ b/script/env.ps1 @@ -24,17 +24,8 @@ if (-not ([Environment]::GetEnvironmentVariable("Path", [EnvironmentVariableTarg # Install mkdocs pip install mkdocs -# Install Ruby: https://github.com/oneclick/rubyinstaller2/releases/download/RubyInstaller-3.1.2-1/rubyinstaller-devkit-3.1.2-1-x64.exe -choco install -y ruby - -# Ensure Ruby scripts directory is added to PATH -if (-not ([Environment]::GetEnvironmentVariable("Path", [EnvironmentVariableTarget]::Machine) -like "*Ruby*")) { - Write-Host "Adding Ruby scripts to PATH..." - [Environment]::SetEnvironmentVariable("Path", "$env:Path;$(Get-Command ruby | Select-Object -ExpandProperty Directory)", [EnvironmentVariableTarget]::Machine) -} - # Install markdownlint -gem install mdl +choco install markdownlint-cli # Install mkdocs plugins pip install mkdocs-material python-markdown-math mkdocs-open-in-new-tab mkdocs-with-pdf qrcode @@ -49,4 +40,4 @@ if (-not ([Environment]::GetEnvironmentVariable("Path", [EnvironmentVariableTarg choco install -y shellcheck # Install madge for generating dependency graphs of typescript projects -npm install -g madge +npm install -g madge \ No newline at end of file diff --git a/script/markdownlint-hook.ps1 b/script/markdownlint-hook.ps1 new file mode 100644 index 000000000..3bd991cf4 --- /dev/null +++ b/script/markdownlint-hook.ps1 @@ -0,0 +1,10 @@ +# This script is used by the pre-commit hook to check the markdown files without exiting the commit process. + +# Invoke markdownlint and capture the output +$output = markdownlint $args + +# Print the output +Write-Output $output + +# Exit with code 0 to indicate success +Exit 0 \ No newline at end of file From 44b1a36cc215f965fb2f6f6cd3e9eebb2f671f4f Mon Sep 17 00:00:00 2001 From: Aryan Bhosale Date: Fri, 29 Mar 2024 15:37:32 +0530 Subject: [PATCH 2/5] docs for ed76aaa commit --- docs/developer/index.md | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/docs/developer/index.md b/docs/developer/index.md index 86e9cd90f..1ec9ff96b 100644 --- a/docs/developer/index.md +++ b/docs/developer/index.md @@ -38,7 +38,7 @@ environment variables. The potential errors are: 1. `gem is not recognized.........` in `env.ps1` If you encounter these errors, -remember to include _node_ and _ruby_ installation locations in +remember to include _node_ installation locations in **PATH** environment variable (`Settings --> search for "system environment variables"` `--> Advanced --> Environment Variables --> PATH`). @@ -46,17 +46,14 @@ remember to include _node_ and _ruby_ installation locations in The `base.ps1` and `env.ps1` scripts can be run again after setting the correct **PATH** environment variable. -#### Pre-install Nodejs and Ruby Software +#### Pre-install Nodejs Another way to solve the **PATH** environment problem is to -install Nodejs and Ruby software packages before running the powershell +install the Nodejs software package before running the powershell scripts. 1. Install the latest stable version of NodeJS from the [official NodeJS website](https://nodejs.org/en). -1. Install Ruby from - [official Ruby website](https://github.com/oneclick/rubyinstaller2/releases/download/RubyInstaller-3.1.2-1/rubyinstaller-devkit-3.1.2-1-x64.exe) - and follow all the defaults during the installation. #### Run Scripts From 99f157eb5fc3df69ce634d00a9a158ff4166afe2 Mon Sep 17 00:00:00 2001 From: Aryan Bhosale Date: Fri, 29 Mar 2024 15:39:51 +0530 Subject: [PATCH 3/5] removed ruby mentions --- docs/developer/index.md | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/developer/index.md b/docs/developer/index.md index 1ec9ff96b..ef715b93f 100644 --- a/docs/developer/index.md +++ b/docs/developer/index.md @@ -35,7 +35,6 @@ software packages. But errors might crop up due to missing environment variables. The potential errors are: 1. `npm is not recognized.........` in `base.ps1`. -1. `gem is not recognized.........` in `env.ps1` If you encounter these errors, remember to include _node_ installation locations in From 7fe0795343f1d6748943aa7a900e57b5cffa97af Mon Sep 17 00:00:00 2001 From: Aryan Bhosale Date: Fri, 29 Mar 2024 17:11:27 +0530 Subject: [PATCH 4/5] updated PUBLISH.md --- docs/PUBLISH.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/PUBLISH.md b/docs/PUBLISH.md index c2ac49f4e..2ab21668f 100644 --- a/docs/PUBLISH.md +++ b/docs/PUBLISH.md @@ -23,7 +23,7 @@ This project uses **markdownlint** linter tool for identifying the formatting issues in markdown files. Run ```sh -mdl docs +markdownlint docs ``` from top-directory of the project and fix any identified issues. This needs @@ -74,4 +74,4 @@ git push webpage-docs The github pages system serves the [project documentation](https://into-cps-association.github.io/DTaaS/) from -this branch. +this branch. \ No newline at end of file From f460288c493101942ec56fc7a36d420392d0b0f1 Mon Sep 17 00:00:00 2001 From: Aryan Bhosale Date: Fri, 29 Mar 2024 20:15:01 +0530 Subject: [PATCH 5/5] reverted mdl changes, mkdocs tested, replaced .sh by .py for markdownlint-hooks for crossplatform, added mdl-check.py --- docs/PUBLISH.md | 4 ++-- docs/developer/index.md | 12 ++++++++---- script/env.ps1 | 11 ++++++++++- script/markdownlint-hook.ps1 | 10 ---------- script/markdownlint-hook.sh | 6 ------ script/markdownlint-hooks.py | 12 ++++++++++++ script/mdl-check.py | 12 ++++++++++++ 7 files changed, 44 insertions(+), 23 deletions(-) delete mode 100644 script/markdownlint-hook.ps1 delete mode 100755 script/markdownlint-hook.sh create mode 100644 script/markdownlint-hooks.py create mode 100644 script/mdl-check.py diff --git a/docs/PUBLISH.md b/docs/PUBLISH.md index 2ab21668f..c2ac49f4e 100644 --- a/docs/PUBLISH.md +++ b/docs/PUBLISH.md @@ -23,7 +23,7 @@ This project uses **markdownlint** linter tool for identifying the formatting issues in markdown files. Run ```sh -markdownlint docs +mdl docs ``` from top-directory of the project and fix any identified issues. This needs @@ -74,4 +74,4 @@ git push webpage-docs The github pages system serves the [project documentation](https://into-cps-association.github.io/DTaaS/) from -this branch. \ No newline at end of file +this branch. diff --git a/docs/developer/index.md b/docs/developer/index.md index ef715b93f..72295c171 100644 --- a/docs/developer/index.md +++ b/docs/developer/index.md @@ -35,9 +35,10 @@ software packages. But errors might crop up due to missing environment variables. The potential errors are: 1. `npm is not recognized.........` in `base.ps1`. +1. `gem is not recognized.........` in `env.ps1` If you encounter these errors, -remember to include _node_ installation locations in +remember to include _node_ and _ruby_ installation locations in **PATH** environment variable (`Settings --> search for "system environment variables"` `--> Advanced --> Environment Variables --> PATH`). @@ -45,15 +46,18 @@ remember to include _node_ installation locations in The `base.ps1` and `env.ps1` scripts can be run again after setting the correct **PATH** environment variable. -#### Pre-install Nodejs +#### Pre-install Nodejs and Ruby Software Another way to solve the **PATH** environment problem is to -install the Nodejs software package before running the powershell +install Nodejs and Ruby software packages before running the powershell scripts. 1. Install the latest stable version of NodeJS from the [official NodeJS website](https://nodejs.org/en). - +1. Install Ruby from + [official Ruby website](https://github.com/oneclick/rubyinstaller2/releases/download/RubyInstaller-3.1.2-1/rubyinstaller-devkit-3.1.2-1-x64.exe) + and follow all the defaults during the installation. + #### Run Scripts Then, open powershell with **administrative** priviledges and run the diff --git a/script/env.ps1 b/script/env.ps1 index e913f7a58..31d72a024 100644 --- a/script/env.ps1 +++ b/script/env.ps1 @@ -24,8 +24,17 @@ if (-not ([Environment]::GetEnvironmentVariable("Path", [EnvironmentVariableTarg # Install mkdocs pip install mkdocs +# Install Ruby: https://github.com/oneclick/rubyinstaller2/releases/download/RubyInstaller-3.1.2-1/rubyinstaller-devkit-3.1.2-1-x64.exe +choco install -y ruby + +# Ensure Ruby scripts directory is added to PATH +if (-not ([Environment]::GetEnvironmentVariable("Path", [EnvironmentVariableTarget]::Machine) -like "*Ruby*")) { + Write-Host "Adding Ruby scripts to PATH..." + [Environment]::SetEnvironmentVariable("Path", "$env:Path;$(Get-Command ruby | Select-Object -ExpandProperty Directory)", [EnvironmentVariableTarget]::Machine) +} + # Install markdownlint -choco install markdownlint-cli +gem install mdl # Install mkdocs plugins pip install mkdocs-material python-markdown-math mkdocs-open-in-new-tab mkdocs-with-pdf qrcode diff --git a/script/markdownlint-hook.ps1 b/script/markdownlint-hook.ps1 deleted file mode 100644 index 3bd991cf4..000000000 --- a/script/markdownlint-hook.ps1 +++ /dev/null @@ -1,10 +0,0 @@ -# This script is used by the pre-commit hook to check the markdown files without exiting the commit process. - -# Invoke markdownlint and capture the output -$output = markdownlint $args - -# Print the output -Write-Output $output - -# Exit with code 0 to indicate success -Exit 0 \ No newline at end of file diff --git a/script/markdownlint-hook.sh b/script/markdownlint-hook.sh deleted file mode 100755 index 7c63ed5e8..000000000 --- a/script/markdownlint-hook.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash - -# This script is used by the pre-commit hook to check the markdown files without exiting the commit process. -output=$(markdownlint "$@") -echo "$output" -exit 0 \ No newline at end of file diff --git a/script/markdownlint-hooks.py b/script/markdownlint-hooks.py new file mode 100644 index 000000000..6ca402cde --- /dev/null +++ b/script/markdownlint-hooks.py @@ -0,0 +1,12 @@ +import subprocess +import sys + +def markdownlint_hooks(files): + command = ["mdl-check.py"] + files + result = subprocess.run(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + output = result.stdout.decode("utf-8") + result.stderr.decode("utf-8") + print(output) + +if __name__ == "__main__": + files = sys.argv[1:] + markdownlint_hooks(files) \ No newline at end of file diff --git a/script/mdl-check.py b/script/mdl-check.py new file mode 100644 index 000000000..3128ae778 --- /dev/null +++ b/script/mdl-check.py @@ -0,0 +1,12 @@ +import subprocess +import sys + +def mdl_check(files): + command = ["mdl"] + files + result = subprocess.run(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + output = result.stdout.decode("utf-8") + result.stderr.decode("utf-8") + print(output) + +if __name__ == "__main__": + files = sys.argv[1:] + mdl_check(files) \ No newline at end of file