public SystemMetadataGenerator(IDocumentBuildContext context)
        {
            _context = context ?? throw new ArgumentNullException(nameof(context));

            // Order toc files by the output folder depth
            _toc = context.GetTocInfo()
                   .Select(s => new FileInfo(s.TocFileKey, context.GetFilePath(s.TocFileKey)))
                   .Where(s => s.RelativePath != null)
                   .OrderBy(s => s.RelativePath.SubdirectoryCount);
        }
예제 #2
0
        public SystemMetadataGenerator(IDocumentBuildContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            _context = context;

            // Order toc files by the output folder depth
            _toc = context.GetTocInfo()
                .Select(s => new FileInfo(s.TocFileKey, (RelativePath)context.GetFilePath(s.TocFileKey)))
                .Where(s => s.File != null)
                .OrderBy(s => s.File.SubdirectoryCount);
        }
예제 #3
0
        private static void SaveManifest(List <TemplateManifestItem> templateManifest, string outputDirectory, IDocumentBuildContext context)
        {
            // Save manifest from template
            // TODO: Keep .manifest for backward-compatability, will remove next sprint
            var manifestPath = Path.Combine(outputDirectory ?? string.Empty, Constants.ObsoleteManifestFileName);

            JsonUtility.Serialize(manifestPath, templateManifest);
            // Logger.LogInfo($"Manifest file saved to {manifestPath}. NOTE: This file is out-of-date and will be removed in version 1.8, if you rely on this file, please change to use {Constants.ManifestFileName} instead.");

            var manifestJsonPath = Path.Combine(outputDirectory ?? string.Empty, Constants.ManifestFileName);

            var toc            = context.GetTocInfo();
            var manifestObject = GenerateManifest(context, templateManifest);

            JsonUtility.Serialize(manifestJsonPath, manifestObject);
            Logger.LogInfo($"Manifest file saved to {manifestJsonPath}.");
        }
예제 #4
0
        private static Manifest GenerateManifest(IDocumentBuildContext context, List <TemplateManifestItem> items)
        {
            var toc       = context.GetTocInfo();
            var homepages = toc
                            .Where(s => !string.IsNullOrEmpty(s.Homepage))
                            .Select(s => new HomepageInfo
            {
                Homepage = RelativePath.GetPathWithoutWorkingFolderChar(s.Homepage),
                TocPath  = RelativePath.GetPathWithoutWorkingFolderChar(context.GetFilePath(s.TocFileKey))
            }).ToList();

            return(new Manifest
            {
                Homepages = homepages,
                Files = items,
            });
        }