Class: Metanorma::Cli::Commands::Site

Inherits:
ThorWithConfig show all
Defined in:
lib/metanorma/cli/commands/site.rb

Constant Summary collapse

SITE_OUTPUT_DIRNAME =
"_site"

Instance Method Summary collapse

Instance Method Details

#generate(manifest_path = nil) ⇒ Object

If no argument is provided, work out the base path to use for calculation of full paths for files referenced in the site manifest.

Additionally, if the config file is not provided, use the current working directory as the base path. If the config file is provided, use the directory of the config file as the base path.

If the source path is a file and no config file is provided, treat the source path as the config file. Similar to the above, use the directory of the config file as the base path.

For stylesheet and template_dir options, and if they are relative paths, they will be resolved relative to whatever defined them.

So, if they are provided via the command line, resolve them relative to the current working directory. If they are provided via the site manifest, resolve them relative to the site manifest’s directory.



83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/metanorma/cli/commands/site.rb', line 83

def generate(manifest_path = nil)
  my_options = options.dup # because options is not modifiable

  base_path = calculate_base_path!(my_options, manifest_path).realpath

  calculate_full_paths!(my_options)

  Cli::SiteGenerator.generate!(
    base_path,
    my_options,
    filter_compile_options(my_options),
  )
  UI.say("Site has been generated at #{options[:output_dir]}")
rescue Cli::Errors::InvalidManifestFileError
  UI.error("Invalid data in: #{options[:config]}")
end