private void ParseEnum(string namespace_, EnumDeclarationSyntax enumSyntax, SemanticModel semanticModel) { var enumDef = new EnumDef(); // 名称 enumDef.Name = enumSyntax.Identifier.ValueText; // ネームスペース enumDef.Namespace = namespace_; // swig enumDef.IsDefinedBySWIG = namespace_.Contains(swig_namespace_keyword); foreach (var member in enumSyntax.Members) { var def = ParseEnumMember(member, semanticModel); enumDef.Members.Add(def); } // Summary var declaredSymbol = semanticModel.GetDeclaredSymbol(enumSyntax); var xml = declaredSymbol?.GetDocumentationCommentXml(); enumDef.Summary = SummaryComment.Parse(xml); definitions.Enums.Add(enumDef); }
private void ParseStrcut(string namespace_, StructDeclarationSyntax structSyntax, SemanticModel semanticModel) { var structDef = new StructDef(); structDef.Internal = structSyntax; structDef.Namespace = namespace_; structDef.Name = structSyntax.Identifier.ValueText; var fullName = namespace_ + "." + structDef.Name; { var partial = definitions.Structs.FirstOrDefault(x => x.Namespace + "." + x.Name == fullName); if (partial != null) { structDef = partial; } } if (TypesNotParsed.Contains(fullName)) { return; } // Summary var declaredSymbol = semanticModel.GetDeclaredSymbol(structSyntax); var xml = declaredSymbol?.GetDocumentationCommentXml(); structDef.Summary = SummaryComment.Parse(xml); ParseTypeDeclaration(structDef, structSyntax, semanticModel); definitions.Structs.Add(structDef); }
/// <summary> /// Initializes a new instance of the <see cref="DocumentedType" /> class. /// </summary> /// <param name="info">The type information.</param> /// <param name="properties">The type's properties.</param> /// <param name="methods">The type's methods.</param> /// <param name="fields">The type's fields.</param> /// <param name="summary">The summary.</param> /// <param name="remarks">The remarks.</param> /// <param name="examples">The examples.</param> /// <param name="metadata">The type metadata.</param> public DocumentedType( ITypeInfo info, IEnumerable <DocumentedProperty> properties, IEnumerable <DocumentedMethod> methods, IEnumerable <DocumentedField> fields, SummaryComment summary, RemarksComment remarks, IEnumerable <ExampleComment> examples, IDocumentationMetadata metadata) : base(MemberClassification.Type, summary, remarks, examples, metadata) { Definition = info.Definition; TypeClassification = info.Definition.GetTypeClassification(); Identity = info.Identity; Properties = new List <DocumentedProperty>(properties); Fields = new List <DocumentedField>(fields); // Materialize all methods. var documentedMethods = methods as DocumentedMethod[] ?? methods.ToArray(); Constructors = new List <DocumentedMethod>(GetConstructors(documentedMethods)); Methods = new List <DocumentedMethod>(GetMethods(documentedMethods)); Operators = new List <DocumentedMethod>(GetOperators(documentedMethods)); _extensionMethods = new List <DocumentedMethod>(); }
/// <summary> /// Initializes a new instance of the <see cref="DocumentedType" /> class. /// </summary> /// <param name="info">The type information.</param> /// <param name="properties">The type's properties.</param> /// <param name="methods">The type's methods.</param> /// <param name="fields">The type's fields.</param> /// <param name="summary">The summary.</param> /// <param name="remarks">The remarks.</param> /// <param name="examples">The examples.</param> /// <param name="metadata">The type metadata.</param> public DocumentedType( ITypeInfo info, IEnumerable<DocumentedProperty> properties, IEnumerable<DocumentedMethod> methods, IEnumerable<DocumentedField> fields, SummaryComment summary, RemarksComment remarks, IEnumerable<ExampleComment> examples, IDocumentationMetadata metadata) : base(MemberClassification.Type, summary, remarks, examples, metadata) { Definition = info.Definition; TypeClassification = info.Definition.GetTypeClassification(); Identity = info.Identity; Properties = new List<DocumentedProperty>(properties); Fields = new List<DocumentedField>(fields); // Materialize all methods. var documentedMethods = methods as DocumentedMethod[] ?? methods.ToArray(); Constructors = new List<DocumentedMethod>(GetConstructors(documentedMethods)); Methods = new List<DocumentedMethod>(GetMethods(documentedMethods)); Operators = new List<DocumentedMethod>(GetOperators(documentedMethods)); _extensionMethods = new List<DocumentedMethod>(); }
private PropertyDef ParseProperty(PropertyDeclarationSyntax propertySyntax, SemanticModel semanticModel) { var propertyDef = new PropertyDef(); propertyDef.Internal = propertySyntax; propertyDef.Name = propertySyntax.Identifier.ValueText; propertyDef.Type = ParseTypeSpecifier(propertySyntax.Type, semanticModel); propertyDef.AccessLevel = ParseAccessLevel(propertySyntax.Modifiers) ?? AccessLevel.Private; propertyDef.IsStatic = propertySyntax.Modifiers.Any(x => x.ValueText == "static"); foreach (var accessor in propertySyntax.AccessorList.Accessors) { var acc = new AccessorDef(); acc.Internal = accessor; acc.AccessLevel = ParseAccessLevel(accessor.Modifiers) ?? propertyDef.AccessLevel; if (accessor.Keyword.Text == "get") { propertyDef.Getter = acc; } else if (accessor.Keyword.Text == "set") { propertyDef.Setter = acc; } } // Summary var declaredSymbol = semanticModel.GetDeclaredSymbol(propertySyntax); var xml = declaredSymbol?.GetDocumentationCommentXml(); propertyDef.Summary = SummaryComment.Parse(xml); return(propertyDef); }
public NamespaceViewModel(IReadOnlyList<DocumentedNamespace> namespaces) { if (namespaces.Count == 0) { throw new ArgumentException("No namespaces in list."); } Data = namespaces[0]; Name = Data.Name; var namespaceWithSummary = namespaces.FirstOrDefault(x => x.Summary != null); if (namespaceWithSummary != null) { Summary = namespaceWithSummary.Summary; } Classes = new List<DocumentedType>(); Interfaces = new List<DocumentedType>(); foreach (var @namespace in namespaces) { var classes = @namespace.Types.Where(x => x.Definition.IsClass && !IsExtensionMethodClass(x)).ToArray(); Classes.AddRange(classes); var interfaces = @namespace.Types.Where(x => x.Definition.IsInterface).ToArray(); Interfaces.AddRange(interfaces); } // For child namespaces, just get them from the first one // since they're going to be the same anyway. Namespaces = new List<DocumentedNamespace>(); foreach (var childNamespace in Data.Tree.Children) { Namespaces.Add(childNamespace.Namespace); } }
/// <summary> /// Initializes a new instance of the <see cref="DocumentedNamespace"/> class. /// </summary> /// <param name="identity">The Identity.</param> /// <param name="types">The types.</param> /// <param name="summaryComment">The summary comment.</param> public DocumentedNamespace( string identity, IEnumerable <DocumentedType> types, SummaryComment summaryComment) : base(MemberClassification.Namespace, summaryComment, null, null) { _identity = identity; _types = new List <DocumentedType>(types); }
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)); }
/// <summary> /// Initializes a new instance of the <see cref="DocumentedField"/> class. /// </summary> /// <param name="info">The field info.</param> /// <param name="summary">The summary comment.</param> /// <param name="remarks">The remarks comment.</param> /// <param name="example">The example comment.</param> public DocumentedField( IFieldInfo info, SummaryComment summary, RemarksComment remarks, ExampleComment example) : base(MemberClassification.Type, summary, remarks, example) { _definition = info.Definition; _identity = info.Identity; }
public static DslModel Build(DocumentModel model) { Dictionary <string, SummaryComment> summaries; var data = GetData(model, out summaries); var categories = new List <DslCategory>(); foreach (var categoryName in data.Keys) { var metadata = (IDocumentationMetadata)null; var categoryMethods = new List <DocumentedMethod>(); var subCategories = new List <DslSubCategory>(); foreach (var subCategoryName in data[categoryName].Keys) { var methods = data[categoryName][subCategoryName]; if (string.IsNullOrWhiteSpace(subCategoryName)) { categoryMethods.AddRange(methods.OrderBy(x => x.Identity)); } else { subCategories.Add(new DslSubCategory(subCategoryName, methods)); } if (metadata == null) { metadata = methods.First().Metadata; } } SummaryComment summary = null; if (summaries.ContainsKey(categoryName)) { summary = summaries[categoryName]; } categories.Add( new DslCategory( categoryName, metadata, summary, categoryMethods, subCategories.OrderBy(x => x.Name))); } var dslModel = new DslModel(categories.OrderBy(x => x.Name)); foreach (var category in dslModel.Categories) { category.Parent = dslModel; } return(dslModel); }
/// <summary> /// Initializes a new instance of the <see cref="DocumentedField"/> class. /// </summary> /// <param name="info">The field info.</param> /// <param name="summary">The summary comment.</param> /// <param name="remarks">The remarks comment.</param> /// <param name="examples">The example comments.</param> /// <param name="metadata">The associated metadata.</param> public DocumentedField( IFieldInfo info, SummaryComment summary, RemarksComment remarks, IEnumerable<ExampleComment> examples, IDocumentationMetadata metadata) : base(MemberClassification.Type, summary, remarks, examples, metadata) { Definition = info.Definition; Identity = info.Identity; }
/// <summary> /// Initializes a new instance of the <see cref="DocumentedMember"/> class. /// </summary> /// <param name="classification">The member classification.</param> /// <param name="summary">The summary comment.</param> /// <param name="remarks">The remarks comment.</param> /// <param name="example">The example comment.</param> protected DocumentedMember( MemberClassification classification, SummaryComment summary, RemarksComment remarks, ExampleComment example) { _classification = classification; _summary = summary; _remarks = remarks; _example = example; }
/// <summary> /// Initializes a new instance of the <see cref="DocumentedNamespace"/> class. /// </summary> /// <param name="identity">The Identity.</param> /// <param name="name">The namespace name.</param> /// <param name="types">The types.</param> /// <param name="summaryComment">The summary comment.</param> public DocumentedNamespace( string identity, string name, IEnumerable<DocumentedType> types, SummaryComment summaryComment) : base(MemberClassification.Namespace, summaryComment, null, null) { _identity = identity; _name = name; _types = new List<DocumentedType>(types); }
/// <summary> /// Initializes a new instance of the <see cref="DocumentedField"/> class. /// </summary> /// <param name="info">The field info.</param> /// <param name="summary">The summary comment.</param> /// <param name="remarks">The remarks comment.</param> /// <param name="examples">The example comments.</param> /// <param name="metadata">The associated metadata.</param> public DocumentedField( IFieldInfo info, SummaryComment summary, RemarksComment remarks, IEnumerable <ExampleComment> examples, IDocumentationMetadata metadata) : base(MemberClassification.Type, summary, remarks, examples, metadata) { Definition = info.Definition; Identity = info.Identity; }
/// <summary> /// Initializes a new instance of the <see cref="DocumentedProperty" /> class. /// </summary> /// <param name="info">The property info.</param> /// <param name="summary">The summary comment.</param> /// <param name="remarks">The remarks comment.</param> /// <param name="example">The example comment.</param> /// <param name="value">The value comment.</param> public DocumentedProperty( IPropertyInfo info, SummaryComment summary, RemarksComment remarks, ExampleComment example, ValueComment value) : base(MemberClassification.Property, summary, remarks, example) { _definition = info.Definition; _identity = info.Identity; _value = value; }
public DslCategory( string name, SummaryComment summary, IEnumerable<DocumentedMethod> methods, IEnumerable<DslSubCategory> categories) { _name = name; _summary = summary; _slug = _name.ToSlug(); _methods = new List<DocumentedMethod>(methods); _subCategories = new List<DslSubCategory>(categories); }
/// <summary> /// Initializes a new instance of the <see cref="DocumentedNamespace"/> class. /// </summary> /// <param name="identity">The Identity.</param> /// <param name="name">The namespace name.</param> /// <param name="types">The types.</param> /// <param name="summaryComment">The summary comment.</param> /// <param name="metadata">The associated metadata.</param> public DocumentedNamespace( string identity, string name, IEnumerable <DocumentedType> types, SummaryComment summaryComment, IDocumentationMetadata metadata) : base(MemberClassification.Namespace, summaryComment, null, null, metadata) { _identity = identity; _name = name; _types = new List <DocumentedType>(types); }
/// <summary> /// Initializes a new instance of the <see cref="DocumentedNamespace"/> class. /// </summary> /// <param name="identity">The Identity.</param> /// <param name="name">The namespace name.</param> /// <param name="types">The types.</param> /// <param name="summaryComment">The summary comment.</param> /// <param name="metadata">The associated metadata.</param> public DocumentedNamespace( string identity, string name, IEnumerable<DocumentedType> types, SummaryComment summaryComment, IDocumentationMetadata metadata) : base(MemberClassification.Namespace, summaryComment, null, null, metadata) { Identity = identity; Name = name; Types = new List<DocumentedType>(types); }
/// <summary> /// Initializes a new instance of the <see cref="DocumentedProperty" /> class. /// </summary> /// <param name="info">The property info.</param> /// <param name="summary">The summary comment.</param> /// <param name="remarks">The remarks comment.</param> /// <param name="examples">The example comments.</param> /// <param name="value">The value comment.</param> /// <param name="metadata">The associated metadata.</param> public DocumentedProperty( IPropertyInfo info, SummaryComment summary, RemarksComment remarks, IEnumerable<ExampleComment> examples, ValueComment value, IDocumentationMetadata metadata) : base(MemberClassification.Property, summary, remarks, examples, metadata) { Definition = info.Definition; Identity = info.Identity; Value = value; }
/// <summary> /// Initializes a new instance of the <see cref="DocumentedProperty" /> class. /// </summary> /// <param name="info">The property info.</param> /// <param name="summary">The summary comment.</param> /// <param name="remarks">The remarks comment.</param> /// <param name="examples">The example comments.</param> /// <param name="value">The value comment.</param> /// <param name="metadata">The associated metadata.</param> public DocumentedProperty( IPropertyInfo info, SummaryComment summary, RemarksComment remarks, IEnumerable <ExampleComment> examples, ValueComment value, IDocumentationMetadata metadata) : base(MemberClassification.Property, summary, remarks, examples, metadata) { Definition = info.Definition; Identity = info.Identity; Value = value; }
public DslCategory( string name, IDocumentationMetadata metadata, SummaryComment summary, IEnumerable<DocumentedMethod> methods, IEnumerable<DslSubCategory> categories) { Name = name; Metadata = metadata; Summary = summary; Slug = Name.ToSlug(); Methods = new List<DocumentedMethod>(methods); SubCategories = new List<DslSubCategory>(categories); }
private FieldDef ParseField(FieldDeclarationSyntax fieldSyntax, SemanticModel semanticModel) { var fieldDef = new FieldDef(); if (fieldSyntax.Declaration.Variables.Count != 1) { var span = fieldSyntax.SyntaxTree.GetLineSpan(fieldSyntax.Declaration.Variables.Span); throw new ParseException(string.Format("{0} : 変数の複数同時宣言は禁止です。", span)); } var declaration = fieldSyntax.Declaration; var variable = fieldSyntax.Declaration.Variables[0]; // 主にfixed配列対象 ArgumentSyntax arguments = null; if (variable.ArgumentList != null) { arguments = variable.ArgumentList.Arguments.FirstOrDefault(); } var type = ParseTypeSpecifier(declaration.Type, semanticModel); // 無理やり書き換える if (arguments != null) { if (type is SimpleType) { var at = new ArrayType(); at.BaseType = (SimpleType)type; type = at; } fieldDef.Argument = arguments.ToString(); } fieldDef.Internal = fieldSyntax; fieldDef.Name = variable.Identifier.ValueText; fieldDef.Type = type; fieldDef.AccessLevel = ParseAccessLevel(fieldSyntax.Modifiers) ?? AccessLevel.Private; fieldDef.IsStatic = fieldSyntax.Modifiers.Any(x => x.ValueText == "static"); // Summary var declaredSymbol = semanticModel.GetDeclaredSymbol(fieldSyntax); var xml = declaredSymbol?.GetDocumentationCommentXml(); fieldDef.Summary = SummaryComment.Parse(xml); return(fieldDef); }
public DslCategory( string name, IDocumentationMetadata metadata, SummaryComment summary, IEnumerable <DocumentedMethod> methods, IEnumerable <DslSubCategory> categories) { _name = name; _metadata = metadata; _summary = summary; _slug = _name.ToSlug(); _methods = new List <DocumentedMethod>(methods); _subCategories = new List <DslSubCategory>(categories); }
/// <summary> /// Initializes a new instance of the <see cref="DocumentedMethod" /> class. /// </summary> /// <param name="info">The method info.</param> /// <param name="parameters">The method's parameters.</param> /// <param name="summary">The summary comment.</param> /// <param name="remarks">The remarks comment.</param> /// <param name="example">The example comment.</param> /// <param name="returns">The return value comment.</param> public DocumentedMethod( IMethodInfo info, IEnumerable <DocumentedParameter> parameters, SummaryComment summary, RemarksComment remarks, ExampleComment example, ReturnsComment returns) : base(MemberClassification.Method, summary, remarks, example) { _definition = info.Definition; _methodClassification = info.Definition.GetMethodClassification(); _identity = info.Identity; _parameters = new List <DocumentedParameter>(parameters); _returns = returns; }
/// <summary> /// Initializes a new instance of the <see cref="DocumentedMethod" /> class. /// </summary> /// <param name="info">The method info.</param> /// <param name="parameters">The method's parameters.</param> /// <param name="summary">The summary comment.</param> /// <param name="remarks">The remarks comment.</param> /// <param name="example">The example comment.</param> /// <param name="returns">The return value comment.</param> public DocumentedMethod( IMethodInfo info, IEnumerable<DocumentedParameter> parameters, SummaryComment summary, RemarksComment remarks, ExampleComment example, ReturnsComment returns) : base(MemberClassification.Method, summary, remarks, example) { _definition = info.Definition; _methodClassification = MethodClassifier.GetMethodClassification(info.Definition); _identity = info.Identity; _parameters = new List<DocumentedParameter>(parameters); _returns = returns; }
private EnumMemberDef ParseEnumMember(EnumMemberDeclarationSyntax syntax, SemanticModel semanticModel) { EnumMemberDef dst = new EnumMemberDef(); // 名称 dst.Name = syntax.Identifier.ValueText; dst.Internal = syntax; // Summary var declaredSymbol = semanticModel.GetDeclaredSymbol(syntax); var xml = declaredSymbol?.GetDocumentationCommentXml(); dst.Summary = SummaryComment.Parse(xml); return(dst); }
/// <summary> /// Initializes a new instance of the <see cref="DocumentedMethod" /> class. /// </summary> /// <param name="info">The method info.</param> /// <param name="parameters">The method's parameters.</param> /// <param name="summary">The summary comment.</param> /// <param name="remarks">The remarks comment.</param> /// <param name="examples">The example comments.</param> /// <param name="returns">The return value comment.</param> /// <param name="metadata">The method metadata.</param> public DocumentedMethod( IMethodInfo info, IEnumerable<DocumentedParameter> parameters, SummaryComment summary, RemarksComment remarks, IEnumerable<ExampleComment> examples, ReturnsComment returns, IDocumentationMetadata metadata) : base(MemberClassification.Method, summary, remarks, examples, metadata) { Definition = info.Definition; MethodClassification = MethodClassifier.GetMethodClassification(info.Definition); Identity = info.Identity; Parameters = new List<DocumentedParameter>(parameters); Returns = returns; }
/// <summary> /// Initializes a new instance of the <see cref="DocumentedMethod" /> class. /// </summary> /// <param name="info">The method info.</param> /// <param name="parameters">The method's parameters.</param> /// <param name="summary">The summary comment.</param> /// <param name="remarks">The remarks comment.</param> /// <param name="examples">The example comments.</param> /// <param name="returns">The return value comment.</param> /// <param name="metadata">The method metadata.</param> public DocumentedMethod( IMethodInfo info, IEnumerable <DocumentedParameter> parameters, SummaryComment summary, RemarksComment remarks, IEnumerable <ExampleComment> examples, ReturnsComment returns, IDocumentationMetadata metadata) : base(MemberClassification.Method, summary, remarks, examples, metadata) { Definition = info.Definition; MethodClassification = MethodClassifier.GetMethodClassification(info.Definition); Identity = info.Identity; Parameters = new List <DocumentedParameter>(parameters); Returns = returns; }
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; bool isPropertyAlias; if (method.Definition.IsCakeAlias(out isPropertyAlias)) { metadata = new AliasMetadataAdapter(metadata, isPropertyAlias); } return(new DocumentedMethod(method, parameters, summary, remarks, examples, returns, metadata)); }
/// <summary> /// Initializes a new instance of the <see cref="DocumentedMember"/> class. /// </summary> /// <param name="classification">The member classification.</param> /// <param name="summary">The summary comment.</param> /// <param name="remarks">The remarks comment.</param> /// <param name="examples">The example comments.</param> /// <param name="metadata">The metadata associated with the member.</param> protected DocumentedMember( MemberClassification classification, SummaryComment summary, RemarksComment remarks, IEnumerable <ExampleComment> examples, IDocumentationMetadata metadata) { if (metadata == null) { throw new ArgumentNullException(nameof(metadata)); } Classification = classification; Summary = summary; Remarks = remarks; Examples = new List <ExampleComment>(examples ?? Enumerable.Empty <ExampleComment>()); Metadata = metadata; }
/// <summary> /// Initializes a new instance of the <see cref="DocumentedMember"/> class. /// </summary> /// <param name="classification">The member classification.</param> /// <param name="summary">The summary comment.</param> /// <param name="remarks">The remarks comment.</param> /// <param name="examples">The example comments.</param> /// <param name="metadata">The metadata associated with the member.</param> protected DocumentedMember( MemberClassification classification, SummaryComment summary, RemarksComment remarks, IEnumerable<ExampleComment> examples, IDocumentationMetadata metadata) { if (metadata == null) { throw new ArgumentNullException("metadata"); } _classification = classification; _summary = summary; _remarks = remarks; _examples = new List<ExampleComment>(examples ?? Enumerable.Empty<ExampleComment>()); _metadata = metadata; }
private static DocumentedType MapType(ITypeInfo type, XmlDocumentationModel xmlModel) { SummaryComment summary = null; RemarksComment remarks = null; 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>().SingleOrDefault(); } // 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)); }
private void ParseClass(string namespace_, ClassDeclarationSyntax classSyntax, SemanticModel semanticModel) { var classDef = new ClassDef(); // swig classDef.IsDefinedBySWIG = namespace_.Contains(swig_namespace_keyword); classDef.Namespace = namespace_; classDef.Name = classSyntax.Identifier.ValueText; var fullName = namespace_ + "." + classDef.Name; if (TypesNotParsed.Contains(fullName)) { return; } if (TypesNotExported.Contains(fullName)) { classDef.IsExported = false; } var partial = definitions.Classes.FirstOrDefault(x => x.Namespace + "." + x.Name == fullName); if (partial != null) { classDef = partial; } if (classSyntax.Modifiers.Any(x => x.ValueText == "abstract")) { classDef.IsAbstract = true; } // Summary var declaredSymbol = semanticModel.GetDeclaredSymbol(classSyntax); var xml = declaredSymbol?.GetDocumentationCommentXml(); classDef.Summary = SummaryComment.Parse(xml); ParseTypeDeclaration(classDef, classSyntax, semanticModel); definitions.Classes.Add(classDef); }
private static DocumentedField MapField(IFieldInfo field, XmlDocumentationModel xmlModel) { SummaryComment summary = null; RemarksComment remarks = null; ExampleComment example = 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(); example = member.Comments.OfType <ExampleComment>().SingleOrDefault(); } return(new DocumentedField(field, summary, remarks, example)); }
private static DocumentedProperty MapProperty(IPropertyInfo property, XmlDocumentationModel xmlModel) { SummaryComment summary = null; RemarksComment remarks = null; ExampleComment example = 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(); example = member.Comments.OfType <ExampleComment>().SingleOrDefault(); value = member.Comments.OfType <ValueComment>().SingleOrDefault(); } return(new DocumentedProperty(property, summary, remarks, example, value)); }
/// <summary> /// Initializes a new instance of the <see cref="DocumentedType" /> class. /// </summary> /// <param name="info">The type information.</param> /// <param name="properties">The type's properties.</param> /// <param name="methods">The type's methods.</param> /// <param name="fields">The type's fields.</param> /// <param name="summary">The summary.</param> /// <param name="remarks">The remarks.</param> /// <param name="example">The example.</param> public DocumentedType( ITypeInfo info, IEnumerable <DocumentedProperty> properties, IEnumerable <DocumentedMethod> methods, IEnumerable <DocumentedField> fields, SummaryComment summary, RemarksComment remarks, ExampleComment example) : base(MemberClassification.Type, summary, remarks, example) { _definition = info.Definition; _typeClassification = info.Definition.GetTypeClassification(); _identity = info.Identity; _properties = new List <DocumentedProperty>(properties); _fields = new List <DocumentedField>(fields); // Materialize all methods. var documentedMethods = methods as DocumentedMethod[] ?? methods.ToArray(); _constructors = new List <DocumentedMethod>(GetConstructors(documentedMethods)); _methods = new List <DocumentedMethod>(GetMethods(documentedMethods)); _operators = new List <DocumentedMethod>(GetOperators(documentedMethods)); }
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)); }
public NamespaceViewModel(IReadOnlyList <DocumentedNamespace> namespaces) { if (namespaces.Count == 0) { throw new ArgumentException("No namespaces in list."); } Data = namespaces[0]; Name = Data.Name; var namespaceWithSummary = namespaces.FirstOrDefault(x => x.Summary != null); if (namespaceWithSummary != null) { Summary = namespaceWithSummary.Summary; } Classes = new List <DocumentedType>(); Interfaces = new List <DocumentedType>(); foreach (var @namespace in namespaces) { var classes = @namespace.Types.Where(x => x.Definition.IsClass && !IsExtensionMethodClass(x)).ToArray(); Classes.AddRange(classes); var interfaces = @namespace.Types.Where(x => x.Definition.IsInterface).ToArray(); Interfaces.AddRange(interfaces); } // For child namespaces, just get them from the first one // since they're going to be the same anyway. Namespaces = new List <DocumentedNamespace>(); foreach (var childNamespace in Data.Tree.Children) { Namespaces.Add(childNamespace.Namespace); } }
private void ParseInterface(string namespace_, InterfaceDeclarationSyntax interfaceSyntax, SemanticModel semanticModel) { var interfaceDef = new InterfaceDef(); interfaceDef.Namespace = namespace_; interfaceDef.Name = interfaceSyntax.Identifier.ValueText; var fullName = interfaceDef.Namespace + "." + interfaceDef.Name; if (TypesNotParsed.Contains(fullName)) { return; } // Summary var declaredSymbol = semanticModel.GetDeclaredSymbol(interfaceSyntax); var xml = declaredSymbol?.GetDocumentationCommentXml(); interfaceDef.Summary = SummaryComment.Parse(xml); ParseTypeDeclaration(interfaceDef, interfaceSyntax, semanticModel); definitions.Interfaces.Add(interfaceDef); }
public override void VisitSummary(SummaryComment comment, StringBuilder context) { context.Append("<summary>"); base.VisitSummary(comment, context); context.Append("</summary>"); }
/// <summary> /// Visits a <c>summary</c> comment. /// </summary> /// <param name="comment">The comment.</param> /// <param name="context">The context.</param> public virtual void VisitSummary(SummaryComment comment, TContext context) { VisitChildren(comment, context); }