public Task UrlIncludeMissing()
    {
        var root      = Path.GetFullPath("DirectoryMarkdownProcessor/UrlIncludeMissing");
        var processor = new DirectoryMarkdownProcessor(root, writeHeader: false, newLine: "\n");

        return(Verifier.Throws(() => processor.Run()));
    }
    public Task NonMd()
    {
        var root      = Path.GetFullPath("DirectoryMarkdownProcessor/NonMd");
        var processor = new DirectoryMarkdownProcessor(
            root,
            writeHeader: false,
            documentExtensions: new List <string> {
            "txt"
        },
            newLine: "\n");

        processor.AddSnippets(
            SnippetBuild("snippet1"),
            SnippetBuild("snippet2")
            );
        processor.Run();

        var builder = new StringBuilder();

        foreach (var file in Directory.EnumerateFiles(root, "*.*", SearchOption.AllDirectories))
        {
            builder.AppendLine(file.Replace(root, ""));
            builder.AppendLine(File.ReadAllText(file));
            builder.AppendLine();
        }

        return(Verifier.Verify(builder.ToString()));
    }
    public void MustErrorByDefaultWhenSnippetsAreMissing()
    {
        var root      = Path.GetFullPath("DirectoryMarkdownProcessor/Convention");
        var processor = new DirectoryMarkdownProcessor(root, writeHeader: false);

        Assert.Throws <MissingSnippetsException>(() => processor.Run());
    }
    public void ReadOnly()
    {
        var root = Path.GetFullPath("DirectoryMarkdownProcessor/Readonly");

        try
        {
            var processor = new DirectoryMarkdownProcessor(
                root,
                writeHeader: false,
                readOnly: true);
            processor.AddSnippets(
                SnippetBuild("snippet1"),
                SnippetBuild("snippet2")
                );
            processor.Run();

            var fileInfo = new FileInfo(Path.Combine(root, "one.md"));
            Assert.True(fileInfo.IsReadOnly);
        }
        finally
        {
            foreach (var file in Directory.EnumerateFiles(root))
            {
                FileEx.ClearReadOnly(file);
            }
        }
    }
Ejemplo n.º 5
0
    public async Task Run()
    {
        var root = GitRepoDirectoryFinder.FindForFilePath();

        var finder             = new FileFinder();
        var addinPath          = Path.Combine(root, "BasicFodyAddin");
        var snippetSourceFiles = finder.FindFiles(
            Path.Combine(root, "src/Docs"),
            addinPath);
        var snippets = FileSnippetExtractor.Read(snippetSourceFiles).ToList();

        await snippets.AppendUrlsAsSnippets(
            "https://raw.githubusercontent.com/Fody/Fody/master/FodyPackaging/Weaver.props",
            "https://raw.githubusercontent.com/Fody/Fody/master/FodyPackaging/build/FodyPackaging.props",
            "https://raw.githubusercontent.com/Fody/Fody/master/FodyPackaging/build/FodyPackaging.targets");

        var pagesDir = Path.Combine(root, "pages");

        PurgeDirectory(pagesDir);

        var markdownProcessor = new DirectoryMarkdownProcessor(root);

        markdownProcessor.IncludeSnippets(snippets);
        markdownProcessor.Run();
    }
Ejemplo n.º 6
0
    static void Inner(string targetDirectory)
    {
        Console.WriteLine($"TargetDirectory: {targetDirectory}");
        if (!Directory.Exists(targetDirectory))
        {
            Console.WriteLine($"Target directory does not exist: {targetDirectory}");
            Environment.Exit(1);
        }

        try
        {
            var processor = new DirectoryMarkdownProcessor(targetDirectory, log: Console.WriteLine);
            processor.Run();
        }
        catch (SnippetReadingException exception)
        {
            Console.WriteLine($"Failed to read snippets: {exception.Message}");
            Environment.Exit(1);
        }
        catch (MissingSnippetsException exception)
        {
            Console.WriteLine($"Failed to process markdown: {exception.Message}");
            Environment.Exit(1);
        }
        catch (MarkdownProcessingException exception)
        {
            Console.WriteLine($"Failed to process markdown files: {exception.Message}");
            Environment.Exit(1);
        }
    }
Ejemplo n.º 7
0
    void RunForFilePath()
    {
        #region RunForFilePath

        DirectoryMarkdownProcessor.RunForFilePath();

        #endregion
    }
Ejemplo n.º 8
0
    void DirectoryMarkdownProcessorRun()
    {
        #region DirectoryMarkdownProcessorRun

        var processor = new DirectoryMarkdownProcessor("targetDirectory");
        processor.Run();

        #endregion
    }
    public Task ValidationErrors()
    {
        var root      = Path.GetFullPath("DirectoryMarkdownProcessor/ValidationErrors");
        var processor = new DirectoryMarkdownProcessor(
            root,
            writeHeader: false,
            validateContent: true);

        return(Verifier.Throws(() => processor.Run()));
    }
    public void MustNotErrorForMissingSnippetsIfConfigured()
    {
        var root      = Path.GetFullPath("DirectoryMarkdownProcessor/Convention");
        var processor = new DirectoryMarkdownProcessor(
            root,
            writeHeader: false,
            treatMissingSnippetAsWarning: true);

        processor.Run();
    }
    public void Run()
    {
        var root = GitRepoDirectoryFinder.FindForFilePath();

        var processor = new DirectoryMarkdownProcessor(root, false, false);

        processor.IncludeMdFiles(Path.Combine(root, "readme.source.md"));
        processor.IncludeSnippetsFrom("src/Tests/Snippets");
        processor.Run();
    }
    public Task UrlInclude()
    {
        var root      = Path.GetFullPath("DirectoryMarkdownProcessor/UrlInclude");
        var processor = new DirectoryMarkdownProcessor(root, writeHeader: false);

        processor.Run();

        var result = Path.Combine(root, "one.md");

        return(Verify(File.ReadAllText(result)));
    }
Ejemplo n.º 13
0
    void DirectoryMarkdownProcessorRunMaxWidth()
    {
        #region DirectoryMarkdownProcessorRunMaxWidth

        var processor = new DirectoryMarkdownProcessor(
            "targetDirectory",
            maxWidth: 80);
        processor.Run();

        #endregion
    }
    public Task FileSnippet()
    {
        var root      = Path.GetFullPath("DirectoryMarkdownProcessor/FileSnippet");
        var processor = new DirectoryMarkdownProcessor(root, writeHeader: false);

        processor.Run();

        var result = Path.Combine(root, "one.md");

        return(Verifier.Verify(File.ReadAllTextAsync(result)));
    }
    public Task MixedCaseInclude()
    {
        var root      = Path.GetFullPath("DirectoryMarkdownProcessor/MixedCaseInclude");
        var processor = new DirectoryMarkdownProcessor(root, writeHeader: false, newLine: "\r");

        processor.Run();

        var result = Path.Combine(root, "one.md");

        return(Verifier.Verify(File.ReadAllTextAsync(result)));
    }
    public Task ExplicitFileIncludeWithSnippetAtEnd()
    {
        var root      = Path.GetFullPath("DirectoryMarkdownProcessor/ExplicitFileIncludeWithSnippetAtEnd");
        var processor = new DirectoryMarkdownProcessor(root, writeHeader: false, newLine: "\r");

        processor.AddSnippets(SnippetBuild("snippet1"));
        processor.Run();

        var result = Path.Combine(root, "one.md");

        return(Verifier.Verify(File.ReadAllTextAsync(result)));
    }
    public Task InPlaceOverwriteUrlInclude()
    {
        var root      = Path.GetFullPath("DirectoryMarkdownProcessor/InPlaceOverwriteUrlInclude");
        var processor = new DirectoryMarkdownProcessor(root,
                                                       convention: DocumentConvention.InPlaceOverwrite);

        processor.Run();

        var result = Path.Combine(root, "one.md");

        return(Verifier.Verify(File.ReadAllTextAsync(result)));
    }
    public Task UrlIncludeMissing()
    {
        var root      = Path.GetFullPath("DirectoryMarkdownProcessor/UrlIncludeMissing");
        var processor = new DirectoryMarkdownProcessor(root, writeHeader: false);
        var exception = Assert.Throws <MissingIncludesException>(() => processor.Run());

        return(Verify(
                   new
        {
            exception.Missing,
            exception.Message
        }));
    }
    public Task InPlaceOverwriteExists()
    {
        var root      = Path.GetFullPath("DirectoryMarkdownProcessor/InPlaceOverwriteExists");
        var processor = new DirectoryMarkdownProcessor(
            root,
            writeHeader: false,
            convention: DocumentConvention.InPlaceOverwrite);

        processor.AddSnippets(SnippetBuild("snippet1", "thePath"));
        processor.Run();

        var fileInfo = new FileInfo(Path.Combine(root, "file.md"));

        return(Verifier.VerifyFile(fileInfo));
    }
    public Task ValidationErrors()
    {
        var root      = Path.GetFullPath("DirectoryMarkdownProcessor/ValidationErrors");
        var processor = new DirectoryMarkdownProcessor(
            root,
            writeHeader: false,
            validateContent: true);
        var exception = Assert.Throws <ContentValidationException>(() => processor.Run());

        return(Verify(
                   new
        {
            exception.Errors,
            exception.Message
        }));
    }
    public void Run()
    {
        var root = GitRepoDirectoryFinder.FindForFilePath();

        var processor = new DirectoryMarkdownProcessor(
            targetDirectory: root,
            tocLevel: 1,
            tocExcludes: new List <string>
        {
            "Icon",
            "Credits",
            "Release Notes"
        },
            directoryFilter: path =>
            !path.Contains("IncludeFileFinder") &&
            !path.Contains("DirectoryMarkdownProcessor"));

        processor.Run();
    }
Ejemplo n.º 22
0
    static async Task Inner(string targetDirectory, ConfigInput configInput)
    {
        var(fileConfig, configFilePath) = ConfigReader.Read(targetDirectory);
        var configResult = ConfigDefaults.Convert(fileConfig, configInput);

        var message = LogBuilder.BuildConfigLogMessage(targetDirectory, configResult, configFilePath);

        Console.WriteLine(message);

        var processor = new DirectoryMarkdownProcessor(
            targetDirectory,
            log: Console.WriteLine,
            directoryFilter: ExcludeToFilterBuilder.ExcludesToFilter(configResult.Exclude),
            readOnly: configResult.ReadOnly,
            writeHeader: configResult.WriteHeader,
            header: configResult.Header,
            urlPrefix: configResult.UrlPrefix,
            linkFormat: configResult.LinkFormat,
            convention: configResult.Convention,
            tocExcludes: configResult.TocExcludes,
            documentExtensions: configResult.DocumentExtensions,
            tocLevel: configResult.TocLevel,
            treatMissingAsWarning: configResult.TreatMissingAsWarning,
            maxWidth: configResult.MaxWidth,
            validateContent: configResult.ValidateContent,
            hashSnippetAnchors: configResult.HashSnippetAnchors);

        var snippets = new List <Snippet>();
        await snippets.AppendUrlsAsSnippets(configResult.UrlsAsSnippets);

        processor.AddSnippets(snippets);

        try
        {
            processor.Run();
        }
        catch (SnippetException exception)
        {
            Console.WriteLine($"Failed: {exception.Message}");
            Environment.Exit(1);
        }
    }
Ejemplo n.º 23
0
    public async Task Run()
    {
        var root = GitRepoDirectoryFinder.FindForFilePath();

        List <Snippet> snippets = new List <Snippet>();

        await snippets.AppendUrlsAsSnippets(
            "https://raw.githubusercontent.com/Fody/Fody/master/FodyPackaging/Weaver.props",
            "https://raw.githubusercontent.com/Fody/Fody/master/FodyPackaging/build/FodyPackaging.props",
            "https://raw.githubusercontent.com/Fody/Fody/master/FodyPackaging/build/FodyPackaging.targets");

        var pagesDir = Path.Combine(root, "pages");

        PurgeDirectory(pagesDir);

        var markdownProcessor = new DirectoryMarkdownProcessor(root);

        markdownProcessor.IncludeSnippets(snippets);
        markdownProcessor.Run();
    }
    public Task Convention()
    {
        var root      = Path.GetFullPath("DirectoryMarkdownProcessor/Convention");
        var processor = new DirectoryMarkdownProcessor(root, writeHeader: false);

        processor.AddSnippets(
            SnippetBuild("snippet1"),
            SnippetBuild("snippet2")
            );
        processor.Run();

        var builder = new StringBuilder();

        foreach (var file in Directory.EnumerateFiles(root, "*.*", SearchOption.AllDirectories))
        {
            builder.AppendLine(file.Replace(root, ""));
            builder.AppendLine(File.ReadAllText(file));
            builder.AppendLine();
        }

        return(Verify(builder.ToString()));
    }
Ejemplo n.º 25
0
 public void Run()
 {
     DirectoryMarkdownProcessor.RunForFilePath();
 }