-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGenerateREADME.ps1
59 lines (48 loc) · 1.76 KB
/
GenerateREADME.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
[xml]$doc = Get-Content ("$PSScriptRoot\HackerRank\Challenges\Challenges.xml")
[string] $out = @"
## HackerRank Solutions
My solutions to HackerRank challenges
---
### Included Challenges
"@
foreach ($category in $doc.challenges.challenge |
Group-Object Category -NoElement |
Sort-Object Name) {
$out += "#### $($category.Name)`r`n"
foreach ($subcategory in $doc.challenges.challenge |
Where-Object {$_.Category -eq $category.Name} |
Group-Object SubCategory -NoElement |
Sort-Object Name) {
$out += "##### $($subcategory.Name)`r`n"
foreach ($challenge in $doc.challenges.challenge |
Where-Object {$_.Category -eq $category.Name} |
Where-Object {$_.SubCategory -eq $subcategory.Name} |
Sort-Object Score, Name) {
$out += "- [x] $($challenge.Name) (Score: $($challenge.Score))`r`n"
}
$out += "`r`n"
}
}
$out += @"
---
### Directory Structure
Item | Description
---- | -----------
UnitTest.vb | Unit tests main
Challenges\ | Root folder for challenges
Challenges\Challenges.xml | Definition file for challenges
Challenges\ChallengeId\ | Challenge folder
Challenges\ChallengeId\Code.vb | Challenge specific solution code
Challenges\ChallengeId\In\ | Challenge specific inputs
Challenges\ChallengeId\Out\ | Challenge specific expected outputs
---
### Version History
"@
foreach ($ver in $doc.challenges.challenge |
Group-Object Version |
Select-Object Name, @{Name = "Value"; Expression = {($_.Group | Foreach-Object {"[$($_.Name)]($($_.Link))"}) -join ", "}} |
Select-Object *, @{Name = "SortKey"; Expression = {[int]$_.Name}} |
Sort-Object SortKey -Descending) {
$out += "- v$($ver.Name) added $($ver.Value)`r`n"
}
$out | Out-File "$PSScriptRoot\README.md" -Encoding utf8 -NoNewline