metanorma-cli 1.5.9 → 1.5.11pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/docs/installation.adoc +23 -28
- data/lib/metanorma/cli/generator.rb +28 -9
- data/lib/metanorma/cli/version.rb +1 -1
- data/templates/base/metanorma.yml +4 -2
- metadata +4 -6
- data/templates/base/Makefile +0 -196
- data/templates/base/Makefile.win +0 -216
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bb86fec8ea47b80c0d2c222cdb382a8bb3a7663a5a32f47fa1fe0bf5e2613aac
|
4
|
+
data.tar.gz: 6d2ec1845f64245a976ebe02f7bd9cf9f26860d83bb38474fcee2c615f61f707
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aa1e985a5d785198342198a84c246f01e3300e5e3d6a6923b145f8a85f90b632479debf269a46b57c4b3fe78036f83458e10d571c5440d2bcc06c88113201013
|
7
|
+
data.tar.gz: 253ff1579d0cd22278d98a9913c54877c0d7ae4d965cb6044fc297d41b7c5042763c7a59033c71cf8a74d2bc01ab13a95e15f526420233223b8832824be84c5a
|
data/docs/installation.adoc
CHANGED
@@ -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
|
45
|
+
Ruby is sometimes included with Linux. To see if you already have it (and check the version):
|
51
46
|
|
52
|
-
|
53
|
-
|
47
|
+
1. Open a console/terminal
|
48
|
+
2. Type `ruby -v`
|
54
49
|
|
55
|
-
|
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
|
-
|
56
|
+
If not, follow the official
|
57
|
+
https://www.ruby-lang.org/en/documentation/installation[Ruby installation guide].
|
58
58
|
|
59
|
-
|
60
|
-
the official
|
61
|
-
https://www.ruby-lang.org/en/documentation/installation[Ruby installation guide])
|
59
|
+
== Windows
|
62
60
|
|
63
|
-
|
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
|
-
[
|
67
|
-
|
68
|
-
|
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:
|
@@ -59,7 +59,7 @@ module Metanorma
|
|
59
59
|
)
|
60
60
|
else
|
61
61
|
templates = base_templates.merge(type_template)
|
62
|
-
templates.each { |
|
62
|
+
templates.each { |dest, source| create_file(source, dest) }
|
63
63
|
end
|
64
64
|
end
|
65
65
|
|
@@ -81,13 +81,17 @@ module Metanorma
|
|
81
81
|
|
82
82
|
def base_templates
|
83
83
|
base_template_root = Cli.base_templates_path
|
84
|
-
build_template_hash(
|
84
|
+
build_template_hash(base_template_root)
|
85
85
|
end
|
86
86
|
|
87
87
|
def type_specific_template
|
88
|
-
|
89
|
-
|
90
|
-
|
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))
|
91
95
|
end
|
92
96
|
|
93
97
|
def custom_template
|
@@ -100,17 +104,32 @@ module Metanorma
|
|
100
104
|
end
|
101
105
|
end
|
102
106
|
|
103
|
-
def
|
104
|
-
|
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
|
105
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)
|
106
123
|
Hash.new.tap do |hash|
|
107
|
-
|
108
|
-
|
124
|
+
paths.each do |path|
|
125
|
+
dest = Pathname.new(path).relative_path_from(source_path).to_s
|
126
|
+
hash[dest] = path
|
109
127
|
end
|
110
128
|
end
|
111
129
|
end
|
112
130
|
|
113
131
|
def create_file(source, destination)
|
132
|
+
p "source=#{source} destination=#{destination}"
|
114
133
|
target_path = [document_path, destination].join("/")
|
115
134
|
target_path = Pathname.new(target_path)
|
116
135
|
|
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.
|
4
|
+
version: 1.5.11pre
|
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-
|
11
|
+
date: 2022-03-07 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:
|
@@ -510,9 +508,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
510
508
|
version: 2.5.0
|
511
509
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
512
510
|
requirements:
|
513
|
-
- - "
|
511
|
+
- - ">"
|
514
512
|
- !ruby/object:Gem::Version
|
515
|
-
version:
|
513
|
+
version: 1.3.1
|
516
514
|
requirements: []
|
517
515
|
rubygems_version: 3.2.32
|
518
516
|
signing_key:
|
data/templates/base/Makefile
DELETED
@@ -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 "$<" "$@"
|
data/templates/base/Makefile.win
DELETED
@@ -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 "$<" "$@"
|