Beispiel #1
0
        void BuildTable <T>(MarkdownBuilder mb, string label, T[] array, IEnumerable <XmlDocumentComment> docs, Func <T, string> type, Func <T, string> name, Func <T, string> finalName)
        {
            if (array.Any())
            {
                mb.AppendLine(label);
                mb.AppendLine();

                string[] head = (this.type.IsEnum)
                    ? new[] { "Value", "Name", "Summary" }
                    : new[] { "Type", "Name", "Summary" };

                IEnumerable <T> seq = array;
                if (!this.type.IsEnum)
                {
                    seq = array.OrderBy(x => name(x));
                }

                var data = seq.Select(item2 =>
                {
                    var summary = docs.FirstOrDefault(x => x.MemberName == name(item2) || x.MemberName.StartsWith(name(item2) + "`"))?.Summary ?? "";
                    return(new[] { MarkdownBuilder.MarkdownCodeQuote(type(item2)), finalName(item2), summary });
                });

                mb.Table(head, data);
                mb.AppendLine();
            }
        }
Beispiel #2
0
        // 0 = dll src path, 1 = dest root
        static void Main(string[] args)
        {
            // put dll & xml on same diretory.
            string target         = "";
            string dest           = "md";
            string namespaceMatch = string.Empty;

            if (args.Length == 1)
            {
                target = args[0];
            }
            else if (args.Length == 2)
            {
                target = args[0];
                dest   = args[1];
            }
            else if (args.Length == 3)
            {
                target         = args[0];
                dest           = args[1];
                namespaceMatch = args[2];
            }

            var types = MarkdownGenerator.Load(target, namespaceMatch);

            // Home Markdown Builder
            var homeBuilder = new MarkdownBuilder();

            homeBuilder.Header(1, "References");
            homeBuilder.AppendLine();

            foreach (var g in types.GroupBy(x => x.Namespace).OrderBy(x => x.Key))
            {
                var namescapeDirectoryPath = Path.Combine(dest, g.Key.Replace('.', '\\'));
                if (!Directory.Exists(namescapeDirectoryPath))
                {
                    Directory.CreateDirectory(namescapeDirectoryPath);
                }

                homeBuilder.HeaderWithLink(2, g.Key, g.Key);
                homeBuilder.AppendLine();

                foreach (var item in g.OrderBy(x => x.Name))
                {
                    var sb = new StringBuilder();
                    homeBuilder.ListLink(MarkdownBuilder.MarkdownCodeQuote(item.BeautifyName), Path.Combine(g.Key.Replace('.', '\\'), item.Name + ".md"));

                    sb.Append(item.ToString());
                    var fileName     = item.FullName.Replace(g.Key, "").TrimStart('.');
                    var fullFileName = Path.Combine(namescapeDirectoryPath, fileName) + ".md";
                    File.WriteAllText(fullFileName, sb.ToString());
                    item.GenerateMethodDocuments(namescapeDirectoryPath);
                }

                homeBuilder.AppendLine();
            }

            // Gen Home
            File.WriteAllText(Path.Combine(dest, "Home.md"), homeBuilder.ToString());
        }
        // 0 = dll src path, 1 = dest root
        static void Main(string[] args)
        {
            // put dll & xml on same diretory.
            var    target         = "UniRx.dll"; // :)
            string dest           = "md";
            string namespaceMatch = string.Empty;

            if (args.Length == 1)
            {
                target = args[0];
            }
            else if (args.Length == 2)
            {
                target = args[0];
                dest   = args[1];
            }
            else if (args.Length == 3)
            {
                target         = args[0];
                dest           = args[1];
                namespaceMatch = args[2];
            }

            var types = MarkdownGenerator.Load(target, namespaceMatch);

            // Home Markdown Builder
            var homeBuilder = new MarkdownBuilder();

            homeBuilder.Header(1, "References");
            homeBuilder.AppendLine();

            foreach (var g in types.GroupBy(x => x.Namespace).OrderBy(x => x.Key))
            {
                if (!Directory.Exists(dest))
                {
                    Directory.CreateDirectory(dest);
                }

                homeBuilder.HeaderWithLink(2, g.Key, g.Key);
                homeBuilder.AppendLine();

                var sb = new StringBuilder();
                foreach (var item in g.OrderBy(x => x.Name))
                {
                    //added .md# extension.
                    homeBuilder.ListLink(MarkdownBuilder.MarkdownCodeQuote(item.BeautifyName), g.Key + ".md#" + item.BeautifyName.Replace("<", "").Replace(">", "").Replace(",", "").Replace(" ", "-").ToLower());

                    sb.Append(item.ToString());
                }

                File.WriteAllText(Path.Combine(dest, g.Key + ".md"), sb.ToString());
                homeBuilder.AppendLine();
            }

            // Gen Home
            File.WriteAllText(Path.Combine(dest, "Home.md"), homeBuilder.ToString());
        }
Beispiel #4
0
        void BuildTable <T>(MarkdownBuilder mb, string label, T[] array, IEnumerable <XmlDocumentComment> docs, Func <T, string> type, Func <T, string> name, Func <T, string> finalName)
        {
            if (array.Any())
            {
                mb.AppendLine(label);
                mb.AppendLine();

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

                IEnumerable <T> seq = array;

                IEnumerable <string[]> data = seq.Select(item2 => {
                    string summary = docs.FirstOrDefault(x => x.MemberName == name(item2))?.Summary ?? "";
                    return(new string[] { MarkdownBuilder.MarkdownCodeQuote(type(item2)), finalName(item2), summary });
                });

                mb.Table(head, data);
                mb.AppendLine();
            }
        }
        void BuildTable <T>(MarkdownBuilder mb, string label, T[] array, IEnumerable <XmlDocumentComment> docs, Func <T, string> type, Func <T, string> name, Func <T, string> finalName)
        {
            if (array.Any())
            {
                mb.AppendLine(label);
                mb.AppendLine();

                string[] head = (this.type.IsEnum)
                    ? new[] { "Value", "Name", "Summary" }
                    : new[] { "Type", "Name", "Summary" };

                IEnumerable <T> seq = array;
                if (!this.type.IsEnum)
                {
                    seq = array.OrderBy(x => name(x));
                }

                var data = seq.Select(item2 =>
                {
                    var candidates = docs.Where(x => x.MemberName == name(item2) || x.MemberName.StartsWith(name(item2) + "`")).ToArray();
                    if (candidates.Count() >= 2 && item2 is MethodBase)
                    {
                        // Attempt to identify method overloads
                        var methodParameterNames = (item2 as MethodBase).GetParameters().Select(p => p.Name);
                        var overloadCandidates   = candidates.Where(x => x.Parameters.Keys.SequenceEqual(methodParameterNames)).ToArray();
                        if (overloadCandidates.Any())
                        {
                            candidates = overloadCandidates;
                        }
                    }
                    var summary = candidates.FirstOrDefault()?.Summary ?? "";
                    return(new[] { MarkdownBuilder.MarkdownCodeQuote(type(item2)), finalName(item2), summary });
                });

                mb.Table(head, data);
                mb.AppendLine();
            }
        }
        // 0 = DLL source path, 1 = destination root
        private static void Main(string[] args)
        {
            // put DLL & XML on same directory.
            string target         = null;
            string dest           = "docs";
            string namespaceMatch = string.Empty;

            if (args.Length == 0)
            {
                Console.WriteLine("DLL file location is a required argument");
                Environment.Exit(1);
            }
            if (args.Length == 1)
            {
                target = args[0];
            }
            else if (args.Length == 2)
            {
                target = args[0];
                dest   = args[1];
            }
            else if (args.Length == 3)
            {
                target         = args[0];
                dest           = args[1];
                namespaceMatch = args[2];
            }

            MarkdownableType[] types = MarkdownGenerator.Load(target, namespaceMatch);

            // Home Markdown Builder
            MarkdownBuilder homeBuilder = new MarkdownBuilder();

            homeBuilder.Header(1, "References");
            homeBuilder.AppendLine();

            foreach (IGrouping <string, MarkdownableType> g in types.GroupBy(x => x.Namespace).OrderBy(x => x.Key))
            {
                if (!Directory.Exists(dest))
                {
                    Directory.CreateDirectory(dest);
                }

                homeBuilder.HeaderWithLink(2, g.Key, g.Key);
                homeBuilder.AppendLine();

                StringBuilder sb = new StringBuilder();
                foreach (MarkdownableType item in g.OrderBy(x => x.Name))
                {
                    homeBuilder.ListLink(MarkdownBuilder.MarkdownCodeQuote(item.BeautifyName), g.Key + "#" + item.BeautifyName.Replace("<", "").Replace(">", "").Replace(",", "").Replace(" ", "-").ToLower());

                    sb.Append(item.ToString());
                }

                File.WriteAllText(Path.Combine(dest, g.Key + ".md"), sb.ToString());
                homeBuilder.AppendLine();
            }

            // Gen Home
            File.WriteAllText(Path.Combine(dest, "Home.md"), homeBuilder.ToString());
        }
Beispiel #7
0
        // 0 = dll src path, 1 = dest root
        static void Main(string[] args)
        {
            // put dll & xml on same diretory.
            var    target         = "UniRx.dll"; // :)
            string dest           = "md";
            string namespaceMatch = string.Empty;

            if (args.Length == 1)
            {
                target = args[0];
            }
            else if (args.Length == 2)
            {
                target = args[0];
                dest   = args[1];
            }
            else if (args.Length == 3)
            {
                target         = args[0];
                dest           = args[1];
                namespaceMatch = args[2];
            }

            var types = new List <MarkdownableType>();

            if (target.EndsWith(".dll"))
            {
                types.AddRange(MarkdownGenerator.Load(target, namespaceMatch).Where(x => x.Name.EndsWith("Extensions")));
            }
            else
            {
                //assume directory:
                var assemblies = Directory.GetFiles(target, namespaceMatch);
                foreach (var assembly in assemblies)
                {
                    if (!assembly.EndsWith(".Tests.dll"))
                    {
                        types.AddRange(MarkdownGenerator.Load(assembly, "").Where(x => x.Name.EndsWith("Extensions")));
                    }
                }
            }

            // Home Markdown Builder
            var homeBuilder = new MarkdownBuilder();

            homeBuilder.Header(1, "Extension Method Library");
            homeBuilder.AppendLine();

            foreach (var g in types.GroupBy(x => x.Namespace).OrderBy(x => x.Key))
            {
                if (!Directory.Exists(dest))
                {
                    Directory.CreateDirectory(dest);
                }

                homeBuilder.HeaderWithLink(2, g.Key, g.Key);
                homeBuilder.AppendLine();

                var sb = new StringBuilder();
                foreach (var item in g.OrderBy(x => x.Name))
                {
                    homeBuilder.ListLink(MarkdownBuilder.MarkdownCodeQuote(item.BeautifyName), g.Key + "#" + item.BeautifyName.Replace("<", "").Replace(">", "").Replace(",", "").Replace(" ", "-").ToLower());

                    sb.Append(item.ToString());
                }

                File.WriteAllText(Path.Combine(dest, g.Key + ".md"), sb.ToString());
                homeBuilder.AppendLine();
            }

            // Gen Home
            File.WriteAllText(Path.Combine(dest, "Home.md"), homeBuilder.ToString());
        }