Skip to content

Commit c450917

Browse files
Ensure external help file from metadata is used for generating the MAML file name (#779)
1 parent d8364c0 commit c450917

File tree

4 files changed

+8
-2
lines changed

4 files changed

+8
-2
lines changed

src/Command/ExportMamlCommandHelp.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,12 @@ protected override void EndProcessing()
7070
}
7171

7272
// emit a MAML file for each group of CommandHelp objects
73-
var helpGroup = _commandHelps.GroupBy(c => c.ModuleName);
73+
var helpGroup = _commandHelps.GroupBy(c => c?.ExternalHelpFile ?? c?.ModuleName)
74+
.OrderBy(g => g.Key);
7475
foreach(var group in helpGroup)
7576
{
7677
string moduleName = group.First().ModuleName;
77-
string helpFileName = $"{moduleName}-Help.xml";
78+
string helpFileName = group.First().ExternalHelpFile ?? $"{moduleName}-Help.xml";
7879

7980
if (!ShouldProcess(helpFileName))
8081
{

src/Common/MergeUtils.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ internal static CommandHelp MergeCommandHelp(CommandHelp fromMarkdown, CommandHe
2929
// We will update this copy with new information from the cmdlet.
3030
CommandHelp helpCopy = new (fromMarkdown);
3131

32+
// Copy the ExternalHelpFile from markdown on cmletinfo
33+
helpCopy.ExternalHelpFile = fromMarkdown.ExternalHelpFile ?? fromCmdlet.ExternalHelpFile;
34+
3235
// The following are not available in the cmdlet, so we will just use what was in the help.
3336
// - Synopsis
3437
// - Description

src/Common/MetadataUtils.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ public static OrderedDictionary GetCommandHelpBaseMetadataFromCommandInfo(Comman
6060

6161
private static string GetHelpFileFromCommandInfo(CommandInfo commandInfo)
6262
{
63+
// We are chosing upper case for the "Help.xml" file name to avoid issues with non-Windows platforms.
6364
string helpFileName;
6465
if (commandInfo is CmdletInfo cmdlet && ! string.IsNullOrEmpty(cmdlet.HelpFile))
6566
{

src/Transform/TransformBase.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ protected CommandHelp ConvertCmdletInfo(CommandInfo? commandInfo)
5757

5858
CommandHelp cmdHelp = new(commandInfo.Name, commandInfo.ModuleName, Settings.Locale);
5959
cmdHelp.Metadata = MetadataUtils.GetCommandHelpBaseMetadataFromCommandInfo(commandInfo);
60+
cmdHelp.ExternalHelpFile = cmdHelp.Metadata["external help file"].ToString() ?? string.Empty;
6061
cmdHelp.OnlineVersionUrl = Settings.OnlineVersionUrl;
6162
cmdHelp.Synopsis = GetSynopsis(helpItem, addDefaultStrings);
6263
cmdHelp.AddSyntaxItemRange(GetSyntaxItem(commandInfo, helpItem));

0 commit comments

Comments
 (0)