add build/serve docs commands to manage script

This commit is contained in:
Ondřej Samohel 2025-03-17 17:03:48 +01:00
parent 3e06feb224
commit e388bc5030
No known key found for this signature in database
GPG key ID: 02376E18990A97C6
2 changed files with 57 additions and 0 deletions

View file

@ -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

View file

@ -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