Skip to content

Commit dbd7577

Browse files
Adding help
1 parent 04876e2 commit dbd7577

File tree

1 file changed

+61
-9
lines changed

1 file changed

+61
-9
lines changed

psturtle.com/CHANGELOG.html.ps1

Lines changed: 61 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,81 @@
1+
<#
2+
.SYNOPSIS
3+
Project CHANGELOG
4+
.DESCRIPTION
5+
The CHANGELOG for the project
6+
.NOTES
7+
The CHANGELOG is a record of major changes and releases for the project.
8+
#>
19
param(
10+
# We can provide the repository url by hard-coding it, or it can be provided in site or page metadata.
211
[uri]
312
$RepositoryUrl = "https://github.com/PowerShellWeb/Turtle",
413

14+
# We can provide the changelog path by hard-coding it, or it can provided in site or page metadata.
515
[string]
616
$ChangeLogPath = '../CHANGELOG.md'
717
)
18+
19+
20+
# Push into this location, in case we are building this file interactively.
821
if ($PSScriptRoot) { Push-Location $PSScriptRoot}
9-
"<style>"
10-
".viewSource {float: right;}"
11-
"</style>"
12-
"<details class='viewSource'>"
13-
"<summary>View Source</summary>"
14-
"<pre><code class='language-PowerShell'>"
15-
[Web.HttpUtility]::HtmlEncode($MyInvocation.MyCommand.ScriptBlock)
16-
"</code></pre>"
22+
23+
# Get my own help
24+
$myHelp = Get-Help $MyInvocation.MyCommand.ScriptBlock.File
25+
if ($myHelp) {
26+
# If we have page metadata
27+
if ($page -is [Collections.IDictionary]) {
28+
# Replace 'Project' in the title with the url, to make the title and description more helpful
29+
$page.Title = $myHelp.SYNOPSIS -replace 'Project', {
30+
$RepositoryUrl.Segments[-1] -replace '/'
31+
}
32+
$page.Description = $myHelp.Description.text -join [Environment]::NewLine -replace 'The Project', {
33+
$RepositoryUrl.Segments[-1] -replace '/'
34+
}
35+
}
36+
37+
# If we have notes, replace the project with our name
38+
$myNotes = $myHelp.alertSet.alert.text -join [Environment]::NewLine -replace 'The Project', {
39+
$RepositoryUrl.Segments[-1] -replace '/'
40+
}
41+
if ($myNotes) {
42+
# and convert our notes from markdown.
43+
(ConvertFrom-Markdown -InputObject $myNotes).Html
44+
}
45+
}
46+
47+
# Break up the space a bit with horizontal rules.
48+
49+
"<hr/>"
50+
# Display source for this page
51+
"<details>"
52+
"<summary>View Source</summary>"
53+
"<pre>"
54+
"<code class='language-PowerShell'>"
55+
[Web.HttpUtility]::HtmlEncode($MyInvocation.MyCommand.ScriptBlock)
56+
"</code>"
57+
"</pre>"
1758
"</details>"
59+
60+
# Break up the space a bit with horizontal rules.
61+
"<hr/>"
62+
63+
# Get our changelog
1864
(Get-ChildItem -Path $ChangeLogPath |
19-
ConvertFrom-Markdown |
65+
ConvertFrom-Markdown | # and convert it from markdown
66+
# Then, replace issue links
2067
Select-Object -ExpandProperty HTML) -replace '(?<=[\(\,)]\s{0,})\#\d+', {
2168
$match = $_
2269
if ($RepositoryUrl) {
70+
# with actual links to the issues.
2371
$issueNumber = $($match -replace '\#' -as [int])
2472
"<a href='$RepositoryUrl/issues/$issueNumber'>" + "#$issueNumber" + "</a>"
2573
} else {
2674
"$match"
2775
}
2876
}
77+
78+
# If we pushed into the location, pop back out.
2979
if ($PSScriptRoot) { Pop-Location}
80+
81+
# We're done!

0 commit comments

Comments
 (0)