metanorma-cli 1.1.8 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/a CHANGED
@@ -1 +1 @@
1
- git add Gemfile.lock lib/metanorma/cli/version.rb
1
+ git add lib/metanorma/cli/version.rb metanorma-cli.gemspec
data/appveyor.yml CHANGED
@@ -1,3 +1,5 @@
1
+ # Auto-generated !!! Do not edit it manually
2
+ # use ci-master https://github.com/metanorma/metanorma-build-scripts
1
3
  version: '{build}'
2
4
 
3
5
  cache:
@@ -7,7 +9,6 @@ environment:
7
9
  matrix:
8
10
  - RUBY_VERSION: 25
9
11
  - RUBY_VERSION: 24
10
- - RUBY_VERSION: 23
11
12
  - RUBY_VERSION: _trunk
12
13
 
13
14
  matrix:
@@ -31,4 +32,4 @@ before_test:
31
32
  - bundle -v
32
33
 
33
34
  test_script:
34
- - bundle exec rake
35
+ - bundle exec rake
data/b ADDED
@@ -0,0 +1,85 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <gb-standard xmlns="http://riboseinc.com/gbstandard">
3
+ <bibdata type="standard">
4
+ <title>
5
+
6
+ </title>
7
+ <title>
8
+
9
+ </title>
10
+ <docidentifier type="gb">T/AAA 123</docidentifier>
11
+ <docidentifier type="gb-structured">
12
+ <project-number>T/AAA 123</project-number>
13
+ </docidentifier>
14
+ <docnumber>123</docnumber>
15
+ <contributor>
16
+ <role type="author"/>
17
+ <person>
18
+ <name>
19
+ <surname>Author</surname>
20
+ </name>
21
+ </person>
22
+ </contributor>
23
+ <contributor>
24
+ <role type="author"/>
25
+ <organization>
26
+ <name>GB</name>
27
+ </organization>
28
+ </contributor>
29
+ <contributor>
30
+ <role type="publisher"/>
31
+ <organization>
32
+ <name>GB</name>
33
+ </organization>
34
+ </contributor>
35
+ <contributor>
36
+ <role type="authority"/>
37
+ <organization>
38
+ <name>GB</name>
39
+ </organization>
40
+ </contributor>
41
+ <contributor>
42
+ <role type="proposer"/>
43
+ <organization>
44
+ <name>GB</name>
45
+ </organization>
46
+ </contributor>
47
+ <contributor>
48
+ <role type="issuer"/>
49
+ <organization>
50
+ <name>GB</name>
51
+ </organization>
52
+ </contributor>
53
+
54
+ <language>en</language>
55
+ <script>Latn</script>
56
+ <status>
57
+ <stage>60</stage>
58
+ <substage>60</substage>
59
+ </status>
60
+ <copyright>
61
+ <from>2019</from>
62
+ <owner>
63
+ <organization>
64
+ <name>GB</name>
65
+ </organization>
66
+ </owner>
67
+ </copyright>
68
+ <relation type="nonequivalent">
69
+ <bibitem>
70
+ <title> Televisual Frequencies</title>
71
+ <docidentifier>ISO 1012</docidentifier>
72
+ </bibitem>
73
+ </relation>
74
+ <ext>
75
+ <doctype>recommendation</doctype>
76
+ <gbtype>
77
+ <gbscope>social-group</gbscope>
78
+ <gbprefix>AAA</gbprefix>
79
+ <gbmandate>recommendation</gbmandate>
80
+ <gbtopic>basic</gbtopic>
81
+ </gbtype>
82
+ </ext>
83
+ </bibdata>
84
+ <sections/>
85
+ </gb-standard
data/lib/metanorma/cli.rb CHANGED
@@ -4,7 +4,6 @@ require "metanorma/cli/command"
4
4
 
5
5
  module Metanorma
6
6
  module Cli
7
-
8
7
  SUPPORTED_GEMS = [
9
8
  "metanorma-iso",
10
9
  "metanorma-ietf",
@@ -57,6 +56,7 @@ module Metanorma
57
56
 
58
57
  rescue Errno::ENOENT => error
59
58
  UI.say("Error: #{error}, \nNot sure what to run? try: metanorma help")
59
+ exit(Errno::ENOENT::Errno)
60
60
  end
61
61
 
62
62
  def self.root
@@ -87,7 +87,7 @@ module Metanorma
87
87
 
88
88
  def self.find_command(arguments)
89
89
  commands = Metanorma::Cli::Command.all_commands.keys
90
- commands.select { |cmd| arguments.include?(cmd) == true }
90
+ commands.select { |cmd| arguments.include?(cmd.gsub("_", "-")) == true }
91
91
  end
92
92
  end
93
93
  end
@@ -9,7 +9,7 @@ module Metanorma
9
9
  desc "new NAME", "Create new Metanorma document"
10
10
  option :type, aliases: "-t", required: true, desc: "Document type"
11
11
  option :doctype, aliases: "-d", required: true, desc: "Metanorma doctype"
12
- option :overwrite, aliases: "-r", desc: "Overwrite existing document"
12
+ option :overwrite, aliases: "-y", type: :boolean, desc: "Overwrite existing document"
13
13
  option :template, aliases: "-l", desc: "Git hosted remote or local FS template skeleton"
14
14
 
15
15
  def new(name)
@@ -20,7 +20,7 @@ module Metanorma
20
20
  option :type, aliases: "-t", desc: "Type of standard to generate"
21
21
  option :extensions, aliases: "-x", type: :string, desc: "Type of extension to generate per type"
22
22
  option :format, aliases: "-f", default: :asciidoc, desc: "Format of source file: eg. asciidoc"
23
- option :require, aliases: "-r", type: :array, desc: "Require LIBRARY prior to execution"
23
+ option :require, aliases: "-r", desc: "Require LIBRARY prior to execution"
24
24
  option :wrapper, aliases: "-w", type: :boolean, desc: "Create wrapper folder for HTML output"
25
25
  option :asciimath, aliases: "-a", type: :boolean, desc: "Keep Asciimath in XML output instead of converting it to MathM"
26
26
  option :datauriimage, aliases: "-d", type: :boolean, desc: "Encode HTML output images as data URIs"
@@ -49,16 +49,46 @@ module Metanorma
49
49
 
50
50
  def version
51
51
  if options[:format] == :asciidoc
52
- UI.say(find_version(options[:type]))
52
+ UI.say(find_backend(options[:type].to_sym).version)
53
53
  end
54
54
  end
55
55
 
56
+ desc "list-extensions", "List supported extensions"
57
+ def list_extensions(type = nil)
58
+ single_type_extensions(type) || all_type_extensions
59
+ rescue LoadError
60
+ UI.say("Couldn't load #{type}, please provide a valid type!")
61
+ end
62
+
56
63
  private
57
64
 
58
- def find_version(type)
65
+ def single_type_extensions(type)
66
+ if type
67
+ format_keys = find_backend(type).output_formats.keys
68
+ UI.say("Supported extensions: #{join_keys(format_keys)}.")
69
+ return true
70
+ end
71
+ end
72
+
73
+ def all_type_extensions
74
+ Metanorma::Cli.load_flavors
75
+
76
+ message = "Supported extensions per type: \n"
77
+ Metanorma::Registry.instance.processors.each do |type_sym, processor|
78
+ format_keys = processor.output_formats.keys
79
+ message += " #{type_sym}: #{join_keys(format_keys)}.\n"
80
+ end
81
+
82
+ UI.say(message)
83
+ end
84
+
85
+ def find_backend(type)
59
86
  require "metanorma-#{type}"
60
- processor = Metanorma::Registry.instance.find_processor(type.to_sym)
61
- processor.version
87
+ Metanorma::Registry.instance.find_processor(type.to_sym)
88
+ end
89
+
90
+ def join_keys(keys)
91
+ [keys[0..-2].join(", "), keys.last].join(" and ")
62
92
  end
63
93
 
64
94
  def create_new_document(name, options)
@@ -4,8 +4,7 @@ module Metanorma
4
4
  def initialize(file, options)
5
5
  @file = file
6
6
  @options = options
7
- @extract = (options.delete(:extract) || "").split(",")
8
- @extensions = (options.delete(:extensions) || "").split(",")
7
+ normalize_special_options
9
8
  end
10
9
 
11
10
  def compile
@@ -51,6 +50,12 @@ module Metanorma
51
50
  end
52
51
  end
53
52
  end
53
+
54
+ def normalize_special_options
55
+ @extract = (options.delete(:extract) || "").split(",")
56
+ @extensions = (options.delete(:extensions) || "").split(",")
57
+ options[:require] = [options[:require]] if options[:require]
58
+ end
54
59
  end
55
60
  end
56
61
  end
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module Cli
3
- VERSION = "1.1.8"
3
+ VERSION = "1.2.0"
4
4
  end
5
5
  end
@@ -21,8 +21,7 @@ Gem::Specification.new do |spec|
21
21
  spec.bindir = "exe"
22
22
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
23
23
  spec.require_paths = ["lib"]
24
-
25
- spec.required_ruby_version = '>= 2.3.0'
24
+ spec.required_ruby_version = '>= 2.4.0'
26
25
 
27
26
  spec.add_development_dependency "bundler", "~> 2.0.1"
28
27
  spec.add_development_dependency "rake", "~> 12.0"
@@ -33,20 +32,20 @@ Gem::Specification.new do |spec|
33
32
  spec.add_development_dependency "rspec-core", "~> 3.4"
34
33
 
35
34
  spec.add_runtime_dependency "thor", "~> 0.20.3"
36
- spec.add_runtime_dependency "metanorma-iso", "~> 1.1.0"
35
+ spec.add_runtime_dependency "metanorma-iso", "~> 1.2.0"
37
36
  spec.add_runtime_dependency 'metanorma-ietf', "~> 1.0.1"
38
- spec.add_runtime_dependency 'metanorma-gb', "~> 1.1.0"
39
- spec.add_runtime_dependency 'metanorma-csd', "~> 1.1.0"
40
- spec.add_runtime_dependency 'metanorma-csand', "~> 1.1.0"
41
- spec.add_runtime_dependency 'metanorma-rsd', "~> 1.1.0"
42
- spec.add_runtime_dependency 'metanorma-m3d', "~> 1.1.0"
43
- spec.add_runtime_dependency 'metanorma-acme', "~> 1.1.0"
44
- spec.add_runtime_dependency 'metanorma-standoc', "~> 1.1.0"
45
- spec.add_runtime_dependency 'metanorma-mpfd', "~> 0.1.0"
46
- spec.add_runtime_dependency 'metanorma-unece', "~> 0.0.1"
47
- spec.add_runtime_dependency 'metanorma-ogc', "~> 0.0.1"
48
- spec.add_runtime_dependency 'metanorma-nist', "~> 0.0.1"
49
- spec.add_runtime_dependency 'isodoc', "~> 0.9.0"
37
+ spec.add_runtime_dependency 'metanorma-gb', "~> 1.2.0"
38
+ spec.add_runtime_dependency 'metanorma-csd', "~> 1.2.0"
39
+ spec.add_runtime_dependency 'metanorma-csand', "~> 1.2.0"
40
+ #spec.add_runtime_dependency 'metanorma-rsd', "~> 1.1.0"
41
+ spec.add_runtime_dependency 'metanorma-m3d', "~> 1.2.0"
42
+ spec.add_runtime_dependency 'metanorma-acme', "~> 1.2.0"
43
+ spec.add_runtime_dependency 'metanorma-standoc', "~> 1.2.0"
44
+ #spec.add_runtime_dependency 'metanorma-mpfd', "~> 0.1.0"
45
+ spec.add_runtime_dependency 'metanorma-unece', "~> 0.1.0"
46
+ spec.add_runtime_dependency 'metanorma-ogc', "~> 0.1.0"
47
+ spec.add_runtime_dependency 'metanorma-nist', "~> 0.1.0"
48
+ spec.add_runtime_dependency 'isodoc', "~> 0.10.0"
50
49
  spec.add_runtime_dependency 'metanorma', "~> 0.3.9"
51
50
  spec.add_runtime_dependency 'nokogiri', ">= 1"
52
51
  spec.add_runtime_dependency "git", "~> 1.5"
@@ -1,14 +1,19 @@
1
1
  #!make
2
2
  SHELL := /bin/bash
3
+ # Ensure the xml2rfc cache directory exists locally
4
+ IGNORE := $(shell mkdir -p $(HOME)/.cache/xml2rfc)
3
5
 
4
6
  FORMAT_MARKER := mn-output-
5
7
  FORMATS := $(shell grep "$(FORMAT_MARKER)" *.adoc | cut -f 2 -d ' ' | tr ',' '\n' | sort | uniq | tr '\n' ' ')
6
8
 
7
9
  SRC := $(filter-out README.adoc, $(wildcard *.adoc))
8
10
  XML := $(patsubst %.adoc,%.xml,$(SRC))
11
+ XMLRFC3 := $(patsubst %.adoc,%.v3.xml,$(SRC))
9
12
  HTML := $(patsubst %.adoc,%.html,$(SRC))
10
13
  DOC := $(patsubst %.adoc,%.doc,$(SRC))
11
14
  PDF := $(patsubst %.adoc,%.pdf,$(SRC))
15
+ TXT := $(patsubst %.adoc,%.txt,$(SRC))
16
+ NITS := $(patsubst %.adoc,%.nits,$(wildcard draft-*.adoc))
12
17
  WSD := $(wildcard models/*.wsd)
13
18
  XMI := $(patsubst models/%,xmi/%,$(patsubst %.wsd,%.xmi,$(WSD)))
14
19
  PNG := $(patsubst models/%,images/%,$(patsubst %.wsd,%.png,$(WSD)))
@@ -27,10 +32,21 @@ OUT_FILES := $(foreach F,$(_OUT_FILES),$($F))
27
32
 
28
33
  all: images $(OUT_FILES)
29
34
 
30
- %.xml %.html %.doc %.pdf: %.adoc | bundle
35
+ %.v3.xml %.xml %.html %.doc %.pdf %.txt: %.adoc | bundle
31
36
  FILENAME=$^; \
32
37
  ${COMPILE_CMD}
33
38
 
39
+ draft-%.nits: draft-%.txt
40
+ VERSIONED_NAME=`grep :name: draft-$*.adoc | cut -f 2 -d ' '`; \
41
+ cp $^ $${VERSIONED_NAME}.txt && \
42
+ idnits --verbose $${VERSIONED_NAME}.txt > $@ && \
43
+ cp $@ $${VERSIONED_NAME}.nits && \
44
+ cat $${VERSIONED_NAME}.nits
45
+
46
+ %.nits:
47
+
48
+ nits: $(NITS)
49
+
34
50
  images: $(PNG)
35
51
 
36
52
  images/%.png: models/%.wsd
@@ -112,6 +128,6 @@ watch-serve: $(NODE_BIN_DIR)/run-p
112
128
 
113
129
  publish:
114
130
  mkdir -p published && \
115
- cp -a $(basename $(SRC)).* published/ && \
131
+ cp -a $(wildcard $(addsuffix .*,$(basename $(SRC)))) published/ && \
116
132
  cp $(firstword $(HTML)) published/index.html; \
117
133
  if [ -d "images" ]; then cp -a images published; fi
@@ -1,23 +1,20 @@
1
1
  #!make
2
2
 
3
- include metanorma.env
4
- export $(shell sed 's/=.*//' metanorma.env)
5
-
6
- FORMATS := $(METANORMA_FORMATS)
7
- comma := ,
8
- empty :=
9
- space := $(empty) $(empty)
3
+ FORMAT_MARKER := mn-output-
4
+ FORMATS := $(shell grep "$(FORMAT_MARKER)" *.adoc | cut -f 2 -d ' ' | tr ',' '\n' | sort | uniq | tr '\n' ' ')
10
5
 
11
6
  SRC := $(filter-out README.adoc, $(wildcard *.adoc))
12
7
  XML := $(patsubst %.adoc,%.xml,$(SRC))
13
8
  HTML := $(patsubst %.adoc,%.html,$(SRC))
14
9
  DOC := $(patsubst %.adoc,%.doc,$(SRC))
15
10
  PDF := $(patsubst %.adoc,%.pdf,$(SRC))
16
- RXL := $(patsubst %.adoc,%.rxl,$(SRC))
11
+ WSD := $(wildcard models/*.wsd)
12
+ XMI := $(patsubst models/%,xmi/%,$(patsubst %.wsd,%.xmi,$(WSD)))
13
+ PNG := $(patsubst models/%,images/%,$(patsubst %.wsd,%.png,$(WSD)))
17
14
 
18
15
  HOST_SHARE_DIR=$(USERPROFILE)\$(shell for %%I in (.) do echo %%~nxI)
19
- COMPILE_CMD_LOCAL := bundle exec metanorma -R $(RXL) $(SRC)
20
- COMPILE_CMD_DOCKER := C:/ProgramData/chocolatey/bin/docker run --rm -it -v $(CURDIR):/metanorma/ ribose/metanorma "metanorma -R $(RXL) $(SRC)"
16
+ COMPILE_CMD_LOCAL := bundle exec metanorma $(SRC)
17
+ COMPILE_CMD_DOCKER := docker run --rm -it -v $(CURDIR):/metanorma/ ribose/metanorma "metanorma $(SRC)"
21
18
 
22
19
  ifdef METANORMA_DOCKER
23
20
  COMPILE_CMD := echo "Compiling via docker..." & $(COMPILE_CMD_DOCKER)
@@ -33,6 +30,16 @@ all: $(OUT_FILES)
33
30
  %.xml %.html %.doc %.pdf: %.adoc | bundle
34
31
  ${COMPILE_CMD}
35
32
 
33
+ images: $(PNG)
34
+
35
+ images/%.png: models/%.wsd
36
+ plantuml -tpng -o ../images/ $<
37
+
38
+ xmi: $(XMI)
39
+
40
+ xmi/%.xmi: models/%.wsd
41
+ plantuml -xmi:star -o ../xmi/ $<
42
+
36
43
  define FORMAT_TASKS
37
44
  OUT_FILES-$(FORMAT) := $($(shell echo $(FORMAT) | tr '[:lower:]' '[:upper:]'))
38
45
 
@@ -50,8 +57,6 @@ endef
50
57
 
51
58
  $(foreach FORMAT,$(FORMATS),$(eval $(FORMAT_TASKS)))
52
59
 
53
- # open: $(foreach FORMAT,$(FORMATS),open-$(FORMAT))
54
-
55
60
  open: open-html
56
61
 
57
62
  clean:
@@ -60,4 +65,52 @@ clean:
60
65
  bundle:
61
66
  IF "" == "${METANORMA_DOCKER}" bundle
62
67
 
63
- .PHONY: bundle all open clean
68
+ .PHONY: bundle all open clean
69
+
70
+ #
71
+ # Watch-related jobs
72
+ #
73
+
74
+ .PHONY: watch serve watch-serve
75
+
76
+ NODE_BINS := onchange live-serve run-p
77
+ NODE_BIN_DIR := node_modules/.bin
78
+ NODE_PACKAGE_PATHS := $(foreach PACKAGE_NAME,$(NODE_BINS),$(NODE_BIN_DIR)/$(PACKAGE_NAME))
79
+
80
+ $(NODE_PACKAGE_PATHS): package.json
81
+ npm i
82
+
83
+ watch: $(NODE_BIN_DIR)/onchange
84
+ make all
85
+ $< $(ALL_SRC) -- make all
86
+
87
+ define WATCH_TASKS
88
+ watch-$(FORMAT): $(NODE_BIN_DIR)/onchange
89
+ make $(FORMAT)
90
+ $$< $$(SRC_$(FORMAT)) -- make $(FORMAT)
91
+
92
+ .PHONY: watch-$(FORMAT)
93
+ endef
94
+
95
+ $(foreach FORMAT,$(FORMATS),$(eval $(WATCH_TASKS)))
96
+
97
+ serve: $(NODE_BIN_DIR)/live-server revealjs-css reveal.js images
98
+ set PORT=$${PORT:-8123} & \
99
+ set port=$${PORT} & \
100
+ for /r %%html in $(HTML) do ( \
101
+ $< --entry-file=%%html --port=%port% --ignore="*.html,*.xml,Makefile,Gemfile.*,package.*.json" --wait=1000 & \
102
+ set /A port=%port%+1 \
103
+ )
104
+
105
+ watch-serve: $(NODE_BIN_DIR)/run-p
106
+ $< watch serve
107
+
108
+ #
109
+ # Deploy jobs
110
+ #
111
+
112
+ publish:
113
+ mkdir -p published
114
+ xcopy $(basename $(SRC)).* published
115
+ copy $(firstword $(HTML)) published\index.html
116
+ IF EXIST "images" xcopy /E images published
data/test.rxl CHANGED
@@ -1,14 +1,9 @@
1
- <bibdata type="article">
2
- <title>
3
-
4
- </title>
5
- <title>
6
-
7
- </title>
1
+ <bibdata type="standard">
2
+
3
+
4
+
5
+
8
6
  <docidentifier type="iso">ISO 123</docidentifier>
9
- <docidentifier type="iso-structured">
10
- <project-number>ISO 123</project-number>
11
- </docidentifier>
12
7
  <docnumber>123</docnumber>
13
8
  <contributor>
14
9
  <role type="author"/>
@@ -40,9 +35,15 @@
40
35
  </organization>
41
36
  </owner>
42
37
  </copyright>
43
- <editorialgroup>
44
- <technical-committee/>
45
- <subcommittee/>
46
- <workgroup/>
47
- </editorialgroup>
38
+ <ext>
39
+ <doctype>article</doctype>
40
+ <editorialgroup>
41
+ <technical-committee/>
42
+ <subcommittee/>
43
+ <workgroup/>
44
+ </editorialgroup>
45
+ <structuredidentifier>
46
+ <project-number>ISO 123</project-number>
47
+ </structuredidentifier>
48
+ </ext>
48
49
  </bibdata>