-
Notifications
You must be signed in to change notification settings - Fork 0
🩹 [Patch]: Update to use Microsoft.PowerShell.PlatyPS for docs generation
#19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
979f75e
dfc2e26
d33423b
2772e54
7c18e2f
8c023f7
cc53996
c0bffe9
e9ac75f
503c423
2a6f7aa
754b7d3
5863d5e
bccd912
c71db9d
aff7358
6dcceb9
7d624a8
4a586da
e526310
b9be1e6
b5bcd82
82c4484
2df9bf0
16b246f
51b6643
ab29008
a7c4cae
42b2077
7e58bbe
2cb6082
70ce267
6b865bc
1a6dc34
922dede
ce3a00c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -47,8 +47,32 @@ | |
|
|
||
| Write-Host '::group::Build docs - Generate markdown help - Raw' | ||
| Install-PSModule -Path $ModuleOutputFolder | ||
| Write-Host ($ModuleName | Get-Module) | ||
| $null = New-MarkdownHelp -Module $ModuleName -OutputFolder $DocsOutputFolder -Force -Verbose | ||
| $moduleInfo = Import-Module -Name $ModuleName -Force -PassThru | ||
|
|
||
| # Get all exported commands from the module | ||
| $commands = $moduleInfo.ExportedCommands.Values | Where-Object { $_.CommandType -ne 'Alias' } | ||
|
|
||
| Write-Host "Found $($commands.Count) commands to process" | ||
|
|
||
| foreach ($command in $commands) { | ||
| try { | ||
| Write-Host "$($command.Name)" -NoNewline | ||
| $params = @{ | ||
| CommandInfo = $command | ||
| OutputFolder = $docsOutputFolder | ||
| Encoding = 'utf8' | ||
| ProgressAction = 'SilentlyContinue' | ||
| ErrorAction = 'Stop' | ||
| Force = $true | ||
| } | ||
| $null = New-MarkdownCommandHelp @params | ||
| Write-Host ' - ✓' -ForegroundColor Green | ||
| } catch { | ||
| Write-Host ' - ✗' -ForegroundColor Red | ||
| $_ | ||
| } | ||
| } | ||
|
|
||
| Get-ChildItem -Path $DocsOutputFolder -Recurse -Force -Include '*.md' | ForEach-Object { | ||
| $fileName = $_.Name | ||
| Write-Host "::group:: - [$fileName]" | ||
|
|
@@ -88,30 +112,40 @@ | |
|
|
||
| Write-Host '::group::Build docs - Structure markdown files to match source files' | ||
| $PublicFunctionsFolder = Join-Path $ModuleSourceFolder.FullName 'functions\public' | Get-Item | ||
| Get-ChildItem -Path $DocsOutputFolder -Recurse -Force -Include '*.md' | ForEach-Object { | ||
| $moduleDocsFolder = Join-Path $DocsOutputFolder.FullName $ModuleName | ||
|
||
| Get-ChildItem -Path $moduleDocsFolder -Recurse -Force -Include '*.md' | ForEach-Object { | ||
| $file = $_ | ||
| $relPath = [System.IO.Path]::GetRelativePath($DocsOutputFolder.FullName, $file.FullName) | ||
| $relPath = [System.IO.Path]::GetRelativePath($moduleDocsFolder, $file.FullName) | ||
| Write-Host " - $relPath" | ||
| Write-Host " Path: $file" | ||
|
|
||
| # find the source code file that matches the markdown file | ||
| $scriptPath = Get-ChildItem -Path $PublicFunctionsFolder -Recurse -Force | Where-Object { $_.Name -eq ($file.BaseName + '.ps1') } | ||
| Write-Host " PS1 path: $scriptPath" | ||
| $docsFilePath = ($scriptPath.FullName).Replace($PublicFunctionsFolder.FullName, $DocsOutputFolder.FullName).Replace('.ps1', '.md') | ||
| $docsFilePath = ($scriptPath.FullName).Replace($PublicFunctionsFolder.FullName, $moduleDocsFolder).Replace('.ps1', '.md') | ||
MariusStorhaug marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| Write-Host " MD path: $docsFilePath" | ||
| $docsFolderPath = Split-Path -Path $docsFilePath -Parent | ||
| $null = New-Item -Path $docsFolderPath -ItemType Directory -Force | ||
| Move-Item -Path $file.FullName -Destination $docsFilePath -Force | ||
| } | ||
|
|
||
| Write-Host '::group::Build docs - Fix frontmatter title' | ||
| Get-ChildItem -Path $moduleDocsFolder -Recurse -Force -Include '*.md' | ForEach-Object { | ||
| $content = Get-Content -Path $_.FullName -Raw | ||
| # Replace 'title:' with 'ms.title:' in frontmatter only (between --- markers) | ||
| $content = $content -replace '(?s)^(---.*?)title:(.*?---)', '$1ms.title:$2' | ||
| $content | Set-Content -Path $_.FullName | ||
| } | ||
|
|
||
| Write-Host '::group::Build docs - Move markdown files from source files to docs' | ||
| $moduleDocsFolder = Join-Path $DocsOutputFolder.FullName $ModuleName | ||
| Get-ChildItem -Path $PublicFunctionsFolder -Recurse -Force -Include '*.md' | ForEach-Object { | ||
| $file = $_ | ||
| $relPath = [System.IO.Path]::GetRelativePath($PublicFunctionsFolder.FullName, $file.FullName) | ||
| Write-Host " - $relPath" | ||
| Write-Host " Path: $file" | ||
|
|
||
| $docsFilePath = ($file.FullName).Replace($PublicFunctionsFolder.FullName, $DocsOutputFolder.FullName) | ||
| $docsFilePath = ($file.FullName).Replace($PublicFunctionsFolder.FullName, $moduleDocsFolder) | ||
| Write-Host " MD path: $docsFilePath" | ||
| $docsFolderPath = Split-Path -Path $docsFilePath -Parent | ||
| $null = New-Item -Path $docsFolderPath -ItemType Directory -Force | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -256,6 +256,9 @@ function Get-PSModuleTest { | |||||||||||
| .SYNOPSIS | ||||||||||||
| Performs tests on a module. | ||||||||||||
|
|
||||||||||||
| .DESCRIPTION | ||||||||||||
| Performs tests on a module. | ||||||||||||
|
|
||||||||||||
| .EXAMPLE | ||||||||||||
| Test-PSModule -Name 'World' | ||||||||||||
|
|
||||||||||||
|
|
@@ -282,6 +285,9 @@ function New-PSModuleTest { | |||||||||||
| .SYNOPSIS | ||||||||||||
| Performs tests on a module. | ||||||||||||
|
|
||||||||||||
| .DESCRIPTION | ||||||||||||
| Performs tests on a module. | ||||||||||||
|
|
||||||||||||
| .EXAMPLE | ||||||||||||
| Test-PSModule -Name 'World' | ||||||||||||
|
|
||||||||||||
|
|
@@ -310,10 +316,19 @@ function Set-PSModuleTest { | |||||||||||
| .SYNOPSIS | ||||||||||||
| Performs tests on a module. | ||||||||||||
|
|
||||||||||||
| .DESCRIPTION | ||||||||||||
| Performs tests on a module. | ||||||||||||
|
|
||||||||||||
| .EXAMPLE | ||||||||||||
| Test-PSModule -Name 'World' | ||||||||||||
|
|
||||||||||||
| "Hello, World!" | ||||||||||||
|
|
||||||||||||
| .NOTES | ||||||||||||
| Controls: | ||||||||||||
| - :q : Quit | ||||||||||||
| - :q! : Quit without saving | ||||||||||||
| - :wq : Save and quit | ||||||||||||
|
Comment on lines
+328
to
+331
|
||||||||||||
| Controls: | |
| - :q : Quit | |
| - :q! : Quit without saving | |
| - :wq : Save and quit | |
| This function outputs a greeting to the specified name. No additional dependencies. |
Uh oh!
There was an error while loading. Please reload this page.