Ejemplo n.º 1
0
        public void AddMdFilesFrom(string directory)
        {
            directory = ExpandDirectory(directory);
            var finder = new MdFileFinder(directoryFilter);
            var files  = finder.FindFiles(directory).ToList();

            sourceMdFiles.AddRange(files);
            log($"Added {files.Count} .source.md files");
        }
        public void AddMdFilesFrom(string directory)
        {
            directory = ExpandDirectory(directory);
            var finder = new MdFileFinder(convention, directoryFilter, documentExtensions);
            var files  = finder.FindFiles(directory).ToList();

            mdFiles.AddRange(files);
            log($"Added {files.Count} markdown files");
        }
        public DirectoryMarkdownProcessor(
            string targetDirectory,
            AppendSnippetsToMarkdown appendSnippets,
            DocumentConvention convention = DocumentConvention.SourceTransform,
            bool scanForMdFiles           = true,
            bool scanForSnippets          = true,
            bool scanForIncludes          = true,
            Action <string>?log           = null,
            bool?writeHeader = null,
            string?header    = null,
            DirectoryFilter?directoryFilter = null,
            bool?readOnly = null,
            int tocLevel  = 2,
            IEnumerable <string>?tocExcludes        = null,
            IEnumerable <string>?documentExtensions = null,
            bool treatMissingAsWarning = false,
            int maxWidth            = int.MaxValue,
            bool validateContent    = false,
            string?newLine          = null,
            bool hashSnippetAnchors = false)
        {
            this.appendSnippets        = appendSnippets;
            this.convention            = convention;
            this.writeHeader           = writeHeader.GetValueOrDefault(convention == DocumentConvention.SourceTransform);
            this.readOnly              = readOnly.GetValueOrDefault(false);
            this.validateContent       = validateContent;
            this.header                = header;
            this.directoryFilter       = directoryFilter;
            this.tocLevel              = tocLevel;
            this.tocExcludes           = tocExcludes;
            this.documentExtensions    = MdFileFinder.BuildDefaultExtensions(documentExtensions);
            this.maxWidth              = maxWidth;
            this.treatMissingAsWarning = treatMissingAsWarning;

            this.log = log ?? (s => { Trace.WriteLine(s); });

            Guard.DirectoryExists(targetDirectory, nameof(targetDirectory));
            this.targetDirectory = Path.GetFullPath(targetDirectory);
            if (scanForMdFiles)
            {
                AddMdFilesFrom(targetDirectory);
            }

            this.newLine = FindNewLine(newLine);
            if (scanForSnippets)
            {
                AddSnippetsFrom(targetDirectory);
            }

            if (scanForIncludes)
            {
                AddIncludeFilesFrom(targetDirectory);
            }
        }