-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrefresh_nvapi_api_docs.ps1
More file actions
105 lines (90 loc) · 3.98 KB
/
refresh_nvapi_api_docs.ps1
File metadata and controls
105 lines (90 loc) · 3.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#
# NVAPIWrapper DocFX Refresh Script (PowerShell)
# Regenerates API documentation and launches the DocFX dev server on port 8000
#
# Get the directory where this script is located
$scriptRoot = $PSScriptRoot
if (-not $scriptRoot) {
$scriptRoot = Split-Path -Parent $MyInvocation.MyCommand.Path
$scriptRoot = Split-Path -Parent $MyInvocation.MyCommand.Path
}
# Change to script directory
Set-Location $scriptRoot
Write-Host "Working directory: $scriptRoot" -ForegroundColor Cyan
Write-Host ""
Write-Host "============================================================================" -ForegroundColor Cyan
Write-Host "NVAPIWrapper API Docs Refresh (DocFX)" -ForegroundColor Cyan
Write-Host "============================================================================" -ForegroundColor Cyan
Write-Host ""
# Paths
$docfxConfig = Join-Path $scriptRoot "APIDocs\\docfx.json"
$docfxSite = Join-Path $scriptRoot "APIDocs\\_site"
$docfxPort = 8080
# Validate DocFX config
if (-not (Test-Path $docfxConfig)) {
Write-Host "ERROR: DocFX config not found at $docfxConfig" -ForegroundColor Red
Write-Host "Please ensure APIDocs/docfx.json exists." -ForegroundColor Yellow
Read-Host "Press Enter to exit"
exit 1
}
# Locate DocFX CLI
Write-Host "Checking for DocFX CLI..." -ForegroundColor Yellow
$docfxCmd = Get-Command docfx -ErrorAction SilentlyContinue
if (-not $docfxCmd) {
Write-Host ""
Write-Host "ERROR: DocFX CLI not found in PATH." -ForegroundColor Red
Write-Host "Install DocFX (e.g., 'choco install docfx' or 'dotnet tool install -g docfx')." -ForegroundColor Yellow
Write-Host "After installation, ensure 'docfx' is available in your PATH." -ForegroundColor Yellow
Write-Host ""
Read-Host "Press Enter to exit"
exit 1
}
try {
$docfxVersion = & $docfxCmd.Source --version 2>&1
Write-Host "DocFX found: $($docfxCmd.Source)" -ForegroundColor Green
if ($docfxVersion) {
Write-Host "DocFX version: $docfxVersion" -ForegroundColor Green
}
Write-Host ""
} catch {
Write-Host "Warning: Unable to read DocFX version: $_" -ForegroundColor Yellow
Write-Host ""
}
# Run DocFX metadata + build
Write-Host "============================================================================" -ForegroundColor Cyan
Write-Host "Generating metadata..." -ForegroundColor Cyan
Write-Host "============================================================================" -ForegroundColor Cyan
Write-Host ""
Push-Location (Split-Path $docfxConfig -Parent)
try {
& $docfxCmd.Source metadata $docfxConfig
if ($LASTEXITCODE -ne 0) { throw "DocFX metadata failed with exit code $LASTEXITCODE" }
Write-Host ""
Write-Host "Metadata generated successfully." -ForegroundColor Green
Write-Host ""
Write-Host "============================================================================" -ForegroundColor Cyan
Write-Host "Building site..." -ForegroundColor Cyan
Write-Host "============================================================================" -ForegroundColor Cyan
Write-Host ""
& $docfxCmd.Source build $docfxConfig
if ($LASTEXITCODE -ne 0) { throw "DocFX build failed with exit code $LASTEXITCODE" }
Write-Host ""
Write-Host "DocFX site built successfully at: $docfxSite" -ForegroundColor Green
Write-Host ""
} catch {
Pop-Location
Write-Host ""
Write-Host "ERROR: DocFX generation failed." -ForegroundColor Red
Write-Host "Error: $_" -ForegroundColor Yellow
Write-Host ""
Read-Host "Press Enter to exit"
exit 1
}
Pop-Location
# Serve the site
Write-Host "============================================================================" -ForegroundColor Cyan
Write-Host "Starting DocFX server on http://localhost:$docfxPort/" -ForegroundColor Cyan
Write-Host "Press Ctrl+C to stop the server." -ForegroundColor Yellow
Write-Host "============================================================================" -ForegroundColor Cyan
Write-Host ""
& $docfxCmd.Source serve $docfxSite -p $docfxPort --hostname localhost