From 04066442eec8d60568e1b810e9394b39195ae0f1 Mon Sep 17 00:00:00 2001 From: Manjunath Beli Date: Wed, 18 Mar 2026 10:45:19 -0500 Subject: [PATCH 1/2] Include Build-Help to generate docs using platyps --- project.json | 2 +- src/private/BuildHelp.ps1 | 37 +++++++++++++++++++ .../{Build.Manifest.ps1 => BuildManifest.ps1} | 0 .../{Build-Module.ps1 => BuildModule.ps1} | 0 src/public/GetMTProjectInfo.ps1 | 1 + src/public/InvokeMTBuild.ps1 | 1 + 6 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 src/private/BuildHelp.ps1 rename src/private/{Build.Manifest.ps1 => BuildManifest.ps1} (100%) rename src/private/{Build-Module.ps1 => BuildModule.ps1} (100%) diff --git a/project.json b/project.json index d9fdb63..2d43cfc 100644 --- a/project.json +++ b/project.json @@ -1,7 +1,7 @@ { "ProjectName": "ModuleTools", "Description": "ModuleTools is a versatile, standalone PowerShell module builder. Create anything from simple to robust modules with ease. Built for CICD and Automation.", - "Version": "1.5.1", + "Version": "1.5.2", "copyResourcesToModuleRoot": false, "Manifest": { "Author": "Manjunath Beli", diff --git a/src/private/BuildHelp.ps1 b/src/private/BuildHelp.ps1 new file mode 100644 index 0000000..8c833fb --- /dev/null +++ b/src/private/BuildHelp.ps1 @@ -0,0 +1,37 @@ +function Build-Help { + [CmdletBinding()] + param( + ) + Write-Verbose 'Running Help update' + + $data = Get-MTProjectInfo + $helpMarkdownFiles = Get-ChildItem -Path $data.DocsDir -Filter '*.md' -Recurse + + if (-not $helpMarkdownFiles) { + Write-Verbose 'No help markdown files in docs directory, skipping building help' + return + } + + #region Check PlatyPS version requirement + $minVersion = [version]'1.0.1' + $module = Get-Module -ListAvailable -Name Microsoft.PowerShell.PlatyPS | Sort-Object Version -Descending | Select-Object -First 1 + if (-not $module -or $module.Version -lt $minVersion) { + throw 'Microsoft.PowerShell.PlatyPS version 1.0.1 or higher is required.' + } + #endregion + + $AllCommandHelpFiles = $helpMarkdownFiles | Measure-PlatyPSMarkdown | Where-Object FileType -Match CommandHelp + + # Export to Dist folder + $AllCommandHelpFiles | Import-MarkdownCommandHelp -Path { $_.FilePath } | + Export-MamlCommandHelp -OutputFolder $data.OutputModuleDir | Out-Null + + # Rename the directory to match locale + $HelpDirOld = Join-Path $data.OutputModuleDir $Data.ProjectName + #TODO: hardcoded locale to en-US, change it based on Doc type + $languageLocale = 'en-US' + $HelpDirNew = Join-Path $data.OutputModuleDir $languageLocale + Write-Verbose "Renamed folder to locale: $languageLocale" + + Rename-Item -Path $HelpDirOld -NewName $HelpDirNew +} \ No newline at end of file diff --git a/src/private/Build.Manifest.ps1 b/src/private/BuildManifest.ps1 similarity index 100% rename from src/private/Build.Manifest.ps1 rename to src/private/BuildManifest.ps1 diff --git a/src/private/Build-Module.ps1 b/src/private/BuildModule.ps1 similarity index 100% rename from src/private/Build-Module.ps1 rename to src/private/BuildModule.ps1 diff --git a/src/public/GetMTProjectInfo.ps1 b/src/public/GetMTProjectInfo.ps1 index 23c9f88..8964dbb 100644 --- a/src/public/GetMTProjectInfo.ps1 +++ b/src/public/GetMTProjectInfo.ps1 @@ -37,6 +37,7 @@ function Get-MTProjectInfo { $Out['PrivateDir'] = [System.IO.Path]::Join($ProjectRoot, 'src', 'private') $Out['ClassesDir'] = [System.IO.Path]::Join($ProjectRoot, 'src', 'classes') $Out['ResourcesDir'] = [System.IO.Path]::Join($ProjectRoot, 'src', 'resources') + $Out['DocsDir'] = [System.IO.Path]::Join($ProjectRoot, 'docs') $Out['OutputDir'] = [System.IO.Path]::Join($ProjectRoot, 'dist') $Out['OutputModuleDir'] = [System.IO.Path]::Join($Out.OutputDir, $ProjectName) $Out['ModuleFilePSM1'] = [System.IO.Path]::Join($Out.OutputModuleDir, "$ProjectName.psm1") diff --git a/src/public/InvokeMTBuild.ps1 b/src/public/InvokeMTBuild.ps1 index b9c6fee..0947c81 100644 --- a/src/public/InvokeMTBuild.ps1 +++ b/src/public/InvokeMTBuild.ps1 @@ -20,5 +20,6 @@ function Invoke-MTBuild { Reset-ProjectDist Build-Module Build-Manifest + Build-Help Copy-ProjectResource } \ No newline at end of file From c771df1514eb3aa14d8a7fe9f5a31ed5f079b001 Mon Sep 17 00:00:00 2001 From: Manjunath Beli Date: Wed, 18 Mar 2026 10:57:32 -0500 Subject: [PATCH 2/2] Closes #18 - fix validation --- src/private/BuildHelp.ps1 | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/private/BuildHelp.ps1 b/src/private/BuildHelp.ps1 index 8c833fb..e3a527b 100644 --- a/src/private/BuildHelp.ps1 +++ b/src/private/BuildHelp.ps1 @@ -12,13 +12,9 @@ function Build-Help { return } - #region Check PlatyPS version requirement - $minVersion = [version]'1.0.1' - $module = Get-Module -ListAvailable -Name Microsoft.PowerShell.PlatyPS | Sort-Object Version -Descending | Select-Object -First 1 - if (-not $module -or $module.Version -lt $minVersion) { - throw 'Microsoft.PowerShell.PlatyPS version 1.0.1 or higher is required.' + if (-not (Get-Module -Name Microsoft.PowerShell.PlatyPS -ListAvailable)) { + throw 'The module Microsoft.PowerShell.PlatyPS must be installed for Markdown documentation to be generated.' } - #endregion $AllCommandHelpFiles = $helpMarkdownFiles | Measure-PlatyPSMarkdown | Where-Object FileType -Match CommandHelp