Example #1
0
        private static DocumentedType MapType(ITypeInfo type, XmlDocumentationModel xmlModel)
        {
            SummaryComment summary = null;
            RemarksComment remarks = null;
            IEnumerable<ExampleComment> example = null;

            // Get the documentation for the type.
            var member = xmlModel.Find(type.Identity);
            if (member != null)
            {
                // Get the comments for the type.
                summary = member.Comments.OfType<SummaryComment>().SingleOrDefault();
                remarks = member.Comments.OfType<RemarksComment>().SingleOrDefault();
                example = member.Comments.OfType<ExampleComment>();
            }

            // Map the methods.
            var methods = new List<DocumentedMethod>();
            foreach (var method in type.Methods)
            {
                methods.Add(MapMethod(method, xmlModel));
            }

            // Map the properties.
            var properties = new List<DocumentedProperty>();
            foreach (var property in type.Properties)
            {
                properties.Add(MapProperty(property, xmlModel));
            }

            // Map the fields.
            var fields = new List<DocumentedField>();
            foreach (var field in type.Fields)
            {
                fields.Add(MapField(field, xmlModel));
            }

            // Return the documented type.
            return new DocumentedType(type, properties, methods, fields, summary, remarks, example, type.Metadata);
        }
Example #2
0
        private static DocumentedProperty MapProperty(IPropertyInfo property, XmlDocumentationModel xmlModel)
        {
            SummaryComment summary = null;
            RemarksComment remarks = null;
            IEnumerable<ExampleComment> examples = null;
            ValueComment value = null;

            // Get the documentation for the type.
            var member = xmlModel.Find(property.Identity);
            if (member != null)
            {
                // Get the comments for the type.
                summary = member.Comments.OfType<SummaryComment>().SingleOrDefault();
                remarks = member.Comments.OfType<RemarksComment>().SingleOrDefault();
                examples = member.Comments.OfType<ExampleComment>();
                value = member.Comments.OfType<ValueComment>().SingleOrDefault();
            }

            return new DocumentedProperty(property, summary, remarks, examples, value, property.Metadata);
        }
Example #3
0
        private static DocumentedMethod MapMethod(IMethodInfo method, XmlDocumentationModel xmlModel)
        {
            var parameters = new List<DocumentedParameter>();

            SummaryComment summary = null;
            RemarksComment remarks = null;
            IEnumerable<ExampleComment> examples = null;
            ReturnsComment returns = null;

            // Get the documentation for the type.
            var member = xmlModel.Find(method.Identity);
            if (member != null)
            {
                // Get the comments for the type.
                summary = member.Comments.OfType<SummaryComment>().FirstOrDefault();
                remarks = member.Comments.OfType<RemarksComment>().FirstOrDefault();
                examples = member.Comments.OfType<ExampleComment>();
                returns = member.Comments.OfType<ReturnsComment>().FirstOrDefault();
            }

            // Map parameters.
            foreach (var parameterDefinition in method.Definition.Parameters.ToList())
            {
                ParamComment comment = null;
                if (member != null)
                {
                    // Try to get the comment for the current parameter.
                    comment = member.Comments.OfType<ParamComment>().FirstOrDefault(x => x.Name == parameterDefinition.Name);
                }

                var parameter = new DocumentedParameter(parameterDefinition, comment, method.Metadata);
                parameters.Add(parameter);
            }

            var metadata = method.Metadata;
            var isPropertyAlias = false;
            if (method.Definition.IsCakeAlias(out isPropertyAlias))
            {
                metadata = new AliasMetadataAdapter(metadata, isPropertyAlias);
            }

            return new DocumentedMethod(method, parameters, summary, remarks, examples, returns, metadata);
        }
Example #4
0
        private static DocumentedField MapField(IFieldInfo field, XmlDocumentationModel xmlModel)
        {
            SummaryComment summary = null;
            RemarksComment remarks = null;
            IEnumerable<ExampleComment> examples = null;

            // Get the documentation for the type.
            var member = xmlModel.Find(field.Identity);
            if (member != null)
            {
                // Get the comments for the type.
                summary = member.Comments.OfType<SummaryComment>().SingleOrDefault();
                remarks = member.Comments.OfType<RemarksComment>().SingleOrDefault();
                examples = member.Comments.OfType<ExampleComment>();
            }

            return new DocumentedField(field, summary, remarks, examples, field.Metadata);
        }
Example #5
0
        private static DocumentedMethod MapMethod(IMethodInfo method, XmlDocumentationModel xmlModel)
        {
            var parameters = new List<DocumentedParameter>();

            SummaryComment summary = null;
            RemarksComment remarks = null;
            ExampleComment example = null;
            ReturnsComment returns = null;

            // Get the documentation for the type.
            var member = xmlModel.Find(method.Identity);
            if (member != null)
            {
                // Get the comments for the type.
                summary = member.Comments.OfType<SummaryComment>().FirstOrDefault();
                remarks = member.Comments.OfType<RemarksComment>().FirstOrDefault();
                example = member.Comments.OfType<ExampleComment>().FirstOrDefault();
                returns = member.Comments.OfType<ReturnsComment>().FirstOrDefault();
            }

            // Map parameters.
            foreach (var parameterDefinition in method.Definition.Parameters.ToList())
            {
                ParamComment comment = null;
                if (member != null)
                {
                    // Try to get the comment for the current parameter.
                    comment = member.Comments.OfType<ParamComment>().FirstOrDefault(x => x.Name == parameterDefinition.Name);
                }

                var parameter = new DocumentedParameter(parameterDefinition, comment);
                parameters.Add(parameter);
            }

            return new DocumentedMethod(method, parameters, summary, remarks, example, returns);
        }
        private static DocumentedType MapType(ITypeInfo type, XmlDocumentationModel xmlModel)
        {
            SummaryComment summary = null;
            RemarksComment remarks = null;
            IEnumerable<ExampleComment> example = null;

            // Get the documentation for the type.
            var member = xmlModel.Find(type.Identity);
            if (member != null)
            {
                // Get the comments for the type.
                summary = member.Comments.OfType<SummaryComment>().Aggregate(
                    null as SummaryComment,
                    (prev, curr) => (curr != null && prev != null)
                        ? new SummaryComment(prev.Children.Concat(curr.Children))
                        : curr ?? prev,
                    result => result
                    );
                remarks = member.Comments.OfType<RemarksComment>().Aggregate(
                    null as RemarksComment,
                    (prev, curr) => (curr != null && prev != null)
                        ? new RemarksComment(prev.Children.Concat(curr.Children))
                        : curr ?? prev,
                    result => result
                    );
                example = member.Comments.OfType<ExampleComment>();
            }

            // Map the methods.
            var methods = new List<DocumentedMethod>();
            foreach (var method in type.Methods)
            {
                methods.Add(MapMethod(method, xmlModel));
            }

            // Map the properties.
            var properties = new List<DocumentedProperty>();
            foreach (var property in type.Properties)
            {
                properties.Add(MapProperty(property, xmlModel));
            }

            // Map the fields.
            var fields = new List<DocumentedField>();
            foreach (var field in type.Fields)
            {
                fields.Add(MapField(field, xmlModel));
            }

            // Return the documented type.
            return new DocumentedType(type, properties, methods, fields, summary, remarks, example, type.Metadata);
        }