Exemplo n.º 1
0
        public override string ToString()
        {
            Type t = Type.GetType("StereoKit." + name + ", StereoKit");

            methods.Sort((a, b) => a.name.CompareTo(b.name));
            fields.Sort((a, b) => a.name.CompareTo(b.name));

            string memberText = "";

            if (methods.Count > 0)
            {
                memberText = "\n\n## Methods\n\n|  |  |\n|--|--|\n";
                for (int i = 0; i < methods.Count; i++)
                {
                    memberText += $"|[{methods[i].ShowName}]({methods[i].UrlName})|{StringHelper.CleanForTable(methods[i].overloads[0].summary)}|\n";
                }
            }

            string fieldText = "";

            if (fields.Count > 0)
            {
                fieldText = "\n\n## Fields and Properties\n\n|  |  |\n|--|--|\n";
                for (int i = 0; i < fields.Count; i++)
                {
                    fieldText += $"|{StringHelper.TypeName(fields[i].GetFieldType(t).Name)} [{fields[i].name}]({fields[i].UrlName})|{StringHelper.CleanForTable(fields[i].summary)}|\n";
                }
            }

            string exampleText = "";

            if (examples.Count > 0)
            {
                exampleText = "\n\n## Examples\n\n";
                for (int i = 0; i < examples.Count; i++)
                {
                    exampleText += examples[i].data;
                }
            }

            return($@"---
layout: default
title: {name}
description: {StringHelper.CleanForDescription(summary)}
---
# {name}

{summary}
{fieldText}
{memberText}
{exampleText}
");
        }
Exemplo n.º 2
0
        public override string ToString()
        {
            MethodBase m          = methodInfo;
            Type       returnType = m is MethodInfo ? ((MethodInfo)m).ReturnType : typeof(void);
            string     methodName = rootMethod.ShowName;
            string     returnName = m is MethodInfo?StringHelper.TypeName(returnType.Name) : "";

            List <ParameterInfo> param = m == null ? new List <ParameterInfo>() : new List <ParameterInfo>(m.GetParameters());

            string paramList = string.Join(", ", param.Select(a => $"{StringHelper.TypeName(a.ParameterType.Name, false)} {a.Name}"));
            string signature = (m.IsStatic ? "static " : "") + $"{StringHelper.TypeName(returnType.Name, false)} {methodName}({paramList})";

            string paramText = "";

            if (parameters.Count > 0 || returnType != typeof(void))
            {
                paramText += "\n|  |  |\n|--|--|\n";
                for (int i = 0; i < parameters.Count; i++)
                {
                    ParameterInfo p = param.Find(a => a.Name == parameters[i].name);
                    if (p == null)
                    {
                        throw new Exception($"Can't find document paramter {parameters[i].name} in {rootMethod.name}");
                    }
                    paramText += $"|{StringHelper.TypeName(p.ParameterType.Name)} {parameters[i].name}|{StringHelper.CleanForTable(parameters[i].summary)}|\n";
                }

                if (returnType != typeof(void))
                {
                    if (string.IsNullOrEmpty(returns))
                    {
                        throw new Exception("Missing doc tag for the return value of " + rootMethod.Name);
                    }
                    paramText += $"|RETURNS: {returnName}|{StringHelper.CleanForTable(returns)}|\n";
                }
            }

            return($@"<div class='signature' markdown='1'>
```csharp
{signature}
```
{summary}
</div>
{paramText}
");
        }
Exemplo n.º 3
0
        public override string ToString()
        {
            Type t = ClassType;

            methods.Sort((a, b) => a.name.CompareTo(b.name));
            fields.Sort((a, b) => a.name.CompareTo(b.name));
            List <DocMethod> methodsStatic   = methods.FindAll(a => a.IsStatic);
            List <DocMethod> methodsInstance = methods.FindAll(a => !a.IsStatic);
            List <DocField>  fieldsStatic    = fields.FindAll(a => a.GetStatic(t));
            List <DocField>  fieldsInstance  = fields.FindAll(a => !a.GetStatic(t));

            Func <DocField, string>  fieldToString  = (f) => { return($"|{StringHelper.TypeName(f.GetFieldType(t).Name)} [{f.name}]({f.UrlName})|{StringHelper.CleanForTable(f.summary)}|"); };
            Func <DocField, string>  enumToString   = (e) => { return($"|{e.name}|{StringHelper.CleanForTable(e.summary)}|"); };
            Func <DocMethod, string> methodToString = (m) => { return($"|[{m.ShowName}]({m.UrlName})|{StringHelper.CleanForTable(m.overloads[0].summary)}|"); };

            string classDescription = "";

            if (t.IsEnum)
            {
                classDescription = "enum";
            }
            else if (t.IsClass)
            {
                classDescription = "class";
            }
            else if (t.IsValueType)
            {
                classDescription = "struct";
            }
            if (t.IsAbstract && t.IsSealed)
            {
                classDescription = "static " + classDescription;
            }

            string memberText = methodsInstance.Count == 0 ?
                                "" : "\n\n## Instance Methods\n\n|  |  |\n|--|--|\n";

            memberText += string.Join("\n", methodsInstance
                                      .Select(methodToString));

            string fieldText = fieldsInstance.Count == 0 ?
                               "" : "\n\n## Instance Fields and Properties\n\n|  |  |\n|--|--|\n";

            fieldText += string.Join("\n", fieldsInstance
                                     .Select(fieldToString));

            string memberTextStatic = methodsStatic.Count == 0 ?
                                      "" : "\n\n## Static Methods\n\n|  |  |\n|--|--|\n";

            memberTextStatic += string.Join("\n", methodsStatic
                                            .Select(methodToString));

            string fieldTextStatic;

            if (t.IsEnum)
            {
                fieldTextStatic = fieldsStatic.Count == 0 ?
                                  "" : "\n\n## Enum Values\n\n|  |  |\n|--|--|\n";
                fieldTextStatic += string.Join("\n", fieldsStatic
                                               .Select(enumToString));
            }
            else
            {
                fieldTextStatic = fieldsStatic.Count == 0 ?
                                  "" : "\n\n## Static Fields and Properties\n\n|  |  |\n|--|--|\n";
                fieldTextStatic += string.Join("\n", fieldsStatic
                                               .Select(fieldToString));
            }

            string exampleText = examples.Count == 0 ?
                                 "" : "\n\n## Examples\n\n";

            exampleText += string.Join("\n", examples.Select(e => e.data));

            return($@"---
layout: default
title: {Name}
description: {StringHelper.CleanForDescription(summary)}
---
# {classDescription} {Name}

{summary}
{fieldText}
{memberText}
{fieldTextStatic}
{memberTextStatic}
{exampleText}
");
        }
Exemplo n.º 4
0
        public override string ToString()
        {
            Type t = Type.GetType("StereoKit." + name + ", StereoKit");

            if (t == null)
            {
                t = Type.GetType("StereoKit.Framework." + name + ", StereoKit");
            }
            methods.Sort((a, b) => a.name.CompareTo(b.name));
            fields.Sort((a, b) => a.name.CompareTo(b.name));
            List <DocMethod> methodsStatic   = methods.FindAll(a => a.IsStatic);
            List <DocMethod> methodsInstance = methods.FindAll(a => !a.IsStatic);
            List <DocField>  fieldsStatic    = fields.FindAll(a => a.GetStatic(t));
            List <DocField>  fieldsInstance  = fields.FindAll(a => !a.GetStatic(t));

            Func <DocField, string>  fieldToString  = (f) => { return($"|{StringHelper.TypeName(f.GetFieldType(t).Name)} [{f.name}]({f.UrlName})|{StringHelper.CleanForTable(f.summary)}|"); };
            Func <DocMethod, string> methodToString = (m) => { return($"|[{m.ShowName}]({m.UrlName})|{StringHelper.CleanForTable(m.overloads[0].summary)}|"); };

            string memberText = methodsInstance.Count == 0 ?
                                "" : "\n\n## Instance Methods\n\n|  |  |\n|--|--|\n";

            memberText += string.Join("\n", methodsInstance
                                      .Select(methodToString));

            string fieldText = fieldsInstance.Count == 0 ?
                               "" : "\n\n## Instance Fields and Properties\n\n|  |  |\n|--|--|\n";

            fieldText += string.Join("\n", fieldsInstance
                                     .Select(fieldToString));

            string memberTextStatic = methodsStatic.Count == 0 ?
                                      "" : "\n\n## Static Methods\n\n|  |  |\n|--|--|\n";

            memberTextStatic += string.Join("\n", methodsStatic
                                            .Select(methodToString));

            string fieldTextStatic = fieldsStatic.Count == 0 ?
                                     "" : "\n\n## Static Fields and Properties\n\n|  |  |\n|--|--|\n";

            fieldTextStatic += string.Join("\n", fieldsStatic
                                           .Select(fieldToString));

            string exampleText = examples.Count == 0 ?
                                 "" : "\n\n## Examples\n\n";

            exampleText += string.Join("\n", examples.Select(e => e.data));

            return($@"---
layout: default
title: {name}
description: {StringHelper.CleanForDescription(summary)}
---
# {name}

{summary}
{fieldText}
{memberText}
{fieldTextStatic}
{memberTextStatic}
{exampleText}
");
        }