Пример #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);
        }
    }
Пример #2
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"));
    }
Пример #3
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();
    }
    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")
        }));
    }
Пример #5
0
    static string Scrub(string value)
    {
        var gitDir = GitRepoDirectoryFinder.FindForFilePath().Replace('\\', '/');

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

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

        GitHubMarkdownProcessor.Run(root, files.ToList());
    }
Пример #7
0
    public void GetHash()
    {
        var path = GitRepoDirectoryFinder.FindForFilePath();
        var hash = GitHashReader.GetHash(path);

        Assert.NotNull(hash);
        Assert.NotEmpty(hash);
    }
    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
 static DataLocations()
 {
     RootDir  = GitRepoDirectoryFinder.Find();
     TempPath = Path.GetFullPath(Path.Combine(RootDir, "temp"));
     Directory.CreateDirectory(TempPath);
     DataPath = Path.GetFullPath(Path.Combine(RootDir, "Data"));
     CountryDataProjectPath = Path.GetFullPath(Path.Combine(RootDir, "src/CountryData"));
     BogusProjectPath       = Path.GetFullPath(Path.Combine(RootDir, "src/CountryData.Bogus"));
     PostCodesPath          = Path.GetFullPath(Path.Combine(DataPath, "PostCodes"));
 }
Пример #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 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, ""));
    }
Пример #12
0
    static void ValidateAndApplyDefaults(Options options)
    {
        if (options.Exclude.Any())
        {
            throw new CommandLineException("`exclude` is obsolete. Use `exclude-directories`.");
        }

        if (options.Header != null && string.IsNullOrWhiteSpace(options.Header))
        {
            throw new CommandLineException("Empty Header is not allowed.");
        }

        if (options.UrlPrefix != null && string.IsNullOrWhiteSpace(options.UrlPrefix))
        {
            throw new CommandLineException("Empty UrlPrefix is not allowed.");
        }

        if (options.TargetDirectory == null)
        {
            options.TargetDirectory = Environment.CurrentDirectory;
            if (!GitRepoDirectoryFinder.IsInGitRepository(options.TargetDirectory))
            {
                throw new CommandLineException($"The current directory does no exist with a .git repository. Pass in a target directory instead. Current directory: {options.TargetDirectory}");
            }
        }
        else
        {
            if (!Directory.Exists(options.TargetDirectory))
            {
                throw new CommandLineException("target-directory does not exist.");
            }
            options.TargetDirectory = Path.GetFullPath(options.TargetDirectory);
        }

        if (options.TocLevel <= 0)
        {
            throw new CommandLineException("toc-level must be positive.");
        }

        if (options.MaxWidth <= 0)
        {
            throw new CommandLineException("max-width must be positive.");
        }

        ValidateItems("exclude", options.ExcludeDirectories);
        ValidateItems("exclude-markdown-directories", options.ExcludeMarkdownDirectories);
        ValidateItems("exclude-snippet-directories", options.ExcludeSnippetDirectories);
        ValidateItems("toc-excludes", options.TocExcludes);
        ValidateItems("urls-as-snippets", options.UrlsAsSnippets);
    }
Пример #13
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")
        }));
    }
Пример #14
0
 static void ApplyDefaults(Options options)
 {
     if (options.TargetDirectory == null)
     {
         options.TargetDirectory = Environment.CurrentDirectory;
         if (!GitRepoDirectoryFinder.IsInGitRepository(options.TargetDirectory))
         {
             throw new CommandLineException($"The current directory does no exist with a .git repository. Pass in a target directory instead. Current directory: {options.TargetDirectory}");
         }
     }
     else
     {
         options.TargetDirectory = Path.GetFullPath(options.TargetDirectory);
     }
 }
Пример #15
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();
    }
Пример #17
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();
    }
Пример #18
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();
    }
Пример #19
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")
        }));
    }
    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")
        });
    }
Пример #21
0
    public void CanFindGirRepoDir()
    {
        var path = GitRepoDirectoryFinder.FindForFilePath();

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

            GitHubMarkdownProcessor.Run(root);
        }
 public void Run()
 {
     new DirectoryMarkdownProcessor(GitRepoDirectoryFinder.FindForFilePath()).Run();
 }
Пример #24
0
    public Task ThisSolution()
    {
        var file = Path.Combine(GitRepoDirectoryFinder.Find(), "src", "PackageUpdate.sln");

        return(SolutionRestore.Run(file));
    }