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..e3a527b --- /dev/null +++ b/src/private/BuildHelp.ps1 @@ -0,0 +1,33 @@ +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 + } + + if (-not (Get-Module -Name Microsoft.PowerShell.PlatyPS -ListAvailable)) { + throw 'The module Microsoft.PowerShell.PlatyPS must be installed for Markdown documentation to be generated.' + } + + $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