Пример #1
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 handling      = new GitHubSnippetMarkdownHandling(root);
        var processor     = new MarkdownProcessor(snippets, handling.AppendGroup, snippetSourceFiles);
        var sourceMdFiles = Directory.EnumerateFiles(Path.Combine(root, "pages/source"), "*.md");
        var pagesDir      = Path.Combine(root, "pages");

        PurgeDirectory(pagesDir);
        foreach (var sourceFile in sourceMdFiles)
        {
            ProcessFile(sourceFile, processor, pagesDir);
        }
    }
    public Task Simple()
    {
        List <Snippet> availableSnippets = new()
        {
            SnippetBuild("cs", "snippet1"),
            SnippetBuild("cs", "snippet2")
        };
        var content = @"
snippet: snippet1

some text

snippet: snippet2

some other text

snippet: FileToUseAsSnippet.txt

some other text

snippet: /FileToUseAsSnippet.txt
";

        return(SnippetVerifier.Verify(
                   DocumentConvention.SourceTransform,
                   content,
                   availableSnippets,
                   new List <string>
        {
            Path.Combine(GitRepoDirectoryFinder.FindForFilePath(), "src/Tests/FileToUseAsSnippet.txt")
        }));
    }
Пример #3
0
    static DataLocations()
    {
        RootDir  = GitRepoDirectoryFinder.FindForFilePath();
        TempPath = Path.GetFullPath(Path.Combine(RootDir, "temp"));
        Directory.CreateDirectory(TempPath);
        DataPath            = Path.GetFullPath(Path.Combine(RootDir, "Data"));
        ElectoratesJsonPath = Path.Combine(DataPath, "electorates.json");

        PartiesJsonPath = Path.Combine(DataPath, "parties.json");
        LocalitiesPath  = Path.GetFullPath(Path.Combine(DataPath, "Localities.json"));
        Directory.CreateDirectory(DataPath);
        MapsPath = Path.GetFullPath(Path.Combine(DataPath, "Maps"));
        Directory.CreateDirectory(MapsPath);
        MapsFuturePath = Path.GetFullPath(Path.Combine(MapsPath, "Future"));
        Directory.CreateDirectory(MapsFuturePath);
        MapsDetail = Path.GetFullPath(Path.Combine(DataPath, "DetailMaps"));
        Directory.CreateDirectory(MapsDetail);
        Maps2016Path = Path.GetFullPath(Path.Combine(MapsPath, "2016"));
        Directory.CreateDirectory(Maps2016Path);
        Australia2016JsonPath = Path.GetFullPath(Path.Combine(Maps2016Path, "australia.geojson"));
        Maps2019Path          = Path.GetFullPath(Path.Combine(MapsPath, "2019"));
        Directory.CreateDirectory(Maps2019Path);
        Australia2019JsonPath = Path.GetFullPath(Path.Combine(Maps2019Path, "australia.geojson"));
        MapsCuratedPath       = Path.GetFullPath(Path.Combine(DataPath, "MapsCurated"));
        Directory.CreateDirectory(MapsCuratedPath);
        AustralianElectoratesProjectPath = Path.GetFullPath(Path.Combine(RootDir, "src/AustralianElectorates"));
        BogusProjectPath        = Path.GetFullPath(Path.Combine(RootDir, "src/AustralianElectorates.Bogus"));
        MapsCuratedZipPath      = Path.GetFullPath(Path.Combine(DataPath, "MapsCurated.zip"));
        FutureAustraliaJsonPath = Path.GetFullPath(Path.Combine(MapsFuturePath, "australia.geojson"));
    }
Пример #4
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();
    }
Пример #5
0
    public void GetHash()
    {
        var path = GitRepoDirectoryFinder.FindForFilePath();
        var hash = GitHashReader.GetHash(path);

        Assert.NotNull(hash);
        Assert.NotEmpty(hash);
    }
Пример #6
0
    static string Scrub(string value)
    {
        var gitDir = GitRepoDirectoryFinder.FindForFilePath().Replace('\\', '/');

        return(value
               .Replace("\\r\\n", "\r\n")
               .Replace(gitDir, ""));
    }
Пример #7
0
    public void Run()
    {
        var root = GitRepoDirectoryFinder.FindForFilePath();

        var files = Directory.EnumerateFiles(Path.Combine(root, "src/Tests/Snippets"), "*.cs");

        GitHubMarkdownProcessor.Run(root, files.ToList());
    }
    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();
    }
Пример #9
0
    public static string Scrub(string s)
    {
        var gitDir        = GitRepoDirectoryFinder.FindForFilePath().Replace('\\', '/');
        var testDirectory = AssemblyLocation.CurrentDirectory;

        return(s.Replace(@"\\", @"\")
               .ReplaceCaseless(testDirectory, @"root\")
               .Replace(Environment.CurrentDirectory, "TheTargetDirectory")
               .Replace(Path.GetFullPath(Path.Combine(Environment.CurrentDirectory, "../")), "TheTargetDirectory")
               .Replace("\\r\\n", "\r\n")
               .Replace(gitDir, ""));
    }
Пример #10
0
    public static void Scrub(StringBuilder builder)
    {
        var gitDir        = GitRepoDirectoryFinder.FindForFilePath().Replace('\\', '/');
        var testDirectory = AssemblyLocation.CurrentDirectory;

        builder.Replace(@"\\", @"\");
        builder.Replace(testDirectory, @"root\");
        builder.Replace(Environment.CurrentDirectory, "TheTargetDirectory");
        builder.Replace(Path.GetFullPath(Path.Combine(Environment.CurrentDirectory, "../")), "TheTargetDirectory");
        builder.Replace("\\r\\n", "\r\n");
        builder.Replace(gitDir, "");
    }
Пример #11
0
    public Task Simple_Overwrite()
    {
        var availableSnippets = new List <Snippet>
        {
            SnippetBuild("cs", "snippet1"),
            SnippetBuild("cs", "snippet2"
                         )
        };
        var content = @"
<!-- snippet: snippet1 -->
```cs
BAD
```
<!-- endSnippet -->

some text

<!-- snippet: snippet2 -->
```cs
BAD
```
<!-- endSnippet -->

some other text

<!-- snippet: FileToUseAsSnippet.txt -->
```txt
BAD
```
<!-- endSnippet -->

some other text

<!-- snippet: /FileToUseAsSnippet.txt -->
```txt
BAD
```
<!-- endSnippet -->
";

        return(SnippetVerifier.Verify(
                   DocumentConvention.InPlaceOverwrite,
                   content,
                   availableSnippets,
                   new List <string>
        {
            Path.Combine(GitRepoDirectoryFinder.FindForFilePath(), "src/Tests/FileToUseAsSnippet.txt")
        }));
    }
Пример #12
0
    public void AppendGroup()
    {
        var builder  = new StringBuilder();
        var snippets = new List <Snippet> {
            Snippet.Build(1, 2, "theValue", "thekey", "thelanguage", "thePath")
        };
        var gitHubSnippetMarkdownHandling = new SnippetMarkdownHandling(GitRepoDirectoryFinder.FindForFilePath());

        using (var writer = new StringWriter(builder))
        {
            gitHubSnippetMarkdownHandling.AppendGroup("key1", snippets, writer);
        }

        Approvals.Verify(builder.ToString());
    }
    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();
    }
Пример #14
0
    public void Run()
    {
        var root = GitRepoDirectoryFinder.FindForFilePath();

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

        processor.Run();
    }
Пример #15
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 void Simple()
    {
        var availableSnippets = new List <Snippet>
        {
            SnippetBuild(
                language: "cs",
                key: "snippet1"
                ),
            SnippetBuild(
                language: "cs",
                key: "snippet2"
                )
        };
        var markdownContent = @"
snippet: snippet1

some text

snippet: snippet2

some other text

snippet: FileToUseAsSnippet.txt

some other text

snippet: /FileToUseAsSnippet.txt

";

        SnippetVerifier.Verify(
            markdownContent,
            availableSnippets,
            new List <string>
        {
            Path.Combine(GitRepoDirectoryFinder.FindForFilePath(), "src/Tests/FileToUseAsSnippet.txt")
        });
    }
Пример #17
0
    public Task Simple()
    {
        var availableSnippets = new List <Snippet>
        {
            SnippetBuild(
                language: "cs",
                key: "snippet1"
                ),
            SnippetBuild(
                language: "cs",
                key: "snippet2"
                )
        };
        var content = @"
snippet: snippet1

some text

snippet: snippet2

some other text

snippet: FileToUseAsSnippet.txt

some other text

snippet: /FileToUseAsSnippet.txt

";

        return(this.VerifySnippets(
                   content,
                   availableSnippets,
                   new List <string>
        {
            Path.Combine(GitRepoDirectoryFinder.FindForFilePath(), "src/Tests/FileToUseAsSnippet.txt")
        }));
    }
Пример #18
0
    public void CanFindGirRepoDir()
    {
        var path = GitRepoDirectoryFinder.FindForFilePath();

        Assert.True(Directory.Exists(path));
    }
Пример #19
0
        public void Run()
        {
            var root = GitRepoDirectoryFinder.FindForFilePath();

            GitHubMarkdownProcessor.Run(root);
        }
 public void Run()
 {
     new DirectoryMarkdownProcessor(GitRepoDirectoryFinder.FindForFilePath()).Run();
 }