Skip to content

Commit dcc2bb6

Browse files
Overwrite docs (#73)
Updated New-MarkdownHelp with force parameter. This is a signed version of #67 ## Description New-MarkdownHelp should always overwrite new old markdown pages. If this is not suitable a parameter should be added to be able to force it. ## Related Issue <!--- This project only accepts pull requests related to open issues --> <!--- If suggesting a new feature or change, please discuss it in an issue first --> <!--- If fixing a bug, there should be an issue describing it with steps to reproduce --> <!--- Please link to the issue here: --> ## Motivation and Context <!--- Why is this change required? What problem does it solve? --> This allows the comment based help to be the source of truth. ## How Has This Been Tested? <!--- Please describe in detail how you tested your changes. --> <!--- Include details of your testing environment, and the tests you ran to --> <!--- see how your change affects other areas of the code, etc. --> ## Checklist: <!--- Go over all the following points, and put an `x` in all the boxes that apply. --> <!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> - [ ] My code follows the code style of this project. - [ ] I have updated the documentation accordingly. - [ ] I have added this change to the CHANGELOG.md. - [ ] I have read the **CONTRIBUTING** document. - [ ] I have added tests to cover my changes. - [ ] All new and existing tests passed. --------- Co-authored-by: Dylan Prins <[email protected]>
1 parent 80605db commit dcc2bb6

File tree

7 files changed

+138
-87
lines changed

7 files changed

+138
-87
lines changed

Diff for: .markdownlint.json

+4
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,9 @@
22
"$schema": "https://raw.githubusercontent.com/DavidAnson/vscode-markdownlint/refs/heads/main/markdownlint-config-schema.json",
33
"MD024": {
44
"siblings_only": true
5+
},
6+
"MD013": {
7+
"code_blocks": false,
8+
"tables": false
59
}
610
}

Diff for: CHANGELOG.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,13 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
77

88
## Unreleased
99

10+
### Breaking Changes
11+
1012
- [**#71**](https://github.com/psake/PowerShellBuild/pull/71) Compiled modules
1113
are now explicitly created as UTF-8 files.
12-
14+
- [**#67**](https://github.com/psake/PowerShellBuild/pull/67) You can now
15+
overwrite existing markdown files using `$PSBPreference.Docs.Overwrite` and
16+
setting it to `$true`.
1317

1418
## [0.6.2] 2024-10-06
1519

Diff for: PowerShellBuild/IB.tasks.ps1

+1
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ task GenerateMarkdown -if (. $genMarkdownPreReqs) StageFiles,{
121121
ModuleName = $PSBPreference.General.ModuleName
122122
DocsPath = $PSBPreference.Docs.RootDir
123123
Locale = $PSBPreference.Help.DefaultLocale
124+
Overwrite = $PSBPreference.Docs.Overwrite
124125
}
125126
Build-PSBuildMarkdown @buildMDParams
126127
}

Diff for: PowerShellBuild/Public/Build-PSBuildMarkdown.ps1

+18-6
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ function Build-PSBuildMarkdown {
1212
The path where PlatyPS markdown docs will be saved.
1313
.PARAMETER Locale
1414
The locale to save the markdown docs.
15+
.PARAMETER Overwrite
16+
Overwrite existing markdown files and use comment based help as the source of truth.
1517
.EXAMPLE
1618
PS> Build-PSBuildMarkdown -ModulePath ./output/MyModule/0.1.0 -ModuleName MyModule -DocsPath ./docs -Locale en-US
1719
@@ -29,7 +31,10 @@ function Build-PSBuildMarkdown {
2931
[string]$DocsPath,
3032

3133
[parameter(Mandatory)]
32-
[string]$Locale
34+
[string]$Locale,
35+
36+
[parameter(Mandatory)]
37+
[bool]$Overwrite
3338
)
3439

3540
$moduleInfo = Import-Module "$ModulePath/$ModuleName.psd1" -Global -Force -PassThru
@@ -52,13 +57,20 @@ function Build-PSBuildMarkdown {
5257

5358
# ErrorAction set to SilentlyContinue so this command will not overwrite an existing MD file.
5459
$newMDParams = @{
55-
Module = $ModuleName
56-
Locale = $Locale
57-
OutputFolder = [IO.Path]::Combine($DocsPath, $Locale)
58-
ErrorAction = 'SilentlyContinue'
59-
Verbose = $VerbosePreference
60+
Module = $ModuleName
61+
Locale = $Locale
62+
OutputFolder = [IO.Path]::Combine($DocsPath, $Locale)
63+
ErrorAction = 'SilentlyContinue'
64+
Verbose = $VerbosePreference
65+
Force = $Overwrite
66+
}
67+
if ($Overwrite) {
68+
$newMDParams.Add('Force', $true)
69+
$newMDParams.Remove('ErrorAction')
6070
}
6171
New-MarkdownHelp @newMDParams > $null
72+
} catch {
73+
Write-Error "Failed to generate markdown help. : $_"
6274
} finally {
6375
Remove-Module $moduleName
6476
}

Diff for: PowerShellBuild/build.properties.ps1

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
BuildHelpers\Set-BuildEnvironment -Force
22

3-
$outDir = [IO.Path]::Combine($env:BHProjectPath, 'Output')
3+
$outDir = [IO.Path]::Combine($env:BHProjectPath, 'Output')
44
$moduleVersion = (Import-PowerShellDataFile -Path $env:BHPSModuleManifest).ModuleVersion
55

66
[ordered]@{
@@ -97,7 +97,7 @@ $moduleVersion = (Import-PowerShellDataFile -Path $env:BHPSModuleManifest).Modul
9797
OutputFileFormat = 'JaCoCo'
9898
}
9999
}
100-
Help = @{
100+
Help = @{
101101
# Path to updateable help CAB
102102
UpdatableHelpOutDir = [IO.Path]::Combine($outDir, 'UpdatableHelp')
103103

@@ -111,6 +111,9 @@ $moduleVersion = (Import-PowerShellDataFile -Path $env:BHPSModuleManifest).Modul
111111
Docs = @{
112112
# Directory PlatyPS markdown documentation will be saved to
113113
RootDir = [IO.Path]::Combine($env:BHProjectPath, 'docs')
114+
115+
# Whether to overwrite existing markdown files and use comment based help as the source of truth
116+
Overwrite = $false
114117
}
115118
Publish = @{
116119
# PowerShell repository name to publish modules to

Diff for: PowerShellBuild/psakeFile.ps1

+1
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ task GenerateMarkdown -depends StageFiles -precondition $genMarkdownPreReqs {
128128
ModuleName = $PSBPreference.General.ModuleName
129129
DocsPath = $PSBPreference.Docs.RootDir
130130
Locale = $PSBPreference.Help.DefaultLocale
131+
Overwrite = $PSBPreference.Docs.Overwrite
131132
}
132133
Build-PSBuildMarkdown @buildMDParams
133134
} -description 'Generates PlatyPS markdown files from module help'

0 commit comments

Comments
 (0)