Skip to content

Fix online help #791

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

Merged
merged 2 commits into from
Jul 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion src/MamlWriter/MamlHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,19 @@ public static HelpItems ConvertCommandHelpToMamlHelpItems(List<CommandHelp> comm
var helpItems = new HelpItems();
foreach(var command in commandHelp)
{
helpItems.Commands.Add(ConvertCommandHelpToMamlCommand(command));
if (command is not null)
{
var onlineHelpUri = command.Metadata?["HelpUri"]?.ToString();

var mamlCommand = ConvertCommandHelpToMamlCommand(command);

if (onlineHelpUri is not null)
{
mamlCommand.RelatedLinks.Insert(0, new NavigationLink { LinkText = "Online Version", Uri = onlineHelpUri });
}

helpItems.Commands.Add(mamlCommand);
}
}
return helpItems;
}
Expand Down
10 changes: 9 additions & 1 deletion test/Pester/ExportMamlCommandHelp.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ Describe "Export-MamlCommandHelp tests" {
}

It "Should have the proper number of relatedLinks" {
$xml2.SelectNodes('//command:command', $ns2).Where({$_.details.name -eq "Get-Date"}).relatedLinks.navigationLink.Count | Should -Be 6
$xml2.SelectNodes('//command:command', $ns2).Where({$_.details.name -eq "Get-Date"}).relatedLinks.navigationLink.Count | Should -Be 7
}

It "Should have the same content for the description" {
Expand All @@ -135,5 +135,13 @@ Describe "Export-MamlCommandHelp tests" {
$mamlFie = $m | Export-MamlCommandHelp -OutputFolder $outputDirectory -Force
$mamlFie | Should -FileContentMatch '<maml:para>&#x80;</maml:para>'
}

It "Should have online help uri" {
$m = Import-MarkdownCommandHelp -Path (Join-Path $assetDir 'Get-Date.V2.md')
$mamlFile = $m | Export-MamlCommandHelp -OutputFolder "$outputDirectory/helpuri" -Force
$mamlFile | Should -Exist
$maml = Get-Content -Path $mamlFile -Raw
$maml | Should -BeLike '*<command:uri>https://learn.microsoft.com/powershell/module/microsoft.powershell.utility/get-date?view=powershell-7.4&amp;WT.mc_id=ps-gethelp</command:uri>*'
}
}
}
Loading