/// <summary> /// Gets the HelpSection that belongs to the name of the given entry. /// </summary> /// <param name="entry">The name of the entry to retrieve.</param> /// <returns>The HelpSection instance.</returns> public HelpSection Get(string entry) { var topic = topics.SelectMany(m => m.Where(n => n.Name.Equals(entry, StringComparison.CurrentCultureIgnoreCase)).Select(n => n)).FirstOrDefault(); var to = topic.Instance.GetType(); if (topic.Instance is IFunction) { var help = new HelpFunctionSection(); help.Name = topic.Name; help.Description = GetDescription(to); help.Topic = topic.Topic.Kind; help.Link = GetLink(to); var functions = to.GetMethods(); foreach (var function in functions) { if (function.Name.Equals("Function")) { var isextern = true; var parameters = function.GetParameters(); foreach (var parameter in parameters) { if (!parameter.ParameterType.IsSubclassOf(typeof(Value))) { isextern = false; break; } } if (isextern) { help.Usages.Add(GetUsage(help.Name, function)); } } } return(help); } else { var help = new HelpSection(); help.Name = topic.Name; help.Description = GetDescription(to); help.Topic = topic.Topic.Kind; help.Link = GetLink(to); return(help); } }
void PrintUsages(HelpFunctionSection section) { if (section != null) { foreach (var usage in section.Usages) { PrintUsage(usage); } } }
/// <summary> /// Gets the HelpSection that belongs to the name of the given entry. /// </summary> /// <param name="entry">The name of the entry to retrieve.</param> /// <returns>The HelpSection instance.</returns> public HelpSection Get(String entry) { var topic = topics.SelectMany(m => m.Where(n => n.Name.Equals(entry, StringComparison.CurrentCultureIgnoreCase)).Select(n => n)).FirstOrDefault(); var to = topic.Instance.GetType(); if (topic.Instance is IFunction) { var help = new HelpFunctionSection(); help.Name = topic.Name; help.Description = GetDescription(to); help.Topic = topic.Topic.Kind; help.Link = GetLink(to); var functions = to.GetMethods(); foreach (var function in functions) { if (function.Name.Equals("Function")) { var isextern = true; var parameters = function.GetParameters(); foreach (var parameter in parameters) { if (!parameter.ParameterType.IsSubclassOf(typeof(Value))) { isextern = false; break; } } if (isextern) { help.Usages.Add(GetUsage(help.Name, function)); } } } return help; } else { var help = new HelpSection(); help.Name = topic.Name; help.Description = GetDescription(to); help.Topic = topic.Topic.Kind; help.Link = GetLink(to); return help; } }