示例#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 pagesDir = Path.Combine(root, "pages");

        PurgeDirectory(pagesDir);

        var markdownProcessor = new DirectoryMarkdownProcessor(root);

        markdownProcessor.IncludeSnippets(snippets);
        markdownProcessor.Run();
    }
示例#2
0
 public List <Snippet> FromText(string contents)
 {
     using (var stringReader = new StringReader(contents))
     {
         return(FileSnippetExtractor.Read(stringReader, "path.cs").ToList());
     }
 }
示例#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 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 List <Snippet> FromText(string contents)
    {
        var extractor = FileSnippetExtractor.Build(VersionRange.All, "package", false);

        using (var stringReader = new StringReader(contents))
        {
            return(extractor.AppendFromReader(stringReader, "path.cs").ToList());
        }
    }
示例#5
0
    void ReadingFiles()
    {
        #region ReadingFilesSimple

        var files = Directory.EnumerateFiles(@"C:\path", "*.cs", SearchOption.AllDirectories);

        var snippets = FileSnippetExtractor.Read(files);

        #endregion
    }
示例#6
0
    void ReadingFiles()
    {
        #region ReadingFiles

        var files = Directory.EnumerateFiles(@"C:\path", "*.cs", SearchOption.AllDirectories);

        var snippetExtractor = FileSnippetExtractor.Build(
            fileVersion: VersionRange.Parse("[1.1,2.0)"),
            package: "ThePackageName",
            isCurrent: true);
        var snippets = snippetExtractor.Read(files);

        #endregion
    }
    public void CanExtractVersionFromFile()
    {
        var input = @"
  <!-- startcode CodeKey -->
  <configSections/>
  <!-- endcode -->";

        using (var stringReader = new StringReader(input))
        {
            var versionRange = new VersionRange(new NuGetVersion(1, 1, 0));
            var extractor    = FileSnippetExtractor.Build(versionRange, "package", false);
            var snippets     = extractor.AppendFromReader(stringReader, "path.cs").ToList();
            ObjectApprover.VerifyWithJson(snippets.Single());
        }
    }
示例#8
0
 static List <Snippet> FromText(string contents)
 {
     using StringReader reader = new(contents);
     return(FileSnippetExtractor.Read(reader, "path.cs", 80).ToList());
 }