コード例 #1
0
        /// <summary>
        /// Builds the markdown for the markdown page
        /// </summary>
        /// <param name="item">The markdown enum item</param>
        /// <returns>The markdown text</returns>
        public string BuildPage(MarkdownEnum item)
        {
            DefaultTheme.ThemeLogger?.LogDebug("Building Enum Page");
            var mb = new MarkdownBuilder();

            mb.HeaderWithCode(1, Cleaner.CreateFullTypeWithLinks(item, item.InternalType, false, false));

            item.BuildNamespaceLinks(item.Namespace, mb);

            if (_options.ShowAssembly)
            {
                mb.Append("Assembly: ").AppendLine(item.InternalType.Module.Name).AppendLine();
            }

            mb.AppendLine();

            var comments = item.Comments;

            if (!String.IsNullOrEmpty(item.Summary))
            {
                mb.AppendLine(item.Summary);
            }

            //mb.Append(GetCode(value));

            mb.AppendLine();

            BuildEnumTable(mb, comments, item);

            return(mb.ToString());
        }
コード例 #2
0
 /// <summary>
 /// Builds Enum Pages with the given MarkdownEnum Item
 /// </summary>
 /// <param name="item">The item to build the page with</param>
 /// <returns>A string of the markdown content or "" if no page created</returns>
 public string BuildPage(MarkdownEnum item)
 {
     if (!_options.BuildTypePages)
     {
         return("");
     }
     return(_enumBuilder.BuildPage(item));
 }
コード例 #3
0
        public MarkdownEnum BuildEnum(MarkdownType type, MarkdownNamespace namespaceItem, IEnumerable <XmlDocumentComment> comments)
        {
            Constants.Logger?.LogTrace("Building Markdown Item for Enum {enumName}", type.Name);
            MarkdownEnum me = new MarkdownEnum();

            me.NamespaceItem = namespaceItem;
            me.InternalType  = type.InternalType;
            me.Comments      = comments;

            me.Summary = comments.FirstOrDefault(x => x.MemberName == me.Name ||
                                                 x.MemberName.StartsWith(me.Name + "`"))?.Summary ?? "";

            MarkdownRepo.TryAdd(me);

            Constants.Logger?.LogTrace("Completed Building Markdown Enum {typeName}", me.Name);
            return(me);
        }
コード例 #4
0
        private static void BuildEnumTable(MarkdownBuilder mb, IEnumerable <XmlDocumentComment> comments, MarkdownEnum value)
        {
            var underlyingEnumType = Enum.GetUnderlyingType(value.InternalType);
            var enums = value.EnumNames
                        .Select(x => new {
                Name = x,

                Value = (Convert.ChangeType(Enum.Parse(value.InternalType, x), underlyingEnumType))
            })
                        .OrderBy(x => x.Value)
                        .ToArray();

            if (enums.Any())
            {
                mb.AppendLine($"##\tEnum");
                mb.AppendLine();

                string[] head = new[] { "Value", "Name", "Summary" };

                var data = enums.Select(item =>
                {
                    var summary = comments.FirstOrDefault(x => x.MemberName == item.Name ||
                                                          x.MemberName.StartsWith(item.Name + "`"))?.Summary ?? "";


                    return(new[] {
                        item.Value.ToString(),
                        item.Name,
                        summary
                    });
                });

                mb.Table(head, data, true);
                mb.AppendLine();
            }
        }