ResolveMetadata() 공개 정적인 메소드

TODO: input Namespace list instead; TODO: Save to ...yml.map
public static ResolveMetadata ( MetadataItem>.Dictionary allMembers, ReferenceItem>.Dictionary allReferences, string apiFolder, bool preserveRawInlineComments, IEnumerable externalReferencePackages ) : MetadataModel
allMembers MetadataItem>.Dictionary
allReferences ReferenceItem>.Dictionary
apiFolder string
preserveRawInlineComments bool
externalReferencePackages IEnumerable
리턴 MetadataModel
예제 #1
0
        private static IList <string> ResolveAndExportYamlMetadata(
            Dictionary <string, MetadataItem> allMembers,
            Dictionary <string, ReferenceItem> allReferences,
            string folder,
            string indexFileName,
            string tocFileName,
            string apiFolder,
            bool preserveRawInlineComments,
            bool shouldSkipMarkup,
            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();
                memberViewModel.ShouldSkipMarkup = shouldSkipMarkup;
                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);
        }
예제 #2
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);
        }