metanorma-cli 1.12.3 → 1.12.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/metanorma/cli/collection.rb +18 -14
- data/lib/metanorma/cli/commands/site.rb +81 -9
- data/lib/metanorma/cli/site_generator.rb +183 -59
- data/lib/metanorma/cli/version.rb +1 -1
- data/metanorma-cli.gemspec +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 838952cee69c23736d7547e92a620e72a827197a29a30e1ea1836f234ed04d82
|
4
|
+
data.tar.gz: 74374105306969e0ad2ef4cb50463f56a10cafb783e7aeaa9e7c1c833ed593a2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4c0ab5db08eaf4d709d9f20c18e690b7eeab0997bd188122f514b022063a94d58454a6d5b06ae8018564724b35dc43a65862057c2fb83723588bd204b6eb5db4
|
7
|
+
data.tar.gz: 03a01f8b46739e421fb458a05ce48e11970535afc921990489edd3b7f6b4c5a1bcff61f4a3149229040e2718bba608576275d2974081e8036869707896c6dd54
|
@@ -3,6 +3,8 @@ require "yaml"
|
|
3
3
|
module Metanorma
|
4
4
|
module Cli
|
5
5
|
class Collection
|
6
|
+
attr_reader :file, :options
|
7
|
+
|
6
8
|
def initialize(file, options)
|
7
9
|
@file = file
|
8
10
|
@options = Cli.with_indifferent_access(options)
|
@@ -17,26 +19,26 @@ module Metanorma
|
|
17
19
|
def render
|
18
20
|
extract_options_from_file
|
19
21
|
collection_file.render(collection_options.compact)
|
22
|
+
self
|
20
23
|
end
|
21
24
|
|
22
|
-
private
|
23
|
-
|
24
|
-
attr_reader :file, :options
|
25
|
-
|
26
25
|
def collection_file
|
27
26
|
@collection_file ||= Metanorma::Collection.parse(file)
|
28
27
|
end
|
29
28
|
|
29
|
+
private
|
30
|
+
|
30
31
|
def source_folder
|
31
|
-
@source_folder ||=
|
32
|
+
@source_folder ||= Pathname.new(file).realpath.parent
|
32
33
|
end
|
33
34
|
|
34
35
|
def collection_options
|
35
36
|
@collection_options ||= {
|
36
37
|
compile: @compile_options,
|
37
38
|
output_folder: build_output_folder,
|
38
|
-
coverpage:
|
39
|
-
format: collection_output_formats(
|
39
|
+
coverpage: options.fetch(:coverpage, nil),
|
40
|
+
format: collection_output_formats(options.fetch(:format, "")),
|
41
|
+
site_generate: options["site_generate"],
|
40
42
|
}
|
41
43
|
end
|
42
44
|
|
@@ -44,9 +46,11 @@ module Metanorma
|
|
44
46
|
output_folder = options.fetch(:output_folder, nil)
|
45
47
|
|
46
48
|
if output_folder && @output_dir
|
47
|
-
@output_dir.join(output_folder)
|
49
|
+
@output_dir.join(output_folder)
|
50
|
+
elsif output_folder
|
51
|
+
Pathname.new(output_folder)
|
48
52
|
else
|
49
|
-
|
53
|
+
source_folder
|
50
54
|
end
|
51
55
|
end
|
52
56
|
|
@@ -59,13 +63,13 @@ module Metanorma
|
|
59
63
|
end
|
60
64
|
|
61
65
|
def extract_options_from_file
|
62
|
-
yaml_file = if /\.ya?ml$/.match?(
|
63
|
-
YAML.safe_load(File.read(
|
64
|
-
elsif /\.xml$/.match?(
|
66
|
+
yaml_file = if /\.ya?ml$/.match?(file.to_s)
|
67
|
+
YAML.safe_load(File.read(file.to_s))
|
68
|
+
elsif /\.xml$/.match?(file.to_s)
|
65
69
|
xml_extract_options_from_file
|
66
70
|
end
|
67
71
|
|
68
|
-
old = options.dup
|
72
|
+
old = @options.dup
|
69
73
|
@options = Cli.with_indifferent_access(
|
70
74
|
yaml_file.slice("coverpage", "format", "output_folder"),
|
71
75
|
)
|
@@ -73,7 +77,7 @@ module Metanorma
|
|
73
77
|
end
|
74
78
|
|
75
79
|
def xml_extract_options_from_file
|
76
|
-
xml = Nokogiri::XML File.read(
|
80
|
+
xml = Nokogiri::XML File.read(file.to_s, encoding: "UTF-8", &:huge)
|
77
81
|
{ "coverpage" => xml.at("//coverpage"),
|
78
82
|
"format" => xml.at("//format"),
|
79
83
|
"output_folder" => xml.at("//output_folder") }.compact
|
@@ -10,14 +10,16 @@ module Metanorma
|
|
10
10
|
class Site < ThorWithConfig
|
11
11
|
SITE_OUTPUT_DIRNAME = "_site"
|
12
12
|
|
13
|
-
desc "generate [
|
13
|
+
desc "generate [SITE_MANIFEST_PATH]", "Generate site from collection"
|
14
14
|
option :config,
|
15
15
|
aliases: "-c",
|
16
|
-
desc: "Metanorma configuration file"
|
16
|
+
desc: "Metanorma configuration file " \
|
17
|
+
"(deprecated: use the first argument of " \
|
18
|
+
"the command instead)"
|
17
19
|
|
18
20
|
option :output_dir,
|
19
21
|
aliases: "-o",
|
20
|
-
default: Pathname.
|
22
|
+
default: Pathname.pwd.join(SITE_OUTPUT_DIRNAME).to_s,
|
21
23
|
desc: "Output directory for generated site"
|
22
24
|
|
23
25
|
option :output_filename_template,
|
@@ -41,27 +43,97 @@ module Metanorma
|
|
41
43
|
|
42
44
|
option :stylesheet,
|
43
45
|
aliases: "-s",
|
44
|
-
desc: "Stylesheet file path
|
46
|
+
desc: "Stylesheet file path " \
|
47
|
+
"(relative to the current working directory) " \
|
48
|
+
"for rendering HTML page"
|
45
49
|
|
46
50
|
option :template_dir,
|
47
51
|
aliases: "-t",
|
48
|
-
desc: "Liquid template directory
|
52
|
+
desc: "Liquid template directory " \
|
53
|
+
"(relative to the current working directory) " \
|
54
|
+
"to render site design"
|
49
55
|
|
50
56
|
option :strict,
|
51
57
|
aliases: "-S",
|
52
58
|
type: :boolean,
|
53
59
|
desc: "Strict compilation: abort if there are any errors"
|
54
60
|
|
55
|
-
|
61
|
+
# If no argument is provided, work out the base
|
62
|
+
# path to use for calculation of full paths for
|
63
|
+
# files referenced in the site manifest.
|
64
|
+
#
|
65
|
+
# Additionally, if the config file is not provided,
|
66
|
+
# use the current working directory as the base path.
|
67
|
+
# If the config file is provided, use the directory
|
68
|
+
# of the config file as the base path.
|
69
|
+
#
|
70
|
+
# If the source path is a file and no config file is provided,
|
71
|
+
# treat the source path as the config file.
|
72
|
+
# Similar to the above, use the directory of the config file
|
73
|
+
# as the base path.
|
74
|
+
#
|
75
|
+
# For stylesheet and template_dir options, and if they are
|
76
|
+
# relative paths, they will be resolved relative to whatever
|
77
|
+
# defined them.
|
78
|
+
#
|
79
|
+
# So, if they are provided via the command line,
|
80
|
+
# resolve them relative to the current working directory.
|
81
|
+
# If they are provided via the site manifest,
|
82
|
+
# resolve them relative to the site manifest's directory.
|
83
|
+
def generate(manifest_path = nil)
|
84
|
+
my_options = options.dup # because options is not modifiable
|
85
|
+
|
86
|
+
base_path = calculate_base_path!(my_options, manifest_path).realpath
|
87
|
+
|
88
|
+
calculate_full_paths!(my_options)
|
89
|
+
|
56
90
|
Cli::SiteGenerator.generate!(
|
57
|
-
|
58
|
-
|
59
|
-
filter_compile_options(
|
91
|
+
base_path,
|
92
|
+
my_options,
|
93
|
+
filter_compile_options(my_options),
|
60
94
|
)
|
61
95
|
UI.say("Site has been generated at #{options[:output_dir]}")
|
62
96
|
rescue Cli::Errors::InvalidManifestFileError
|
63
97
|
UI.error("Invalid data in: #{options[:config]}")
|
64
98
|
end
|
99
|
+
|
100
|
+
private
|
101
|
+
|
102
|
+
# Make relative paths absolute.
|
103
|
+
def calculate_full_paths!(my_options)
|
104
|
+
%i[stylesheet template_dir].each do |key|
|
105
|
+
if my_options[key]
|
106
|
+
path = Pathname.new(my_options[key])
|
107
|
+
if path.relative?
|
108
|
+
my_options[key] = Pathname.pwd.join(path)
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
# Calculate the base path for the site generation.
|
115
|
+
def calculate_base_path!(my_options, manifest_path = nil)
|
116
|
+
config_file = options[:config]
|
117
|
+
if manifest_path.nil?
|
118
|
+
if config_file.nil?
|
119
|
+
# If no config file is given, use the current working directory
|
120
|
+
# as the base path.
|
121
|
+
Pathname.pwd
|
122
|
+
else
|
123
|
+
# If a config file is given, use it as the config file
|
124
|
+
# and use its directory as the base path.
|
125
|
+
Pathname.new(config_file).dirname
|
126
|
+
end
|
127
|
+
elsif File.file?(manifest_path) && config_file.nil?
|
128
|
+
# If a file is given, use it as the config file
|
129
|
+
# and use its directory as the base path.
|
130
|
+
my_options["config"] = manifest_path
|
131
|
+
Pathname.new(manifest_path).dirname
|
132
|
+
else
|
133
|
+
# If directory is given, use it as the base path.
|
134
|
+
Pathname.new(manifest_path)
|
135
|
+
end
|
136
|
+
end
|
65
137
|
end
|
66
138
|
end
|
67
139
|
end
|
@@ -13,12 +13,12 @@ module Metanorma
|
|
13
13
|
DEFAULT_CONFIG_FILE = "metanorma.yml"
|
14
14
|
|
15
15
|
# rubocop:disable Metrics/AbcSize
|
16
|
-
def initialize(
|
16
|
+
def initialize(source_path, options = {}, compile_options = {})
|
17
17
|
@collection_queue = []
|
18
|
-
@
|
19
|
-
@site_path =
|
20
|
-
:output_dir, Commands::Site::SITE_OUTPUT_DIRNAME
|
21
|
-
)
|
18
|
+
@source_path = find_realpath(source_path)
|
19
|
+
@site_path = Pathname.new(
|
20
|
+
options.fetch(:output_dir, Commands::Site::SITE_OUTPUT_DIRNAME),
|
21
|
+
)
|
22
22
|
|
23
23
|
@asset_folder = options.fetch(:asset_folder, DEFAULT_ASSET_FOLDER).to_s
|
24
24
|
@relaton_collection_index = options.fetch(
|
@@ -34,6 +34,17 @@ module Metanorma
|
|
34
34
|
template_data("output_filename"),
|
35
35
|
)
|
36
36
|
|
37
|
+
# Determine base path for stylesheet & template files
|
38
|
+
# If the file path is relative, it is relative to the directory
|
39
|
+
# containing the site manifest file.
|
40
|
+
# If site manifest file is not provided, then it is relative to the
|
41
|
+
# current directory.
|
42
|
+
@base_path = if manifest_file.nil?
|
43
|
+
Pathname.pwd
|
44
|
+
else
|
45
|
+
Pathname.new(manifest_file).parent
|
46
|
+
end
|
47
|
+
|
37
48
|
@compile_options = compile_options
|
38
49
|
end
|
39
50
|
# rubocop:enable Metrics/AbcSize
|
@@ -45,101 +56,182 @@ module Metanorma
|
|
45
56
|
def generate!
|
46
57
|
ensure_site_asset_directory!
|
47
58
|
|
59
|
+
# compile individual document files
|
48
60
|
compile_files!(select_source_files)
|
49
61
|
|
50
|
-
site_directory = asset_directory.
|
62
|
+
site_directory = asset_directory.parent
|
63
|
+
|
64
|
+
# actually compile collection file(s)
|
65
|
+
compile_collections!
|
66
|
+
|
51
67
|
Dir.chdir(site_directory) do
|
52
68
|
build_collection_file!(relaton_collection_index)
|
53
69
|
convert_to_html_page!(relaton_collection_index, DEFAULT_SITE_INDEX)
|
54
70
|
end
|
55
|
-
|
56
|
-
dequeue_jobs!
|
57
71
|
end
|
58
72
|
|
59
73
|
private
|
60
74
|
|
61
|
-
attr_reader :
|
75
|
+
attr_reader :source_path, :asset_folder, :asset_directory, :site_path,
|
62
76
|
:manifest_file, :relaton_collection_index, :stylesheet,
|
63
77
|
:template_dir,
|
64
|
-
:output_filename_template
|
78
|
+
:output_filename_template,
|
79
|
+
:base_path
|
65
80
|
|
66
|
-
def find_realpath(
|
67
|
-
Pathname.new(
|
81
|
+
def find_realpath(path)
|
82
|
+
Pathname.new(path).realpath if path
|
68
83
|
rescue Errno::ENOENT
|
69
|
-
|
84
|
+
path
|
70
85
|
end
|
71
86
|
|
72
87
|
def default_config
|
73
|
-
default_file = Pathname.
|
88
|
+
default_file = Pathname.pwd.join(DEFAULT_CONFIG_FILE)
|
74
89
|
default_file if File.exist?(default_file)
|
75
90
|
end
|
76
91
|
|
92
|
+
# @return [Array<Pathname>] the list of ADOC source files
|
93
|
+
def select_source_adoc_files
|
94
|
+
select_source_files do |source_path|
|
95
|
+
source_path.glob("**/*.adoc")
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
# @return [Array<Pathname>] the list of YAML/XML source files
|
100
|
+
def select_source_collection_files
|
101
|
+
select_source_files do |source_path|
|
102
|
+
source_path.glob("**/*.{yaml,yml,xml}")
|
103
|
+
end.select do |f|
|
104
|
+
collection_file?(f)
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
# Select source files from the manifest if available, otherwise
|
109
|
+
# select all .adoc files in the source directory.
|
110
|
+
# If a block is given, yield the source directory to the block.
|
111
|
+
#
|
112
|
+
# @return [Array<Pathname>] the list of source files
|
113
|
+
# @yieldparam source [Pathname] the source directory
|
114
|
+
# @yieldreturn [Array<Pathname>] the list of source files
|
115
|
+
# @example
|
116
|
+
# select_source_files do |source|
|
117
|
+
# source.glob("**/*.adoc")
|
118
|
+
# end
|
119
|
+
# # => [#<Pathname:source/1.adoc>, #<Pathname:source/2.adoc>]
|
120
|
+
#
|
77
121
|
def select_source_files
|
78
122
|
files = source_from_manifest
|
79
123
|
|
80
124
|
if files.empty?
|
81
|
-
files =
|
125
|
+
files = if block_given?
|
126
|
+
yield(source_path)
|
127
|
+
else
|
128
|
+
source_path.glob("**/*.adoc")
|
129
|
+
end
|
82
130
|
end
|
83
131
|
|
84
132
|
result = files.flatten
|
85
133
|
result.uniq!
|
86
|
-
result.reject!
|
134
|
+
result.reject!(&:directory?)
|
87
135
|
result
|
88
136
|
end
|
89
137
|
|
138
|
+
# @dependency: files (YAML, XML, RXL) in asset_directory's parent, from
|
139
|
+
# #compile_files! and #compile_collections!
|
140
|
+
#
|
141
|
+
# This looks for collection artifacts from the `collections`
|
142
|
+
# sub-directory, and individual document artifacts from the `documents`
|
143
|
+
# sub-directory.
|
144
|
+
#
|
145
|
+
# @output: documents.xml in site_path
|
146
|
+
#
|
147
|
+
# @param relaton_collection_index_filename [String] the name of the
|
148
|
+
# collection index file (usually documents.xml), but can be changed
|
149
|
+
# through the :collection_name option
|
90
150
|
def build_collection_file!(relaton_collection_index_filename)
|
91
|
-
collection_path =
|
92
|
-
relaton_collection_index_filename].join("/")
|
151
|
+
collection_path = site_path.join(relaton_collection_index_filename)
|
93
152
|
UI.info("Building collection file: #{collection_path} ...")
|
94
153
|
|
154
|
+
# First concatenate individual document files
|
155
|
+
# But be sure to provide a *relative* path of _site,
|
156
|
+
# that is relative to the manifest file itself? or relative to PWD!
|
157
|
+
#
|
158
|
+
# It has to be relative to PWD, otherwise the resolved relative paths
|
159
|
+
# will simply not be valid.
|
160
|
+
#
|
161
|
+
# If paths are desired to be relative from the manifest file, then
|
162
|
+
# `RelatonFile.concatenate` needs to accept a base path option, so
|
163
|
+
# `concatenate` can calculate the correct full path to use.
|
164
|
+
#
|
165
|
+
target_path = asset_directory.parent.relative_path_from(Pathname.pwd)
|
166
|
+
|
95
167
|
Relaton::Cli::RelatonFile.concatenate(
|
96
|
-
|
168
|
+
target_path.to_s,
|
97
169
|
relaton_collection_index_filename,
|
98
170
|
title: manifest[:collection_name],
|
99
171
|
organization: manifest[:collection_organization],
|
100
172
|
)
|
101
173
|
end
|
102
174
|
|
103
|
-
|
104
|
-
|
175
|
+
# @dependency: file in file_path, from #select_source_files
|
176
|
+
# @output: file in asset_folder
|
177
|
+
def compile_file!(file_path)
|
178
|
+
if collection_file?(file_path)
|
179
|
+
@collection_queue << file_path
|
105
180
|
return
|
106
181
|
end
|
107
182
|
|
108
|
-
UI.info("Compiling #{
|
183
|
+
UI.info("Compiling #{file_path} ...")
|
109
184
|
|
110
185
|
# Incorporate output_filename_template so the output file
|
111
186
|
# can be named as desired, using liquid template and Relaton LiquidDrop
|
112
187
|
options = @compile_options.merge(
|
113
188
|
output_filename_template: output_filename_template,
|
114
189
|
format: :asciidoc,
|
115
|
-
output_dir:
|
190
|
+
output_dir: ensure_site_asset_output_sub_directory!(file_path),
|
116
191
|
site_generate: true,
|
117
192
|
)
|
118
193
|
|
119
|
-
options[:baseassetpath] = Pathname.new(
|
120
|
-
Metanorma::Cli::Compiler.compile(
|
194
|
+
options[:baseassetpath] = Pathname.new(file_path.to_s).dirname.to_s
|
195
|
+
Metanorma::Cli::Compiler.compile(file_path.to_s, options)
|
121
196
|
end
|
122
197
|
|
198
|
+
# @dependency: files in source_path, from #select_source_files
|
199
|
+
# @output: files in asset_folder
|
123
200
|
def compile_files!(files)
|
124
|
-
fatals = files.map { |
|
201
|
+
fatals = files.map { |file| compile_file!(file) }
|
125
202
|
fatals.flatten!
|
126
203
|
fatals.compact!
|
127
204
|
|
128
205
|
raise Errors::FatalCompilationError, fatals unless fatals.empty?
|
129
206
|
end
|
130
207
|
|
208
|
+
# Given a path, return the full path if it is not nil.
|
209
|
+
# If the path is absolute, return the path as is.
|
210
|
+
# If the path is relative, return the path relative to the base path.
|
211
|
+
# @param some_path [String, nil] the path to be converted to full path
|
212
|
+
# @return [String, nil] the full path
|
213
|
+
def full_path_for(some_path)
|
214
|
+
if some_path.nil?
|
215
|
+
nil
|
216
|
+
elsif Pathname.new(some_path).absolute?
|
217
|
+
some_path
|
218
|
+
elsif !base_path.nil?
|
219
|
+
base_path.join(some_path)
|
220
|
+
end
|
221
|
+
end
|
222
|
+
|
223
|
+
# @dependency: documents.xml from #build_collection_file!
|
224
|
+
# @output: index.html in site_path
|
131
225
|
def convert_to_html_page!(relaton_index_filename, page_name)
|
132
226
|
UI.info("Generating html site in #{site_path} ...")
|
133
227
|
|
134
228
|
Relaton::Cli::XMLConvertor.to_html(
|
135
229
|
relaton_index_filename,
|
136
|
-
stylesheet,
|
137
|
-
template_dir,
|
138
|
-
)
|
139
|
-
File.rename(
|
140
|
-
Pathname.new(relaton_index_filename).sub_ext(".html").to_s,
|
141
|
-
page_name,
|
230
|
+
full_path_for(stylesheet),
|
231
|
+
full_path_for(template_dir),
|
142
232
|
)
|
233
|
+
|
234
|
+
Pathname.new(relaton_index_filename).sub_ext(".html").rename(page_name)
|
143
235
|
end
|
144
236
|
|
145
237
|
def template_data(node)
|
@@ -184,52 +276,84 @@ module Metanorma
|
|
184
276
|
def source_from_manifest
|
185
277
|
@source_from_manifest ||= begin
|
186
278
|
result = manifest[:files].map do |source_file|
|
187
|
-
file_path =
|
188
|
-
file_path.include?("*")
|
279
|
+
file_path = source_path.join(source_file)
|
280
|
+
if file_path.to_s.include?("*")
|
281
|
+
source_path.glob(source_file)
|
282
|
+
else
|
283
|
+
file_path
|
284
|
+
end
|
189
285
|
end
|
190
286
|
result.flatten!
|
191
287
|
result
|
192
288
|
end
|
193
289
|
end
|
194
290
|
|
291
|
+
# Use 'realpath' throughout to ensure consistency with file paths,
|
292
|
+
# especially with temporary directories generated in RSpec.
|
195
293
|
def ensure_site_asset_directory!
|
196
|
-
asset_path =
|
197
|
-
@asset_directory = Pathname.
|
198
|
-
|
199
|
-
|
294
|
+
asset_path = site_path.join(asset_folder)
|
295
|
+
@asset_directory = Pathname.pwd.join(asset_path)
|
296
|
+
@asset_directory.mkpath
|
297
|
+
@asset_directory = @asset_directory.realpath
|
298
|
+
@asset_directory
|
200
299
|
end
|
201
300
|
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
sub_directory = Pathname.new(source.gsub(@source.to_s, "")).dirname.to_s
|
301
|
+
# TODO: spec
|
302
|
+
def ensure_site_asset_output_sub_directory!(source)
|
303
|
+
sub_directory = Pathname.new(
|
304
|
+
source.to_s.gsub(@source_path.to_s, ""),
|
305
|
+
).dirname.to_s
|
208
306
|
sub_directory.gsub!("/sources", "")
|
209
|
-
sub_directory.
|
307
|
+
sub_directory.sub!(%r{^/}, "")
|
210
308
|
|
211
|
-
|
212
|
-
|
309
|
+
outdir = asset_directory.join(sub_directory)
|
310
|
+
outdir.mkpath
|
213
311
|
|
214
|
-
|
312
|
+
outdir
|
215
313
|
end
|
216
314
|
|
315
|
+
# @param source [Pathname] the source file
|
217
316
|
def collection_file?(source)
|
218
|
-
|
219
|
-
|
220
|
-
if [".yml", ".yaml"].include?(ext)
|
221
|
-
@collection_queue << source
|
222
|
-
end
|
317
|
+
[".yml", ".yaml", ".xml"].include?(source.extname&.downcase)
|
223
318
|
end
|
224
319
|
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
320
|
+
# Compile each collection file encountered in the site manifest file.
|
321
|
+
#
|
322
|
+
# The collection files are compiled into the `collections` sub-directory
|
323
|
+
# under the asset_directory. The output folder specified in each of the
|
324
|
+
# collections will be relative to this `collections` folder.
|
325
|
+
#
|
326
|
+
# Putting the files under the asset_directory is important because
|
327
|
+
# the collection files are used to generate the collection index file
|
328
|
+
# and the HTML page. It is what `Relaton::Cli::RelatonFile.concatenate`
|
329
|
+
# uses to find all artifacts and generate the correct links for them on
|
330
|
+
# the site index.
|
331
|
+
#
|
332
|
+
# Potential conflicts considered:
|
333
|
+
# On the one hand, each individual collection.yml specifies its own
|
334
|
+
# output folder. This has to be respected.
|
335
|
+
#
|
336
|
+
# On the other hand, the output folders specified in collection.yml files
|
337
|
+
# naturally cannot be expected to live within the `asset_directory`.
|
338
|
+
#
|
339
|
+
# So, for the build_collection_file! method to correctly consider all
|
340
|
+
# generated artifacts, we need to copy the collection files over to the
|
341
|
+
# asset_directory.
|
342
|
+
#
|
343
|
+
# A question you may have: How much does the specific output folder
|
344
|
+
# matter, when doing a site generate? Since the intent is to generate a
|
345
|
+
# site, the output folder is not really relevant. The collection files
|
346
|
+
# are copied over to the asset_directory anyway.
|
347
|
+
#
|
348
|
+
# TODO: parallelize the compilation of collection files?
|
349
|
+
#
|
350
|
+
def compile_collections!
|
351
|
+
@collection_queue.compact.each do |file|
|
229
352
|
Cli::Collection.render(
|
230
|
-
|
353
|
+
file.to_s,
|
231
354
|
compile: @compile_options,
|
232
|
-
output_dir:
|
355
|
+
output_dir: asset_directory,
|
356
|
+
site_generate: true,
|
233
357
|
)
|
234
358
|
end
|
235
359
|
end
|
data/metanorma-cli.gemspec
CHANGED
@@ -39,7 +39,7 @@ Gem::Specification.new do |spec|
|
|
39
39
|
spec.add_dependency "metanorma-standoc", "~> 3.0.0"
|
40
40
|
# spec.add_dependency 'metanorma-mpfa', "~> 0.9.0"
|
41
41
|
spec.add_dependency "git", "~> 1.5"
|
42
|
-
spec.add_dependency "lutaml-model"
|
42
|
+
spec.add_dependency "lutaml-model"
|
43
43
|
spec.add_dependency "metanorma", "~> 2.1.0"
|
44
44
|
spec.add_dependency "metanorma-iho", "~> 1.1.0"
|
45
45
|
spec.add_dependency "metanorma-itu", "~> 2.6.0"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: metanorma-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.12.
|
4
|
+
version: 1.12.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-
|
11
|
+
date: 2025-04-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: metanorma-ietf
|
@@ -154,16 +154,16 @@ dependencies:
|
|
154
154
|
name: lutaml-model
|
155
155
|
requirement: !ruby/object:Gem::Requirement
|
156
156
|
requirements:
|
157
|
-
- - "
|
157
|
+
- - ">="
|
158
158
|
- !ruby/object:Gem::Version
|
159
|
-
version: 0
|
159
|
+
version: '0'
|
160
160
|
type: :runtime
|
161
161
|
prerelease: false
|
162
162
|
version_requirements: !ruby/object:Gem::Requirement
|
163
163
|
requirements:
|
164
|
-
- - "
|
164
|
+
- - ">="
|
165
165
|
- !ruby/object:Gem::Version
|
166
|
-
version: 0
|
166
|
+
version: '0'
|
167
167
|
- !ruby/object:Gem::Dependency
|
168
168
|
name: metanorma
|
169
169
|
requirement: !ruby/object:Gem::Requirement
|