예제 #1
0
        private static void CheckDuplicateShortcuts(IEnumerable <Snippet> snippets, SnippetEnvironment environment)
        {
            foreach (IGrouping <Language, Snippet> grouping in snippets
                     .GroupBy(f => f.Language)
                     .OrderBy(f => f.Key.GetIdentifier()))
            {
                Console.WriteLine($"checking duplicate shortcuts for '{environment.Kind.GetIdentifier()}.{grouping.Key.GetIdentifier()}'");

                foreach (DuplicateShortcutInfo info in SnippetUtility.FindDuplicateShortcuts(grouping))
                {
                    if (info.Snippets.Any(f => !f.HasTag(KnownTags.NonUniqueShortcut)))
                    {
                        Console.WriteLine($"DUPLICATE SHORTCUT: {info.Shortcut}");

                        foreach (Snippet item in info.Snippets)
                        {
                            Console.WriteLine($"  {item.FileNameWithoutExtension()}");
                        }
                    }
                }
            }
        }
예제 #2
0
        private static (List <SnippetGeneratorResult> results, List <Snippet> snippets) GenerateSnippets(
            SnippetEnvironment environment,
            SnippetDirectory[] directories,
            string projectPath)
        {
            environment.Shortcuts.AddRange(_shortcuts.Where(f => f.Environments.Contains(environment.Kind)));

            PackageGenerator generator = environment.CreatePackageGenerator();

            var results    = new List <SnippetGeneratorResult>();
            var devResults = new List <SnippetGeneratorResult>();

            foreach (SnippetGeneratorResult result in environment.GenerateSnippets(directories))
            {
                if (result.IsDevelopment)
                {
                    devResults.Add(result);
                }
                else
                {
                    results.Add(result);
                }
            }

            var snippets = new List <Snippet>();

            snippets.AddRange(generator.GeneratePackageFiles(projectPath, results));

            snippets.AddRange(generator.GeneratePackageFiles(projectPath + DevSuffix, devResults));

#if !DEBUG
            MarkdownFileWriter.WriteProjectReadme(projectPath, results, environment.CreateProjectReadmeSettings());
#endif

            return(results, snippets);
        }
예제 #3
0
 public PackageGenerator(SnippetEnvironment environment)
 {
     Environment = environment;
 }
예제 #4
0
 public EnvironmentSnippetGenerator(SnippetEnvironment environment, LanguageDefinition languageDefinition)
     : base(languageDefinition)
 {
     Environment = environment;
 }
 public EnvironmentExecutionContext(Snippet snippet, LanguageDefinition language, SnippetEnvironment environment)
     : base(snippet, language)
 {
     Environment = environment;
 }