Exemple #1
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);
        }
Exemple #2
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);
        }