metanorma-cli 1.2.13.1 → 1.3.3

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.
@@ -25,10 +25,12 @@ module Metanorma
25
25
  end
26
26
  end
27
27
 
28
+ # @return [Array<String>]
28
29
  def compile
29
30
  compile_file
30
31
  end
31
32
 
33
+ # @return [Array<String>]
32
34
  def self.compile(file, options)
33
35
  new(file, options).compile
34
36
  end
@@ -37,8 +39,11 @@ module Metanorma
37
39
 
38
40
  attr_reader :file, :options, :extract, :extensions
39
41
 
42
+ # @return [Array<String>]
40
43
  def compile_file
41
- Compile.new.compile(file, serialize_options)
44
+ c = Compile.new
45
+ c.compile(file, serialize_options)
46
+ c.errors
42
47
  end
43
48
 
44
49
  def serialize_options
@@ -40,9 +40,11 @@ module Metanorma
40
40
  end
41
41
 
42
42
  def download_font
43
- Fontist::Finder.find(font_name)
44
- rescue Fontist::Errors::MissingFontError
45
- ask_user_and_download_font(font_name)
43
+ begin
44
+ Fontist::Font.find(font_name)
45
+ rescue Fontist::Errors::MissingFontError
46
+ ask_user_and_download_font(font_name)
47
+ end
46
48
  end
47
49
 
48
50
  def copy_to_fonts(fonts_path)
@@ -54,25 +56,37 @@ module Metanorma
54
56
 
55
57
  def ask_user_and_download_font(font_name)
56
58
  response = term_agreement ? "yes" : "no"
59
+ formula = Fontist::Formula.find(font_name)
57
60
 
58
61
  if !term_agreement
59
- response = UI.ask(message.strip)
62
+ response = UI.ask(message(formula.license).strip)
60
63
  end
61
64
 
62
65
  if response.downcase === "yes"
63
- Fontist::Installer.download(font_name, confirmation: response)
66
+ Fontist::Font.install(font_name, confirmation: response)
64
67
  end
65
68
  end
66
69
 
67
- def message
70
+ def message(license)
68
71
  <<~MSG
69
- Metanorma has detected that you do not have the necessary fonts installed
70
- for PDF generation. The generated PDF will use generic fonts that may not
71
- resemble the desired styling. Metanorma can download these files for you
72
- if you accept the font licensing conditions for the font #{font_name}.
72
+ FONT LICENSE ACCEPTANCE REQUIRED:
73
+
74
+ Metanorma has detected that you do not have the necessary fonts installed
75
+ for PDF generation. Without those fonts, the generated PDF will use
76
+ generic fonts that may not resemble the desired styling.
77
+
78
+ Metanorma can download these files for you if you accept the font
79
+ licensing conditions for the font "#{font_name}".
80
+
81
+ FONT LICENSE BEGIN ("#{font_name}")
82
+ -----------------------------------------------------------------------
83
+ #{license}
84
+ -----------------------------------------------------------------------
85
+ FONT LICENSE END ("#{font_name}")
73
86
 
74
- If you want Metanorma to download these fonts for you and indicate your
75
- acceptance of the font licenses, type "Yes" / "No":
87
+ Do you accept all presented font licenses, and want Metanorma to
88
+ download these fonts for you?
89
+ => TYPE "Yes" or "No":
76
90
  MSG
77
91
  end
78
92
  end
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module Cli
3
- VERSION = "1.2.13.1"
3
+ VERSION = "1.3.3"
4
4
  end
5
5
  end
@@ -24,6 +24,7 @@ Gem::Specification.new do |spec|
24
24
  spec.required_ruby_version = '>= 2.4.0'
25
25
 
26
26
  spec.add_development_dependency "pry"
27
+ spec.add_development_dependency "sassc", "2.4.0"
27
28
  spec.add_development_dependency "rake", "~> 12.0"
28
29
  spec.add_development_dependency "rspec", "~> 3.0"
29
30
  spec.add_development_dependency "byebug", "~> 10.0"
@@ -31,27 +32,27 @@ Gem::Specification.new do |spec|
31
32
  spec.add_development_dependency "equivalent-xml", "~> 0.6"
32
33
  spec.add_development_dependency "rspec-core", "~> 3.4"
33
34
 
34
- spec.add_runtime_dependency "thor", "~> 0.20.3"
35
- spec.add_runtime_dependency "metanorma-iso", "~> 1.3.0"
36
- spec.add_runtime_dependency 'metanorma-ietf', "~> 2.0.0"
37
- spec.add_runtime_dependency 'metanorma-gb', "~> 1.3.0"
38
- spec.add_runtime_dependency 'metanorma-iec', "~> 1.0.0"
39
- spec.add_runtime_dependency 'metanorma-csd', "~> 1.3.0"
40
- spec.add_runtime_dependency 'metanorma-csa', "~> 1.4.0"
41
- #spec.add_runtime_dependency 'metanorma-rsd', "~> 1.4.0"
42
- spec.add_runtime_dependency 'metanorma-m3d', "~> 1.3.0"
43
- spec.add_runtime_dependency 'metanorma-generic', "~> 1.4.0"
35
+ spec.add_runtime_dependency "thor", "~> 1.0"
36
+ spec.add_runtime_dependency "metanorma-iso", "~> 1.4.0"
37
+ spec.add_runtime_dependency 'metanorma-ietf', "~> 2.1.0"
38
+ spec.add_runtime_dependency 'metanorma-gb', "~> 1.4.0"
39
+ spec.add_runtime_dependency 'metanorma-iec', "~> 1.1.0"
40
+ spec.add_runtime_dependency 'metanorma-cc', "~> 1.4.0"
41
+ spec.add_runtime_dependency 'metanorma-csa', "~> 1.5.0"
42
+ #spec.add_runtime_dependency 'metanorma-ribose', "~> 1.5.0"
43
+ spec.add_runtime_dependency 'metanorma-m3aawg', "~> 1.4.0"
44
+ spec.add_runtime_dependency 'metanorma-generic', "~> 1.5.0"
44
45
  spec.add_runtime_dependency 'metanorma-standoc', "~> 1.4.0"
45
- #spec.add_runtime_dependency 'metanorma-mpfd', "~> 0.1.0"
46
- spec.add_runtime_dependency 'metanorma-un', "~> 0.3.1"
47
- spec.add_runtime_dependency 'metanorma-ogc', "~> 1.0.0"
48
- spec.add_runtime_dependency 'metanorma-nist', "~> 1.0.0"
49
- spec.add_runtime_dependency 'metanorma-itu', "~> 1.0.0"
50
- spec.add_runtime_dependency 'metanorma-iho', "~> 0.0.1"
51
- spec.add_runtime_dependency 'isodoc', "~> 1.0.0"
52
- spec.add_runtime_dependency 'metanorma', "~> 1.0.0"
46
+ #spec.add_runtime_dependency 'metanorma-mpfa', "~> 0.4.0"
47
+ spec.add_runtime_dependency 'metanorma-un', "~> 0.4.0"
48
+ spec.add_runtime_dependency 'metanorma-ogc', "~> 1.1.0"
49
+ spec.add_runtime_dependency 'metanorma-nist', "~> 1.1.0"
50
+ spec.add_runtime_dependency 'metanorma-itu', "~> 1.1.0"
51
+ spec.add_runtime_dependency 'metanorma-iho', "~> 0.1.0"
52
+ spec.add_runtime_dependency 'isodoc', "~> 1.1.0"
53
+ spec.add_runtime_dependency 'metanorma', "~> 1.1.0"
53
54
  #spec.add_runtime_dependency 'nokogiri', ">= 1"
54
55
  spec.add_runtime_dependency "git", "~> 1.5"
55
56
  spec.add_runtime_dependency "relaton-cli", ">= 0.8.2"
56
- spec.add_runtime_dependency "fontist", "~> 0.2.0"
57
+ spec.add_runtime_dependency "fontist", "~> 1.0"
57
58
  end
@@ -0,0 +1 @@
1
+ 0.5.0
@@ -0,0 +1,51 @@
1
+ <bibdata type="standard">
2
+ <title language="en" format="text/plain">Rice model</title>
3
+ <title language="intro-en" format="text/plain">Cereals and pulses</title>
4
+ <title language="main-en" format="text/plain">Specifications and test methods</title>
5
+ <title language="part-en" format="text/plain">Rice</title>
6
+ <title language="intro-fr" format="text/plain">Céréales et légumineuses</title>
7
+ <title language="main-fr" format="text/plain">Spécification et méthodes d'essai</title>
8
+ <title language="part-fr" format="text/plain">Riz</title>
9
+ <docidentifier type="m3d">17301:2016</docidentifier>
10
+ <docnumber>17301</docnumber>
11
+ <contributor>
12
+ <role type="author"/>
13
+ <organization>
14
+ <name>Messaging Malware and Mobile Anti-Abuse Working Group</name>
15
+ <abbreviation>M3AAWG</abbreviation>
16
+ </organization>
17
+ </contributor>
18
+ <contributor>
19
+ <role type="publisher"/>
20
+ <organization>
21
+ <name>Messaging Malware and Mobile Anti-Abuse Working Group</name>
22
+ <abbreviation>M3AAWG</abbreviation>
23
+ </organization>
24
+ </contributor>
25
+ <edition>2</edition>
26
+ <version>
27
+ <revision-date>2016-05-01</revision-date>
28
+
29
+ </version>
30
+ <language>en</language>
31
+ <script>Latn</script>
32
+ <status>
33
+ <stage>30</stage>
34
+ <substage>92</substage>
35
+ </status>
36
+ <copyright>
37
+ <from>2016</from>
38
+ <owner>
39
+ <organization>
40
+ <name>Messaging Malware and Mobile Anti-Abuse Working Group</name>
41
+ <abbreviation>M3AAWG</abbreviation>
42
+ </organization>
43
+ </owner>
44
+ </copyright>
45
+ <ext>
46
+ <doctype>report</doctype>
47
+ <editorialgroup>
48
+ <committee>Food products</committee>
49
+ </editorialgroup>
50
+ </ext>
51
+ </bibdata>
@@ -0,0 +1,5 @@
1
+ def ruby(x)
2
+ if x < 0 && x > 1
3
+ return
4
+ end
5
+ end
@@ -0,0 +1,52 @@
1
+ <bibdata type="standard">
2
+
3
+
4
+
5
+
6
+ <docidentifier type="iso">ISO 123</docidentifier>
7
+ <docidentifier type="iso-with-lang">ISO 123(E)</docidentifier>
8
+ <docidentifier type="iso-reference">ISO 123(E)</docidentifier>
9
+ <docnumber>123</docnumber>
10
+ <contributor>
11
+ <role type="author"/>
12
+ <organization>
13
+ <name>International Organization for Standardization</name>
14
+ <abbreviation>ISO</abbreviation>
15
+ </organization>
16
+ </contributor>
17
+ <contributor>
18
+ <role type="publisher"/>
19
+ <organization>
20
+ <name>International Organization for Standardization</name>
21
+ <abbreviation>ISO</abbreviation>
22
+ </organization>
23
+ </contributor>
24
+
25
+ <language>en</language>
26
+ <script>script.html</script>
27
+ <status>
28
+ <stage abbreviation="IS">60</stage>
29
+ <substage>60</substage>
30
+ </status>
31
+ <copyright>
32
+ <from>2020</from>
33
+ <owner>
34
+ <organization>
35
+ <name>International Organization for Standardization</name>
36
+ <abbreviation>ISO</abbreviation>
37
+ </organization>
38
+ </owner>
39
+ </copyright>
40
+ <ext>
41
+ <doctype>article</doctype>
42
+ <editorialgroup>
43
+ <technical-committee/>
44
+ <subcommittee/>
45
+ <workgroup/>
46
+ </editorialgroup>
47
+ <structuredidentifier>
48
+ <project-number>ISO 123</project-number>
49
+ </structuredidentifier>
50
+ <stagename>International standard</stagename>
51
+ </ext>
52
+ </bibdata>
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ gem "metanorma-cli"
4
+ gem "relaton-cli"
@@ -0,0 +1,144 @@
1
+ #!make
2
+ SHELL := /bin/bash
3
+ # Ensure the xml2rfc cache directory exists locally
4
+ IGNORE := $(shell mkdir -p $(HOME)/.cache/xml2rfc)
5
+
6
+ SRC := $(shell yq r metanorma.yml metanorma.source.files | cut -c 3-999)
7
+ ifeq ($(SRC),ll)
8
+ SRC := $(filter-out README.adoc, $(wildcard *.adoc))
9
+ endif
10
+
11
+ FORMAT_MARKER := mn-output-
12
+ FORMATS := $(shell grep "$(FORMAT_MARKER)" $(SRC) | cut -f 2 -d ' ' | tr ',' '\n' | sort | uniq | tr '\n' ' ')
13
+
14
+ XML := $(patsubst %.adoc,%.xml,$(SRC))
15
+ XMLRFC3 := $(patsubst %.adoc,%.v3.xml,$(SRC))
16
+ HTML := $(patsubst %.adoc,%.html,$(SRC))
17
+ DOC := $(patsubst %.adoc,%.doc,$(SRC))
18
+ PDF := $(patsubst %.adoc,%.pdf,$(SRC))
19
+ TXT := $(patsubst %.adoc,%.txt,$(SRC))
20
+ NITS := $(patsubst %.adoc,%.nits,$(wildcard draft-*.adoc))
21
+ WSD := $(wildcard models/*.wsd)
22
+ XMI := $(patsubst models/%,xmi/%,$(patsubst %.wsd,%.xmi,$(WSD)))
23
+ PNG := $(patsubst models/%,images/%,$(patsubst %.wsd,%.png,$(WSD)))
24
+
25
+ COMPILE_CMD_LOCAL := bundle exec metanorma $$FILENAME
26
+ COMPILE_CMD_DOCKER := docker run -v "$$(pwd)":/metanorma/ ribose/metanorma "metanorma $$FILENAME"
27
+
28
+ ifdef METANORMA_DOCKER
29
+ COMPILE_CMD := echo "Compiling via docker..."; $(COMPILE_CMD_DOCKER)
30
+ else
31
+ COMPILE_CMD := echo "Compiling locally..."; $(COMPILE_CMD_LOCAL)
32
+ endif
33
+
34
+ _OUT_FILES := $(foreach FORMAT,$(FORMATS),$(shell echo $(FORMAT) | tr '[:lower:]' '[:upper:]'))
35
+ OUT_FILES := $(foreach F,$(_OUT_FILES),$($F))
36
+
37
+ all: images $(OUT_FILES)
38
+
39
+ %.v3.xml %.xml %.html %.doc %.pdf %.txt: %.adoc | bundle
40
+ FILENAME=$^; \
41
+ ${COMPILE_CMD}
42
+
43
+ draft-%.nits: draft-%.txt
44
+ VERSIONED_NAME=`grep :name: draft-$*.adoc | cut -f 2 -d ' '`; \
45
+ cp $^ $${VERSIONED_NAME}.txt && \
46
+ idnits --verbose $${VERSIONED_NAME}.txt > $@ && \
47
+ cp $@ $${VERSIONED_NAME}.nits && \
48
+ cat $${VERSIONED_NAME}.nits
49
+
50
+ %.nits:
51
+
52
+ nits: $(NITS)
53
+
54
+ images: $(PNG)
55
+
56
+ images/%.png: models/%.wsd
57
+ plantuml -tpng -o ../images/ $<
58
+
59
+ xmi: $(XMI)
60
+
61
+ xmi/%.xmi: models/%.wsd
62
+ plantuml -xmi:star -o ../xmi/ $<
63
+
64
+ define FORMAT_TASKS
65
+ OUT_FILES-$(FORMAT) := $($(shell echo $(FORMAT) | tr '[:lower:]' '[:upper:]'))
66
+
67
+ open-$(FORMAT):
68
+ open $$(OUT_FILES-$(FORMAT))
69
+
70
+ clean-$(FORMAT):
71
+ rm -f $$(OUT_FILES-$(FORMAT))
72
+
73
+ $(FORMAT): clean-$(FORMAT) $$(OUT_FILES-$(FORMAT))
74
+
75
+ .PHONY: clean-$(FORMAT)
76
+
77
+ endef
78
+
79
+ $(foreach FORMAT,$(FORMATS),$(eval $(FORMAT_TASKS)))
80
+
81
+ open: open-html
82
+
83
+ clean:
84
+ rm -f $(OUT_FILES) && rm -rf published
85
+
86
+ bundle:
87
+ if [ "x" == "${METANORMA_DOCKER}x" ]; then bundle; fi
88
+
89
+ .PHONY: bundle all open clean
90
+
91
+ #
92
+ # Watch-related jobs
93
+ #
94
+
95
+ .PHONY: watch serve watch-serve
96
+
97
+ NODE_BINS := onchange live-serve run-p
98
+ NODE_BIN_DIR := node_modules/.bin
99
+ NODE_PACKAGE_PATHS := $(foreach PACKAGE_NAME,$(NODE_BINS),$(NODE_BIN_DIR)/$(PACKAGE_NAME))
100
+
101
+ $(NODE_PACKAGE_PATHS): package.json
102
+ npm i
103
+
104
+ watch: $(NODE_BIN_DIR)/onchange
105
+ $(MAKE) all
106
+ $< $(ALL_SRC) -- $(MAKE) all
107
+
108
+ define WATCH_TASKS
109
+ watch-$(FORMAT): $(NODE_BIN_DIR)/onchange
110
+ $(MAKE) $(FORMAT)
111
+ $$< $$(SRC_$(FORMAT)) -- $(MAKE) $(FORMAT)
112
+
113
+ .PHONY: watch-$(FORMAT)
114
+ endef
115
+
116
+ $(foreach FORMAT,$(FORMATS),$(eval $(WATCH_TASKS)))
117
+
118
+ serve: $(NODE_BIN_DIR)/live-server revealjs-css reveal.js images
119
+ export PORT=$${PORT:-8123} ; \
120
+ port=$${PORT} ; \
121
+ for html in $(HTML); do \
122
+ $< --entry-file=$$html --port=$${port} --ignore="*.html,*.xml,Makefile,Gemfile.*,package.*.json" --wait=1000 & \
123
+ port=$$(( port++ )) ;\
124
+ done
125
+
126
+ watch-serve: $(NODE_BIN_DIR)/run-p
127
+ $< watch serve
128
+
129
+ #
130
+ # Deploy jobs
131
+ #
132
+
133
+ publish:
134
+ $(MAKE) published
135
+
136
+ published:
137
+ mkdir -p $@ && \
138
+ export GLOBIGNORE=$(SRC); \
139
+ cp -a $(addsuffix .*,$(basename $(SRC))) $@/; \
140
+ unset GLOBIGNORE; \
141
+ cp $(firstword $(HTML)) $@/index.html
142
+
143
+ .PHONY: publish
144
+
@@ -0,0 +1,116 @@
1
+ #!make
2
+
3
+ FORMAT_MARKER := mn-output-
4
+ FORMATS := $(shell grep "$(FORMAT_MARKER)" *.adoc | cut -f 2 -d ' ' | tr ',' '\n' | sort | uniq | tr '\n' ' ')
5
+
6
+ SRC := $(filter-out README.adoc, $(wildcard *.adoc))
7
+ XML := $(patsubst %.adoc,%.xml,$(SRC))
8
+ HTML := $(patsubst %.adoc,%.html,$(SRC))
9
+ DOC := $(patsubst %.adoc,%.doc,$(SRC))
10
+ PDF := $(patsubst %.adoc,%.pdf,$(SRC))
11
+ WSD := $(wildcard models/*.wsd)
12
+ XMI := $(patsubst models/%,xmi/%,$(patsubst %.wsd,%.xmi,$(WSD)))
13
+ PNG := $(patsubst models/%,images/%,$(patsubst %.wsd,%.png,$(WSD)))
14
+
15
+ HOST_SHARE_DIR=$(USERPROFILE)\$(shell for %%I in (.) do echo %%~nxI)
16
+ COMPILE_CMD_LOCAL := bundle exec metanorma $(SRC)
17
+ COMPILE_CMD_DOCKER := docker run --rm -it -v $(CURDIR):/metanorma/ ribose/metanorma "metanorma $(SRC)"
18
+
19
+ ifdef METANORMA_DOCKER
20
+ COMPILE_CMD := echo "Compiling via docker..." & $(COMPILE_CMD_DOCKER)
21
+ else
22
+ COMPILE_CMD := echo "Compiling locally..." & $(COMPILE_CMD_LOCAL)
23
+ endif
24
+
25
+ _OUT_FILES := $(foreach FORMAT,$(FORMATS),$(shell echo $(FORMAT) | tr '[:lower:]' '[:upper:]'))
26
+ OUT_FILES := $(foreach F,$(_OUT_FILES),$($F))
27
+
28
+ all: $(OUT_FILES)
29
+
30
+ %.xml %.html %.doc %.pdf: %.adoc | bundle
31
+ ${COMPILE_CMD}
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
+
43
+ define FORMAT_TASKS
44
+ OUT_FILES-$(FORMAT) := $($(shell echo $(FORMAT) | tr '[:lower:]' '[:upper:]'))
45
+
46
+ open-$(FORMAT):
47
+ $$(OUT_FILES-$(FORMAT))
48
+
49
+ clean-$(FORMAT):
50
+ rm $$(OUT_FILES-$(FORMAT))
51
+
52
+ $(FORMAT): clean-$(FORMAT) $$(OUT_FILES-$(FORMAT))
53
+
54
+ .PHONY: clean-$(FORMAT)
55
+
56
+ endef
57
+
58
+ $(foreach FORMAT,$(FORMATS),$(eval $(FORMAT_TASKS)))
59
+
60
+ open: open-html
61
+
62
+ clean:
63
+ rm -rf $(OUT_FILES)
64
+
65
+ bundle:
66
+ IF "" == "${METANORMA_DOCKER}" bundle
67
+
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