Ejemplo n.º 1
0
        private static void PrintStruct(StringBuilder b, StructDocType type, DocTree tree)
        {
            b.AppendLine("<div style=\"line-height: 1;\">");
            b.AppendLine("\t<h2 markdown=\"1\">" + Utils.GetSafeTypeName(type.Type, true) + " ``struct``" + (type.Obsolete ? " <small><span class=\"label label-warning\" title=\"" + type.ObsoleteString + "\">Obsolete</span></small>" : "") + "</h2>");
            b.AppendLine("\t<p style=\"font-size: 20px;\"><b>Namespace:</b> " + type.Namespace + "</p>");
            b.AppendLine("\t<p style=\"font-size: 20px;\"><b>Assembly:</b> MLAPI.dll</p>");
            b.AppendLine("</div>");

            if (type.Summary != null)
            {
                b.AppendLine("<p>" + type.Summary + "</p>");
                b.AppendLine();
            }

            PrintProperties(b, type.Properties, tree);
            PrintFields(b, type.Fields, tree);
            PrintConstructors(b, type.Constructors, tree);
            PrintMethods(b, type.Methods, tree);
        }
Ejemplo n.º 2
0
        private void ParseStruct(Type type, XmlDocTree xmlDocTree)
        {
            StructDocType structDoc = new StructDocType()
            {
                Name           = type.Name,
                Type           = type,
                Namespace      = type.Namespace,
                IsGeneric      = type.IsGenericType,
                Obsolete       = type.IsDefined(typeof(ObsoleteAttribute), true),
                ObsoleteString = type.GetCustomAttribute <ObsoleteAttribute>(true)?.Message
            };

            foreach (MethodInfo method in type.GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.Static).Where(x => !x.IsSpecialName))
            {
                structDoc.Methods.Add(ParseMethod(type, method, xmlDocTree));
            }

            foreach (FieldInfo field in type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.Static))
            {
                structDoc.Fields.Add(ParseField(type, field, xmlDocTree));
            }

            foreach (PropertyInfo property in type.GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.Static))
            {
                structDoc.Properties.Add(ParseProperty(type, property, xmlDocTree));
            }

            foreach (ConstructorInfo constructor in type.GetConstructors(BindingFlags.Instance | BindingFlags.Public | BindingFlags.Static))
            {
                structDoc.Constructors.Add(ParseConstructor(type, constructor, xmlDocTree));
            }

            DocMember member = xmlDocTree.GetDocumentation(type);

            if (member != null)
            {
                structDoc.Summary = member.Summary;
            }

            docTypes.Add(structDoc);
        }
Ejemplo n.º 3
0
        public static void Print(DocTree tree, string yamlPath, string apiFolder)
        {
            List <DocType> apis = new List <DocType>();

            for (int i = 0; i < tree.docTypes.Count; i++)
            {
                if (tree.docTypes[i] is ClassTypeDoc)
                {
                    ClassTypeDoc type = (ClassTypeDoc)tree.docTypes[i];

                    apis.Add(type);

                    StringBuilder b = new StringBuilder();
                    b.AppendLine("---");
                    b.AppendLine("title: " + Utils.GetSafeTypeName(type.Type, true));
                    b.AppendLine("name: " + Utils.GetSafeTypeName(type.Type, false));
                    b.AppendLine("permalink: " + Utils.GetRelativeApiUrl(type.Type));
                    b.AppendLine("---");
                    b.AppendLine();

                    PrintClass(b, type, tree);

                    File.WriteAllText(Path.Combine(apiFolder, Utils.GetSafeTypeName(type.Type, false).Replace("<", "_").Replace(">", "_") + ".md"), b.ToString());
                }
                else if (tree.docTypes[i] is EnumTypeDoc)
                {
                    EnumTypeDoc type = (EnumTypeDoc)tree.docTypes[i];

                    apis.Add(type);

                    StringBuilder b = new StringBuilder();
                    b.AppendLine("---");
                    b.AppendLine("title: " + Utils.GetSafeTypeName(type.Type, true));
                    b.AppendLine("name: " + Utils.GetSafeTypeName(type.Type, false));
                    b.AppendLine("permalink: " + Utils.GetRelativeApiUrl(type.Type));
                    b.AppendLine("---");
                    b.AppendLine();

                    PrintEnum(b, type);

                    File.WriteAllText(Path.Combine(apiFolder, Utils.GetSafeTypeName(type.Type, false).Replace("<", "_").Replace(">", "_") + ".md"), b.ToString());
                }
                else if (tree.docTypes[i] is StructDocType)
                {
                    StructDocType type = (StructDocType)tree.docTypes[i];

                    apis.Add(type);

                    StringBuilder b = new StringBuilder();
                    b.AppendLine("---");
                    b.AppendLine("title: " + Utils.GetSafeTypeName(type.Type, true));
                    b.AppendLine("name: " + Utils.GetSafeTypeName(type.Type, false));
                    b.AppendLine("permalink: " + Utils.GetRelativeApiUrl(type.Type));
                    b.AppendLine("---");
                    b.AppendLine();

                    PrintStruct(b, type, tree);

                    File.WriteAllText(Path.Combine(apiFolder, Utils.GetSafeTypeName(type.Type, false).Replace("<", "_").Replace(">", "_") + ".md"), b.ToString());
                }
            }

            StringBuilder builder = new StringBuilder();

            WriteYaml(builder, apis);

            File.WriteAllText(yamlPath, builder.ToString());
        }