-
Notifications
You must be signed in to change notification settings - Fork 158
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
Improve checking of module markdown files in GetMarkdownFilesFromPath #456
base: master
Are you sure you want to change the base?
Changes from all commits
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 |
---|---|---|
|
@@ -1512,7 +1512,20 @@ function GetMarkdownFilesFromPath | |
} | ||
} | ||
|
||
return $MarkdownFiles | ||
$MarkdownFilesFiltered = @() | ||
|
||
If ($IncludeModulePage) { | ||
$MarkdownFilesFiltered = $MarkdownFiles | ||
} Else { | ||
ForEach ($File in $MarkdownFiles) { | ||
$Matches = [regex]::Match((Get-Content $File.FullName -Raw), "# $($File.BaseName) Module").Captures.Groups | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't understand that line, can you add a comment that explains the intention here? |
||
if ($Matches.Length -eq 0) { | ||
$MarkdownFilesFiltered += $File | ||
} | ||
} | ||
} | ||
|
||
return $MarkdownFilesFiltered | ||
} | ||
|
||
function GetParserMode | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -657,6 +657,90 @@ Describe 'New-ExternalHelp' { | |
$xml = [xml] (Get-Content (Join-Path $TestDrive 'TestOrderFunction.xml')) | ||
$xml.helpItems.namespaceuri | Should Be 'http://msh' | ||
} | ||
|
||
It "Checks if external help files are generated correctly" { | ||
New-Item -ItemType Directory -Path (Join-Path $TestDrive "\docs\") | ||
New-Item -ItemType Directory -Path (Join-Path $TestDrive "\en-US\") | ||
|
||
Set-Content -Path (Join-Path $TestDrive "\docs\TestModule.md") -Value @' | ||
--- | ||
Module Name: TestModule | ||
Module Guid: 3790ec3e-4ec0-41cb-9ebf-ae083b883b74 | ||
Download Help Link: https://test.com/release/TestModule/docs/TestModule.md | ||
Help Version: 0.1.0 | ||
Locale: en-US | ||
--- | ||
|
||
# TestModule Module | ||
## Description | ||
Blablablabla | ||
|
||
## TestModule Cmdlets | ||
### [Invoke-Test](Invoke-Test.md) | ||
TBD | ||
|
||
|
||
|
||
'@ | ||
|
||
Set-Content -Path (Join-Path $TestDrive "\docs\Invoke-Test.md") -Value @' | ||
--- | ||
external help file: TestModule-help.xml | ||
Module Name: TestModule | ||
online version: https://test.com | ||
schema: 2.0.0 | ||
--- | ||
|
||
# Invoke-Test | ||
|
||
## SYNOPSIS | ||
TBD | ||
|
||
## SYNTAX | ||
|
||
``` | ||
Invoke-Test [<CommonParameters>] | ||
``` | ||
|
||
## DESCRIPTION | ||
TBD | ||
|
||
## EXAMPLES | ||
|
||
### EXAMPLE 1 | ||
``` | ||
TBD | ||
``` | ||
|
||
## PARAMETERS | ||
|
||
### CommonParameters | ||
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. | ||
For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). | ||
|
||
## INPUTS | ||
|
||
## OUTPUTS | ||
|
||
## NOTES | ||
Author: Bart | ||
|
||
## RELATED LINKS | ||
|
||
[https://test.com](https://test.com) | ||
|
||
|
||
'@ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All the "setup" steps in this |
||
|
||
(New-ExternalHelp -Path "$TestDrive\docs" -OutputPath "$TestDrive\en-US" -Force)[0].Name | Should Be 'TestModule-help.xml' | ||
} | ||
|
||
It "Checks if external help files are generated correctly with dash in module markdown file" { | ||
Rename-Item -Path (Join-Path $TestDrive "\docs\TestModule.md") -NewName "Test-Module.md" | ||
(Get-Content "$TestDrive\docs\Test-Module.md") -replace "TestModule", "Test-Module" | Set-Content "$TestDrive\docs\Test-Module.md" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it needed, why we cannot create it directly? |
||
|
||
(New-ExternalHelp -Path "$TestDrive\docs" -OutputPath "$TestDrive\en-US" -Force)[0].Name | Should Be 'TestModule-help.xml' | ||
} | ||
} | ||
|
||
Describe 'New-ExternalHelp -ErrorLogFile' { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we are going this route of the more intelligent heuristic, we should remove the old dash-based heuristic.