Skip to content

Commit 1977764

Browse files
authored
Merge pull request #22 from belibug/DocPlatyPS
Doc platy ps
2 parents 85c6f4a + c771df1 commit 1977764

6 files changed

Lines changed: 36 additions & 1 deletion

File tree

project.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"ProjectName": "ModuleTools",
33
"Description": "ModuleTools is a versatile, standalone PowerShell module builder. Create anything from simple to robust modules with ease. Built for CICD and Automation.",
4-
"Version": "1.5.1",
4+
"Version": "1.5.2",
55
"copyResourcesToModuleRoot": false,
66
"Manifest": {
77
"Author": "Manjunath Beli",

src/private/BuildHelp.ps1

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
function Build-Help {
2+
[CmdletBinding()]
3+
param(
4+
)
5+
Write-Verbose 'Running Help update'
6+
7+
$data = Get-MTProjectInfo
8+
$helpMarkdownFiles = Get-ChildItem -Path $data.DocsDir -Filter '*.md' -Recurse
9+
10+
if (-not $helpMarkdownFiles) {
11+
Write-Verbose 'No help markdown files in docs directory, skipping building help'
12+
return
13+
}
14+
15+
if (-not (Get-Module -Name Microsoft.PowerShell.PlatyPS -ListAvailable)) {
16+
throw 'The module Microsoft.PowerShell.PlatyPS must be installed for Markdown documentation to be generated.'
17+
}
18+
19+
$AllCommandHelpFiles = $helpMarkdownFiles | Measure-PlatyPSMarkdown | Where-Object FileType -Match CommandHelp
20+
21+
# Export to Dist folder
22+
$AllCommandHelpFiles | Import-MarkdownCommandHelp -Path { $_.FilePath } |
23+
Export-MamlCommandHelp -OutputFolder $data.OutputModuleDir | Out-Null
24+
25+
# Rename the directory to match locale
26+
$HelpDirOld = Join-Path $data.OutputModuleDir $Data.ProjectName
27+
#TODO: hardcoded locale to en-US, change it based on Doc type
28+
$languageLocale = 'en-US'
29+
$HelpDirNew = Join-Path $data.OutputModuleDir $languageLocale
30+
Write-Verbose "Renamed folder to locale: $languageLocale"
31+
32+
Rename-Item -Path $HelpDirOld -NewName $HelpDirNew
33+
}

src/public/GetMTProjectInfo.ps1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ function Get-MTProjectInfo {
3737
$Out['PrivateDir'] = [System.IO.Path]::Join($ProjectRoot, 'src', 'private')
3838
$Out['ClassesDir'] = [System.IO.Path]::Join($ProjectRoot, 'src', 'classes')
3939
$Out['ResourcesDir'] = [System.IO.Path]::Join($ProjectRoot, 'src', 'resources')
40+
$Out['DocsDir'] = [System.IO.Path]::Join($ProjectRoot, 'docs')
4041
$Out['OutputDir'] = [System.IO.Path]::Join($ProjectRoot, 'dist')
4142
$Out['OutputModuleDir'] = [System.IO.Path]::Join($Out.OutputDir, $ProjectName)
4243
$Out['ModuleFilePSM1'] = [System.IO.Path]::Join($Out.OutputModuleDir, "$ProjectName.psm1")

src/public/InvokeMTBuild.ps1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,6 @@ function Invoke-MTBuild {
2020
Reset-ProjectDist
2121
Build-Module
2222
Build-Manifest
23+
Build-Help
2324
Copy-ProjectResource
2425
}

0 commit comments

Comments
 (0)