metanorma-cli 1.5.8pre → 1.5.10pre

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2c45c765fe09773fc302a9138c49433c959af48c400bc434f07ba3a5de53e3a2
4
- data.tar.gz: 3acb4e442a9dfff40828f46608412adf957d62c9974fd2349f74d6ae95778671
3
+ metadata.gz: c7b87729b55b389bbeed049a929bfdecc42ee4f6603efdfedd44d3ea01a2276e
4
+ data.tar.gz: a0fb8c445b698e21e599b90c43e2bad6a84594a2667b48b88e9a8ec32143b8c1
5
5
  SHA512:
6
- metadata.gz: d8d575f9de2da502fc6d92b2d42df9d390bde84d1a0e16947371e0dc02ecbca624745e3d77fae27621948276a306988d5bb2530d3b638eebe572b0df7555c27c
7
- data.tar.gz: 33a367efb1c9dc7770e0ca50ea1292368e1883111943b9493d4cf0ecf608f080c5294457ae8b1013b922f24c197fb616f7b78ad0ed7dceff679aee4e9e877e4d
6
+ metadata.gz: 1b6b0a5469ddc50b96db40845c2b91ea349de9d86154c94af7cbac423afb2befac08070eef891d49483fa3de5dc19a28a842da18280cbcda99a6bb99e07d2b83
7
+ data.tar.gz: c64bf740a521b66ebde060f6ffd4e895fc7c96a14e81e610b4ad99ec1b9c1f7727d38cc4a05279f012005b5767015c091aecae23ff885cbeb810bd9b8f5aaa17
@@ -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.8pre".freeze
3
+ VERSION = "1.5.10pre".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.8pre
4
+ version: 1.5.10pre
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 "$<" "$@"