metanorma / bipm-si-brochure

SI Brochure edition 9, semantic encoded version (WARNING: DRAFT)
3 stars 0 forks source link

feat: use new collection functionality #186

Closed ronaldtse closed 2 years ago

ronaldtse commented 2 years ago

Fixes #185.

Related to https://github.com/metanorma/metanorma-cli/issues/205

Metanorma PR checklist

ronaldtse commented 2 years ago

@abunashir there are several problems with the current functionality implemented in https://github.com/metanorma/metanorma-cli/issues/205.

metanorma collection collection.yaml does not work without explicit options

Right now,

bundle exec metanorma collection collection.yml
> No value provided for required options '--output-folder'

This is wrong, because the option is already provided in the collection.yaml file. https://github.com/metanorma/bipm-si-brochure/blob/a588390f6d323ae9df8ad119027d440543bf5cd8/collection.yml#L30

Clearly the metanorma collection command is not reading the YAML options properly. This needs to be fixed.

metanorma site generate with a collection source file generates output in the wrong location

Notice that collection.yaml has this line: https://github.com/metanorma/bipm-si-brochure/blob/a588390f6d323ae9df8ad119027d440543bf5cd8/collection.yml#L30

But the site generate command output location should override the specified output folder, because the whole point of site generate is to keep the generated output under /site/ for deployment to a website.

This case is similar to when we run the normal metanorma command:

$ metanorma compile path/document.adoc
# => generates under path/document.xml
$ metanorma site generate config.yml # which points to path/document.adoc
# => generates under site/path/document.xml

Methods to generate a defined collection

As I updated in the README, there are two ways to generate a collection.

Method 1: single command to generate the dependencies and then the collection (with the order fixed in the "site generate" file)

$ metanorma site generate -c brochure.yml --agree-to-terms

Problem: This method works, but generates the collection in the originally defined location, not the "site generate" location.

Method 2: separately compile the source components and create the collection

$ metanorma sources/si-brochure-en.adoc
$ metanorma sources/si-brochure-fr.adoc
$ mkdir -p site/documents
$ mv sources/si-brochure-en.xml site/documents
$ mv sources/si-brochure-fr.xml site/documents
$ metanorma collection collection.yml

Problem: This method is not working because of the CLI argument issue.

ronaldtse commented 2 years ago

Completion of this PR requires these issues fulfilled:

abunashir commented 2 years ago

Thanks for the all the details @ronaldtse, I guess previously I only implemented it for the site interface that might explains the first issue but I will also check the other and get back to you :)

ronaldtse commented 2 years ago

This works! Thank you @abunashir.

There is just one problem -- the si-brochure-en.pdf and si-brochure-fr.pdf files are compiled twice, once under site/documents and once under site/brochure, which is not ideal. Let's do that in a new ticket.

Proof:

image