Exemple #1
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());
        }
        // 0 = dll src path, 1 = dest root, 2 = namespace regex filter, 3 = intro text, 4 = meta output path
        private static void Main(string[] args)
        {
            try
            {
                //args = new[] { @"C:\Users\Elringus\Documents\UnityProjects\Naninovel\DocsGenerator\Elringus.Naninovel.Runtime.dll", @"C:\Users\Elringus\Documents\GitHub\NaninovelWeb\docs\api", @"^Naninovel.Commands", "..." };

                var target         = args.ElementAtOrDefault(0);
                var dest           = args.ElementAtOrDefault(1);
                var namespaceMatch = args.ElementAtOrDefault(2);
                var introText      = args.ElementAtOrDefault(3);
                var metaPath       = args.ElementAtOrDefault(4);

                var docBuilder = new StringBuilder();
                docBuilder.Append(introText);

                var metaJArray = new JArray();

                var types = MarkdownGenerator.Load(target, namespaceMatch)
                            .OrderBy(x => x.HasCommandAlias ? x.CommandAlias : x.Name).ToList();

                foreach (var type in types)
                {
                    if (!type.IsCommand || type.Type.IsAbstract)
                    {
                        continue;
                    }
                    docBuilder.Append(type.ToString());
                    metaJArray.Add(type.ToJson());
                }

                if (!Directory.Exists(dest))
                {
                    Directory.CreateDirectory(dest);
                }
                File.WriteAllText(Path.Combine(dest, "index.md"), docBuilder.ToString().Replace("*vertical-bar*", "&#124;"), Encoding.UTF8);

                if (string.IsNullOrWhiteSpace(metaPath))
                {
                    return;
                }
                var rootObject = new JObject();
                rootObject["commands"] = metaJArray;
                if (!Directory.Exists(metaPath))
                {
                    Directory.CreateDirectory(metaPath);
                }
                File.WriteAllText(Path.Combine(metaPath, "metadata.json"), rootObject.ToString(), Encoding.UTF8);
            }
            catch (Exception e) { Console.WriteLine("Error: " + e.Message); Console.ReadKey(); }
        }
        // 0 = dll src path, 1 = dest root
        static void Main(string[] args)
        {
            //var iobserverType = Type.GetType("System.IObserver`1[]");
            //var t = iobserverType.GetGenericArguments()[0];

            //var parameters = methodInfo.GetParameters();
            //foreach (var p in parameters)
            //{
            //    BeautifyType(x.ParameterType);
            //}

            // 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);

            NewMdWriter(dest, types);
        }
        // 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());
        }
Exemple #6
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());
        }
Exemple #7
0
        // 0 = dll src path, 1 = dest root
        static void Main(string[] args)
        {
            string        target      = null; // target .dll file
            string        destination = "md"; // where to store generated md files
            bool          namespaces  = true; // include namespaces in filename
            List <string> whitelist   = null; // Whitelist namespaces

            //Parse args
            foreach (string arg in args)
            {
                if (arg.EndsWith(".dll", StringComparison.CurrentCultureIgnoreCase))
                {
                    if (File.Exists(arg))
                    {
                        target = arg;
                    }
                    else
                    {
                        Console.WriteLine("Target .dll not found at " + arg);
                    }
                }
                else if (Directory.Exists(arg))
                {
                    destination = arg;
                }
                else if (arg == "-nonamespace")
                {
                    namespaces = false;
                }
                else if (arg.Contains('='))
                {
                    string[] splitArgs = arg.Split(new char[] { '=' }, StringSplitOptions.RemoveEmptyEntries);
                    if (splitArgs.Length == 2)
                    {
                        if (splitArgs[0] == "-whitelist")
                        {
                            if (whitelist == null)
                            {
                                whitelist = new List <string>();
                            }
                            whitelist.Add(splitArgs[1]);
                        }
                    }
                }
            }

            if (target == null)
            {
                Console.WriteLine("No target .dll");
                Console.ReadLine();
            }

            MarkdownableType[] types = MarkdownGenerator.Load(target, whitelist);
            if (!Directory.Exists(destination))
            {
                Directory.CreateDirectory(destination);
            }

            //BuildHome(types, dest);
            BuildClasses(types, destination, namespaces);
            Console.ReadLine();
        }