Class: Metanorma::Cli::SiteGenerator
- Inherits:
-
Object
- Object
- Metanorma::Cli::SiteGenerator
- Defined in:
- lib/metanorma/cli/site_generator.rb
Constant Summary collapse
- DEFAULT_RELATON_COLLECTION_INDEX =
"documents.xml"
- DEFAULT_ASSET_FOLDER =
"documents"
- DEFAULT_SITE_INDEX =
"index.html"
- DEFAULT_CONFIG_FILE =
"metanorma.yml"
Class Method Summary collapse
-
.generate!(source, options = {}, compile_options = {}) ⇒ Object
rubocop:enable Metrics/AbcSize.
Instance Method Summary collapse
- #generate! ⇒ Object
-
#initialize(source_path, options = {}, compile_options = {}) ⇒ SiteGenerator
constructor
rubocop:disable Metrics/AbcSize.
Constructor Details
#initialize(source_path, options = {}, compile_options = {}) ⇒ SiteGenerator
rubocop:disable Metrics/AbcSize
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/metanorma/cli/site_generator.rb', line 16 def initialize(source_path, = {}, = {}) @collection_queue = [] @source_path = find_realpath(source_path) @site_path = Pathname.new( .fetch(:output_dir, Commands::Site::SITE_OUTPUT_DIRNAME), ) @asset_folder = .fetch(:asset_folder, DEFAULT_ASSET_FOLDER).to_s @relaton_collection_index = .fetch( :collection_name, DEFAULT_RELATON_COLLECTION_INDEX, ) @manifest_file = find_realpath(.fetch(:config, default_config)) @template_dir = .fetch(:template_dir, template_data("path")) @stylesheet = .fetch(:stylesheet, template_data("stylesheet")) @output_filename_template = .fetch( :output_filename_template, template_data("output_filename"), ) # Determine base path for stylesheet & template files # If the file path is relative, it is relative to the directory # containing the site manifest file. # If site manifest file is not provided, then it is relative to the # current directory. @base_path = if manifest_file.nil? Pathname.pwd else Pathname.new(manifest_file).parent end @compile_options = end |
Class Method Details
.generate!(source, options = {}, compile_options = {}) ⇒ Object
rubocop:enable Metrics/AbcSize
52 53 54 |
# File 'lib/metanorma/cli/site_generator.rb', line 52 def self.generate!(source, = {}, = {}) new(source, , ).generate! end |
Instance Method Details
#generate! ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/metanorma/cli/site_generator.rb', line 56 def generate! ensure_site_asset_directory! # compile individual document files compile_files!(select_source_files) site_directory = asset_directory.parent # actually compile collection file(s) compile_collections! Dir.chdir(site_directory) do build_collection_file!(relaton_collection_index) convert_to_html_page!(relaton_collection_index, DEFAULT_SITE_INDEX) end end |