Example #1
0
        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);
        }
Example #2
0
        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));
        }
Example #3
0
        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);
        }
Example #4
0
 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);
 }