Beispiel #1
0
        private void UpdateCore(string name, XRefMap map)
        {
            var entry = _archive.GetEntry(name);

            entry.Delete();
            entry = _archive.CreateEntry(name);
            using (var sw = new StreamWriter(entry.Open()))
            {
                YamlUtility.Serialize(sw, map, YamlMime.XRefMap);
            }
        }
Beispiel #2
0
 private IEnumerable <Tuple <string, PageViewModel> > GetViewModels()
 {
     foreach (var yaml in Directory.GetFiles(_yamlDirectory, "*.yml", SearchOption.AllDirectories))
     {
         if (Path.GetFileName(yaml) == "toc.yml")
         {
             continue;
         }
         yield return(Tuple.Create(yaml, YamlUtility.Deserialize <PageViewModel>(yaml)));
     }
 }
Beispiel #3
0
 private static IXRefContainer ReadLocalFile(string filePath)
 {
     if (".zip".Equals(Path.GetExtension(filePath), StringComparison.OrdinalIgnoreCase))
     {
         return(XRefArchive.Open(filePath, XRefArchiveMode.Read));
     }
     using (var sr = File.OpenText(filePath))
     {
         return(YamlUtility.Deserialize <XRefMap>(sr));
     }
 }
 private static Tuple <string, PageViewModel> LoadViewModelNoThrow(string filePath)
 {
     try
     {
         return(Tuple.Create(Path.GetFileName(filePath), YamlUtility.Deserialize <PageViewModel>(filePath)));
     }
     catch (Exception)
     {
         return(null);
     }
 }
 public SaveResult Save(FileModel model)
 {
     if (model.Type == DocumentType.Article)
     {
         YamlUtility.Serialize(model.File, model.Content);
         return(new SaveResult {
             DocumentType = "MergeMrefOverwrite"
         });
     }
     return(null);
 }
Beispiel #6
0
 private XRefMap OpenCore(string name)
 {
     lock (_archive)
     {
         var entry = _archive.GetEntry(name);
         using (var sr = new StreamReader(entry.Open()))
         {
             return(YamlUtility.Deserialize <XRefMap>(sr));
         }
     }
 }
        public static DocumentBuildContext DeserializeFrom(string outputBaseDir)
        {
            var context = new DocumentBuildContext(outputBaseDir);

            context.Manifest         = YamlUtility.Deserialize <List <ManifestItem> >(Path.Combine(outputBaseDir, ManifestFileName));
            context.FileMap          = new Dictionary <string, string>(YamlUtility.Deserialize <Dictionary <string, string> >(Path.Combine(outputBaseDir, FileMapFileName)), FilePathComparer.OSPlatformSensitiveStringComparer);
            context.ExternalXRefSpec = YamlUtility.Deserialize <List <XRefSpec> >(Path.Combine(outputBaseDir, ExternalXRefSpecFileName)).ToDictionary(x => x.Uid, x => x.ToReadOnly());
            context.XRefSpecMap      = YamlUtility.Deserialize <List <XRefSpec> >(Path.Combine(outputBaseDir, InternalXRefSpecFileName)).ToDictionary(x => x.Uid, x => x.ToReadOnly());
            context.TocMap           = new Dictionary <string, HashSet <string> >(YamlUtility.Deserialize <Dictionary <string, HashSet <string> > >(Path.Combine(outputBaseDir, TocFileName)), FilePathComparer.OSPlatformSensitiveStringComparer);
            return(context);
        }
Beispiel #8
0
        private static IList <string> ResolveAndExportYamlMetadata(
            Dictionary <string, MetadataItem> allMembers,
            Dictionary <string, ReferenceItem> allReferences,
            string folder,
            string indexFileName,
            string tocFileName,
            string apiFolder,
            bool preserveRawInlineComments,
            IEnumerable <string> externalReferencePackages,
            bool useCompatibilityFileName)
        {
            var outputFiles = new List <string>();
            var model       = YamlMetadataResolver.ResolveMetadata(allMembers, allReferences, apiFolder, preserveRawInlineComments, externalReferencePackages);

            // 1. generate toc.yml
            outputFiles.Add(tocFileName);
            model.TocYamlViewModel.Type = MemberType.Toc;

            // TOC do not change
            var    tocViewModel = model.TocYamlViewModel.ToTocViewModel();
            string tocFilePath  = Path.Combine(folder, tocFileName);

            YamlUtility.Serialize(tocFilePath, tocViewModel, YamlMime.TableOfContent);

            ApiReferenceViewModel indexer = new ApiReferenceViewModel();

            // 2. generate each item's yaml
            var members = model.Members;

            foreach (var memberModel in members)
            {
                var outputPath = memberModel.Name + Constants.YamlExtension;
                if (!useCompatibilityFileName)
                {
                    outputPath = outputPath.Replace('`', '-');
                }

                outputFiles.Add(Path.Combine(apiFolder, outputPath));
                string itemFilePath = Path.Combine(folder, apiFolder, outputPath);
                Directory.CreateDirectory(Path.GetDirectoryName(itemFilePath));
                var memberViewModel = memberModel.ToPageViewModel();
                YamlUtility.Serialize(itemFilePath, memberViewModel, YamlMime.ManagedReference);
                Logger.Log(LogLevel.Verbose, $"Metadata file for {memberModel.Name} is saved to {itemFilePath}.");
                AddMemberToIndexer(memberModel, outputPath, indexer);
            }

            // 3. generate manifest file
            outputFiles.Add(indexFileName);
            string indexFilePath = Path.Combine(folder, indexFileName);

            JsonUtility.Serialize(indexFilePath, indexer);

            return(outputFiles);
        }
        protected void FillInheritedMembers(ArticleItemYaml yaml, XElement node)
        {
            var allMembers = from m in node.NullableElement("listofallmembers").Elements("member")
                             where !YamlUtility.IsFiltered(m.NullableAttribute("prot").NullableValue())
                             select m.NullableAttribute("refid").NullableValue();

            yaml.InheritedMembers = allMembers.Except(yaml.Children).ToList();
            _references.AddRange(yaml.InheritedMembers.Select(i => new ReferenceViewModel {
                Uid = i
            }));
        }
 public T ConvertTo <T>() where T : class
 {
     using (var sw = new StringWriter())
     {
         YamlUtility.Serialize(sw, this);
         using (var sr = new StringReader(sw.ToString()))
         {
             return(YamlUtility.Deserialize <T>(sr));
         }
     }
 }
 private static void AssertTocEqual(TocItemViewModel expected, TocItemViewModel actual)
 {
     using (var swForExpected = new StringWriter())
     {
         YamlUtility.Serialize(swForExpected, expected);
         using (var swForActual = new StringWriter())
         {
             YamlUtility.Serialize(swForActual, actual);
             Assert.Equal(swForExpected.ToString(), swForActual.ToString());
         }
     }
 }
Beispiel #12
0
 private static void AssertTocEqual(TocItemViewModel expected, TocItemViewModel actual, bool noMetadata = true)
 {
     using var swForExpected = new StringWriter();
     YamlUtility.Serialize(swForExpected, expected);
     using var swForActual = new StringWriter();
     if (noMetadata)
     {
         actual.Metadata.Clear();
     }
     YamlUtility.Serialize(swForActual, actual);
     Assert.Equal(swForExpected.ToString(), swForActual.ToString());
 }
Beispiel #13
0
 private string CreateCore(string name, XRefMap map)
 {
     lock (_archive)
     {
         var entry = CreateEntry(name);
         using (var sw = new StreamWriter(entry.Open()))
         {
             YamlUtility.Serialize(sw, map, YamlMime.XRefMap);
         }
         return(name);
     }
 }
        public void TestXrefResolver()
        {
            using var listener = new TestListenerScope("TestXrefResolver");
            // arrange
            var schemaFile   = CreateFile("template/schemas/mref.test.schema.json", File.ReadAllText("TestData/schemas/mref.test.schema.json"), _templateFolder);
            var templateXref = CreateFile(
                "template/partials/overview.tmpl", @"{{name}}:{{{summary}}}|{{#boolProperty}}{{intProperty}}{{/boolProperty}}|{{#monikers}}<span>{{.}}</span>{{/monikers}}",
                _templateFolder);
            var            templateFile  = CreateFile("template/ManagedReference.html.tmpl", @"
{{#items}}
{{#children}}
<xref uid={{.}} template=""partials/overview.tmpl""/>
{{/children}}
{{/items}}
", _templateFolder);
            var            inputFileName = "inputs/CatLibrary.ICat.yml";
            var            inputFile     = CreateFile(inputFileName, File.ReadAllText("TestData/inputs/CatLibrary.ICat.yml"), _inputFolder);
            FileCollection files         = new FileCollection(_defaultFiles);

            files.Add(DocumentType.Article, new[] { inputFile }, _inputFolder);

            // act
            BuildDocument(files);

            // assert
            Assert.Single(listener.Items);
            listener.Items.Clear();

            var xrefspec = Path.Combine(_outputFolder, "xrefmap.yml");
            var xrefmap  = YamlUtility.Deserialize <XRefMap>(xrefspec);

            Assert.Equal(2, xrefmap.References.Count);
            Assert.Equal(8, xrefmap.References[0].Keys.Count);
            Assert.Equal(10, xrefmap.References[1].Keys.Count);

            Assert.Equal("ICat", xrefmap.References[0].Name);
            Assert.Equal("CatLibrary.ICat.CatLibrary.ICatExtension.Sleep(System.Int64)", xrefmap.References[0]["extensionMethods/0"]);
            var outputFileName = Path.ChangeExtension(inputFileName, ".html");

            Assert.Equal(outputFileName, xrefmap.References[0].Href);
            Assert.NotNull(xrefmap.References[0]["summary"]);

            var outputFilePath = Path.Combine(_outputFolder, outputFileName);

            Assert.True(File.Exists(outputFilePath));
            var outputFileContent = File.ReadAllLines(outputFilePath);

            Assert.Equal(@"
eat:<p>eat event of cat. Every cat must implement this event.
This method is within <a class=""xref"" href=""CatLibrary.ICat.html"">ICat</a></p>
|666|<span>net472</span><span>netstandard2_0</span>".Split(new string[] { "\r\n", "\n" }, StringSplitOptions.None),
                         outputFileContent);
        }
Beispiel #15
0
        public override FileModel Load(FileAndType file, ImmutableDictionary <string, object> metadata)
        {
            switch (file.Type)
            {
            case DocumentType.Article:
                var page = YamlUtility.Deserialize <PageViewModel>(Path.Combine(file.BaseDir, file.File));
                if (page.Items == null || page.Items.Count == 0)
                {
                    return(null);
                }
                if (page.Metadata == null)
                {
                    page.Metadata = metadata.ToDictionary(p => p.Key, p => p.Value);
                }
                else
                {
                    foreach (var item in metadata)
                    {
                        if (!page.Metadata.ContainsKey(item.Key))
                        {
                            page.Metadata[item.Key] = item.Value;
                        }
                    }
                }
                var filePath         = Path.Combine(file.BaseDir, file.File);
                var displayLocalPath = filePath.ToDisplayPath();

                object baseDirectory;
                if (metadata.TryGetValue("baseRepositoryDirectory", out baseDirectory))
                {
                    displayLocalPath = PathUtility.MakeRelativePath((string)baseDirectory, filePath);
                }

                return(new FileModel(file, page, serializer: new BinaryFormatter())
                {
                    Uids = (from item in page.Items select new UidDefinition(item.Uid, displayLocalPath)).ToImmutableArray(),

                    Properties =
                    {
                        LinkToFiles = new HashSet <string>(),
                        LinkToUids  = new HashSet <string>(),
                    },
                    LocalPathFromRepoRoot = displayLocalPath,
                });

            case DocumentType.Overwrite:
                // TODO: Refactor current behavior that overwrite file is read multiple times by multiple processors
                return(OverwriteDocumentReader.Read(file));

            default:
                throw new NotSupportedException();
            }
        }
Beispiel #16
0
        private static void MergeToc(MetadataMergeParameters parameters, string outputBase)
        {
            var tocFiles =
                (from f in parameters.Files.EnumerateFiles()
                 where f.Type == DocumentType.Article && "toc.yml".Equals(Path.GetFileName(f.File), StringComparison.OrdinalIgnoreCase)
                 select f).ToList();
            var vm = MergeTocViewModel(
                from f in tocFiles
                select YamlUtility.Deserialize <TocViewModel>(Path.Combine(f.BaseDir, f.File)));

            YamlUtility.Serialize(Path.Combine(outputBase, tocFiles[0].PathRewriter(tocFiles[0].File)), vm);
        }
        protected virtual void Save(object obj, string comment, string fileName)
        {
            if (obj == null || string.IsNullOrEmpty(fileName))
            {
                return;
            }

            var    fullFileName   = fileName + Constants.Constants.YamlExtension;
            string sdpymlfilePath = Path.Combine(StepUtility.GetSDPYmlOutputPath(_outputFolder), fullFileName);

            YamlUtility.Serialize(sdpymlfilePath, obj, comment);
        }
Beispiel #18
0
        private static IEnumerable <string> ResolveAndExportYamlMetadata(
            Dictionary <string, MetadataItem> allMembers,
            Dictionary <string, ReferenceItem> allReferences,
            string folder,
            bool preserveRawInlineComments,
            bool shouldSkipMarkup,
            bool useCompatibilityFileName)
        {
            var outputFileNames = new Dictionary <string, int>(FilePathComparer.OSPlatformSensitiveStringComparer);
            var model           = YamlMetadataResolver.ResolveMetadata(allMembers, allReferences, preserveRawInlineComments);

            var tocFileName = Constants.TocYamlFileName;

            // 0. load last Manifest and remove files
            CleanupHistoricalFile(folder);

            // 1. generate toc.yml
            model.TocYamlViewModel.Type = MemberType.Toc;

            // TOC do not change
            var    tocViewModel = model.TocYamlViewModel.ToTocViewModel();
            string tocFilePath  = Path.Combine(folder, tocFileName);

            YamlUtility.Serialize(tocFilePath, tocViewModel, YamlMime.TableOfContent);
            outputFileNames.Add(tocFilePath, 1);
            yield return(tocFileName);

            ApiReferenceViewModel indexer = new ApiReferenceViewModel();

            // 2. generate each item's yaml
            var members = model.Members;

            foreach (var memberModel in members)
            {
                var    fileName       = useCompatibilityFileName ? memberModel.Name : memberModel.Name.Replace('`', '-');
                var    outputFileName = GetUniqueFileNameWithSuffix(fileName + Constants.YamlExtension, outputFileNames);
                string itemFilePath   = Path.Combine(folder, outputFileName);
                Directory.CreateDirectory(Path.GetDirectoryName(itemFilePath));
                var memberViewModel = memberModel.ToPageViewModel();
                memberViewModel.ShouldSkipMarkup = shouldSkipMarkup;
                YamlUtility.Serialize(itemFilePath, memberViewModel, YamlMime.ManagedReference);
                Logger.Log(LogLevel.Diagnostic, $"Metadata file for {memberModel.Name} is saved to {itemFilePath}.");
                AddMemberToIndexer(memberModel, outputFileName, indexer);
                yield return(outputFileName);
            }

            // 3. generate manifest file
            string indexFilePath = Path.Combine(folder, IndexFileName);

            JsonUtility.Serialize(indexFilePath, indexer, Newtonsoft.Json.Formatting.Indented);
            yield return(IndexFileName);
        }
Beispiel #19
0
        public override FileModel Load(FileAndType file, ImmutableDictionary <string, object> metadata)
        {
            switch (file.Type)
            {
            case DocumentType.Article:
                // TODO: Support dynamic in YAML deserializer
                try
                {
                    // MUST be a dictionary
                    var obj = YamlUtility.Deserialize <Dictionary <string, object> >(file.File);

                    var content      = ConvertToObjectHelper.ConvertToDynamic(obj);
                    var pageMetadata = _schema.MetadataReference.GetValue(content) as IDictionary <string, object>;
                    if (pageMetadata == null)
                    {
                        pageMetadata = new ExpandoObject();
                        _schema.MetadataReference.SetValue(ref content, pageMetadata);
                    }
                    foreach (var pair in metadata)
                    {
                        if (!pageMetadata.ContainsKey(pair.Key))
                        {
                            pageMetadata[pair.Key] = pair.Value;
                        }
                    }

                    var localPathFromRoot = PathUtility.MakeRelativePath(EnvironmentContext.BaseDirectory, EnvironmentContext.FileAbstractLayer.GetPhysicalPath(file.File));

                    var fm = new FileModel(
                        file,
                        content,
                        serializer: new BinaryFormatter())
                    {
                        LocalPathFromRoot = localPathFromRoot,
                    };

                    fm.Properties.Schema   = _schema;
                    fm.Properties.Metadata = pageMetadata;
                    return(fm);
                }
                catch (YamlDotNet.Core.YamlException e)
                {
                    throw new DocumentException($"{file.File} is not in supported format: {e.Message}", e);
                }

            case DocumentType.Overwrite:
                return(OverwriteDocumentReader.Read(file));

            default:
                throw new NotSupportedException();
            }
        }
        public void TestObjectWithStringProperty(string input)
        {
            var sw = new StringWriter();

            YamlUtility.Serialize(sw, new BasicClass {
                C = input
            });
            var yaml  = sw.ToString();
            var value = YamlUtility.Deserialize <BasicClass>(new StringReader(yaml));

            Assert.NotNull(value);
            Assert.Equal(input, value.C);
        }
Beispiel #21
0
        protected static IXRefContainer DownloadFromLocal(Uri uri)
        {
            var filePath = uri.LocalPath;

            if (".zip".Equals(Path.GetExtension(filePath), StringComparison.OrdinalIgnoreCase))
            {
                return(XRefArchive.Open(filePath, XRefArchiveMode.Read));
            }
            using (var sr = File.OpenText(filePath))
            {
                return(YamlUtility.Deserialize <XRefMap>(sr));
            }
        }
        public void SerializeTo(string outputBaseDir)
        {
            YamlUtility.Serialize(Path.Combine(outputBaseDir, ManifestFileName), Manifest);
            YamlUtility.Serialize(Path.Combine(outputBaseDir, FileMapFileName), FileMap);
            if (ExternalXRefSpec == null)
            {
                ExternalXRefSpec = GetExternalXRefSpec();
            }

            YamlUtility.Serialize(Path.Combine(outputBaseDir, ExternalXRefSpecFileName), ExternalXRefSpec.Values);
            YamlUtility.Serialize(Path.Combine(outputBaseDir, InternalXRefSpecFileName), XRefSpecMap.Values);
            YamlUtility.Serialize(Path.Combine(outputBaseDir, TocFileName), TocMap);
        }
Beispiel #23
0
        private TocViewModel LoadSingleToc(string filePath)
        {
            if ("toc.md".Equals(Path.GetFileName(filePath), StringComparison.OrdinalIgnoreCase))
            {
                return(MarkdownTocReader.LoadToc(File.ReadAllText(filePath), filePath));
            }
            else if ("toc.yml".Equals(Path.GetFileName(filePath), StringComparison.OrdinalIgnoreCase))
            {
                return(YamlUtility.Deserialize <TocViewModel>(filePath));
            }

            throw new NotSupportedException($"{filePath} is not a valid TOC file, supported toc files could be \"toc.md\" or \"toc.yml\".");
        }
Beispiel #24
0
        public void TestMetadataCommandFromCSProjectWithFilterInOption()
        {
            // Create default project
            var projectFile = Path.Combine(_projectFolder, "test.csproj");
            var sourceFile  = Path.Combine(_projectFolder, "test.cs");
            var filterFile  = Path.Combine(_projectFolder, "filter.yaml");

            File.Copy("Assets/test.csproj.sample.1", projectFile);
            File.Copy("Assets/test.cs.sample.1", sourceFile);
            File.Copy("Assets/filter.yaml.sample", filterFile);

            new MetadataCommand(new MetadataCommandOptions
            {
                OutputFolder = Path.Combine(Directory.GetCurrentDirectory(), _outputFolder),
                Projects     = new List <string> {
                    projectFile
                },
                FilterConfigFile = filterFile,
            }).Exec(null);

            Assert.True(File.Exists(Path.Combine(_outputFolder, ".manifest")));

            var file = Path.Combine(_outputFolder, "toc.yml");

            Assert.True(File.Exists(file));
            var tocViewModel = YamlUtility.Deserialize <TocViewModel>(file);

            Assert.Equal("Foo", tocViewModel[0].Uid);
            Assert.Equal("Foo", tocViewModel[0].Name);
            Assert.Equal("Foo.Bar", tocViewModel[0].Items[0].Uid);
            Assert.Equal("Bar", tocViewModel[0].Items[0].Name);

            file = Path.Combine(_outputFolder, "Foo.yml");
            Assert.True(File.Exists(file));
            var memberViewModel = YamlUtility.Deserialize <PageViewModel>(file);

            Assert.Equal("Foo", memberViewModel.Items[0].Uid);
            Assert.Equal("Foo", memberViewModel.Items[0].Id);
            Assert.Equal("Foo", memberViewModel.Items[0].Name);
            Assert.Equal("Foo", memberViewModel.Items[0].FullName);

            file = Path.Combine(_outputFolder, "Foo.Bar.yml");
            Assert.True(File.Exists(file));
            memberViewModel = YamlUtility.Deserialize <PageViewModel>(file);
            Assert.Equal("Foo.Bar", memberViewModel.Items[0].Uid);
            Assert.Equal("Bar", memberViewModel.Items[0].Id);
            Assert.Equal("Bar", memberViewModel.Items[0].Name);
            Assert.Equal("Foo.Bar", memberViewModel.Items[0].FullName);
            Assert.Equal(1, memberViewModel.Items.Count);
            Assert.NotNull(memberViewModel.References.Find(s => s.Uid.Equals("Foo")));
        }
Beispiel #25
0
        private static void ProcessFilePair(string ymlInputFile, string ymlOutputFile, string mdFile, Dictionary <string, DocumentSchema> schemas)
        {
            var yamlStream = new YamlStream();

            using (var sr = new StreamReader(ymlInputFile))
            {
                yamlStream.Load(sr);
            }
            if (yamlStream.Documents.Count != 1)
            {
                throw new NotSupportedException("Does not support mutiple YAML documents");
            }

            var mime       = YamlMime.ReadMime(ymlInputFile);
            var schemaName = mime.Substring(YamlMime.YamlMimePrefix.Length);

            if (!schemas.ContainsKey(schemaName))
            {
                Console.WriteLine("Schema {0} not found", schemaName);
                return;
            }
            var schema = schemas[schemaName];

            var mdFragments = FragmentModelHelper.LoadMarkdownFragment(mdFile);

            Traverse(yamlStream.Documents[0].RootNode, mdFragments, schema);

            var validFragments = mdFragments.Values.Where(v => v.Properties?.Count > 0).ToList();

            if (validFragments.Count > 0)
            {
                StringBuilder sb = new StringBuilder();
                foreach (var fragment in validFragments)
                {
                    sb.AppendLine(fragment.ToString());
                }
                var mdFolder = Path.GetDirectoryName(mdFile);
                if (!Directory.Exists(mdFolder))
                {
                    Directory.CreateDirectory(mdFolder);
                }
                File.WriteAllText(mdFile, sb.ToString());

                var ymlFolder = Path.GetDirectoryName(ymlOutputFile);
                if (!Directory.Exists(ymlFolder))
                {
                    Directory.CreateDirectory(ymlFolder);
                }
                YamlUtility.Serialize(ymlOutputFile, yamlStream.Documents[0].RootNode, mime);
            }
        }
Beispiel #26
0
 private async Task <IActionResult> Upload(string url)
 {
     using (var client = new WebClient())
     {
         using (var stream = await client.OpenReadTaskAsync(url))
         {
             using (var sr = new StreamReader(stream))
             {
                 var xm = YamlUtility.Deserialize <XRefMap>(sr);
                 return(await AddXrefs(xm?.References));
             }
         }
     }
 }
        public void ProcessMrefWithMergeOverwriteProcessorShouldSucceed()
        {
            var files = new FileCollection(Directory.GetCurrentDirectory());

            files.Add(DocumentType.Article, new[] { "TestData/mref/CatLibrary.Cat-2.yml" }, "TestData/");
            files.Add(DocumentType.Overwrite, new[]
            {
                "TestData/overwrite/mref.overwrite.default.md",
                "TestData/overwrite/mref.overwrite.simple.md",
            });

            var outputDir = GetRandomFolder();

            var parameters = new DocumentBuildParameters
            {
                Files                 = files,
                OutputBaseDir         = outputDir,
                MarkdownEngineName    = "momd",
                ApplyTemplateSettings = new ApplyTemplateSettings("", outputDir),
            };

            var assemblies = new[]
            {
                typeof(ManagedReferenceDocumentProcessor).Assembly,
                typeof(MergeMrefOverwriteDocumentProcessor).Assembly,
            };

            using (var builder = new DocumentBuilder(assemblies, ImmutableArray <string> .Empty, null))
            {
                builder.Build(parameters);
            }

            var yaml = YamlUtility.Deserialize <PageViewModel>(Path.Combine(outputDir, "mref/CatLibrary.Cat-2.yml"));

            Assert.Collection(
                yaml.Items.Where(item => item.Uid == "CatLibrary.Cat`2.#ctor"),
                e =>
            {
                Assert.Equal("Overwrite *markdown* summary\n\n", e.Summary);
                Assert.Equal("Overwrite *markdown* content\n\n", e.Conceptual);
            });

            Assert.Collection(
                yaml.Items.Where(item => item.Uid == "CatLibrary.Cat`2"),
                e =>
            {
                Assert.Equal("Overwrite <b>html</b> content\n\n", e.Summary);
                Assert.Equal("original conceptual", e.Conceptual);
            });
        }
Beispiel #28
0
 protected void FillImplementsOrInherits(ArticleItemYaml yaml, XElement node)
 {
     foreach (var basenode in node.Elements("basecompoundref"))
     {
         string refId = basenode.NullableAttribute("refid").NullableValue();
         string specializedFullName = YamlUtility.RegularizeName(basenode.NullableValue(), Constants.Dot);
         if (refId != null)
         {
             yaml.ImplementsOrInherits.Add(new SpecializedType {
                 Type = refId, SpecializedFullName = specializedFullName
             });
         }
     }
 }
Beispiel #29
0
        static void Main(string[] args)
        {
            var items = new List <TocItemViewModel>();

            foreach (var file in args)
            {
                var toc = YamlUtility.Deserialize <TocViewModel>(file);
                items.AddRange(toc);
            }
            var combined = new TocViewModel();

            combined.AddRange(items.OrderBy(item => item.Name));
            YamlUtility.Serialize(Console.Out, combined, "YamlMime:TableOfContent");
        }
Beispiel #30
0
        private void CheckResult()
        {
            Assert.True(File.Exists(Path.Combine(_outputFolder, ".manifest")));

            var file = Path.Combine(_outputFolder, "toc.yml");

            Assert.True(File.Exists(file));
            var tocViewModel = YamlUtility.Deserialize <TocViewModel>(file);

            Assert.Equal("Foo", tocViewModel[0].Uid);
            Assert.Equal("Foo", tocViewModel[0].Name);
            Assert.Equal("Foo.Bar", tocViewModel[0].Items[0].Uid);
            Assert.Equal("Bar", tocViewModel[0].Items[0].Name);

            file = Path.Combine(_outputFolder, "Foo.yml");
            Assert.True(File.Exists(file));
            var memberViewModel = YamlUtility.Deserialize <PageViewModel>(file);

            Assert.Equal("Foo", memberViewModel.Items[0].Uid);
            Assert.Equal("Foo", memberViewModel.Items[0].Id);
            Assert.Equal("Foo", memberViewModel.Items[0].Name);
            Assert.Equal("Foo", memberViewModel.Items[0].FullName);

            file = Path.Combine(_outputFolder, "Foo.Bar.yml");
            Assert.True(File.Exists(file));
            memberViewModel = YamlUtility.Deserialize <PageViewModel>(file);
            Assert.Equal("Foo.Bar", memberViewModel.Items[0].Uid);
            Assert.Equal("Bar", memberViewModel.Items[0].Id);
            Assert.Equal("Bar", memberViewModel.Items[0].Name);
            Assert.Equal("Foo.Bar", memberViewModel.Items[0].FullName);
            Assert.Equal("Foo.Bar.FooBar``1(System.Int32[],System.Byte*,``0,System.Collections.Generic.List{``0[]})", memberViewModel.Items[1].Uid);
            Assert.Equal("FooBar``1(System.Int32[],System.Byte*,``0,System.Collections.Generic.List{``0[]})", memberViewModel.Items[1].Id);
            Assert.Equal("FooBar<TArg>(Int32[], Byte*, TArg, List<TArg[]>)", memberViewModel.Items[1].Name);
            Assert.Equal("Foo.Bar.FooBar<TArg>(System.Int32[], System.Byte*, TArg, System.Collections.Generic.List<TArg[]>)", memberViewModel.Items[1].FullName);
            Assert.NotNull(memberViewModel.References.Find(
                               s => s.Uid.Equals("System.Collections.Generic.List{System.String}")
                               ));
            Assert.NotNull(memberViewModel.References.Find(
                               s => s.Uid.Equals("System.Int32[]")
                               ));
            Assert.NotNull(memberViewModel.References.Find(
                               s => s.Uid.Equals("System.Byte*")
                               ));
            Assert.NotNull(memberViewModel.References.Find(
                               s => s.Uid.Equals("{TArg}")
                               ));
            Assert.NotNull(memberViewModel.References.Find(
                               s => s.Uid.Equals("System.Collections.Generic.List{{TArg}[]}")
                               ));
        }