public static ModuleHelpData FromModuleInfo(ModuleInfo module) { var moduleName = module.Name.Humanize(LetterCasing.Title); /* * var suffixPosition = moduleName.IndexOf("Module", StringComparison.OrdinalIgnoreCase); * if (suffixPosition > -1) * { * moduleName = moduleName.Substring(0, suffixPosition).Humanize(); * } */ // moduleName = moduleName.ApplyCase(LetterCasing.Title); var ret = new ModuleHelpData { Name = moduleName, Summary = string.IsNullOrWhiteSpace(module.Summary) ? "No Summary" : module.Summary, Commands = module.Commands .Where(x => !ShouldBeHidden(x)) .Select(x => CommandHelpData.FromCommandInfo(x)) .ToArray(), HelpTags = module.Attributes .OfType <HelpTagsAttribute>() .SingleOrDefault() ?.Tags ?? Array.Empty <string>(), SystemModule = module.IsSystemModule() }; return(ret); bool ShouldBeHidden(CommandInfo command) => command.Preconditions.Any(x => x is RequireOwnerAttribute) || command.Attributes.Any(x => x is HiddenFromHelpAttribute); }
/// <inheritdoc /> public IReadOnlyCollection <ModuleHelpData> GetModuleHelpData() => LazyInitializer.EnsureInitialized(ref _cachedHelpData, () => _commands.Modules .Where(x => !x.Attributes.Any(attr => attr is HiddenFromHelpAttribute)) .Select(x => ModuleHelpData.FromModuleInfo(x)) .ToArray());