Beispiel #1
0
        static string GenerateMarkdown(MetadataItem item, int level, MetadataItem parent = null)
        {
            var itemContent = item.Type switch
            {
                MemberType.Class => item.GenerateClassMarkdown(level),
                MemberType.Interface => item.GenerateClassMarkdown(level),
                MemberType.Struct => item.GenerateClassMarkdown(level),
                MemberType.Constructor => item.GenerateConstructorMarkdown(level),
                MemberType.Method => item.GenerateMethodMarkdown(level),
                MemberType.Property => item.GeneratePropertyMarkdown(level),
                MemberType.Enum => item.GenerateEnumMarkdown(level),
                MemberType.Field => item.GenerateFieldMarkdown(level, parent),
                MemberType.Namespace => MarkdownBase.Header(level, $"Namespace: {item.Name}{NewLine}"),
                MemberType.Assembly => MarkdownBase.Header(level, $"Assembly: {item.Name}{NewLine}"),
                _ => item + NewLine
            };

            var nestedContent = item.Items == null
                ? ""
                : string.Join(
                NewLine,
                item.Items.Select(x => GenerateMarkdown(x, level + 1, item))
                );

            return(itemContent + nestedContent);
        }
    }
Beispiel #2
0
        public static string GenerateEnumMarkdown(this MetadataItem item, int level)
        {
            var builder = item.GenerateBaseMarkdown(level);

            builder
            .AppendLine(item.Syntax.GenerateMarkdown(level + 1))
            .AppendLine(MarkdownBase.Header(level + 1, "Fields"))
            .AppendLine("Name | Description")
            .AppendLine("--- | ---");

            return(builder.ToString());
        }