internal static CommentHelpInfo GetHelpContents(List <System.Management.Automation.Language.Token> comments, List <string> parameterDescriptions) { HelpCommentsParser parser = new HelpCommentsParser(parameterDescriptions); parser.AnalyzeCommentBlock(comments); return(parser._sections); }
internal static bool IsCommentHelpText(List <System.Management.Automation.Language.Token> commentBlock) { if ((commentBlock == null) || (commentBlock.Count == 0)) { return(false); } HelpCommentsParser parser = new HelpCommentsParser(); return(parser.AnalyzeCommentBlock(commentBlock)); }
internal static HelpInfo CreateFromComments( ExecutionContext context, CommandInfo commandInfo, List <Token> comments, List <List <Token> > parameterComments, out string helpFile) { HelpCommentsParser helpCommentsParser = new HelpCommentsParser(commandInfo, parameterComments); helpCommentsParser.AnalyzeCommentBlock(comments); helpFile = helpCommentsParser.GetHelpFile(commandInfo); RemoteHelpInfo remoteHelpInfo = helpCommentsParser.GetRemoteHelpInfo(context, commandInfo); if (remoteHelpInfo != null) { return((HelpInfo)remoteHelpInfo); } MamlCommandHelpInfo helpInfo = MamlCommandHelpInfo.Load((XmlNode)helpCommentsParser.BuildXmlFromComments().DocumentElement, commandInfo.HelpCategory); if (helpInfo != null) { helpCommentsParser.SetAdditionalData(helpInfo); if (!string.IsNullOrEmpty(helpCommentsParser.sections.forwardHelpTargetName) || !string.IsNullOrEmpty(helpCommentsParser.sections.fowardHelpCategory)) { if (string.IsNullOrEmpty(helpCommentsParser.sections.forwardHelpTargetName)) { helpInfo.ForwardTarget = helpInfo.Name; } else { helpInfo.ForwardTarget = helpCommentsParser.sections.forwardHelpTargetName; } if (!string.IsNullOrEmpty(helpCommentsParser.sections.fowardHelpCategory)) { try { helpInfo.ForwardHelpCategory = (HelpCategory)Enum.Parse(typeof(HelpCategory), helpCommentsParser.sections.fowardHelpCategory, true); } catch (ArgumentException ex) { } } else { helpInfo.ForwardHelpCategory = HelpCategory.Alias | HelpCategory.Cmdlet | HelpCategory.ScriptCommand | HelpCategory.Function | HelpCategory.Filter | HelpCategory.ExternalScript; } } } return((HelpInfo)helpInfo); }
internal static HelpInfo CreateFromComments(ExecutionContext context, CommandInfo commandInfo, List <System.Management.Automation.Language.Token> comments, List <string> parameterDescriptions, bool dontSearchOnRemoteComputer, out string helpFile, out string helpUriFromDotLink) { HelpCommentsParser helpCommentsParser = new HelpCommentsParser(commandInfo, parameterDescriptions); helpCommentsParser.AnalyzeCommentBlock(comments); if ((helpCommentsParser._sections.Links != null) && (helpCommentsParser._sections.Links.Count != 0)) { helpUriFromDotLink = helpCommentsParser._sections.Links[0]; } else { helpUriFromDotLink = null; } helpFile = helpCommentsParser.GetHelpFile(commandInfo); if (((comments.Count == 1) && helpCommentsParser.isExternalHelpSet) && (helpFile == null)) { return(null); } return(CreateFromComments(context, commandInfo, helpCommentsParser, dontSearchOnRemoteComputer)); }
/// <summary> /// Analyze a block of comments to determine if it is a special help block. /// </summary> /// <param name="commentBlock">The block of comments to analyze.</param> /// <returns>true if the block is our special comment block for help, false otherwise.</returns> internal static bool IsCommentHelpText(List<Token> commentBlock) { if ((commentBlock == null) || (commentBlock.Count == 0)) return false; HelpCommentsParser generator = new HelpCommentsParser(); return generator.AnalyzeCommentBlock(commentBlock); }
internal static HelpInfo CreateFromComments(ExecutionContext context, CommandInfo commandInfo, HelpCommentsParser helpCommentsParser, bool dontSearchOnRemoteComputer) { if (!dontSearchOnRemoteComputer) { RemoteHelpInfo remoteHelpInfo = helpCommentsParser.GetRemoteHelpInfo(context, commandInfo); if (remoteHelpInfo != null) { // Add HelpUri if necessary if (remoteHelpInfo.GetUriForOnlineHelp() == null) { DefaultCommandHelpObjectBuilder.AddRelatedLinksProperties(remoteHelpInfo.FullHelp, commandInfo.CommandMetadata.HelpUri); } return remoteHelpInfo; } } XmlDocument doc = helpCommentsParser.BuildXmlFromComments(); HelpCategory helpCategory = commandInfo.HelpCategory; MamlCommandHelpInfo localHelpInfo = MamlCommandHelpInfo.Load(doc.DocumentElement, helpCategory); if (localHelpInfo != null) { helpCommentsParser.SetAdditionalData(localHelpInfo); if (!string.IsNullOrEmpty(helpCommentsParser._sections.ForwardHelpTargetName) || !string.IsNullOrEmpty(helpCommentsParser._sections.ForwardHelpCategory)) { if (string.IsNullOrEmpty(helpCommentsParser._sections.ForwardHelpTargetName)) { localHelpInfo.ForwardTarget = localHelpInfo.Name; } else { localHelpInfo.ForwardTarget = helpCommentsParser._sections.ForwardHelpTargetName; } if (!string.IsNullOrEmpty(helpCommentsParser._sections.ForwardHelpCategory)) { try { localHelpInfo.ForwardHelpCategory = (HelpCategory)Enum.Parse(typeof(HelpCategory), helpCommentsParser._sections.ForwardHelpCategory, true); } catch (System.ArgumentException) { // Ignore conversion errors. } } else { localHelpInfo.ForwardHelpCategory = (HelpCategory.Alias | HelpCategory.Cmdlet | HelpCategory.ExternalScript | HelpCategory.Filter | HelpCategory.Function | HelpCategory.ScriptCommand | HelpCategory.Workflow); } } WorkflowInfo workflowInfo = commandInfo as WorkflowInfo; if (workflowInfo != null) { bool common = DefaultCommandHelpObjectBuilder.HasCommonParameters(commandInfo.Parameters); bool commonWorkflow = ((commandInfo.CommandType & CommandTypes.Workflow) == CommandTypes.Workflow); localHelpInfo.FullHelp.Properties.Add(new PSNoteProperty("CommonParameters", common)); localHelpInfo.FullHelp.Properties.Add(new PSNoteProperty("WorkflowCommonParameters", commonWorkflow)); DefaultCommandHelpObjectBuilder.AddDetailsProperties(obj: localHelpInfo.FullHelp, name: workflowInfo.Name, noun: workflowInfo.Noun, verb: workflowInfo.Verb, typeNameForHelp: "MamlCommandHelpInfo", synopsis: localHelpInfo.Synopsis); DefaultCommandHelpObjectBuilder.AddSyntaxProperties(localHelpInfo.FullHelp, workflowInfo.Name, workflowInfo.ParameterSets, common, commonWorkflow, "MamlCommandHelpInfo"); } // Add HelpUri if necessary if (localHelpInfo.GetUriForOnlineHelp() == null) { DefaultCommandHelpObjectBuilder.AddRelatedLinksProperties(localHelpInfo.FullHelp, commandInfo.CommandMetadata.HelpUri); } } return localHelpInfo; }
internal static HelpInfo CreateFromComments(ExecutionContext context, CommandInfo commandInfo, List<Language.Token> comments, List<string> parameterDescriptions, bool dontSearchOnRemoteComputer, out string helpFile, out string helpUriFromDotLink) { HelpCommentsParser helpCommentsParser = new HelpCommentsParser(commandInfo, parameterDescriptions); helpCommentsParser.AnalyzeCommentBlock(comments); if (helpCommentsParser._sections.Links != null && helpCommentsParser._sections.Links.Count != 0) { helpUriFromDotLink = helpCommentsParser._sections.Links[0]; } else { helpUriFromDotLink = null; } helpFile = helpCommentsParser.GetHelpFile(commandInfo); // If only .ExternalHelp is defined and the help file is not found, then we // use the metadata driven help if (comments.Count == 1 && helpCommentsParser.isExternalHelpSet && helpFile == null) { return null; } return CreateFromComments(context, commandInfo, helpCommentsParser, dontSearchOnRemoteComputer); }
internal static CommentHelpInfo GetHelpContents(List<Language.Token> comments, List<string> parameterDescriptions) { HelpCommentsParser helpCommentsParser = new HelpCommentsParser(parameterDescriptions); helpCommentsParser.AnalyzeCommentBlock(comments); return helpCommentsParser._sections; }
internal static HelpInfo CreateFromComments(ExecutionContext context, CommandInfo commandInfo, HelpCommentsParser helpCommentsParser, bool dontSearchOnRemoteComputer) { if (!dontSearchOnRemoteComputer) { RemoteHelpInfo remoteHelpInfo = helpCommentsParser.GetRemoteHelpInfo(context, commandInfo); if (remoteHelpInfo != null) { if (remoteHelpInfo.GetUriForOnlineHelp() == null) { DefaultCommandHelpObjectBuilder.AddRelatedLinksProperties(remoteHelpInfo.FullHelp, commandInfo.CommandMetadata.HelpUri); } return(remoteHelpInfo); } } XmlDocument document = helpCommentsParser.BuildXmlFromComments(); HelpCategory helpCategory = commandInfo.HelpCategory; MamlCommandHelpInfo helpInfo = MamlCommandHelpInfo.Load(document.DocumentElement, helpCategory); if (helpInfo != null) { helpCommentsParser.SetAdditionalData(helpInfo); if (!string.IsNullOrEmpty(helpCommentsParser._sections.ForwardHelpTargetName) || !string.IsNullOrEmpty(helpCommentsParser._sections.ForwardHelpCategory)) { if (string.IsNullOrEmpty(helpCommentsParser._sections.ForwardHelpTargetName)) { helpInfo.ForwardTarget = helpInfo.Name; } else { helpInfo.ForwardTarget = helpCommentsParser._sections.ForwardHelpTargetName; } if (!string.IsNullOrEmpty(helpCommentsParser._sections.ForwardHelpCategory)) { try { helpInfo.ForwardHelpCategory = (HelpCategory)Enum.Parse(typeof(HelpCategory), helpCommentsParser._sections.ForwardHelpCategory, true); } catch (ArgumentException) { } } else { helpInfo.ForwardHelpCategory = HelpCategory.Workflow | HelpCategory.ExternalScript | HelpCategory.Filter | HelpCategory.Function | HelpCategory.ScriptCommand | HelpCategory.Cmdlet | HelpCategory.Alias; } } WorkflowInfo info3 = commandInfo as WorkflowInfo; if (info3 != null) { bool flag = DefaultCommandHelpObjectBuilder.HasCommonParameters(commandInfo.Parameters); bool flag2 = (commandInfo.CommandType & CommandTypes.Workflow) == CommandTypes.Workflow; helpInfo.FullHelp.Properties.Add(new PSNoteProperty("CommonParameters", flag)); helpInfo.FullHelp.Properties.Add(new PSNoteProperty("WorkflowCommonParameters", flag2)); DefaultCommandHelpObjectBuilder.AddDetailsProperties(helpInfo.FullHelp, info3.Name, info3.Noun, info3.Verb, "MamlCommandHelpInfo", helpInfo.Synopsis); DefaultCommandHelpObjectBuilder.AddSyntaxProperties(helpInfo.FullHelp, info3.Name, info3.ParameterSets, flag, flag2, "MamlCommandHelpInfo"); } if (helpInfo.GetUriForOnlineHelp() == null) { DefaultCommandHelpObjectBuilder.AddRelatedLinksProperties(helpInfo.FullHelp, commandInfo.CommandMetadata.HelpUri); } } return(helpInfo); }
internal static bool IsCommentHelpText(List<System.Management.Automation.Language.Token> commentBlock) { if ((commentBlock == null) || (commentBlock.Count == 0)) { return false; } HelpCommentsParser parser = new HelpCommentsParser(); return parser.AnalyzeCommentBlock(commentBlock); }
internal static CommentHelpInfo GetHelpContents(List<System.Management.Automation.Language.Token> comments, List<string> parameterDescriptions) { HelpCommentsParser parser = new HelpCommentsParser(parameterDescriptions); parser.AnalyzeCommentBlock(comments); return parser._sections; }
internal static HelpInfo CreateFromComments(ExecutionContext context, CommandInfo commandInfo, List<System.Management.Automation.Language.Token> comments, List<string> parameterDescriptions, bool dontSearchOnRemoteComputer, out string helpFile, out string helpUriFromDotLink) { HelpCommentsParser helpCommentsParser = new HelpCommentsParser(commandInfo, parameterDescriptions); helpCommentsParser.AnalyzeCommentBlock(comments); if ((helpCommentsParser._sections.Links != null) && (helpCommentsParser._sections.Links.Count != 0)) { helpUriFromDotLink = helpCommentsParser._sections.Links[0]; } else { helpUriFromDotLink = null; } helpFile = helpCommentsParser.GetHelpFile(commandInfo); if (((comments.Count == 1) && helpCommentsParser.isExternalHelpSet) && (helpFile == null)) { return null; } return CreateFromComments(context, commandInfo, helpCommentsParser, dontSearchOnRemoteComputer); }
internal static HelpInfo CreateFromComments(ExecutionContext context, CommandInfo commandInfo, HelpCommentsParser helpCommentsParser, bool dontSearchOnRemoteComputer) { if (!dontSearchOnRemoteComputer) { RemoteHelpInfo remoteHelpInfo = helpCommentsParser.GetRemoteHelpInfo(context, commandInfo); if (remoteHelpInfo != null) { if (remoteHelpInfo.GetUriForOnlineHelp() == null) { DefaultCommandHelpObjectBuilder.AddRelatedLinksProperties(remoteHelpInfo.FullHelp, commandInfo.CommandMetadata.HelpUri); } return remoteHelpInfo; } } XmlDocument document = helpCommentsParser.BuildXmlFromComments(); HelpCategory helpCategory = commandInfo.HelpCategory; MamlCommandHelpInfo helpInfo = MamlCommandHelpInfo.Load(document.DocumentElement, helpCategory); if (helpInfo != null) { helpCommentsParser.SetAdditionalData(helpInfo); if (!string.IsNullOrEmpty(helpCommentsParser._sections.ForwardHelpTargetName) || !string.IsNullOrEmpty(helpCommentsParser._sections.ForwardHelpCategory)) { if (string.IsNullOrEmpty(helpCommentsParser._sections.ForwardHelpTargetName)) { helpInfo.ForwardTarget = helpInfo.Name; } else { helpInfo.ForwardTarget = helpCommentsParser._sections.ForwardHelpTargetName; } if (!string.IsNullOrEmpty(helpCommentsParser._sections.ForwardHelpCategory)) { try { helpInfo.ForwardHelpCategory = (HelpCategory) Enum.Parse(typeof(HelpCategory), helpCommentsParser._sections.ForwardHelpCategory, true); } catch (ArgumentException) { } } else { helpInfo.ForwardHelpCategory = HelpCategory.Workflow | HelpCategory.ExternalScript | HelpCategory.Filter | HelpCategory.Function | HelpCategory.ScriptCommand | HelpCategory.Cmdlet | HelpCategory.Alias; } } WorkflowInfo info3 = commandInfo as WorkflowInfo; if (info3 != null) { bool flag = DefaultCommandHelpObjectBuilder.HasCommonParameters(commandInfo.Parameters); bool flag2 = (commandInfo.CommandType & CommandTypes.Workflow) == CommandTypes.Workflow; helpInfo.FullHelp.Properties.Add(new PSNoteProperty("CommonParameters", flag)); helpInfo.FullHelp.Properties.Add(new PSNoteProperty("WorkflowCommonParameters", flag2)); DefaultCommandHelpObjectBuilder.AddDetailsProperties(helpInfo.FullHelp, info3.Name, info3.Noun, info3.Verb, "MamlCommandHelpInfo", helpInfo.Synopsis); DefaultCommandHelpObjectBuilder.AddSyntaxProperties(helpInfo.FullHelp, info3.Name, info3.ParameterSets, flag, flag2, "MamlCommandHelpInfo"); } if (helpInfo.GetUriForOnlineHelp() == null) { DefaultCommandHelpObjectBuilder.AddRelatedLinksProperties(helpInfo.FullHelp, commandInfo.CommandMetadata.HelpUri); } } return helpInfo; }