Esempio n. 1
0
        private static void MergePageViewModel(MetadataMergeParameters parameters, string outputBase)
        {
            var p = new ManagedReferenceDocumentProcessor();

            p.BuildSteps = new List <IDocumentBuildStep>
            {
                new ApplyPlatformVersion(),
                new MergeManagedReferenceDocument(),
            };
            var fc = new FileCollection(parameters.Files);

            fc.RemoveAll(x => "toc.yml".Equals(Path.GetFileName(x.File), StringComparison.OrdinalIgnoreCase));
            var models = DocumentBuilder.Build(
                p,
                new DocumentBuildParameters
            {
                Files          = fc,
                FileMetadata   = parameters.FileMetadata,
                MaxParallelism = 1,
                Metadata       = parameters.Metadata,
                OutputBaseDir  = parameters.OutputBaseDir,
            });

            foreach (var m in models)
            {
                m.File = m.PathRewriter(m.File);
            }
            foreach (var m in models)
            {
                YamlUtility.Serialize(Path.Combine(outputBase, m.File), m.Content);
            }
        }
        public void ProcessMrefWithComplexFileNameShouldSucceed()
        {
            FileCollection files = new FileCollection(_defaultFiles);

            files.RemoveAll(s => true);
            files.Add(DocumentType.Article, new string[] { "TestData/mref/Namespace1.Class1`2.yml", "TestData/mref/Namespace1.Class1`2.#ctor.yml" }, "TestData/");
            BuildDocument(files);

            var outputRawModelPath = GetRawModelFilePath("Namespace1.Class1`2.yml");

            Assert.True(File.Exists(outputRawModelPath));
            var model = JsonUtility.Deserialize <ApiBuildOutput>(outputRawModelPath);

            Assert.NotNull(model);
            outputRawModelPath = GetRawModelFilePath("Namespace1.Class1`2.#ctor.yml");
            Assert.True(File.Exists(outputRawModelPath));
            model = JsonUtility.Deserialize <ApiBuildOutput>(outputRawModelPath);
            Assert.NotNull(model);
            var outputHtml = GetOutputFilePath("mref/Namespace1.Class1`2.html");

            Assert.True(File.Exists(outputHtml));
            var content = File.ReadAllText(outputHtml);

            Assert.Equal("<p><a class=\"xref\" href=\"Namespace1.Class1%602.%23ctor.html#constructor\">Constructor</a></p>\n", content);
        }
Esempio n. 3
0
        private void MergePageViewModel(MetadataMergeParameters parameters)
        {
            var p = new ManagedReferenceDocumentProcessor()
            {
                BuildSteps = new List <IDocumentBuildStep>
                {
                    new ApplyPlatformVersion(),
                    new MergeManagedReferenceDocument(),
                }
            };
            var fc = new FileCollection(parameters.Files);

            fc.RemoveAll(x => "toc.yml".Equals(Path.GetFileName(x.File), StringComparison.OrdinalIgnoreCase));
            var models = SingleDocumentBuilder.Build(
                p,
                new DocumentBuildParameters
            {
                Files          = fc,
                FileMetadata   = parameters.FileMetadata,
                MaxParallelism = 1,
                Metadata       = parameters.Metadata,
                OutputBaseDir  = parameters.OutputBaseDir,
            },
                new DfmServiceProvider().CreateMarkdownService(
                    new MarkdownServiceParameters
            {
                BasePath = fc.DefaultBaseDir,
            }));

            foreach (var m in models)
            {
                m.File = (RelativePath)m.FileAndType.DestinationDir + (((RelativePath)m.File) - (RelativePath)m.FileAndType.SourceDir);
                Console.WriteLine($"File:{m.OriginalFileAndType.File} from:{m.FileAndType.SourceDir} to:{m.FileAndType.DestinationDir} => {m.File}");
            }
            foreach (var m in models)
            {
                InitTable(m, parameters.TocMetadata);
                YamlUtility.Serialize(m.File, m.Content, YamlMime.ManagedReference);
            }
        }
        public void ProcessMrefWithDynamicDevLangsShouldSucceed()
        {
            FileCollection files = new FileCollection(_defaultFiles);

            files.RemoveAll(s => true);
            files.Add(DocumentType.Article, new [] { "TestData/mref/System.String.yml" }, "TestData/");

            BuildDocument(files);

            var outputRawModelPath = GetRawModelFilePath("System.String.yml");

            Assert.True(File.Exists(outputRawModelPath));
            var model = JsonUtility.Deserialize <ApiBuildOutput>(outputRawModelPath);

            Assert.NotNull(model);
            Assert.NotNull(model.Syntax);
            Assert.NotNull(model.Syntax.Content);
            Assert.Equal(4, model.Syntax.Content.Count);
            Assert.Equal("public ref class String sealed", model.Syntax.Content.First(c => c.Language == "cpp").Value);
            Assert.Equal("public sealed class String", model.Syntax.Content.First(c => c.Language == "csharp").Value);
            Assert.Equal("type String", model.Syntax.Content.First(c => c.Language == "fsharp").Value);
            Assert.Equal("Public NotInheritable Class String", model.Syntax.Content.First(c => c.Language == "vb").Value);
        }