metanorma-cli 1.16.4 → 1.16.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.
@@ -58,6 +58,13 @@ module Metanorma
58
58
  type: :boolean,
59
59
  desc: "Strict compilation: abort if there are any errors"
60
60
 
61
+ option :extensions,
62
+ aliases: "-x",
63
+ desc: "Comma-separated list of output formats to generate " \
64
+ "(e.g. html,rxl); overrides the manifest `extensions:` " \
65
+ "key and any per-collection `format:`. " \
66
+ "Default: all formats the flavor supports"
67
+
61
68
  # If no argument is provided, work out the base
62
69
  # path to use for calculation of full paths for
63
70
  # files referenced in the site manifest.
@@ -153,8 +153,11 @@ module Metanorma
153
153
  EXPORT_CONFIG_FLAVOR_FILES = [
154
154
  "metanorma/*/*.adoc",
155
155
  "isodoc/*/html/*",
156
+ "isodoc/*/*.xsl",
156
157
  "isodoc/*/*.yml",
158
+ "isodoc/*/*.yaml",
157
159
  "relaton/render/*.yml",
160
+ "relaton/render/*.yaml",
158
161
  ].freeze
159
162
 
160
163
  def export_config_flavor(type)
@@ -12,7 +12,7 @@ module Metanorma
12
12
  DEFAULT_SITE_INDEX = "index.html"
13
13
  DEFAULT_CONFIG_FILE = "metanorma.yml"
14
14
 
15
- # rubocop:disable Metrics/AbcSize
15
+ # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
16
16
  def initialize(source_path, options = {}, compile_options = {})
17
17
  @collection_queue = []
18
18
  @source_path = find_realpath(source_path)
@@ -46,8 +46,16 @@ module Metanorma
46
46
  end
47
47
 
48
48
  @compile_options = compile_options
49
+
50
+ # Resolve the output formats to generate: CLI `--extensions` (a
51
+ # comma-separated string in compile_options) takes precedence over the
52
+ # manifest `extensions:` list; empty means "all formats the flavor
53
+ # supports" (the historical default). Remove it from @compile_options
54
+ # so it is injected explicitly and not double-handled downstream.
55
+ @extensions = resolve_extensions
56
+ @compile_options.delete(:extensions)
49
57
  end
50
- # rubocop:enable Metrics/AbcSize
58
+ # rubocop:enable Metrics/AbcSize, Metrics/MethodLength
51
59
 
52
60
  def self.generate!(source, options = {}, compile_options = {})
53
61
  new(source, options, compile_options).generate!
@@ -189,9 +197,10 @@ module Metanorma
189
197
  format: :asciidoc,
190
198
  output_dir: ensure_site_asset_output_sub_directory!(file_path),
191
199
  site_generate: true,
200
+ baseassetpath: Pathname.new(file_path.to_s).dirname.to_s,
201
+ **extensions_option,
192
202
  )
193
203
 
194
- options[:baseassetpath] = Pathname.new(file_path.to_s).dirname.to_s
195
204
  Metanorma::Cli::Compiler.compile(file_path.to_s, options)
196
205
  end
197
206
 
@@ -257,22 +266,39 @@ module Metanorma
257
266
  end
258
267
 
259
268
  def manifest_config(manifest_model)
269
+ mn = manifest_model&.metanorma
260
270
  {
261
- files: manifest_model&.metanorma&.source&.files || [],
262
- template: manifest_model&.metanorma&.template,
263
- collection_name: manifest_model
264
- .metanorma
265
- .collection
266
- .name,
267
- collection_organization: manifest_model
268
- .metanorma
269
- .collection
270
- .organization,
271
+ files: mn&.source&.files || [],
272
+ template: mn&.template,
273
+ extensions: mn&.extensions || [],
274
+ collection_name: mn.collection.name,
275
+ collection_organization: mn.collection.organization,
271
276
  }
272
277
  rescue NoMethodError
273
278
  raise Errors::InvalidManifestFileError.new("Invalid manifest file")
274
279
  end
275
280
 
281
+ # @return [Array<String>] the output formats to generate, resolved from
282
+ # the CLI `--extensions` flag (highest precedence) then the manifest
283
+ # `extensions:` list. Empty array means "all formats" (no filtering).
284
+ def resolve_extensions
285
+ cli = @compile_options[:extensions]
286
+ cli = cli.split(",") if cli.is_a?(String)
287
+ cli = (cli || []).map(&:strip).reject(&:empty?)
288
+ return cli unless cli.empty?
289
+
290
+ manifest[:extensions] || []
291
+ end
292
+
293
+ # Restrict output formats when extensions were requested (CLI or
294
+ # manifest); Compiler turns this into `extension_keys`. Empty means no
295
+ # filtering (all formats the flavor supports).
296
+ def extensions_option
297
+ return {} if @extensions.empty?
298
+
299
+ { extensions: @extensions.join(",") }
300
+ end
301
+
276
302
  def source_from_manifest
277
303
  @source_from_manifest ||= begin
278
304
  result = manifest[:files].map do |source_file|
@@ -349,12 +375,18 @@ module Metanorma
349
375
  #
350
376
  def compile_collections!
351
377
  @collection_queue.compact.each do |file|
352
- Cli::Collection.render(
353
- file.to_s,
378
+ render_options = {
354
379
  compile: @compile_options,
355
380
  output_dir: asset_directory,
356
381
  site_generate: true,
357
- )
382
+ }
383
+
384
+ # Override each collection file's own `format:` when extensions were
385
+ # requested (CLI or manifest); passed-in options win over the
386
+ # file-extracted ones in Cli::Collection.
387
+ render_options[:format] = @extensions unless @extensions.empty?
388
+
389
+ Cli::Collection.render(file.to_s, render_options)
358
390
  end
359
391
  end
360
392
  end
@@ -22,6 +22,7 @@ module Metanorma
22
22
  continue_without_fonts
23
23
  progress
24
24
  strict
25
+ extensions
25
26
  ]
26
27
  options.select { |k, _| copts.include?(k) }.symbolize_all_keys
27
28
  end
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module Cli
3
- VERSION = "1.16.4".freeze
3
+ VERSION = "1.16.5".freeze
4
4
  end
5
5
  end
@@ -23,6 +23,7 @@ module Metanorma
23
23
  attribute :source, SourceEntries
24
24
  attribute :collection, SiteMetadata
25
25
  attribute :template, SiteTemplate
26
+ attribute :extensions, :string, collection: true
26
27
  end
27
28
 
28
29
  class Base < Lutaml::Model::Serializable
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.16.4
4
+ version: 1.16.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
@@ -321,8 +321,16 @@ description: Executable to process any Metanorma standard.
321
321
  email:
322
322
  - open.source@ribose.com
323
323
  executables:
324
+ - index.html
325
+ - index.xml
324
326
  - metanorma
325
327
  - metanorma-manifest
328
+ - metanorma.old
329
+ - rfc2629-other.ent
330
+ - rfc2629-xhtml.ent
331
+ - rfc2629.dtd
332
+ - rfc6350.adoc
333
+ - rfc6350.xml
326
334
  extensions: []
327
335
  extra_rdoc_files:
328
336
  - CODE_OF_CONDUCT.md
@@ -340,9 +348,18 @@ files:
340
348
  - bin/setup
341
349
  - docs/installation.adoc
342
350
  - docs/navigation.adoc
351
+ - docs/testing.adoc
343
352
  - docs/usage.adoc
353
+ - exe/index.html
354
+ - exe/index.xml
344
355
  - exe/metanorma
345
356
  - exe/metanorma-manifest
357
+ - exe/metanorma.old
358
+ - exe/rfc2629-other.ent
359
+ - exe/rfc2629-xhtml.ent
360
+ - exe/rfc2629.dtd
361
+ - exe/rfc6350.adoc
362
+ - exe/rfc6350.xml
346
363
  - i18n.yaml
347
364
  - lib/metanorma-cli.rb
348
365
  - lib/metanorma/cli.rb