Skip to content

Commit

Permalink
migrating document to metanorma template
Browse files Browse the repository at this point in the history
includes:
- cleaning up diagrams for geopackage#622
- fixing figures in conventions
- definition updates from #626
  • Loading branch information
jyutzler committed Sep 18, 2022
1 parent ff3930d commit b87a396
Show file tree
Hide file tree
Showing 71 changed files with 1,021 additions and 2,533 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,9 @@ Gemfile.lock
*.iml
.project
.DS_Store
/spec/conceptual-model/relaton
document.doc
document.html
document.err
document.presentation.xml
document.xml
Expand Down
77 changes: 77 additions & 0 deletions spec/conceptual-model/.github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# Auto-generated by Cimas: Do not edit it manually!
# See https://github.com/metanorma/cimas
name: docker

on:
push:
branches: [ master, main ]
pull_request:
paths-ignore:
- .gitlab-ci.yml
- .github/workflows/test.yml
- .github/workflows/generate.yml
repository_dispatch:
types: [ metanorma/metanorma-docker ]

jobs:
test-docker:
runs-on: ubuntu-latest
container: docker://metanorma/mn
steps:
- uses: actions/checkout@v2
with:
token: ${{ secrets.METANORMA_CI_PAT_TOKEN || github.token }}
submodules: true

- uses: actions/cache@v2
with:
path: /config/fonts
key: fontist-docker
restore-keys: fontist-docker

- uses: actions/cache@v2
with:
path: ~/.metanorma-ietf-workgroup-cache.json
key: metanorma-ietf-workgroup-cache
restore-keys: metanorma-ietf-workgroup-cache

- uses: metanorma/metanorma-build-scripts/gh-rubygems-setup-action@master
with:
token: ${{ secrets.METANORMA_CI_PAT_TOKEN }}

- run: |
curl -L --retry 3 https://raw.githubusercontent.com/metanorma/metanorma-build-scripts/master/gemfile-to-bundle-add.sh | bash
- uses: actions-mn/cli/site-gen@main
with:
agree-to-terms: true

- uses: actions/upload-artifact@master
with:
name: site
path: site

deploy-gh-pages:
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
needs: test-docker
steps:
- uses: actions/checkout@v2

- uses: actions/download-artifact@v1
with:
name: site

- uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ github.token }}
publish_dir: ./site
force_orphan: true
user_name: ${{ github.actor }}
user_email: ${{ format('{0}@users.noreply.github.com', github.actor) }}
commit_message: "${{ format('Deploy to GitHub Pages: {0}', github.sha) }}"

- uses: kolpav/purge-artifacts-action@v1
with:
token: ${{ github.token }}
expire-in: 0
54 changes: 54 additions & 0 deletions spec/conceptual-model/.github/workflows/generate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Auto-generated by Cimas: Do not edit it manually!
# See https://github.com/metanorma/cimas
name: generate

on:
push:
branches: [ master, main ]
pull_request:
paths-ignore:
- .gitlab-ci.yml
- .github/workflows/test.yml
- .github/workflows/docker.yml
workflow_dispatch:

jobs:
test-linux:
name: Test on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest, windows-latest, macos-latest ]
steps:
- uses: actions/checkout@v2
with:
token: ${{ secrets.METANORMA_CI_PAT_TOKEN || github.token }}
submodules: true

- uses: actions/cache@v2
with:
path: ~/.cache/xml2rfc
key: xml2rfc
restore-keys: xml2rfc

- uses: actions/cache@v2
with:
path: ~/.fontist
key: fontist-${{ runner.os }}
restore-keys: fontist-${{ runner.os }}

- uses: actions/cache@v2
with:
path: ~/.metanorma-ietf-workgroup-cache.json
key: metanorma-ietf-workgroup-cache
restore-keys: metanorma-ietf-workgroup-cache

- if: matrix.os == 'windows-latest'
run: rm Gemfile

- uses: actions-mn/setup@master

- uses: actions-mn/cli/site-gen@main
with:
agree-to-terms: true
6 changes: 6 additions & 0 deletions spec/conceptual-model/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.DS_Store
.swp
.tmp.xml

# Deploy key
deploy_key
46 changes: 46 additions & 0 deletions spec/conceptual-model/.gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Auto-generated by Cimas: Do not edit it manually!
# See https://github.com/metanorma/cimas
image:
name: metanorma/mn
entrypoint: [ "" ]

cache:
paths:

stages:
- build
- deploy


build:
stage: build
script:
# We need to do this to install mscorefonts
- curl -Ls -o yq https://github.com/mikefarah/yq/releases/download/3.3.0/yq_linux_amd64
- chmod +x yq && mv yq /usr/bin
- yq
- apt-add-repository -y contrib && apt-get update
- echo ttf-mscorefonts-installer msttcorefonts/accepted-mscorefonts-eula select true | debconf-set-selections
- apt-get install -y ttf-mscorefonts-installer
- curl -Ls https://raw.githubusercontent.com/metanorma/vista-fonts-installer/master/vista-fonts-installer.sh | bash
- curl -L --retry 3 https://raw.githubusercontent.com/metanorma/metanorma-build-scripts/master/gemfile-to-bundle-add.sh | bash
- bundle install
- metanorma site generate sources --output-dir public

artifacts:
paths:
- public

pages:
dependencies:
- build
stage: deploy
script:
- >
'curl --location --output artifacts.zip --header
"JOB-TOKEN: $CI_JOB_TOKEN" "https://gitlab.com/api/v4/projects/$CI_PROJECT_ID/jobs/artifacts/master/download?job=build"'
artifacts:
paths:
- public
only:
- master
4 changes: 4 additions & 0 deletions spec/conceptual-model/Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
source "https://rubygems.org"

gem "metanorma-cli"
gem "relaton-cli"
196 changes: 196 additions & 0 deletions spec/conceptual-model/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,196 @@
# Auto-generated by Cimas: Do not edit it manually!
# See https://github.com/metanorma/cimas
#!make
SHELL := /bin/bash
# Ensure the xml2rfc cache directory exists locally
IGNORE := $(shell mkdir -p $(HOME)/.cache/xml2rfc)

SRC := $(shell yq r metanorma.yml metanorma.source.files | cut -c 3-)

ifeq ($(SRC),null)
SRC :=
endif
ifeq ($(SRC),ll)
SRC :=
endif

ifeq ($(SRC),)
BUILT := $(shell yq r metanorma.yml metanorma.source.built_targets | cut -d ':' -f 1 | tr -s '\n' ' ')

ifeq ($(BUILT),null)
SRC :=
endif
ifeq ($(BUILT),ll)
SRC :=
endif

ifeq ($(BUILT),)
SRC := $(filter-out README.adoc, $(wildcard sources/*.adoc))
else
XML := $(patsubst sources/%,documents/%,$(BUILT))
endif
endif

FORMATS := $(shell yq r metanorma.yml metanorma.formats | tr -d '[:space:]' | tr -s '-' ' ')
ifeq ($(FORMATS),)
FORMAT_MARKER := mn-output-
FORMATS := $(shell grep "$(FORMAT_MARKER)" $(SRC) | cut -f 2 -d " " | tr "," "\\n" | sort | uniq | tr "\\n" " ")
endif

XML ?= $(patsubst sources/%,documents/%,$(patsubst %.adoc,%.xml,$(SRC)))
HTML := $(patsubst %.xml,%.html,$(XML))

ifdef METANORMA_DOCKER
PREFIX_CMD := echo "Running via docker..."; docker run -v "$$(pwd)":/metanorma/ $(METANORMA_DOCKER)
else
ifdef SKIP_BUNDLE
PREFIX_CMD := echo "Running locally...";
else
PREFIX_CMD := echo "Running locally via bundle ..."; bundle exec
endif
endif

_OUT_FILES := $(foreach FORMAT,$(FORMATS),$(shell echo $(FORMAT) | tr '[:lower:]' '[:upper:]'))
OUT_FILES := $(foreach F,$(_OUT_FILES),$($F))

define print_vars
$(info "src $(SRC)")
$(info "xml $(XML)")
$(info "formats $(FORMATS)")
endef

all: documents.html
$(call print_vars)

documents:
mkdir -p $@

documents/%.html: documents/%.xml | documents
${PREFIX_CMD} metanorma $<

documents/%.xml: sources/%.xml | documents
mkdir -p $(dir $@)
mv $< $@

# Build canonical XML output
# If XML file is provided, copy it over
# Otherwise, build the xml using adoc
sources/%.xml: | bundle
BUILT_TARGET="$(shell yq r metanorma.yml metanorma.source.built_targets[$@])"; \
if [ "$$BUILT_TARGET" = "" ] || [ "$$BUILT_TARGET" = "null" ]; then \
BUILT_TARGET=$@; \
$(PREFIX_CMD) metanorma -x xml "$${BUILT_TARGET//xml/adoc}"; \
else \
if [ -f "$$BUILT_TARGET" ] && [ "$${BUILT_TARGET##*.}" == "xml" ]; then \
cp "$$BUILT_TARGET" $@; \
else \
$(PREFIX_CMD) metanorma -x xml $$BUILT_TARGET; \
cp "$${BUILT_TARGET//adoc/xml}" $@; \
fi \
fi

documents.rxl: $(XML) $(HTML)
${PREFIX_CMD} relaton concatenate \
-t "$(shell yq r metanorma.yml relaton.collection.name)" \
-g "$(shell yq r metanorma.yml relaton.collection.organization)" \
documents $@

documents.html: documents.rxl
$(PREFIX_CMD) relaton xml2html documents.rxl

%.adoc:

define FORMAT_TASKS
OUT_FILES-$(FORMAT) := $($(shell echo $(FORMAT) | tr '[:lower:]' '[:upper:]'))

open-$(FORMAT):
open $$(OUT_FILES-$(FORMAT))

clean-$(FORMAT):
rm -f $$(OUT_FILES-$(FORMAT))

$(FORMAT): clean-$(FORMAT) $$(OUT_FILES-$(FORMAT))

.PHONY: clean-$(FORMAT)

endef

$(foreach FORMAT,$(FORMATS),$(eval $(FORMAT_TASKS)))

open: open-html

clean:
rm -rf documents documents.{html,rxl} published *_images $(OUT_FILES)

bundle:
ifndef METANORMA_DOCKER
ifndef SKIP_BUNDLE
bundle install --jobs 4 --retry 3
endif
endif
$(call print_vars)

.PHONY: bundle all open clean

#
# Watch-related jobs
#

.PHONY: watch serve watch-serve

NODE_BINS := onchange live-serve run-p
NODE_BIN_DIR := node_modules/.bin
NODE_PACKAGE_PATHS := $(foreach PACKAGE_NAME,$(NODE_BINS),$(NODE_BIN_DIR)/$(PACKAGE_NAME))

$(NODE_PACKAGE_PATHS): package.json
npm i

watch: $(NODE_BIN_DIR)/onchange
make all
$< $(ALL_SRC) -- make all

define WATCH_TASKS
watch-$(FORMAT): $(NODE_BIN_DIR)/onchange
make $(FORMAT)
$$< $$(SRC_$(FORMAT)) -- make $(FORMAT)

.PHONY: watch-$(FORMAT)
endef

$(foreach FORMAT,$(FORMATS),$(eval $(WATCH_TASKS)))

serve: $(NODE_BIN_DIR)/live-server revealjs-css reveal.js
export PORT=$${PORT:-8123} ; \
port=$${PORT} ; \
for html in $(HTML); do \
$< --entry-file=$$html --port=$${port} --ignore="*.html,*.xml,Makefile,Gemfile.*,package.*.json" --wait=1000 & \
port=$$(( port++ )) ;\
done

watch-serve: $(NODE_BIN_DIR)/run-p
$< watch serve

#
# Deploy jobs
#

publish: published

published: documents.html
mkdir -p $@ && \
cp -a documents $@/ && \
cp $< $@/index.html;

#
# PDF
#

PDFTEXT := $(patsubst %.pdf,%.txt,$(subst /pdfs,/text,$(wildcard reference-docs/pdfs/*.pdf)))

pdf2text: $(PDFTEXT)

reference-docs/text:
mkdir -p $@

reference-docs/text/%.txt: reference-docs/pdfs/%.pdf | reference-docs/text
ps2ascii "$<" "$@"
Loading

0 comments on commit b87a396

Please sign in to comment.