forked from exercism/csharp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
update-docs.ps1
45 lines (38 loc) · 1.28 KB
/
update-docs.ps1
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
<#
.SYNOPSIS
Regenerate the docs.
.DESCRIPTION
Regenerate the docs for all exercises based on the latest canonical data.
.PARAMETER Exercise
The slug of the exercise to regenerate the doc for (optional).
.EXAMPLE
The example below will regenerate all docs
PS C:\> ./update-docs.ps1
.EXAMPLE
The example below will regenerate the doc for the "acronym" exercise
PS C:\> ./update-docs.ps1 acronym
#>
[CmdletBinding(SupportsShouldProcess)]
param (
[Parameter(Position = 0, Mandatory = $false)]
[string]$Exercise
)
# Import shared functionality
. ./shared.ps1
. ./update-canonical-data.ps1
function Update-Documentation {
[CmdletBinding(SupportsShouldProcess)]
param (
[Parameter(Position = 0, Mandatory = $false)]
[string]$Exercise
)
if ($PSCmdlet.ShouldProcess((& { If ($Exercise) { $Exercise } Else { "All Exercises" } }), "fetch configlet and pull specifications")) {
Write-Output "Updating docs"
Invoke-CallScriptExitOnError { ./bin/fetch-configlet }
$configletArgs = if ($Exercise) { @("-e", $Exercise) } else { @() }
Invoke-CallScriptExitOnError { ./bin/configlet sync -p problem-specifications -o $configletArgs }
}
}
Update-CanonicalData
Update-Documentation -Exercise $Exercise
exit $LastExitCode