示例#1
0
 internal static void CollectClassField(XmlNodeList nodes, FieldInfo field, out string name, out string type,
                                        out string description)
 {
     name        = $"`{field.Name}`";
     type        = DocClassUtil.GetTypeMarkdown(field.FieldType);
     description = FullSummaryCollection(field.DeclaringType, field.Name, null, nodes);
 }
示例#2
0
 internal static void CollectClassProperty(XmlNodeList nodes, PropertyInfo property, out string name,
                                           out string type, out string protection, out string description)
 {
     name        = $"`{property.Name}`";
     type        = DocClassUtil.GetTypeMarkdown(property.PropertyType);
     protection  = FullProtectionCollection(property);
     description = FullSummaryCollection(property.DeclaringType, property.Name, null, nodes);
 }
示例#3
0
        internal static void CollectClassMethod(XmlNodeList nodes, MethodInfo info, out string name, out string returnType,
                                                out string description)
        {
            var parameters = info.GetParameters();

            returnType  = DocClassUtil.GetTypeMarkdown(info.ReturnType);
            name        = $"`{info.Name}`{DocClassUtil.GetParametersMarkdownString(parameters)}";
            description = FullSummaryCollection(info.DeclaringType, info.Name, parameters, nodes);
        }
示例#4
0
        private static string FullSummaryCollection(Type t, string n, ParameterInfo[] p, XmlNodeList nodes)
        {
            var fullXmlName = (t?.FullName ?? throw new NullReferenceException("oops")) + "." + n;

            if (p != null)
            {
                fullXmlName = DocClassUtil.GetParametersXmlString(p, fullXmlName);
            }

            DocXmlUtil.CollectSummaryFromNode(nodes, fullXmlName, out var description);
            return(description);
        }
示例#5
0
        private string BuildType(Type t)
        {
            if (!t.IsVisible)
            {
                Program.Process($"Target type ({t.Name}) is not visible!", true);
                return(null);
            }

            if (DocBuilderHelper.IsTypeArrayContainsNotAllowed(t))
            {
                Program.Process($"Target type ({t.Name}) is not allowed to be generated!", true);
                return(null);
            }

            var fileName = DocSyntax.CollectTypeName(t);
            var filePath = DocSyntax.GetMarkdownFile($"{DeployDir}{JEMVar.DirectorySeparatorChar}{fileName}");

            if (DocSyntax.FixVarName(ref filePath))
            {
                Program.Process($"Target type ({t.Name}) has invalid filePath ({filePath}).", true);
                return(null);
            }

            var str    = new StringBuilder();
            var subStr = new StringBuilder();

            if (t.IsClass)
            {
                Program.Process($"New class: {t.Name}");

                // HEADER
                str.AppendLine($"# {t.Name}");
                if (t.BaseType != null && t.BaseType != typeof(object))
                {
                    str.AppendLine($"<small>class in `{Path.GetFileNameWithoutExtension(new Uri(t.Assembly.CodeBase).AbsolutePath)}` " +
                                   $"/ inherits from {DocClassUtil.GetTypeMarkdown(t.BaseType, false)}</small>");
                }
                else
                {
                    str.AppendLine($"<small>{(t.IsAbstract && t.IsSealed ? "static " : string.Empty)}class in `{Path.GetFileNameWithoutExtension(new Uri(t.Assembly.CodeBase).AbsolutePath)}`</small>");
                }
                str.AppendLine(string.Empty);

                // SUMMARY
                DocXmlUtil.CollectSummaryFromNode(_nodes, t.FullName, out var classSummary);
                str.AppendLine("### Description");
                str.AppendLine(classSummary);

                // EVENTS
                DocBuilderHelper.BuildEvents(t, str, _nodes, TypeContent.Target, false);
                // FIELDS
                DocBuilderHelper.BuildFields(t, str, _nodes, TypeContent.Target, false);
                // PROPERTIES
                DocBuilderHelper.BuildProperties(t, str, _nodes, TypeContent.Target, false);
                // METHODS
                DocBuilderHelper.BuildMethods(t, str, _nodes, TypeContent.Target, false);

                // STATIC EVENTS
                DocBuilderHelper.BuildEvents(t, str, _nodes, TypeContent.Target, true);
                // STATIC FIELDS
                DocBuilderHelper.BuildFields(t, str, _nodes, TypeContent.Target, true);
                // STATIC PROPERTIES
                DocBuilderHelper.BuildProperties(t, str, _nodes, TypeContent.Target, true);
                // STATIC METHODS
                DocBuilderHelper.BuildMethods(t, str, _nodes, TypeContent.Target, true);

                subStr.Clear();
                // INHERITED MEMBERS
                // EVENTS
                DocBuilderHelper.BuildEvents(t, str, _nodes, TypeContent.Inherited, false);
                // INHERITED MEMBERS
                // FIELDS
                DocBuilderHelper.BuildFields(t, subStr, _nodes, TypeContent.Inherited, false);
                // INHERITED MEMBERS
                // PROPERTIES
                DocBuilderHelper.BuildProperties(t, subStr, _nodes, TypeContent.Inherited, false);
                // INHERITED MEMBERS
                // METHODS
                DocBuilderHelper.BuildMethods(t, subStr, _nodes, TypeContent.Inherited, false);

                // INHERITED MEMBERS
                // STATIC EVENTS
                DocBuilderHelper.BuildEvents(t, str, _nodes, TypeContent.Inherited, true);
                // INHERITED MEMBERS
                // STATIC FIELDS
                DocBuilderHelper.BuildFields(t, subStr, _nodes, TypeContent.Inherited, true);
                // INHERITED MEMBERS
                // STATIC PROPERTIES
                DocBuilderHelper.BuildProperties(t, subStr, _nodes, TypeContent.Inherited, true);
                // INHERITED MEMBERS
                // STATIC METHODS
                DocBuilderHelper.BuildMethods(t, subStr, _nodes, TypeContent.Inherited, true);

                if (!string.IsNullOrEmpty(subStr.ToString()) && !string.IsNullOrWhiteSpace(subStr.ToString()))
                {
                    str.AppendLine();
                    str.AppendLine();
                    str.AppendLine("## Inherited Members");
                    str.AppendLine(subStr.ToString());
                }

                // EXAMPLES
                BuildExample(t, str);
            }
            else if (t.IsEnum)
            {
                Program.Process($"New Enum: {t.Name}");

                // HEADER
                str.AppendLine($"# {t.Name}");
                if (t.BaseType != null && t.BaseType != typeof(Object))
                {
                    str.AppendLine($"<small>enumeration in `{Path.GetFileNameWithoutExtension(new Uri(t.Assembly.CodeBase).AbsolutePath)}`</small>");
                }
                str.AppendLine(string.Empty);

                // SUMMARY
                DocXmlUtil.CollectSummaryFromNode(_nodes, t.FullName, out var classSummary);
                str.AppendLine("### Description");
                str.AppendLine(classSummary);

                // PROPERTIES
                DocBuilderHelper.BuildEnum(t, str, _nodes);

                // EXAMPLES
                BuildExample(t, str);
            }

            if (File.Exists(AppConfig.Loaded.FileEnd))
            {
                str.AppendLine();
                str.AppendLine(File.ReadAllText(AppConfig.Loaded.FileEnd));
            }

            WriteAllText(filePath, str.ToString());
            return(fileName);
        }
示例#6
0
 internal static void CollectClassEvent(XmlNodeList nodes, EventInfo @event, out string name, out string type, out string description)
 {
     name        = $"`{@event.Name}`";
     type        = DocClassUtil.GetTypeMarkdown(@event.EventHandlerType);
     description = FullSummaryCollection(@event.DeclaringType, @event.Name, null, nodes);
 }