Exemple #1
0
        private void BuildPropertyHtml(IEnumerable <ReflectedPropertyInfo> properties)
        {
            var q = from p in properties
                    where !p.IsInherited
                    group p by p.Name
                    into overloads
                    select overloads;

            foreach (var memberOverloadsEnumerable in q)
            {
                XDoc   html            = null;
                string href            = null;
                string path            = null;
                string title           = null;
                string assembly        = null;
                var    memberOverloads = memberOverloadsEnumerable.ToList();
                foreach (var member in memberOverloads.OrderBy(x => x.DisplayName))
                {
                    var xmlDoc = GetDoc(member.Signature);
                    if (html == null)
                    {
                        href = member.UriPath;
                        if (string.IsNullOrEmpty(href))
                        {
                            continue;
                        }
                        path     = member.FilePath;
                        title    = member.Name + " Property";
                        html     = NewHtmlDocument(title, true);
                        assembly = member.Assembly;
                    }
                    html.StartSection(1, "property", member.DisplayName);
                    html.CSharpBlock(member.CodeSignature)
                    .Div("summary", xmlDoc["summary"])
                    .Section(2, "remarks", "Remarks", xmlDoc["remarks"]);
                    if (member.IsIndexer)
                    {
                        BuildParameterTable(html, xmlDoc, member.IndexerParameters);
                    }
                    html.StartSection(2, "returns", "Value");
                    html.StartNameValueLine("type", "Type");
                    BuildParameterMarkup(html, member.ReturnType);
                    html.EndNameValue()
                    .Start("div")
                    .Attr("class", "summary")
                    .AddNodes(xmlDoc["returns"])
                    .End()
                    .EndSection();     // returns section
                    AddExceptionSection(html, xmlDoc);
                    html.EndSection();
                }
                if (html != null)
                {
                    Save(html, title, href, path, assembly);
                }
            }
        }
Exemple #2
0
 private void BuildGenericParameterSection(int level, XDoc html, XDoc xmlDoc, IEnumerable <ReflectedGenericParameterInfo> genericParameters)
 {
     if (genericParameters.Any())
     {
         html.StartSection(level, "genericparameters", "Generic Parameters");
         foreach (var parameter in genericParameters.OrderBy(x => x.ParameterPosition))
         {
             html.StartSection(level + 1, "genericparameter", "Parameter " + parameter.Name)
             .Div("description", xmlDoc[string.Format("typeparam[@name='{0}']", parameter.Name)])
             .StartNameValueBlock("constraints", "Constraints");
             var constraints = new List <string>();
             if (parameter.MustBeReferenceType)
             {
                 constraints.Add("class");
             }
             if (parameter.MustBeValueType)
             {
                 constraints.Add("struct");
             }
             if (parameter.MustHaveDefaultConstructor)
             {
                 constraints.Add("new()");
             }
             if (constraints.Any() || parameter.Types.Any())
             {
                 html.Start("ul");
                 foreach (var constraint in constraints)
                 {
                     html.Start("li").Elem("b", constraint).End();
                 }
                 foreach (var parameterType in parameter.Types)
                 {
                     html.Start("li");
                     BuildParameterMarkup(html, parameterType);
                     html.End();
                 }
                 html.End(); // ul
             }
             else
             {
                 html.Elem("i", "none");
             }
             html.EndNameValue()
             .EndSection();
         }
         html.EndSection();
     }
 }
Exemple #3
0
        private void BuildInheritanceChain(XDoc html, ReflectedTypeInfo type)
        {
            html.StartNameValueBlock("inheritance", "Type Hierarchy");
            var chain = GetParents(type.BaseType).ToList();

            foreach (var link in chain)
            {
                html.Start("ul")
                .Start("li");
                BuildParameterMarkup(html, link);
                html.End(); // li
            }
            html.Start("ul")
            .Start("li").Elem("b", type.DisplayName).End();
            var subclasses = (from t in _types
                              where t.BaseType != null && !t.BaseType.IsGenericParameter && t.BaseType.Type == type
                              select t).ToList();

            if (subclasses.Any())
            {
                html.Start("ul");
                foreach (var subclass in subclasses)
                {
                    html.Start("li");
                    if (IsTypeInDocumentation(subclass))
                    {
                        html.Link(subclass.UriPath, subclass.DisplayName);
                    }
                    else
                    {
                        html.Value(subclass.DisplayName);
                    }
                    html.End(); // li
                }
                html.End();     // subclass ul
            }
            html.End();         // type ul
            for (var i = 0; i < chain.Count; i++)
            {
                html.End();
            }
            html.EndNameValue();
        }
 private void BuildInheritanceChain(XDoc html, ReflectedTypeInfo type) {
     html.StartNameValueBlock("inheritance", "Type Hierarchy");
     var chain = GetParents(type.BaseType).ToList();
     foreach(var link in chain) {
         html.Start("ul")
                 .Start("li");
         BuildParameterMarkup(html, link);
         html.End(); // li
     }
     html.Start("ul")
         .Start("li").Elem("b", type.DisplayName).End();
     var subclasses = (from t in _types
                       where t.BaseType != null && !t.BaseType.IsGenericParameter && t.BaseType.Type == type
                       select t).ToList();
     if(subclasses.Any()) {
         html.Start("ul");
         foreach(var subclass in subclasses) {
             html.Start("li");
             if(IsTypeInDocumentation(subclass)) {
                 html.Link(subclass.UriPath, subclass.DisplayName);
             } else {
                 html.Value(subclass.DisplayName);
             }
             html.End(); // li
         }
         html.End(); // subclass ul
     }
     html.End(); // type ul
     for(var i = 0; i < chain.Count; i++) {
         html.End();
     }
     html.EndNameValue();
 }
 private void BuildGenericParameterSection(int level, XDoc html, XDoc xmlDoc, IEnumerable<ReflectedGenericParameterInfo> genericParameters) {
     if(genericParameters.Any()) {
         html.StartSection(level, "genericparameters", "Generic Parameters");
         foreach(var parameter in genericParameters.OrderBy(x => x.ParameterPosition)) {
             html.StartSection(level + 1, "genericparameter", "Parameter " + parameter.Name)
                .Div("description", xmlDoc[string.Format("typeparam[@name='{0}']", parameter.Name)])
                .StartNameValueBlock("constraints", "Constraints");
             var constraints = new List<string>();
             if(parameter.MustBeReferenceType) {
                 constraints.Add("class");
             }
             if(parameter.MustBeValueType) {
                 constraints.Add("struct");
             }
             if(parameter.MustHaveDefaultConstructor) {
                 constraints.Add("new()");
             }
             if(constraints.Any() || parameter.Types.Any()) {
                 html.Start("ul");
                 foreach(var constraint in constraints) {
                     html.Start("li").Elem("b", constraint).End();
                 }
                 foreach(var parameterType in parameter.Types) {
                     html.Start("li");
                     BuildParameterMarkup(html, parameterType);
                     html.End();
                 }
                 html.End(); // ul
             } else {
                 html.Elem("i", "none");
             }
             html.EndNameValue()
                 .EndSection();
         }
         html.EndSection();
     }
 }
Exemple #6
0
        private void BuildMethodHtml(IEnumerable <ReflectedMethodInfo> methods)
        {
            var q = from m in methods
                    where !m.IsInherited
                    group m by m.Name
                    into overloads
                    select overloads;

            foreach (var memberOverloads in q)
            {
                XDoc   html     = null;
                string href     = null;
                string path     = null;
                string title    = null;
                string assembly = null;
                foreach (var method in memberOverloads.OrderBy(x => x.DisplayName))
                {
                    var xmlDoc = GetDoc(method.Signature);
                    if (html == null)
                    {
                        href = method.UriPath;
                        if (string.IsNullOrEmpty(href))
                        {
                            continue;
                        }
                        path     = method.FilePath;
                        title    = method.Name + (method.IsExtensionMethod ? " Extension" : "") + " Method";
                        html     = NewHtmlDocument(title, true);
                        assembly = method.Assembly;
                    }
                    html
                    .StartSection(1, "method", method.DisplayName)
                    .CSharpBlock(method.CodeSignature)
                    .Div("summary", xmlDoc["summary"])
                    .Section(2, "remarks", "Remarks", xmlDoc["remarks"]);
                    BuildGenericParameterSection(2, html, xmlDoc, method.GenericParameters.Where(x => x.MethodParameter));
                    BuildParameterTable(html, xmlDoc, method.Parameters);
                    html.StartSection(2, "returns", "Returns");
                    if (!method.ReturnType.IsGenericParameter && method.ReturnType.Type.Name == "Void")
                    {
                        html.Value("void");
                    }
                    else
                    {
                        html.StartNameValueLine("type", "Type");
                        BuildParameterMarkup(html, method.ReturnType);
                        html.EndNameValue()
                        .Start("div")
                        .Attr("class", "summary")
                        .AddNodes(xmlDoc["returns"])
                        .End();
                    }
                    html.EndSection(); // return section
                    AddExceptionSection(html, xmlDoc);
                    html.EndSection();
                }
                if (html != null)
                {
                    Save(html, title, href, path, assembly);
                }
            }
        }