示例#1
0
        private string GetSummary(TypeScriptClass @class)
        {
            var itemSummary = @class.Comment?.ShortText;

            if (string.IsNullOrEmpty(itemSummary))
            {
                var properties = @class.GetSignificantProperties();
                var methods    = @class.GetSignificantMethods();

                if (!properties.Any() && !methods.Any())
                {
                    properties = @class.Properties.Where(p => !p.IsPrivate).Take(5);
                    methods    = @class.Methods.Where(m => !m.IsPrivate).Take(5);
                }

                if (properties.Any() || methods.Any())
                {
                    itemSummary = BuildHTMLList(@class.GetPath().MakeUriFromString(), properties, methods);
                }

                if (string.IsNullOrEmpty(itemSummary))
                {
                    //prevent autoexcerpt
                    itemSummary = " ";
                }
            }

            return(itemSummary);
        }
示例#2
0
        private void BuildIndex(MarkdownBuilder mb, TypeScriptClass @class)
        {
            var publicMethods    = @class.Methods.Where(m => !m.IsStatic && !m.IsPrivate && !m.IsProtected).ToList();
            var protectedMethods = @class.Methods.Where(m => m.IsProtected).ToList();
            var staticMethods    = @class.Methods.Where(m => m.IsStatic && !m.IsPrivate).ToList();


            var publicProperties    = @class.Properties.Where(p => !p.IsStatic && !p.IsPrivate && !p.IsProtected).ToList();
            var protectedProperties = @class.Properties.Where(p => p.IsProtected).ToList();
            var staticProperties    = @class.Properties.Where(p => p.IsStatic && !p.IsPrivate).ToList();

            var publicAccessors    = @class.Accessors.Where(m => !m.IsPrivate && !m.IsProtected).ToList();
            var protectedAccessors = @class.Accessors.Where(p => p.IsProtected).ToList();

            var path = @class.GetPath().MakeUriFromString();

            //Index region
            mb.Header(2, "Index");
            if (@class.Constructor != null)
            {
                mb.HeaderWithLink(3, "Constructors", CombineWithRootUrl(path.CombineWithUri("#constructors-1")));
                mb.ListLink("constructor", CombineWithRootUrl(path.CombineWithUri("#constructor")));

                mb.AppendLine();
            }

            if (publicProperties.Any())
            {
                mb.HeaderWithLink(3, "Public Properties", CombineWithRootUrl(path.CombineWithUri("#public-properties-1")));

                foreach (var property in publicProperties)
                {
                    mb.ListLink(property.Name, CombineWithRootUrl(path.CombineWithUri("#" + property.Name.MakeUriFromString())));
                }

                mb.AppendLine();
            }

            if (protectedProperties.Any())
            {
                mb.HeaderWithLink(3, "Protected Properties", CombineWithRootUrl(path.CombineWithUri("#protected-properties-1")));

                foreach (var property in protectedProperties)
                {
                    mb.ListLink(property.Name, CombineWithRootUrl(path.CombineWithUri("#" + property.Name.MakeUriFromString())));
                }

                mb.AppendLine();
            }

            if (staticProperties.Any())
            {
                mb.HeaderWithLink(3, "Static Properties", CombineWithRootUrl(path.CombineWithUri("#static-properties-1")));

                foreach (var property in staticProperties)
                {
                    mb.ListLink(property.Name, CombineWithRootUrl(path.CombineWithUri("#" + property.Name.MakeUriFromString())));
                }

                mb.AppendLine();
            }

            if (publicAccessors.Any())
            {
                mb.HeaderWithLink(3, "Public Accessors", CombineWithRootUrl(path.CombineWithUri("#public-accessors-1")));

                foreach (var accessor in publicAccessors)
                {
                    mb.ListLink(accessor.Name, CombineWithRootUrl(path.CombineWithUri("#" + accessor.Name.MakeUriFromString())));
                }

                mb.AppendLine();
            }

            if (protectedAccessors.Any())
            {
                mb.HeaderWithLink(3, "Protected Accessors", CombineWithRootUrl(path.CombineWithUri("#protected-accessors-1")));

                foreach (var accessor in protectedAccessors)
                {
                    mb.ListLink(accessor.Name, CombineWithRootUrl(path.CombineWithUri("#" + accessor.Name.MakeUriFromString())));
                }

                mb.AppendLine();
            }

            if (publicMethods.Any())
            {
                mb.HeaderWithLink(3, "Public Methods", CombineWithRootUrl(path.CombineWithUri("#public-methods-1")));
                foreach (var method in publicMethods)
                {
                    mb.ListLink(method.Name, CombineWithRootUrl(path.CombineWithUri("#" + method.Name.MakeUriFromString())));
                }
                mb.AppendLine();
            }

            if (protectedMethods.Any())
            {
                mb.HeaderWithLink(3, "Protected Methods", CombineWithRootUrl(path.CombineWithUri("#protected-methods-1")));
                foreach (var method in protectedMethods)
                {
                    mb.ListLink(method.Name, CombineWithRootUrl(path.CombineWithUri("#" + method.Name.MakeUriFromString())));
                }
                mb.AppendLine();
            }

            if (staticMethods.Any())
            {
                mb.HeaderWithLink(3, "Static Methods", CombineWithRootUrl(path.CombineWithUri("#static-methods-1")));
                foreach (var property in staticMethods)
                {
                    mb.ListLink(property.Name, CombineWithRootUrl(path.CombineWithUri("#" + property.Name.MakeUriFromString())));
                }
                mb.AppendLine();
            }
            mb.AppendLine();
        }