metanorma-cli 1.5.8 → 1.5.10

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f21088e13696d1170c99a3533f1fff240743ccfd11e5988bfb5a2542ed5d9de7
4
- data.tar.gz: 74254c94389b45e243685087d5bb661ae00a9871438dabd7798f1f5c750e3324
3
+ metadata.gz: 54eb6a2ad7f5f0483dd32189632d20386457c90257f83b2a0b9c395d335a9031
4
+ data.tar.gz: 6d816f2d883e86292f65dd55a10c6a0042a9f3e487dd251b206bae2b2153f602
5
5
  SHA512:
6
- metadata.gz: 36ebaac6f842b6ef166329fb06e4d7b4856f0576e8775a36d57a2084ea7bb883812726362982d7047cf22ede3a425f88fcbd6ea18648a73c61d965e1fb1577b5
7
- data.tar.gz: d8c432f10e48f7b2291eed12242e5628845cbe6687134d1a0b33484088f8673d526ead112a599a4291e2e901479804aaa6f1df31d3be4ceed36c991736ca7b1c
6
+ metadata.gz: e4816f15879472cf5618c5cf85ff09411f5a879c79c28867b6c6aed60f2fb7d9d958677955c36051343630eddd4add57adf90920e98de90030911e0600d6faf5
7
+ data.tar.gz: caf5d48067f2ba0181af121676566a70fce0cc5635dfeacbaef2862592375b857883455a214617d88429a9d5dcf8a5c4b9a70503c09ee0d1c04c96055fa90668
@@ -4,24 +4,19 @@ The `metanorma` command-line executable is installed by this Ruby gem.
4
4
 
5
5
  [IMPORTANT]
6
6
  ====
7
- Users of the Metanorma suite should install Metanorma according to the steps at
8
- the
9
- https://www.metanorma.org/author/topics/install/[Metanorma installation guide].
7
+ Users of the Metanorma suite should install Metanorma according to the steps at the https://www.metanorma.org/author/topics/install/[Metanorma installation guide].
10
8
 
11
9
  The instructions provided here are intended for Metanorma developers, since
12
10
  a number of third-party dependencies will also need to be installed manually.
13
11
  ====
14
12
 
15
-
16
13
  == Install Ruby
17
14
 
18
15
  == macOS
19
16
 
20
- While macOS provides a default installation of Ruby, it is restricted in a
21
- number of ways.
17
+ While macOS provides a default installation of Ruby, it is restricted in a number of ways.
22
18
 
23
- We strongly recommend installing a Ruby outside of the system Ruby using
24
- `rbenv`.
19
+ We strongly recommend installing a Ruby outside of the system Ruby using `rbenv`.
25
20
 
26
21
  [source,console]
27
22
  ----
@@ -47,39 +42,39 @@ $ rbenv global 2.7.4
47
42
 
48
43
  == Linux
49
44
 
50
- Ruby may not be pre-installed on your Linux distribution.
45
+ Ruby is sometimes included with Linux. To see if you already have it (and check the version):
51
46
 
52
- Please follow the official
53
- https://www.ruby-lang.org/en/documentation/installation[Ruby installation guide].
47
+ 1. Open a console/terminal
48
+ 2. Type `ruby -v`
54
49
 
55
- == Windows
50
+ If Ruby is installed, you'll see something like the following
51
+ [source, console]
52
+ ----
53
+ ruby 3.1.0p0 (2021-12-25 revision fb4df44d16) [x86_64-linux]
54
+ ----
56
55
 
57
- Ruby is not pre-installed on Windows.
56
+ If not, follow the official
57
+ https://www.ruby-lang.org/en/documentation/installation[Ruby installation guide].
58
58
 
59
- The easiest way to install Ruby is with `RubyInstaller`, as recommended by
60
- the official
61
- https://www.ruby-lang.org/en/documentation/installation[Ruby installation guide])
59
+ == Windows
62
60
 
63
- If you prefer an automated way to install, we recommend using
64
- https://chocolatey.org/install[Chocolatey] with commands below:
61
+ Ruby is not pre-installed on Windows. There are several ways to install it:
65
62
 
66
- [source,console]
67
- ----
68
- choco install -y msys2 ruby
69
- refreshenv
70
- ridk install 3
71
- ----
63
+ . For an *easy* experience, use `RubyInstaller`, via the official https://www.ruby-lang.org/en/documentation/installation[Ruby installation guide])
64
+ . For a more *developer-friendly* experience, install Ruby via a Linux distribution (like Ubuntu) hosted in the [Windows Subsystem for Linux (WSL)](https://docs.microsoft.com/en-us/windows/wsl/). [Install WSL2]((https://docs.microsoft.com/en-us/windows/wsl/install), and then [Install Ruby](https://gorails.com/setup/ubuntu/21.04).
65
+ . For a *simpler command-line* experience, first install the [Chocolatey](https://chocolatey.org/install) package manager, then add Ruby packaged with [the MSYS2 build tools](https://www.msys2.org/). This process is explained below:
72
66
 
73
- Those commands will work with both PowerShell and CMD.exe.
74
67
 
68
+ .. Open a command prompt (`cmd.exe`) or *PowerShell* console.
69
+ .. Type `choco install -y msys2 ruby`. (If you have a firewall, you may be prompted to allow *dirmngr.exe* and *pacman.exe*. These are part of Ruby and are safe).
70
+ .. When the installation completes, type `refreshenv` to make Ruby available to you.
71
+ .. Type `ridk install 3` to complete the installation of Ruby version 3. This make take a while.
75
72
 
76
- == Other
73
+ == Other Ruby Resources
77
74
 
78
75
  Further details (or FAQ) on Ruby installation please visit the official
79
76
  https://www.ruby-lang.org/en/documentation/installation[Ruby installation guide].
80
77
 
81
-
82
-
83
78
  == Installing the Metanorma CLI gem
84
79
 
85
80
  Once Ruby is installed, you can install `metanorma-cli` as a gem:
@@ -18,12 +18,12 @@ module Metanorma
18
18
  if Cli.writable_templates_path?
19
19
  if name && document_path.exist?
20
20
  return unless overwrite?(document_path)
21
+
21
22
  document_path.rmtree
22
23
  end
23
24
 
24
25
  create_metanorma_document
25
26
  end
26
-
27
27
  rescue Errno::EACCES
28
28
  permission_missing_error
29
29
  end
@@ -53,17 +53,24 @@ module Metanorma
53
53
  def create_metanorma_document
54
54
  type_template = type_specific_template
55
55
 
56
- unless type_template.empty?
57
- templates = base_templates.merge(type_template)
58
- templates.each { |source, dest| create_file(source, dest) }
59
- else
56
+ if type_template.empty?
60
57
  UI.say(
61
- "Unable to generate document:\n" \
62
- "Templates for type #{type.to_s} cannot be found -- please provide a valid `type` or a template URL"
58
+ "Unable to generate document:\n#{create_metanorma_document_error}",
63
59
  )
60
+ else
61
+ templates = base_templates.merge(type_template)
62
+ templates.each { |dest, source| create_file(source, dest) }
64
63
  end
65
64
  end
66
65
 
66
+ def create_metanorma_document_error
67
+ type == "ogc" && doctype == "charter" and return <<~ERR
68
+ The template for OGC charter documents can be downloaded from https://github.com/opengeospatial/templates/tree/master/charter_templates
69
+ ERR
70
+ "Templates for type #{type} cannot be found -- "\
71
+ "please provide a valid `type` or a template URL"
72
+ end
73
+
67
74
  def find_standard_template(type)
68
75
  Cli::GitTemplate.find_or_download_by(type)
69
76
  end
@@ -74,18 +81,22 @@ module Metanorma
74
81
 
75
82
  def base_templates
76
83
  base_template_root = Cli.base_templates_path
77
- build_template_hash(dir_files(base_template_root), base_template_root)
84
+ build_template_hash(base_template_root)
78
85
  end
79
86
 
80
87
  def type_specific_template
81
- type_template_path = custom_template || find_standard_template(type)
82
- doctype_templates = dir_files(type_template_path, doctype)
83
- build_template_hash(doctype_templates, type_template_path, doctype)
88
+ template_path = custom_template || find_standard_template(type)
89
+ return {} if template_path.nil?
90
+
91
+ result = build_template_hash(template_path, doctype)
92
+ return result if result.empty?
93
+
94
+ result.merge(build_template_common_hash(template_path))
84
95
  end
85
96
 
86
97
  def custom_template
87
98
  if template
88
- if template !~ URI::regexp
99
+ if !template&.match?(URI::DEFAULT_PARSER.make_regexp)
89
100
  return Pathname.new(template)
90
101
  end
91
102
 
@@ -93,17 +104,32 @@ module Metanorma
93
104
  end
94
105
  end
95
106
 
96
- def build_template_hash(elements, source_root, type = nil)
97
- type_template_path = [source_root, type].join("/")
107
+ def build_template_common_hash(source_root)
108
+ common_path = Pathname.new(source_root) / "common"
109
+ paths = dir_files(common_path)
110
+
111
+ Hash.new.tap do |hash|
112
+ paths.each do |path|
113
+ dest = Pathname.new(path).relative_path_from(common_path).to_s
114
+ hash[dest] = path
115
+ end
116
+ end
117
+ end
98
118
 
119
+ def build_template_hash(source_root, doctype = nil)
120
+ source_path = Pathname.new(source_root)
121
+ source_path /= doctype unless doctype.nil?
122
+ paths = dir_files(source_path)
99
123
  Hash.new.tap do |hash|
100
- elements.each do |element|
101
- hash[element] = element.gsub(type_template_path, "")
124
+ paths.each do |path|
125
+ dest = Pathname.new(path).relative_path_from(source_path).to_s
126
+ hash[dest] = path
102
127
  end
103
128
  end
104
129
  end
105
130
 
106
131
  def create_file(source, destination)
132
+ p "source=#{source} destination=#{destination}"
107
133
  target_path = [document_path, destination].join("/")
108
134
  target_path = Pathname.new(target_path)
109
135
 
@@ -124,13 +150,13 @@ module Metanorma
124
150
 
125
151
  def ask_to_confirm(document)
126
152
  UI.ask(
127
- "You've an existing document with the #{document.to_s}\n" \
153
+ "You've an existing document with the #{document}\n" \
128
154
  "Still want to continue, and overwrite the existing one? (yes/no):",
129
155
  ).downcase
130
156
  end
131
157
 
132
158
  def file_creation_message(document, destination)
133
- UI.say("Creating #{[document, destination].join("/").gsub("//", "/")}")
159
+ UI.say("Creating #{[document, destination].join('/').gsub('//', '/')}")
134
160
  end
135
161
 
136
162
  def permission_missing_error
@@ -139,7 +165,7 @@ module Metanorma
139
165
  "The current user does not have permission to write to this path:\n" \
140
166
  "#{Cli.templates_path}\n" \
141
167
  "Please ensure the path is writable by the current user, or\n" \
142
- "run Metanorma using a different user with write permissions."
168
+ "run Metanorma using a different user with write permissions.",
143
169
  )
144
170
  end
145
171
  end
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module Cli
3
- VERSION = "1.5.8".freeze
3
+ VERSION = "1.5.10".freeze
4
4
  end
5
5
  end
@@ -1,4 +1,6 @@
1
1
  ---
2
2
  metanorma:
3
- deploy:
4
- email: "ci@metanorma.org"
3
+ source:
4
+ files:
5
+ - document.adoc
6
+
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.5.8
4
+ version: 1.5.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-01-22 00:00:00.000000000 Z
11
+ date: 2022-02-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: debug
@@ -492,8 +492,6 @@ files:
492
492
  - lib/metanorma/flavor.rb
493
493
  - metanorma-cli.gemspec
494
494
  - templates/base/Gemfile
495
- - templates/base/Makefile
496
- - templates/base/Makefile.win
497
495
  - templates/base/metanorma.yml
498
496
  homepage: https://www.metanorma.com
499
497
  licenses:
@@ -1,196 +0,0 @@
1
- # Auto-generated by Cimas: Do not edit it manually!
2
- # See https://github.com/metanorma/cimas
3
- #!make
4
- SHELL := /bin/bash
5
- # Ensure the xml2rfc cache directory exists locally
6
- IGNORE := $(shell mkdir -p $(HOME)/.cache/xml2rfc)
7
-
8
- SRC := $(shell yq r metanorma.yml metanorma.source.files | cut -c 3-)
9
-
10
- ifeq ($(SRC),null)
11
- SRC :=
12
- endif
13
- ifeq ($(SRC),ll)
14
- SRC :=
15
- endif
16
-
17
- ifeq ($(SRC),)
18
- BUILT := $(shell yq r metanorma.yml metanorma.source.built_targets | cut -d ':' -f 1 | tr -s '\n' ' ')
19
-
20
- ifeq ($(BUILT),null)
21
- SRC :=
22
- endif
23
- ifeq ($(BUILT),ll)
24
- SRC :=
25
- endif
26
-
27
- ifeq ($(BUILT),)
28
- SRC := $(filter-out README.adoc, $(wildcard sources/*.adoc))
29
- else
30
- XML := $(patsubst sources/%,documents/%,$(BUILT))
31
- endif
32
- endif
33
-
34
- FORMATS := $(shell yq r metanorma.yml metanorma.formats | tr -d '[:space:]' | tr -s '-' ' ')
35
- ifeq ($(FORMATS),)
36
- FORMAT_MARKER := mn-output-
37
- FORMATS := $(shell grep "$(FORMAT_MARKER)" $(SRC) | cut -f 2 -d " " | tr "," "\\n" | sort | uniq | tr "\\n" " ")
38
- endif
39
-
40
- XML ?= $(patsubst sources/%,documents/%,$(patsubst %.adoc,%.xml,$(SRC)))
41
- HTML := $(patsubst %.xml,%.html,$(XML))
42
-
43
- ifdef METANORMA_DOCKER
44
- PREFIX_CMD := echo "Running via docker..."; docker run -v "$$(pwd)":/metanorma/ $(METANORMA_DOCKER)
45
- else
46
- ifdef SKIP_BUNDLE
47
- PREFIX_CMD := echo "Running locally...";
48
- else
49
- PREFIX_CMD := echo "Running locally via bundle ..."; bundle exec
50
- endif
51
- endif
52
-
53
- _OUT_FILES := $(foreach FORMAT,$(FORMATS),$(shell echo $(FORMAT) | tr '[:lower:]' '[:upper:]'))
54
- OUT_FILES := $(foreach F,$(_OUT_FILES),$($F))
55
-
56
- define print_vars
57
- $(info "src $(SRC)")
58
- $(info "xml $(XML)")
59
- $(info "formats $(FORMATS)")
60
- endef
61
-
62
- all: documents.html
63
- $(call print_vars)
64
-
65
- documents:
66
- mkdir -p $@
67
-
68
- documents/%.html: documents/%.xml | documents
69
- ${PREFIX_CMD} metanorma $<
70
-
71
- documents/%.xml: sources/%.xml | documents
72
- mkdir -p $(dir $@)
73
- mv $< $@
74
-
75
- # Build canonical XML output
76
- # If XML file is provided, copy it over
77
- # Otherwise, build the xml using adoc
78
- sources/%.xml: | bundle
79
- BUILT_TARGET="$(shell yq r metanorma.yml metanorma.source.built_targets[$@])"; \
80
- if [ "$$BUILT_TARGET" = "" ] || [ "$$BUILT_TARGET" = "null" ]; then \
81
- BUILT_TARGET=$@; \
82
- $(PREFIX_CMD) metanorma -x xml "$${BUILT_TARGET//xml/adoc}"; \
83
- else \
84
- if [ -f "$$BUILT_TARGET" ] && [ "$${BUILT_TARGET##*.}" == "xml" ]; then \
85
- cp "$$BUILT_TARGET" $@; \
86
- else \
87
- $(PREFIX_CMD) metanorma -x xml $$BUILT_TARGET; \
88
- cp "$${BUILT_TARGET//adoc/xml}" $@; \
89
- fi \
90
- fi
91
-
92
- documents.rxl: $(XML) $(HTML)
93
- ${PREFIX_CMD} relaton concatenate \
94
- -t "$(shell yq r metanorma.yml relaton.collection.name)" \
95
- -g "$(shell yq r metanorma.yml relaton.collection.organization)" \
96
- documents $@
97
-
98
- documents.html: documents.rxl
99
- $(PREFIX_CMD) relaton xml2html documents.rxl
100
-
101
- %.adoc:
102
-
103
- define FORMAT_TASKS
104
- OUT_FILES-$(FORMAT) := $($(shell echo $(FORMAT) | tr '[:lower:]' '[:upper:]'))
105
-
106
- open-$(FORMAT):
107
- open $$(OUT_FILES-$(FORMAT))
108
-
109
- clean-$(FORMAT):
110
- rm -f $$(OUT_FILES-$(FORMAT))
111
-
112
- $(FORMAT): clean-$(FORMAT) $$(OUT_FILES-$(FORMAT))
113
-
114
- .PHONY: clean-$(FORMAT)
115
-
116
- endef
117
-
118
- $(foreach FORMAT,$(FORMATS),$(eval $(FORMAT_TASKS)))
119
-
120
- open: open-html
121
-
122
- clean:
123
- rm -rf documents documents.{html,rxl} published *_images $(OUT_FILES)
124
-
125
- bundle:
126
- ifndef METANORMA_DOCKER
127
- ifndef SKIP_BUNDLE
128
- bundle install --jobs 4 --retry 3
129
- endif
130
- endif
131
- $(call print_vars)
132
-
133
- .PHONY: bundle all open clean
134
-
135
- #
136
- # Watch-related jobs
137
- #
138
-
139
- .PHONY: watch serve watch-serve
140
-
141
- NODE_BINS := onchange live-serve run-p
142
- NODE_BIN_DIR := node_modules/.bin
143
- NODE_PACKAGE_PATHS := $(foreach PACKAGE_NAME,$(NODE_BINS),$(NODE_BIN_DIR)/$(PACKAGE_NAME))
144
-
145
- $(NODE_PACKAGE_PATHS): package.json
146
- npm i
147
-
148
- watch: $(NODE_BIN_DIR)/onchange
149
- make all
150
- $< $(ALL_SRC) -- make all
151
-
152
- define WATCH_TASKS
153
- watch-$(FORMAT): $(NODE_BIN_DIR)/onchange
154
- make $(FORMAT)
155
- $$< $$(SRC_$(FORMAT)) -- make $(FORMAT)
156
-
157
- .PHONY: watch-$(FORMAT)
158
- endef
159
-
160
- $(foreach FORMAT,$(FORMATS),$(eval $(WATCH_TASKS)))
161
-
162
- serve: $(NODE_BIN_DIR)/live-server revealjs-css reveal.js
163
- export PORT=$${PORT:-8123} ; \
164
- port=$${PORT} ; \
165
- for html in $(HTML); do \
166
- $< --entry-file=$$html --port=$${port} --ignore="*.html,*.xml,Makefile,Gemfile.*,package.*.json" --wait=1000 & \
167
- port=$$(( port++ )) ;\
168
- done
169
-
170
- watch-serve: $(NODE_BIN_DIR)/run-p
171
- $< watch serve
172
-
173
- #
174
- # Deploy jobs
175
- #
176
-
177
- publish: published
178
-
179
- published: documents.html
180
- mkdir -p $@ && \
181
- cp -a documents $@/ && \
182
- cp $< $@/index.html;
183
-
184
- #
185
- # PDF
186
- #
187
-
188
- PDFTEXT := $(patsubst %.pdf,%.txt,$(subst /pdfs,/text,$(wildcard reference-docs/pdfs/*.pdf)))
189
-
190
- pdf2text: $(PDFTEXT)
191
-
192
- reference-docs/text:
193
- mkdir -p $@
194
-
195
- reference-docs/text/%.txt: reference-docs/pdfs/%.pdf | reference-docs/text
196
- ps2ascii "$<" "$@"
@@ -1,216 +0,0 @@
1
- # Auto-generated by Cimas: Do not edit it manually!
2
- # See https://github.com/metanorma/cimas
3
- #!make
4
- SHELL := cmd
5
- # Ensure the xml2rfc cache directory exists locally
6
- IGNORE := $(shell md $(USERPROFILE)\.cache\xml2rfc)
7
-
8
- SRC := $(shell yq r metanorma.yml metanorma.source.files | cut -c 3-)
9
-
10
- ifeq ($(SRC),null)
11
- SRC :=
12
- endif
13
- ifeq ($(SRC),ll)
14
- SRC :=
15
- endif
16
-
17
- ifeq ($(SRC),)
18
- BUILT := $(subst ${ },${\n},$(shell yq r metanorma.yml metanorma.source.built_targets | cut -d ":" -f 1))
19
-
20
- ifeq ($(BUILT),null)
21
- BUILT :=
22
- SRC :=
23
- endif
24
- ifeq ($(BUILT),ll)
25
- BUILT :=
26
- SRC :=
27
- endif
28
- ifeq ($(BUILT),)
29
- SRC :=
30
- endif
31
-
32
- ifeq ($(BUILT),)
33
- SRC := $(filter-out README.adoc, $(wildcard sources/*.adoc))
34
- else
35
- XML := $(patsubst sources/%,documents/%,$(BUILT))
36
- endif
37
- endif
38
-
39
- FORMATS := $(subst -,${ },$(strip $(shell yq r metanorma.yml metanorma.formats)))
40
- ifeq ($(FORMATS),null)
41
- FORMATS :=
42
- endif
43
- ifeq ($(FORMATS),)
44
- FORMAT_MARKER := mn-output-
45
- FORMATS := $(subst ${\n},${ },$(shell grep "$(FORMAT_MARKER)" $(SRC) | cut -f 2 -d " " | tr "," "\n" | sort | uniq))
46
- endif
47
-
48
- XML ?= $(patsubst sources/%,documents/%,$(patsubst %.adoc,%.xml,$(SRC)))
49
- HTML := $(patsubst %.xml,%.html,$(XML))
50
-
51
- ifdef METANORMA_DOCKER
52
- PREFIX_CMD := echo "Running via docker..." & docker run -v "$$(pwd)":/metanorma/ $(METANORMA_DOCKER)
53
- else
54
- ifdef SKIP_BUNDLE
55
- PREFIX_CMD := echo "Running locally..." &
56
- else
57
- PREFIX_CMD := echo "Running locally via bundle ..." & bundle exec
58
- endif
59
- endif
60
-
61
- _OUT_FILES := $(foreach FORMAT,$(FORMATS),$(shell echo $(FORMAT) | tr '[:lower:]' '[:upper:]'))
62
- OUT_FILES := $(foreach F,$(_OUT_FILES),$($F))
63
-
64
- define print_vars
65
- $(info "src $(SRC)")
66
- $(info "xml $(XML)")
67
- $(info "formats $(FORMATS)")
68
- endef
69
-
70
- all: documents.html
71
- $(call print_vars)
72
-
73
- documents:
74
- setlocal enableextensions & md $@ & endlocal
75
-
76
- documents/%.html: documents/%.xml | documents
77
- ${PREFIX_CMD} metanorma $<
78
-
79
- documents/%.xml: sources/%.xml | documents
80
- if not exist "$(subst /,\,$(dir $@))" md "$(subst /,\,$(dir $@))"
81
- move "$(subst /,\,$<)" "$(subst /,\,$@)"
82
-
83
- # Build canonical XML output
84
- # If XML file is provided, copy it over
85
- # Otherwise, build the xml using adoc
86
- sources/%.xml: | bundle
87
- $(eval BUILT_TARGET := $(subst /,\,$(shell yq r metanorma.yml metanorma.source.built_targets[$@])))
88
- $(eval BUILT_TARGET_EMPTY := $(if $(filter $(or $(BUILT_TARGET),null),null ll),true,false))
89
- if "$(BUILT_TARGET_EMPTY)" == "true" ( \
90
- $(PREFIX_CMD) metanorma -x xml "$(subst xml,adoc,$@)" \
91
- ) else ( \
92
- if exist "$(BUILT_TARGET)" ( \
93
- if "$(suffix $(BUILT_TARGET))" == ".xml" ( \
94
- copy "$(BUILT_TARGET)" "$(subst /,\,$@)" \
95
- ) else ( \
96
- $(PREFIX_CMD) metanorma $(BUILT_TARGET) & \
97
- copy "$(subst adoc,xml,$(BUILT_TARGET))" "$(subst /,\,$@)" \
98
- ) \
99
- ) else ( \
100
- $(PREFIX_CMD) metanorma $(BUILT_TARGET) & \
101
- copy "$(subst adoc,xml,$(BUILT_TARGET))" "$(subst /,\,$@)" \
102
- ) \
103
- )
104
-
105
- documents.rxl: $(XML) $(HTML)
106
- ${PREFIX_CMD} relaton concatenate \
107
- -t "$(shell yq r metanorma.yml relaton.collection.name)" \
108
- -g "$(shell yq r metanorma.yml relaton.collection.organization)" \
109
- documents $@
110
-
111
- documents.html: documents.rxl
112
- $(PREFIX_CMD) relaton xml2html documents.rxl
113
-
114
- %.adoc:
115
-
116
- define FORMAT_TASKS
117
- OUT_FILES-$(FORMAT) := $($(shell echo $(FORMAT) | tr '[:lower:]' '[:upper:]'))
118
-
119
- open-$(FORMAT):
120
- "$$(OUT_FILES-$(FORMAT))"
121
-
122
- clean-$(FORMAT):
123
- del /q $$(OUT_FILES-$(FORMAT))
124
-
125
- $(FORMAT): clean-$(FORMAT) $$(OUT_FILES-$(FORMAT))
126
-
127
- .PHONY: clean-$(FORMAT)
128
-
129
- endef
130
-
131
- $(foreach FORMAT,$(FORMATS),$(eval $(FORMAT_TASKS)))
132
-
133
- open: open-html
134
-
135
- clean:
136
- rm -rf $(OUT_FILES)
137
- del /q documents published
138
- del /q *_images
139
- del /q documents.*
140
-
141
- bundle:
142
- ifndef METANORMA_DOCKER
143
- ifndef SKIP_BUNDLE
144
- bundle install --jobs 4 --retry 3
145
- endif
146
- endif
147
- $(call print_vars)
148
-
149
- .PHONY: bundle all open clean
150
-
151
- #
152
- # Watch-related jobs
153
- #
154
-
155
- .PHONY: watch serve watch-serve
156
-
157
- NODE_BINS := onchange live-serve run-p
158
- NODE_BIN_DIR := node_modules/.bin
159
- NODE_PACKAGE_PATHS := $(foreach PACKAGE_NAME,$(NODE_BINS),$(NODE_BIN_DIR)/$(PACKAGE_NAME))
160
-
161
- $(NODE_PACKAGE_PATHS): package.json
162
- npm i
163
-
164
- watch: $(NODE_BIN_DIR)/onchange
165
- make all
166
- $< $(ALL_SRC) -- make all
167
-
168
- define WATCH_TASKS
169
- watch-$(FORMAT): $(NODE_BIN_DIR)/onchange
170
- make $(FORMAT)
171
- $$< $$(SRC_$(FORMAT)) -- make $(FORMAT)
172
-
173
- .PHONY: watch-$(FORMAT)
174
- endef
175
-
176
- $(foreach FORMAT,$(FORMATS),$(eval $(WATCH_TASKS)))
177
-
178
- ifndef PORT
179
- override PORT = 8123
180
- endif
181
-
182
- serve: $(NODE_BIN_DIR)/live-server revealjs-css reveal.js
183
- set port=$(PORT) & \
184
- for /r %%html in $(HTML) do ( \
185
- $< --entry-file=%%html --port=%port% --ignore="*.html,*.xml,Makefile,Gemfile.*,package.*.json" --wait=1000 & \
186
- set /A port=%port%+1 \
187
- )
188
-
189
- watch-serve: $(NODE_BIN_DIR)/run-p
190
- $< watch serve
191
-
192
- #
193
- # Deploy jobs
194
- #
195
-
196
- publish: published
197
-
198
- published: documents.html
199
- setlocal enableextensions & md $@ & endlocal
200
- copy documents $@/
201
- copy $< $@/index.html
202
- if exist "source\images" xcopy /E source\images $@
203
-
204
- #
205
- # PDF
206
- #
207
-
208
- PDFTEXT := $(patsubst %.pdf,%.txt,$(subst /pdfs,/text,$(wildcard reference-docs/pdfs/*.pdf)))
209
-
210
- pdf2text: $(PDFTEXT)
211
-
212
- reference-docs/text:
213
- md $@
214
-
215
- reference-docs/text/%.txt: reference-docs/pdfs/%.pdf | reference-docs/text
216
- ps2ascii "$<" "$@"