-
Notifications
You must be signed in to change notification settings - Fork 108
Fix PDF generation, exit code from make and parallelization #1002
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,8 @@ source 'https://rubygems.org' | |
|
|
||
| gem 'asciidoctor' | ||
| gem 'asciidoctor-pdf' | ||
| # missing dependency for asciidoctor-pdf | ||
| gem 'matrix' | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was causing Ruby to fail. |
||
|
|
||
| gem 'compass', '0.12.7' | ||
| gem 'zurb-foundation', '4.3.2' | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,37 +1,29 @@ | ||
| SHELL := /bin/bash | ||
| ALL_DIRS = $(shell ls -d doc-*) | ||
| GUIDES-HTML = $(ALL_DIRS) | ||
| SUBDIRS = $(shell ls -d doc-*) | ||
|
|
||
| .PHONY: all html pdf linkchecker all-html all-pdf clean all-clean linkchecker-tryer $(GUIDES-HTML) | ||
| .PHONY: all clean html pdf linkchecker linkchecker-tryer serve subdirs $(SUBDIRS) | ||
|
|
||
| all: html | ||
|
|
||
| html: all-html | ||
| html: subdirs | ||
|
|
||
| pdf: all-pdf | ||
| pdf: subdirs | ||
|
|
||
| clean: all-clean | ||
| subdirs: $(SUBDIRS) | ||
|
|
||
| $(SUBDIRS): | ||
| $(MAKE) -C "$@" $(MAKECMDGOALS) | ||
|
|
||
| clean: | ||
| @for DIR in $(SUBDIRS) ; do \ | ||
| $(MAKE) -s --directory="$$DIR" clean ; \ | ||
| done | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is completely simplified, it now properly calls make so recursive option does work. |
||
|
|
||
| linkchecker: | ||
| find build -type f -name index\*html | xargs linkchecker -r1 -f common/linkchecker.ini --check-extern | ||
|
|
||
| linkchecker-tryer: | ||
| find build -type f -name index\*html | xargs linkchecker -r1 -f common/linkchecker.ini --check-extern | linkchecker-tryer | ||
|
|
||
| all-html: $(GUIDES-HTML) | ||
|
|
||
| $(GUIDES-HTML): | ||
| $(MAKE) --directory=$@ html | ||
|
|
||
| all-pdf: | ||
| for DIR in $(ALL_DIRS) ; do \ | ||
| $(MAKE) --directory="$$DIR" pdf ; \ | ||
| done | ||
|
|
||
| $(GUIDES-PDF): | ||
| $(MAKE) --directory=$@ pdf | ||
|
|
||
| all-clean: | ||
| for DIR in $(ALL_DIRS) ; do \ | ||
| $(MAKE) --directory="$$DIR" clean ; \ | ||
| done | ||
| serve: | ||
| python -m http.server --directory ./build 8813 | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The same target is in the common Makefile, I use this for testing. |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,19 +31,22 @@ ifeq ($(LINKS), LOCAL) | |
| BASEURL_ATTR = "-a BaseURL=file://$(BUILD_DIRA)" | ||
| endif | ||
|
|
||
| .SHELLFLAGS = -o pipefail -c | ||
| .PHONY = all prepare css html pdf clean browser server linkchecker open-pdf | ||
|
|
||
| all: html | ||
|
|
||
| prepare: | ||
| @mkdir -p $(BUILD_DIR) $(DEST_DIR) $(IMAGES_DIR) $(IMAGES_DIR) $(DEST_DIR)/common/images | ||
| @mkdir -p $(BUILD_DIR) $(DEST_DIR) $(IMAGES_DIR) $(DEST_DIR)/sass-cache | ||
|
|
||
| css: prepare $(DEST_DIR)/$(BUILD).css | ||
|
|
||
| html: css $(IMAGES_TS) $(DEST_HTML) | ||
|
|
||
| pdf: prepare $(DEST_PDF) | ||
| pdf: prepare $(IMAGES_TS) $(DEST_PDF) | ||
|
|
||
| clean: | ||
| @rm -rf "$(DEST_DIR)" "$(DEST_PDF)" "$(BUILD_DIR)/default.css" | ||
| @rm -rf "$(DEST_DIR)" "$(DEST_PDF)" | ||
|
|
||
| browser: html | ||
| ${BROWSER_OPEN} "file://$(realpath $(ROOTDIR)/$(DEST_HTML))" | ||
|
|
@@ -57,15 +60,11 @@ linkchecker: html | |
| open-pdf: pdf | ||
| ${BROWSER_OPEN} "$(realpath $(ROOTDIR)/$(DEST_PDF))" | ||
|
|
||
| $(BUILD_DIR)/default.css: $(CSS_SOURCES) | ||
| bundle exec sass -C --style $(CSS_STYLE) -I $(COMMON_DIR)/css $(COMMON_DIR)/css/default.scss $@ | ||
|
|
||
| $(DEST_DIR)/$(BUILD).css: $(BUILD_DIR)/default.css | ||
| cp $< $@ | ||
| $(DEST_DIR)/$(BUILD).css: $(CSS_SOURCES) | ||
| bundle exec sass --cache-location $(DEST_DIR)/sass-cache --style $(CSS_STYLE) -I $(COMMON_DIR)/css $(COMMON_DIR)/css/default.scss $@ | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because sass command is a bit slow, previously it built into a common BUILD_DIR just once and other guides could simply copy the generated file quickly over to the destination. With parallel option this is no longer possible (I was hitting problems). So now sass needs to be executed for each guide separately, which is a bit slower. I implemented cache option, but that does not speeds things up on CI (where we start from a clean state anyway). Later on, we can migrate to Dart-SCSS. |
||
|
|
||
| $(IMAGES_TS): $(IMAGES) | ||
| cp $? $(IMAGES_DIR)/ | ||
| pushd "$(IMAGES_DIR)" >/dev/null && for IMG in *.*; do ln -fs ../../images/$$IMG ../common/images/$$IMG; done && popd >/dev/null | ||
| cp -lrf $? $(IMAGES_DIR) | ||
| @touch $(IMAGES_TS) | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was dodgy, now images are properly copied (if they are new). |
||
|
|
||
| $(DEST_HTML): $(SOURCES) $(DEPENDENCIES) $(DOCINFO_SOURCES) | ||
|
|
@@ -76,6 +75,6 @@ $(DEST_HTML): $(SOURCES) $(DEPENDENCIES) $(DOCINFO_SOURCES) | |
| @! grep -RE '<a href="#[a-zA-Z0-9_-]+">\[[a-zA-Z0-9_-]+\]</a>' $@ | ||
|
|
||
| $(DEST_PDF): $(SOURCES) $(IMAGES) $(DEPENDENCIES) | ||
| bundle exec asciidoctor-pdf -a build=$(BUILD) -d book --trace -o $@ $< 2>&1 | tee $@.log | ||
| bundle exec asciidoctor-pdf -a build=$(BUILD) -a imagesdir=$(IMAGES_DIR) -d book --trace -o $@ $< 2>&1 | tee $@.log | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was another issue with PDF generation - it could not find images in the correct directory. This fixes it. |
||
| @echo CHECKING FOR ASCIIDOCTOR-PDF ERRORS AND WARNINGS | ||
| @! grep -Eq "^asciidoctor: (ERROR|WARNING)" $@.log | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| include::common/attributes.adoc[] | ||
| :imagesdir: common/images | ||
| :imagesdir: images | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This also consolidates where images should be find - they are always copied by make into the BUILD_DIR/images so no longer we will confuse common and non-common images. They are all copied to the same destination, of course locals overriding common. |
||
| include::common/header.adoc[] | ||
|
|
||
| :configuring-ansible: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| :imagesdir: common/images | ||
| :imagesdir: images | ||
| :installing-capsule-server: | ||
| :numbered: | ||
| :toc: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| :imagesdir: common/images | ||
| :imagesdir: images | ||
| :numbered: | ||
| ifndef::satellite[] | ||
| :toc: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| :imagesdir: common/images | ||
| :imagesdir: images | ||
| :numbered: | ||
| :toc: | ||
| :toc-placement: left | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I moved this down, we now build one PDF version for PR CI and all for deploy commits.