Skip to content

Commit 905577e

Browse files
HeyItsGilbertclaude
andcommitted
Add PowerShellBuild command reference generation
- Add PowerShellBuild module to requirements.psd1 - Add $psbOptions/$psbVersion/$psbOutputFolder to Properties block - Add GenerateCommandReferencePSB task set (Clean, Gen) - Wire GenerateCommandReferencePSB into Build task DependsOn - Add docs/psb-commands/ placeholder sidebar (empty until task runs) - Import psbCommands in sidebars.ts with conditional category in powershellBuildSidebar Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent bc65c45 commit 905577e

4 files changed

Lines changed: 73 additions & 1 deletion

File tree

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/**
2+
* Import this file in your Docusaurus `sidebars.js` file.
3+
*
4+
* Auto-generated by New-PsakeDocusaurusHelp using Microsoft.PowerShell.PlatyPS.
5+
* Run .\build.ps1 -Task GenerateCommandReferencePSB to populate.
6+
*/
7+
8+
module.exports = [];

‎psakeFile.ps1‎

Lines changed: 56 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,37 @@ Contributions are welcome in [Psake-repo](https://github.com/psake/psake).
3737
HelpVersion = "$($script:psakeVersion)"
3838
}
3939
$script:docsOutputFolder = Join-Path -Path $docusaurusOptions.DocsFolder -ChildPath $docusaurusOptions.Sidebar | Join-Path -ChildPath "*.*"
40+
41+
# -----------------------------------------------------------------------------
42+
# PowerShellBuild command reference options
43+
# -----------------------------------------------------------------------------
44+
45+
$script:psbVersion = (Get-Module PowerShellBuild -ListAvailable | Sort-Object Version -Descending | Select-Object -First 1).Version
46+
$script:psbOptions = @{
47+
Module = "PowerShellBuild"
48+
DocsFolder = "./docs"
49+
SideBar = "psb-commands"
50+
EditUrl = "null"
51+
Exclude = @()
52+
MetaDescription = 'Help page for the PowerShellBuild "%1" command'
53+
MetaKeywords = @(
54+
"PowerShell"
55+
"PowerShellBuild"
56+
"Help"
57+
"Documentation"
58+
)
59+
PrependMarkdown = @"
60+
:::info This page was generated
61+
Contributions are welcome in [PowerShellBuild-repo](https://github.com/psake/PowerShellBuild).
62+
:::
63+
"@
64+
AppendMarkdown = @"
65+
## VERSION
66+
*This page was generated using comment-based help in [PowerShellBuild $($psbVersion)](https://github.com/psake/PowerShellBuild).*
67+
"@
68+
HelpVersion = "$($script:psbVersion)"
69+
}
70+
$script:psbOutputFolder = Join-Path -Path $psbOptions.DocsFolder -ChildPath $psbOptions.Sidebar | Join-Path -ChildPath "*.*"
4071
}
4172

4273
FormatTaskName {
@@ -56,7 +87,7 @@ Task 'Init' @{
5687

5788
Task 'Build' @{
5889
Description = 'Full production site build.'
59-
DependsOn = @('Init', 'GenerateCommandReference', 'FrontMatterCMSSync')
90+
DependsOn = @('Init', 'GenerateCommandReference', 'GenerateCommandReferencePSB', 'FrontMatterCMSSync')
6091
Action = { exec { bun run build } }
6192
}
6293

@@ -119,6 +150,30 @@ Task -Name "GenerateCommandReference-Gen" -Depends 'GenerateCommandReference-Cle
119150
}
120151
#endregion Command Reference Generation Tasks
121152

153+
#region PSB Command Reference Generation Tasks
154+
$taskSplat = @{
155+
description = "Use Microsoft.PowerShell.PlatyPS to generate PowerShellBuild command reference docs."
156+
depends = 'GenerateCommandReferencePSB-Gen'
157+
}
158+
Task -Name 'GenerateCommandReferencePSB' @taskSplat
159+
160+
Task -Name 'GenerateCommandReferencePSB-Clean' -Action {
161+
Write-Host "Removing existing PSB MDX files" -ForegroundColor Magenta
162+
if (Test-Path -Path $script:psbOutputFolder) {
163+
Remove-Item -Path $script:psbOutputFolder
164+
}
165+
}
166+
167+
Task -Name "GenerateCommandReferencePSB-Gen" -Depends 'GenerateCommandReferencePSB-Clean' {
168+
Write-Host "Generating new PSB MDX files using Microsoft.PowerShell.PlatyPS" -ForegroundColor Magenta
169+
New-Item -ItemType Directory -Path (Join-Path $psbOptions.DocsFolder $psbOptions.SideBar) -Force | Out-Null
170+
. "$PSScriptRoot\scripts\New-PsakeDocusaurusHelp.ps1"
171+
Import-Module Microsoft.PowerShell.PlatyPS -Force
172+
Import-Module PowerShellBuild -Force
173+
New-PsakeDocusaurusHelp @psbOptions
174+
}
175+
#endregion PSB Command Reference Generation Tasks
176+
122177
#region Sync Front Matter Data
123178
Task -Name 'FrontMatterCMSSync' {
124179
(

‎requirements.psd1‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
'Microsoft.PowerShell.PlatyPS' = @{
1515
Version = 'latest'
1616
}
17+
'PowerShellBuild' = @{
18+
Version = 'latest'
19+
}
1720
'Yayaml' = @{
1821
Version = '0.6.0'
1922
}

‎sidebars.ts‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type { SidebarsConfig } from '@docusaurus/plugin-content-docs';
22
import commands from "./docs/commands/docusaurus.sidebar.js";
3+
import psbCommands from "./docs/psb-commands/docusaurus.sidebar.js";
34

45
/**
56
* Creating a sidebar enables you to:
@@ -87,6 +88,11 @@ const sidebars: SidebarsConfig = {
8788
'powershellbuild/task-reference',
8889
'powershellbuild/configuration',
8990
'powershellbuild/real-world-example',
91+
...(psbCommands.length > 0 ? [{
92+
type: 'category' as const,
93+
label: 'Command Reference',
94+
items: psbCommands,
95+
}] : []),
9096
],
9197

9298
// Reference - Command reference, troubleshooting, and lookup materials

0 commit comments

Comments
 (0)