Class: Metanorma::Cli::SiteGenerator
- Inherits:
-
Object
- Object
- Metanorma::Cli::SiteGenerator
- Defined in:
- lib/metanorma/cli/site_generator.rb
Class Method Summary collapse
Instance Method Summary collapse
- #generate ⇒ Object
-
#initialize(source, options = {}, compile_options = {}) ⇒ SiteGenerator
constructor
A new instance of SiteGenerator.
Constructor Details
#initialize(source, options = {}, compile_options = {}) ⇒ SiteGenerator
Returns a new instance of SiteGenerator.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/metanorma/cli/site_generator.rb', line 8 def initialize(source, = {}, = {}) @collection_queue = [] @source = find_realpath(source) @site_path = .fetch( :output_dir, Commands::Site::SITE_OUTPUT_DIRNAME ).to_s @asset_folder = .fetch(:asset_folder, "documents").to_s @collection_name = .fetch(:collection_name, "documents.xml") @manifest_file = find_realpath(.fetch(:config, default_config)) @template_dir = .fetch(:template_dir, template_data("path")) @stylesheet = .fetch(:stylesheet, template_data("stylesheet")) @compile_options = ensure_site_asset_directory! end |
Class Method Details
.generate(source, options = {}, compile_options = {}) ⇒ Object
25 26 27 |
# File 'lib/metanorma/cli/site_generator.rb', line 25 def self.generate(source, = {}, = {}) new(source, , ).generate end |
Instance Method Details
#generate ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/metanorma/cli/site_generator.rb', line 29 def generate site_directory = asset_directory.join("..") fatals = select_source_files.map { |source| compile(source) } .flatten .compact raise Errors::FatalCompilationError, fatals unless fatals.empty? Dir.chdir(site_directory) do build_collection_file(collection_name) convert_to_html_page(collection_name, "index.html") end dequeue_jobs end |