diff --git a/tools/manage.ps1 b/tools/manage.ps1 index 8324277713..3044d63af9 100755 --- a/tools/manage.ps1 +++ b/tools/manage.ps1 @@ -247,6 +247,30 @@ function Run-Tests { & $Poetry $RunArgs @arguments } +function Clean-Cache { + Write-Info -Text ">>> ", "Cleaning cache files ... " -Color Green, Gray -NoNewline + Get-ChildItem $repo_root -Filter "*.pyc" -Force -Recurse | Remove-Item -Force + Get-ChildItem $repo_root -Filter "*.pyo" -Force -Recurse | Remove-Item -Force + Get-ChildItem $repo_root -Filter "__pycache__" -Force -Recurse | Remove-Item -Force -Recurse + Write-Info -Text "OK" -Color green +} + +function Build-Docs { + Clean-Cache + $Poetry = "$RepoRoot\.poetry\bin\poetry.exe" + $RunArgs = @( "run", "mkdocs", "build") + + & $Poetry $RunArgs @arguments +} + +function Serve-Docs { + Clean-Cache + $Poetry = "$RepoRoot\.poetry\bin\poetry.exe" + $RunArgs = @( "run", "mkdocs", "serve") + + & $Poetry $RunArgs @arguments +} + function Write-Help { <# .SYNOPSIS @@ -264,6 +288,8 @@ function Write-Help { Write-Info -Text " codespell ", "Run codespell check for the repository" -Color White, Cyan Write-Info -Text " run ", "Run a poetry command in the repository environment" -Color White, Cyan Write-Info -Text " run-tests ", "Run ayon-core tests" -Color White, Cyan + Write-Info -Text " build-docs ", "Build documentation" -Color White, Cyan + Write-Info -Text " serve-docs ", "Serve documentation" -Color White, Cyan Write-Host "" } @@ -291,6 +317,13 @@ function Resolve-Function { } elseif ($FunctionName -eq "runtests") { Set-Cwd Run-Tests + } elseif ($FunctionName -eq "builddocs") + { + Set-Cwd + Build-Docs + } elseif ($FunctionName -eq "servedocs") { + Set-Cwd + Serve-Docs } else { Write-Host "Unknown function ""$FunctionName""" Write-Help diff --git a/tools/manage.sh b/tools/manage.sh index 86ae7155c5..766737944b 100755 --- a/tools/manage.sh +++ b/tools/manage.sh @@ -159,6 +159,8 @@ default_help() { echo -e " ${BWhite}codespell${RST} ${BCyan}Run codespell check for the repository${RST}" echo -e " ${BWhite}run${RST} ${BCyan}Run a poetry command in the repository environment${RST}" echo -e " ${BWhite}run-tests${RST} ${BCyan}Run ayon-core tests${RST}" + echo -e " ${BWhite}build-docs${RST} ${BCyan}Build documentation${RST}" + echo -e " ${BWhite}serve-docs${RST} ${BCyan}Local serve documentation${RST}" echo "" } @@ -189,6 +191,20 @@ run_tests () { "$POETRY_HOME/bin/poetry" run pytest ./tests } +build_docs () { + echo -e "${BIGreen}>>>${RST} Cleaning cache files ..." + clean_pyc + echo -e "${BIGreen}>>>${RST} Building docs..." + "$POETRY_HOME/bin/poetry" run mkdocs build +} + +serve_docs () { + echo -e "${BIGreen}>>>${RST} Cleaning cache files ..." + clean_pyc + echo -e "${BIGreen}>>>${RST} Building docs..." + "$POETRY_HOME/bin/poetry" run mkdocs serve +} + main () { detect_python || return 1 @@ -229,6 +245,14 @@ main () { run_tests "$@" || return_code=$? exit $return_code ;; + "builddocs") + build_docs "$@" || return_code=$? + exit $return_code + ;; + "servedocs") + serve_docs "$@" || return_code=$? + exit $return_code + ;; esac if [ "$function_name" != "" ]; then