Comments(this DocXmlReader reader, IEnumerable <MethodBase> methodInfos) { return(methodInfos .Select(info => (Info: info, Comments: reader.GetMethodComments(info, info.IsConstructor && info.GetParameters().Length == 0))) .Where(data => data.Comments != null)); }
public DocumentationGenerator( IMarkdownWriter writer, TypeCollection typeCollection, Type firstType = null) { Reader = new DocXmlReader(); Writer = writer; TypeCollection = typeCollection; TypesToDocument = typeCollection.ReferencedTypes.Values .OrderBy(t => t.Type.Namespace) .ThenBy(t => t.Type.Name).ToList(); if (firstType != null) { var typeDesc = TypesToDocument.FirstOrDefault(t => t.Type == firstType); if (typeDesc != null) { TypesToDocument.Remove(typeDesc); TypesToDocument.Insert(0, typeDesc); } } TypesToDocumentSet = new HashSet <Type>(TypesToDocument.Select(t => t.Type)); typeLinkConverter = (type, _) => TypesToDocumentSet.Contains(type) ? Writer.HeadingLink(TypeTitle(type), type.ToNameString()) : null; }
public void Reader_From_XPathDocument() { var m = new DocXmlReader(new XPathDocument("DocXmlUnitTests.xml")); var mm = m.GetTypeComments(MyClass_Type); Assert.AreEqual("This is MyClass", mm.Summary); }
public void DocXmlReader_AutoName_ClassComment() { var doc = new DocXmlReader((a) => Path.GetFileNameWithoutExtension(a.Location) + ".xml"); var mm = doc.GetTypeComments(typeof(MyClass)); Assert.AreEqual("This is MyClass", mm.Summary); }
internal static string GenerateDocumentationText( string xmlCommentFile, string binaryFile, string assemblyName, string assemblyVersion, IEnumerable <Mql5FunctionDefinition> definitions) { var sortedFunctionDefinitions = definitions.OrderBy(x => x.MethodName).ToList(); var asm = Assembly.UnsafeLoadFrom(binaryFile); var asmTypes = asm.GetMatchingTypesInAssembly(t => t.IsClass && t.Name.EndsWith("Module")); dllExportsType = asmTypes.FirstOrDefault(t => t.IsClass && t.Name.EndsWith("Module")); reader = new DocXmlReader($"{xmlCommentFile}"); var builder = new StringBuilder(); builder.Append($"# {assemblyName} {assemblyVersion} Documentation\n"); foreach (var definition in sortedFunctionDefinitions) { builder.Append(GenerateFunctionDocumentationText(definition) + "\n"); } return(builder.ToString()); }
public void EnumType_WithValue_Comments_OtherAssembly() { var mm = new DocXmlReader().GetEnumComments(typeof(OtherEnum)); Assert.AreEqual("Other enum", mm.Summary); Assert.AreEqual(1, mm.ValueComments.Count); AssertEnumComment(1, "Value1", "Enum value one", mm.ValueComments[0]); }
public void DocXmlReader_AutoName_OtherAssembly_ClassComment() { var doc = new DocXmlReader((a) => Path.GetFileNameWithoutExtension(a.Location) + ".xml"); var mm = doc.GetTypeComments(typeof(OtherClass)); Assert.IsNotNull(mm.Summary); Assert.IsNotNull(mm.Remarks); Assert.IsNotNull(mm.Example); }
public void MemberFunction_Inheritdoc_Cref_OtherAssembly() { var docReader = new DocXmlReader( new Assembly[] { typeof(MyClass).Assembly, typeof(OtherClass).Assembly }, (a) => Path.GetFileNameWithoutExtension(a.Location) + ".xml"); var comments = docReader.GetMethodComments(typeof(ClassForInheritdocCref) .GetMethod(nameof(ClassForInheritdocCref.OtherLibMethod))); Assert.IsNotNull(comments.Inheritdoc); Assert.AreEqual("OtherLibMethod summary", comments.Summary); }
public DocumentationGenerator( IMarkdownWriter writer, OrderedTypeList typeList, bool msdnLinks = false, string msdnView = null, bool documentMethodDetails = false) { Reader = new DocXmlReader(); Writer = writer; TypeList = typeList; typeLinkConverter = (type, _) => TypeNameWithLinks(type, msdnLinks, msdnView); DocumentMethodDetails = documentMethodDetails; }
public void DocXmlReader_AutoName_PreservesWhitespace() { var doc = new DocXmlReader((a) => Path.GetFileNameWithoutExtension(a.Location) + ".xml"); var summary = doc.GetMemberComment(typeof(MyClass).GetMethod(nameof(MyClass.MemberFunctionWithParaTagsInSummary))); Assert.AreEqual( @"<para> First paragraph. </para> <para> Second paragraph. </para>", summary); }
public DocumentationGenerator( IMarkdownWriter writer, TypeCollection typeCollection, Type firstType = null, bool msdnLinks = false, string msdnView = null) { Reader = new DocXmlReader(); Writer = writer; TypeCollection = typeCollection; TypesToDocument = typeCollection.ReferencedTypes.Values .OrderBy(t => t.Type.Namespace) .ThenBy(t => t.Type.Name).ToList(); if (firstType != null) { var typeDesc = TypesToDocument.FirstOrDefault(t => t.Type == firstType); if (typeDesc != null) { TypesToDocument.Remove(typeDesc); TypesToDocument.Insert(0, typeDesc); } } TypesToDocumentSet = new HashSet <Type>(TypesToDocument.Select(t => t.Type)); typeLinkConverter = (type, _) => { if (TypesToDocumentSet.Contains(type)) { return(Writer.HeadingLink(TypeTitle(type), type.ToNameString())); } if (msdnLinks && (type.Assembly.ManifestModule.Name.StartsWith("System.") || type.Assembly.ManifestModule.Name.StartsWith("Microsoft."))) { return(Writer.Link(MsdnUrlForType(type, msdnView), type.IsGenericTypeDefinition ? type.Name.CleanGenericTypeName() : type.ToNameString())); } if (type.IsGenericTypeDefinition) { return($"{type.Name.CleanGenericTypeName()}"); } return(null); }; }
public DocumentationGenerator( IMarkdownWriter writer, OrderedTypeList typeList, bool msdnLinks = false, string msdnView = null, bool documentMethodDetails = false) { Reader = new DocXmlReader(); Writer = writer; TypeList = typeList; typeLinkConverter = (type, _) => { if (TypeList.TypesToDocumentSet.Contains(type)) { return(type.IsGenericTypeDefinition ? Writer.HeadingLink(TypeTitle(type), type.Name.CleanGenericTypeName()) : Writer.HeadingLink(TypeTitle(type), type.ToNameString())); } if (msdnLinks && type != typeof(string) && (!type.IsValueType || type.IsEnum) && (type.Assembly.ManifestModule.Name.StartsWith("System.") || type.Assembly.ManifestModule.Name.StartsWith("Microsoft."))) { return(Writer.Link(MsdnUrlForType(type, msdnView), type.IsGenericTypeDefinition ? type.Name.CleanGenericTypeName() : type.ToNameString())); } if (type.IsGenericTypeDefinition) { return($"{type.Name.CleanGenericTypeName()}"); } return(null); }; DocumentMethodDetails = documentMethodDetails; }
Comments(this DocXmlReader reader, IEnumerable <FieldInfo> fieldInfos) { return(fieldInfos.Select(info => (info, reader.GetMemberComments(info)))); }
Comments(this DocXmlReader reader, IEnumerable <PropertyInfo> propInfos) { return(propInfos.Select(info => (info, reader.GetMemberComments(info)))); }
public void Setup() { Reader = new DocXmlReader("DocXmlUnitTests.xml"); MultiAssemblyReader = new DocXmlReader((a) => Path.GetFileNameWithoutExtension(a.Location) + ".xml"); MyClass_Type = typeof(MyClass); }