示例#1
0
        public static bool GenerateSummaryFile(string workDir, Config configuration, ILog log)
        {
            FsPath source = new FsPath(workDir, ".chapters");

            if (source.IsExisting)
            {
                log.Info(".chapters file doesn't exist.");
                return(false);
            }

            StringBuilder buffer = new StringBuilder();

            List <Chapter>?chapters = source.DeserializeYaml <List <Chapter> >(log);

            if (chapters == null)
            {
                log.Detail(".chapters file reading failed. Bad markup?");
                return(false);
            }

            ConvertChaptersToMarkdown(workDir, log, buffer, chapters);

            FsPath destination = new FsPath(workDir, configuration.TOCFile);

            if (destination.IsExisting)
            {
                destination.CreateBackup(log);
            }
            destination.WriteFile(log, buffer.ToString());

            return(true);
        }