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 static void GenerateMarkdown( Type rootType, IMarkdownWriter writer, string outputFileName, List <string> ignoreAttributes, bool ignoreMethods, bool recursive) { GenerateMarkdown(rootType, null, recursive, null, ignoreAttributes, ignoreMethods, writer, outputFileName); }
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 static void GenerateMarkdown( Type rootType, Assembly assembly, bool recursiveAssemblyTraversal, List <string> recursiveAssemblies, List <string> ignoreAttributes, bool ignoreMethods, IMarkdownWriter markdownWriter, string outputFileName) { // Reflection setup var allAssemblyTypes = assembly != null; if (assembly == null) { assembly = rootType.Assembly; } var ignoreAttributesHash = ignoreAttributes == null || ignoreAttributes.Count == 0 ? null : new HashSet <string>(ignoreAttributes); var reflectionSettings = ReflectionSettings.Default; var prevPropertyFilter = reflectionSettings.PropertyFilter; reflectionSettings.PropertyFilter = info => (prevPropertyFilter == null || prevPropertyFilter(info)) && !HasIgnoreAttribute(info, ignoreAttributesHash); reflectionSettings.MethodFilter = info => !ignoreMethods && !HasIgnoreAttribute(info, ignoreAttributesHash); reflectionSettings.TypeFilter = type => !HasIgnoreAttribute(type, ignoreAttributesHash); reflectionSettings.AssemblyFilter = reflectionAssembly => reflectionAssembly == assembly || recursiveAssemblyTraversal && (recursiveAssemblies == null || recursiveAssemblies.Count == 0 || recursiveAssemblies.Any(name => name.Equals(Path.GetFileName(assembly.Location), StringComparison.OrdinalIgnoreCase))); // Reflection var typeCollection = allAssemblyTypes ? TypeCollection.ForReferencedTypes(assembly, reflectionSettings) : TypeCollection.ForReferencedTypes(rootType, reflectionSettings); // Generate markdown var generator = new DocumentationGenerator(markdownWriter, typeCollection, rootType); if (assembly != null) { generator.WriteDocumentTitle(assembly); } generator.WriteTypeIndex(); generator.DocumentTypes(); // Write markdown to the output file File.WriteAllText(outputFileName, generator.Writer.FullText); }
public static void GenerateMarkdown( Type rootType, IMarkdownWriter writer, string outputFileName, List <string> ignoreAttributes, bool ignoreMethods, bool recursive, bool msdnLinks, string msdnView, bool showDateLine, bool verbose) { GenerateMarkdown(rootType, null, recursive, null, ignoreAttributes, ignoreMethods, msdnLinks, msdnView, showDateLine, verbose, writer, outputFileName); }
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 static void GenerateMarkdown( OrderedTypeList typeList, string documentTitle, bool showDocumentDateTime, bool documentMethodDetails, bool msdnLinks, string msdnLinkViewParameter, IMarkdownWriter markdownWriter) { // Generate markdown var generator = new DocumentationGenerator(markdownWriter, typeList, msdnLinks, msdnLinkViewParameter, documentMethodDetails); if (documentTitle != null) { generator.WriteDocumentTitle(documentTitle); } if (showDocumentDateTime) { generator.WritedDateLine(); } generator.WriteTypeIndex(); generator.WriteDocumentationForTypes(); }
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; }
public static void GenerateMarkdown( Type rootType, Assembly assembly, bool recursiveAssemblyTraversal, List <string> recursiveAssemblies, List <string> ignoreAttributes, bool ignoreMethods, bool msdnLinks, string msdnView, bool showDateLine, bool verbose, IMarkdownWriter markdownWriter, string outputFileName) { // Reflection setup var allAssemblyTypes = assembly != null; if (assembly == null) { assembly = rootType.Assembly; } var ignoreAttributesSet = ignoreAttributes == null || ignoreAttributes.Count == 0 ? null : new HashSet <string>(ignoreAttributes); if (recursiveAssemblies != null && recursiveAssemblies.Count == 0) { recursiveAssemblies = null; } if (verbose) { if (assembly != null) { Log(assembly, "Root assembly "); } } var reflectionSettings = ReflectionSettings.Default; reflectionSettings.PropertyFilter = info => PropertyFilter(info, ignoreAttributesSet, verbose); reflectionSettings.MethodFilter = info => MethodFilter(info, ignoreMethods, ignoreAttributesSet, verbose); reflectionSettings.TypeFilter = type => TypeFilter(type, ignoreAttributesSet, verbose); reflectionSettings.AssemblyFilter = reflectionAssembly => AssemblyFilter(reflectionAssembly, assembly, recursiveAssemblies, recursiveAssemblyTraversal, verbose); // Reflection var typeCollection = allAssemblyTypes ? TypeCollection.ForReferencedTypes(assembly, reflectionSettings) : TypeCollection.ForReferencedTypes(rootType, reflectionSettings); // Generate markdown var generator = new DocumentationGenerator(markdownWriter, typeCollection, rootType, msdnLinks, msdnView); if (assembly != null) { generator.WriteDocumentTitle(assembly); } if (showDateLine) { generator.WritedDateLine(); } generator.WriteTypeIndex(); generator.DocumentTypes(); // Write markdown to the output file File.WriteAllText(outputFileName, generator.Writer.FullText); }