public void Exec(SubCommandRunningContext context) { EnvironmentContext.SetBaseDirectory(Path.GetFullPath(string.IsNullOrEmpty(_config.BaseDirectory) ? Directory.GetCurrentDirectory() : _config.BaseDirectory)); // TODO: remove BaseDirectory from Config, it may cause potential issue when abused var baseDirectory = EnvironmentContext.BaseDirectory; var outputFolder = Path.GetFullPath(Path.Combine(string.IsNullOrEmpty(_config.OutputFolder) ? baseDirectory : _config.OutputFolder, _config.Destination ?? string.Empty)); var rawOutputFolder = string.IsNullOrEmpty(_config.RawOutputFolder) ? Path.Combine(outputFolder, "_raw") : _config.RawOutputFolder; var options = new PdfOptions { BasePath = _config.BasePath, CssFilePath = _config.CssFilePath, DestDirectory = outputFolder, Host = _config.Host, Locale = _config.Locale, NeedGeneratePdfExternalLink = _config.GeneratesExternalLink, GenerateAppendices = _config.GeneratesAppendices, PdfConvertParallelism = _config.MaxParallelism == null || _config.MaxParallelism <= 0 ? Environment.ProcessorCount : _config.MaxParallelism.Value, PdfDocsetName = _config.Name ?? Path.GetFileName(EnvironmentContext.BaseDirectory), SourceDirectory = Path.Combine(rawOutputFolder, _config.Destination ?? string.Empty), ExcludeTocs = _config.ExcludedTocs?.ToArray(), KeepRawFiles = _config.KeepRawFiles, ExcludeDefaultToc = _config.ExcludeDefaultToc, LoadErrorHandling = _config.LoadErrorHandling, FilePath = _wkhtmltopdfFilePath, AdditionalPdfCommandArgs = _config.Wkhtmltopdf?.AdditionalArguments, TocTitle = _config.TocTitle, OutlineOption = _config.OutlineOption, CoverPageTitle = _config.CoverPageTitle, NoInputStreamArgs = _config.NoInputStreamArgs, }; // 1. call BuildCommand to generate html files first // Output build command exec result to temp folder _innerBuildCommand.Config.OutputFolder = rawOutputFolder; _innerBuildCommand.Exec(context); // 2. call html2pdf converter var converter = new ConvertWrapper(options); try { using (new LoggerPhaseScope("PDF", LogLevel.Info)) { Logger.LogInfo("Start generating PDF files..."); converter.Convert(); } } catch (IOException ioe) { throw new DocfxException(ioe.Message, ioe); } // 3. Should we delete generated files according to manifest }
public RideEffortsV2 ToRideEfforts() { var rideEffort = new RideEffortsV2 { RideId = ConvertWrapper.ToInt32(Id), Version = Version, Efforts = new List <EffortSegmentV2>() }; if (Efforts != null) { Efforts.Each(effort => rideEffort.Efforts.Add(effort.ToEffortSegment())); } return(rideEffort); }
public void Exec(SubCommandRunningContext context) { EnvironmentContext.SetBaseDirectory(Path.GetFullPath(string.IsNullOrEmpty(_config.BaseDirectory) ? Directory.GetCurrentDirectory() : _config.BaseDirectory)); // TODO: remove BaseDirectory from Config, it may cause potential issue when abused var baseDirectory = EnvironmentContext.BaseDirectory; var intermediateOutputFolder = Path.Combine(baseDirectory, "obj"); var outputFolder = Path.GetFullPath(Path.Combine(string.IsNullOrEmpty(_config.OutputFolder) ? baseDirectory : _config.OutputFolder, _config.Destination ?? string.Empty)); var options = new PdfOptions { BasePath = _config.BasePath, CssFilePath = _config.CssFilePath, DestDirectory = outputFolder, Host = _config.Host, Locale = _config.Locale, NeedGeneratePdfExternalLink = _config.GeneratesExternalLink, GenerateAppendices = _config.GeneratesAppendices, PdfConvertParallelism = _config.MaxParallelism == null || _config.MaxParallelism <= 0 ? Environment.ProcessorCount : _config.MaxParallelism.Value, PdfDocsetName = _config.Name ?? Path.GetFileName(EnvironmentContext.BaseDirectory), SourceDirectory = outputFolder, ExcludeTocs = _config.ExcludedTocs?.ToArray(), }; // 1. call BuildCommand to generate html files first _innerBuildCommand.Exec(context); // 2. call html2pdf converter var converter = new ConvertWrapper(options); try { using (new LoggerPhaseScope("PDF", LogLevel.Info)) { Logger.LogInfo("Start generating PDF files..."); converter.Convert(); } } catch (IOException ioe) { throw new DocfxException(ioe.Message, ioe); } // 3. Should we delete generated files according to manifest }
public PdfCommand(PdfCommandOptions options) { ConvertWrapper.PrerequisiteCheck(); _config = ParseOptions(options); if (_config.Serve == true) { Logger.LogWarning("--serve is not supported in pdf command, ignored"); _config.Serve = false; } if (_config.Templates == null || _config.Templates.Count == 0) { _config.Templates = new ListWithStringFallback(new List <string> { "pdf.default" }); } _innerBuildCommand = new BuildCommand(_config); }
public MapDetailV2 ToMapDetail() { var map = new MapDetailV2 { RideId = ConvertWrapper.ToInt32(Id), Version = Version, Coordinates = new List <Coordinate>() }; if (Coordinates != null) { Coordinates.Each(pair => { if (pair.Count == 2) { map.Coordinates.Add(new Coordinate { Latitude = pair[0], Longitude = pair[1] }); } }); } return(map); }