Ejemplo n.º 1
0
        static string ToString(DocIndexFolder curr, int indent)
        {
            string result = "";
            string ind    = "";

            for (int i = 0; i < indent; i++)
            {
                ind += '\t';
            }

            result += $"{ind}{{\n";
            result += $"{ind}name : '{curr.name}',\n";
            if (curr.pages.Count > 0)
            {
                result += $"{ind}pages : ['{string.Join("','",curr.pages)}'],\n";
            }
            else
            {
                result += $"{ind}pages : [],\n";
            }


            if (curr.folders.Count > 0)
            {
                result += $"{ind}folders : [\n";
                for (int i = 0; i < curr.folders.Count; i++)
                {
                    result += ToString(curr.folders[i], indent + 1);
                }
                result += $"{ind}]\n";
            }
            result += $"{ind}}},\n";

            return(result);
        }
Ejemplo n.º 2
0
        static string ToString(DocIndexFolder curr, int indent)
        {
            StringBuilder result = new StringBuilder();
            string        ind    = "";

            for (int i = 0; i < indent; i++)
            {
                ind += '\t';
            }

            result.Append($"{ind}{{name : '{curr.name}'");

            if (curr.folders.Count > 0)
            {
                result.Append($",\n{ind} pages: [\n");
                for (int i = 0; i < curr.folders.Count; i++)
                {
                    result.Append(ToString(curr.folders[i], indent + 1));
                }
                result.Append($"{ind}]\n{ind}");
            }
            result.Append($"}},\n");

            return(result.ToString());
        }
Ejemplo n.º 3
0
        static string WriteIndex()
        {
            DocIndexFolder root      = new DocIndexFolder("Pages");
            DocIndexFolder reference = new DocIndexFolder("Reference");

            root.folders.Add(reference);

            for (int i = 0; i < classes.Count; i++)
            {
                DocIndexFolder classFolder = new DocIndexFolder(classes[i].name);
                reference.folders.Add(classFolder);

                for (int f = 0; f < classes[i].fields.Count; f++)
                {
                    classFolder.pages.Add(classes[i].fields[f].name);
                }

                for (int m = 0; m < classes[i].methods.Count; m++)
                {
                    classFolder.pages.Add(classes[i].methods[m].ShowName);
                }
            }

            DocExampleFinder.examples.Sort((a, b) => a.info.CompareTo(b.info));
            for (int e = 0; e < DocExampleFinder.examples.Count; e++)
            {
                DocExample ex = DocExampleFinder.examples[e];
                if (ex.type == ExampleType.Document)
                {
                    DocIndexFolder folder = null;
                    if (ex.category.ToLower() == "root")
                    {
                        folder = root;
                    }
                    else
                    {
                        folder = root.folders.Find((a) => a.name == ex.category);
                    }
                    if (folder == null)
                    {
                        folder = new DocIndexFolder(ex.category);
                        root.folders.Add(folder);
                    }
                    folder.pages.Add(ex.Name);
                }
            }

            root.folders.Sort((a, b) => string.Compare(a.name, b.name));
            reference.folders.Sort((a, b) => string.Compare(a.name, b.name));

            return(root.ToString());
        }
Ejemplo n.º 4
0
        static string WriteIndex()
        {
            DocIndexFolder root      = new DocIndexFolder("Pages");
            DocIndexFolder reference = new DocIndexFolder("Reference");

            root.folders.Add(reference);

            for (int i = 0; i < classes.Count; i++)
            {
                DocIndexFolder classFolder = new DocIndexFolder(classes[i].Name);
                reference.folders.Add(classFolder);

                // Enums don't need child items, it's a little much.
                if (classes[i].IsEnum)
                {
                    continue;
                }

                for (int f = 0; f < classes[i].fields.Count; f++)
                {
                    classFolder.folders.Add(new DocIndexFolder(classes[i].fields[f].name));
                }

                for (int m = 0; m < classes[i].methods.Count; m++)
                {
                    classFolder.folders.Add(new DocIndexFolder(classes[i].methods[m].ShowName));
                }
            }

            DocExampleFinder.examples.Sort((a, b) => a.info.CompareTo(b.info));
            for (int e = 0; e < DocExampleFinder.examples.Count; e++)
            {
                DocExample ex = DocExampleFinder.examples[e];
                if (ex.type == ExampleType.Document)
                {
                    DocIndexFolder folder = null;
                    if (ex.category.ToLower() == "root")
                    {
                        folder = root;
                    }
                    else
                    {
                        folder = root.folders.Find((a) => a.name == ex.category);
                    }
                    if (folder == null)
                    {
                        folder = new DocIndexFolder(ex.category, ex.SortIndex);
                        root.folders.Add(folder);
                    }
                    folder.folders.Add(new DocIndexFolder(ex.Name, ex.SortIndex));
                }
            }
            for (int i = 0; i < root.folders.Count; i++)
            {
                if (root.folders[i] == reference)
                {
                    continue;
                }
                root.folders[i].folders.Sort((a, b) => a.order - b.order);
            }

            root.folders.Sort((a, b) => string.Compare(a.name, b.name));
            reference.folders.Sort((a, b) => string.Compare(a.name, b.name));

            return(root.ToString());
        }