From 75e4656989aa0138509f1a322378c7baf642b0c9 Mon Sep 17 00:00:00 2001 From: cjsha Date: Thu, 24 Oct 2024 12:41:55 -0400 Subject: [PATCH 1/3] Exclude certain URLs for local linkchecks - branched github URLs being checked even though they don't exist until pushed. Those URLs are now optionally checked with the -r flag - "linkcheck" -> "lychee" to distinguish the function that runs lychee linkchecks and the function that runs doclinkchecker linkchecks --- docfx-utils.ps1 | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/docfx-utils.ps1 b/docfx-utils.ps1 index 4c1cb08..8db20f7 100644 --- a/docfx-utils.ps1 +++ b/docfx-utils.ps1 @@ -4,27 +4,31 @@ param [parameter(mandatory=$false)][switch][Alias("c")]$clean, [parameter(mandatory=$false)][switch][Alias("b")]$build, [parameter(mandatory=$false)][switch][Alias("d")]$doclinkchecker, - [parameter(mandatory=$false)][string][Alias("l")]$linkcheck, - [parameter(mandatory=$false)][string][Alias("a")]$all + [parameter(mandatory=$false)][string][Alias("l")]$lychee, + [parameter(mandatory=$false)][string][Alias("a")]$all, + [parameter(mandatory=$false)][switch][Alias("r")]$remote ) # this is called removeartifacts instead of clean because clean might be already mean something in powershell? function removeartifacts { $deletePaths = ".\workflows\**\*.svg", ".\workflows\hardware\**\*.svg", ".\workflows\**\*.bonsai.layout", ".\workflows\hardware\**\*.bonsai.layout", ".\api\*.yml", ".\api\.manifest", ".\_site\", ".\_raw\", ".\_view\", ".\src\onix-bonsai-onix1\artifacts\" - foreach($deletePath in $deletePaths){if (Test-Path $deletePath){Remove-Item $deletePath -Recurse}} Write-Output "" } function build{.\build.ps1 --logLevel Suggestion --warningsAsErrors} -function linkcheck +function lychee($lycheePath, $remote) { - param($lycheePath) Write-Output "`nRunning lychee..." Write-Output "------------------------------------------`n" - Invoke-Expression "& `"$lycheePath`" --no-progress --base _site --exclude ^https://github\.com.*merge.* --exclude ^https://github\.com.*apiSpec.* '_site/**/*.html'" + if ($remote){ + Invoke-Expression "& `"$lycheePath`" --no-progress --base _site --exclude ^https://github\.com.*merge.* --exclude ^https://github\.com.*apiSpec.* '_site/**/*.html'" + } + else{ + Invoke-Expression "& `"$lycheePath`" --no-progress --base _site --exclude ^https://github\.com.*merge.* --exclude ^https://github\.com.*apiSpec.* --exclude ^https://github\.com/open-ephys/onix1-bonsai-docs/blob/.*/#L1 '_site/**/*.html'" + } Write-Output "`n" } @@ -41,7 +45,7 @@ if ($build){build} if ($doclinkchecker){doclinkchecker} -if ($PSBoundParameters.ContainsKey("linkcheck")){linkcheck($linkcheck)} +if ($PSBoundParameters.ContainsKey("lychee")){lychee $lychee $remote} if ($PSBoundParameters.ContainsKey("all")) { From ec35e746900f027d112cfdfa10da99e20fc78737 Mon Sep 17 00:00:00 2001 From: cjsha Date: Thu, 24 Oct 2024 12:53:48 -0400 Subject: [PATCH 2/3] call lychee instead of linkchec when utils are run w/ -a flag --- docfx-utils.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docfx-utils.ps1 b/docfx-utils.ps1 index 8db20f7..d4c0db8 100644 --- a/docfx-utils.ps1 +++ b/docfx-utils.ps1 @@ -64,5 +64,5 @@ if ($PSBoundParameters.ContainsKey("all")) Start-Sleep -Seconds 2 doclinkchecker Start-Sleep -Seconds 2 - linkcheck($all) + lychee $all $remote } From 309c1d9c0bed1657a9d31d51f0a5f159b1772014 Mon Sep 17 00:00:00 2001 From: cjsha Date: Fri, 25 Oct 2024 12:52:42 -0400 Subject: [PATCH 3/3] Remove "-r" flag from utils --- docfx-utils.ps1 | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/docfx-utils.ps1 b/docfx-utils.ps1 index d4c0db8..53f875f 100644 --- a/docfx-utils.ps1 +++ b/docfx-utils.ps1 @@ -5,8 +5,7 @@ param [parameter(mandatory=$false)][switch][Alias("b")]$build, [parameter(mandatory=$false)][switch][Alias("d")]$doclinkchecker, [parameter(mandatory=$false)][string][Alias("l")]$lychee, - [parameter(mandatory=$false)][string][Alias("a")]$all, - [parameter(mandatory=$false)][switch][Alias("r")]$remote + [parameter(mandatory=$false)][string][Alias("a")]$all ) # this is called removeartifacts instead of clean because clean might be already mean something in powershell? @@ -19,16 +18,11 @@ function removeartifacts function build{.\build.ps1 --logLevel Suggestion --warningsAsErrors} -function lychee($lycheePath, $remote) +function lychee($lycheePath) { Write-Output "`nRunning lychee..." Write-Output "------------------------------------------`n" - if ($remote){ - Invoke-Expression "& `"$lycheePath`" --no-progress --base _site --exclude ^https://github\.com.*merge.* --exclude ^https://github\.com.*apiSpec.* '_site/**/*.html'" - } - else{ - Invoke-Expression "& `"$lycheePath`" --no-progress --base _site --exclude ^https://github\.com.*merge.* --exclude ^https://github\.com.*apiSpec.* --exclude ^https://github\.com/open-ephys/onix1-bonsai-docs/blob/.*/#L1 '_site/**/*.html'" - } + Invoke-Expression "& `"$lycheePath`" --no-progress --base _site --exclude ^https://github\.com.*merge.* --exclude ^https://github\.com.*apiSpec.* --exclude ^https://github\.com/open-ephys/onix1-bonsai-docs/blob/.*/#L1 '_site/**/*.html'" Write-Output "`n" } @@ -45,7 +39,7 @@ if ($build){build} if ($doclinkchecker){doclinkchecker} -if ($PSBoundParameters.ContainsKey("lychee")){lychee $lychee $remote} +if ($PSBoundParameters.ContainsKey("lychee")){lychee $lychee} if ($PSBoundParameters.ContainsKey("all")) { @@ -64,5 +58,5 @@ if ($PSBoundParameters.ContainsKey("all")) Start-Sleep -Seconds 2 doclinkchecker Start-Sleep -Seconds 2 - lychee $all $remote + lychee $all }