Represents a document index configuration.
示例#1
0
        /// <summary>
        /// Initializes a new instance of <see cref="ProjbookEngine"/>.
        /// </summary>
        /// <param name="fileSystem">Initializes the required file system abstraction.</param>
        /// <param name="extensionPath">Initializes the required extension path.</param>
        /// <param name="csprojFile">Initializes the required <see cref="CsprojFile"/>.</param>
        /// <param name="indexConfiguration">Initializes the required <see cref="IndexConfiguration"/>.</param>
        /// <param name="outputDirectoryPath">Initializes the required <see cref="OutputDirectory"/>.</param>
        /// <param name="skipPdf">Initializes the required <see cref="SkipPdf"/>.</param>
        public ProjbookEngine(IFileSystem fileSystem, string csprojFile, string extensionPath, IndexConfiguration indexConfiguration, string outputDirectoryPath, bool skipPdf)
        {
            // Data validation
            Ensure.That(() => fileSystem).IsNotNull();
            Ensure.That(() => csprojFile).IsNotNullOrWhiteSpace();
            Ensure.That(() => indexConfiguration).IsNotNull();
            Ensure.That(() => indexConfiguration.Configurations).HasItems();
            Ensure.That(() => outputDirectoryPath).IsNotNullOrWhiteSpace();
            Ensure.That(fileSystem.File.Exists(csprojFile), string.Format("Could not find '{0}' file", csprojFile)).IsTrue();

            // Initialize
            this.fileSystem = fileSystem;
            this.CsprojFile = this.fileSystem.FileInfo.FromFileName(csprojFile);
            this.IndexConfiguration = indexConfiguration;
            this.OutputDirectory = this.fileSystem.DirectoryInfo.FromDirectoryName(outputDirectoryPath);
            this.snippetExtractorFactory = new SnippetExtractorFactory(this.fileSystem.DirectoryInfo.FromDirectoryName(this.fileSystem.Path.GetFullPath(extensionPath)));
            this.SkipPdf = skipPdf;
        }
示例#2
0
 /// <summary>
 /// Generates the index file.
 /// </summary>
 /// <param name="templateName">The template name.</param>
 /// <param name="outputFileHtml">The file to output to.</param>
 /// <param name="indexConfiguration">The index configuration.</param>
 private void GenerateIndexFile(string templateName, string outputFileHtml, IndexConfiguration indexConfiguration)
 {
     // Generate the index html for the configurations using Razor
     var fileConfiguration = new { IndexConfiguration = indexConfiguration };
     this.WriteFile(templateName, outputFileHtml, fileConfiguration);
 }
示例#3
0
        /// <summary>
        /// Generates the index page for the documentation.
        /// </summary>
        /// <param name="indexConfiguration">The index configuration.</param>
        /// <returns>The generation errors.</returns>
        public GenerationError[] GenerateIndex(IndexConfiguration indexConfiguration)
        {
            // Data validation
            Ensure.That(() => indexConfiguration).IsNotNull();

            // Try to generate the index html file
            List<GenerationError> generationError = new List<GenerationError>();
            try
            {
                string outputFileHtml = this.fileSystem.Path.Combine(this.OutputDirectory.FullName, indexConfiguration.Output);
                this.GenerateIndexFile(indexConfiguration.Template, outputFileHtml, indexConfiguration);
            }
            catch (TemplateParsingException templateParsingException)
            {
                generationError.Add(new Model.GenerationError(indexConfiguration.Template, string.Format("Error during HTML generation: {0}", templateParsingException.Message), templateParsingException.Line, templateParsingException.Column));
            }
            catch (System.Exception exception)
            {
                generationError.Add(new Model.GenerationError(indexConfiguration.Template, string.Format("Error during HTML generation: {0}", exception.Message), 0, 0));
            }

            // Return generation errors
            return generationError.ToArray();
        }