Пример #1
0
        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);
        }
Пример #2
0
        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();
        }
Пример #3
0
        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);
        }