Skip to content

Commit 4aeae9c

Browse files
Update utils
Standardize documentation and formatting
1 parent 616f56a commit 4aeae9c

File tree

3 files changed

+49
-35
lines changed

3 files changed

+49
-35
lines changed

util/check-links.ps1

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,43 @@
11
#!/usr/bin/env pwsh
2+
# This script is designed to be run in a PowerShell environment.
3+
4+
# Name: TCAT Wiki - Link Checker
5+
# Version: 1.0.1
6+
# Date: 2025-09-17
7+
# Author: Amy Bordenave, Taskar Center for Accessible Technology, University of Washington
8+
# License: CC-BY-ND 4.0 International
9+
210
<#
311
.SYNOPSIS
4-
Link validation script for TCAT Wiki documentation
12+
Link validation script for the TCAT Wiki
513
614
.DESCRIPTION
715
Checks all .md files in the specified directory for broken internal and external links.
8-
Returns exit code 0 if all links are valid, 1 if any links are broken.
16+
Returns exit code 0 if all links are valid, 1 if any links are broken or there is an error.
917
1018
.PARAMETER docsPath
1119
Path to the documentation directory to scan (default: "docs")
1220
1321
.PARAMETER verboseOutput
1422
Show verbose output during validation
1523
24+
.PARAMETER internal
25+
Check internal relative links
26+
27+
.PARAMETER external
28+
Check external absolute links
29+
1630
.EXAMPLE
1731
.\check-links.ps1
18-
Validates links in the default "docs" directory
32+
Validates both internal and external links in the default "docs" directory
1933
2034
.EXAMPLE
21-
.\check-links.ps1 -docsPath "documentation" -verboseOutput
22-
Validates links in "documentation" directory with verbose output
35+
.\check-links.ps1 -verboseOutput -internal
36+
Validates only internal relative links, with verbose output
2337
#>
2438

2539
param(
26-
[Parameter(HelpMessage = "Path to the documentation directory")]
40+
[Parameter(HelpMessage = "Path to the docs directory")]
2741
[string]$docsPath = "",
2842

2943
[Parameter(HelpMessage = "Show verbose output")]
@@ -79,9 +93,9 @@ if ($markdownFiles.Count -eq 0) {
7993
Write-Host "Found $($markdownFiles.Count) markdown files to validate" -ForegroundColor Green
8094
Write-Host ""
8195

82-
$brokenInternalLinks = @()
83-
$brokenExternalLinks = @()
8496
$externalUrls = @{}
97+
$brokenExternalLinks = @()
98+
$brokenInternalLinks = @()
8599

86100
# Function to extract links from markdown content
87101
function Get-MarkdownLinks {
@@ -133,7 +147,7 @@ function Test-InternalLink {
133147
function Test-ExternalUrlValid {
134148
param([string]$url)
135149

136-
# Skip known problematic domains that block automated requests
150+
# Skip domains that block automated requests or are known to always fail
137151
$skipDomains = @(
138152
"*visualstudio.com*"
139153
)
@@ -142,7 +156,7 @@ function Test-ExternalUrlValid {
142156
if ($url -like $domain) {
143157
return @{
144158
valid = $true
145-
status = "Skipped (known to block automated requests)"
159+
status = "Skipped (known to block automated requests or always fail)"
146160
}
147161
}
148162
}

util/generate-guides-lists.ps1

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
#!/usr/bin/env pwsh
2+
# This script is designed to be run in a PowerShell environment.
3+
4+
# Name: TCAT Wiki - Guides Lists Generator
5+
# Version: 1.0.1
6+
# Date: 2025-09-17
7+
# Author: Amy Bordenave, Taskar Center for Accessible Technology, University of Washington
8+
# License: CC-BY-ND 4.0 International
9+
210
<#
311
.SYNOPSIS
4-
Generates index.md files for all guides directories in the docs folder.
12+
Generates index.md files for all guides directories
513
614
.DESCRIPTION
715
This script recursively searches through the docs directory for any subdirectory
@@ -144,7 +152,7 @@ function New-GuidesList {
144152

145153
Write-Host "Processing guides directory: $GuidesPath"
146154

147-
# Get all .md files except index.md
155+
# Get all .md files except main index.md
148156
$mdFiles = Get-ChildItem -Path $GuidesPath -Filter "*.md" |
149157
Where-Object { $_.Name -ne "index.md" } |
150158
Sort-Object Name
@@ -404,8 +412,6 @@ foreach ($guidesDir in $guidesDirectories | Where-Object { $_.FullName -notmatch
404412
}
405413
}
406414

407-
# No longer need miscellaneous section - misc guides are now in docs/misc/guides/
408-
409415
# Write the master guides index
410416
$masterIndexPath = Join-Path $docsPath "guides-list" "index.md"
411417
$masterContent | Set-Content -Path $masterIndexPath -Encoding UTF8

util/generate-nav.ps1

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
#!/usr/bin/env pwsh
2+
# This script is designed to be run in a PowerShell environment.
3+
4+
# Name: TCAT Wiki - Navigation Section Generator
5+
# Version: 1.0.1
6+
# Date: 2025-09-17
7+
# Author: Amy Bordenave, Taskar Center for Accessible Technology, University of Washington
8+
# License: CC-BY-ND 4.0 International
9+
210
<#
311
.SYNOPSIS
412
Generates MkDocs navigation structure from docs directory
@@ -7,26 +15,20 @@
715
Scans the docs directory structure and generates a YAML navigation tree
816
that can be inserted into mkdocs.yml. Uses frontmatter titles when available,
917
otherwise derives titles from filenames and directory names.
18+
1019
.PARAMETER docsPath
1120
Path to the documentation directory to scan (default: "docs")
1221
13-
.PARAMETER outputFile
14-
Output file path for the generated navigation YAML (default: console output)
22+
.PARAMETER mkdocsPath
23+
Path to the mkdocs.yml file (default: "../mkdocs.yml")
1524
1625
.PARAMETER updateMkdocs
1726
Update the mkdocs.yml file directly by replacing the nav section
1827
19-
.PARAMETER mkdocsPath
20-
Path to the mkdocs.yml file (default: "../mkdocs.yml")
21-
2228
.EXAMPLE
2329
.\generate-nav.ps1
2430
Generates navigation and outputs to console
2531
26-
.EXAMPLE
27-
.\generate-nav.ps1 -outputFile "nav.yml"
28-
Generates navigation and saves to nav.yml
29-
3032
.EXAMPLE
3133
.\generate-nav.ps1 -updateMkdocs
3234
Updates mkdocs.yml directly with generated navigation
@@ -36,9 +38,6 @@ param(
3638
[Parameter(HelpMessage = "Path to the documentation directory")]
3739
[string]$docsPath = "",
3840

39-
[Parameter(HelpMessage = "Output file path for generated navigation")]
40-
[string]$outputFile = "",
41-
4241
[Parameter(HelpMessage = "Update mkdocs.yml directly")]
4342
[switch]$updateMkdocs,
4443

@@ -118,7 +117,7 @@ function Build-DirectoryNav {
118117
)
119118

120119
$items = @()
121-
$indent = " " * $indentLevel
120+
$indent = " " * $indentLevel
122121

123122
# Get directory name and relative path
124123
$dirInfo = Get-Item $dirPath
@@ -139,7 +138,7 @@ function Build-DirectoryNav {
139138

140139
# Add index.md first if it exists
141140
if ($hasIndex) {
142-
$subItems += "$indent - $relativePath/index.md"
141+
$subItems += "$indent - $relativePath/index.md"
143142
}
144143

145144
# Add other files in this directory
@@ -149,7 +148,7 @@ function Build-DirectoryNav {
149148
if (-not $fileTitle) {
150149
$fileTitle = ConvertTo-Title $file.BaseName
151150
}
152-
$subItems += "$indent - $($fileTitle): $fileRelativePath"
151+
$subItems += "$indent - $($fileTitle): $fileRelativePath"
153152
}
154153

155154
# Add subdirectories
@@ -245,7 +244,7 @@ foreach ($file in $rootFiles) {
245244

246245
# Generate final navigation YAML with proper indentation
247246
$indentedNavItems = $navItems | ForEach-Object { " $_" }
248-
$navYaml = "nav:" + [Environment]::NewLine + ($indentedNavItems -join [Environment]::NewLine)
247+
$navYaml = "nav:" + [Environment]::NewLine + ($indentedNavItems -join [Environment]::NewLine) + [Environment]::NewLine
249248

250249
# Output results
251250
if ($updateMkdocs) {
@@ -304,11 +303,6 @@ if ($updateMkdocs) {
304303
Set-Content -Path $mkdocsPath -Value $newContent -Encoding UTF8 -NoNewline
305304
Write-Host "Successfully updated mkdocs.yml navigation section" -ForegroundColor Green
306305
}
307-
elseif ($outputFile) {
308-
# Save to output file
309-
Set-Content -Path $outputFile -Value $navYaml -Encoding UTF8
310-
Write-Host "Navigation saved to: $outputFile" -ForegroundColor Green
311-
}
312306
else {
313307
# Output to console
314308
Write-Host ""

0 commit comments

Comments
 (0)