Skip to content
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

feat(makefile) Produce a combined .epub file including the arf.md and… #212

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

SOURCE_DOCS := $(wildcard docs/*.md)
BUILD_DIR :=./build
EPUB_OUTPUT := $(BUILD_DIR)/epub/arf+annexes.epub
MD_FILES := docs/arf.md $(sort $(wildcard docs/annexes/*/*.md))
SITE_DIR :=./site
EXPORTED_DOCS=\
$(SOURCE_DOCS:.md=.pdf) \
Expand All @@ -32,6 +34,13 @@ PANDOC_PDF_OPTIONS= --pdf-engine=xelatex
PANDOC_DOCX_OPTIONS=
PANDOC_EPUB_OPTIONS=--to epub3

# Check if the pandoc is installed
check-pandoc:
@which pandoc > /dev/null || (echo "Pandoc not found, installing..." && make install-pandoc)

install-pandoc:
sudo apt-get update && sudo apt-get install -y pandoc
Comment on lines +41 to +42
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This target is specific to distributions that use the apt-get package manager, Debian and Ubuntu mainly. This excludes other distributions like Fedora and OpenSUSE and many more. And other operating systems like macOS and Windows.

I think it's better to fail with a warning that a certain program is necessary, installing things system-wide just for a single project can be undesirable. There's many ways to do this so I wouldn't choose any particular one for the user. I myself use the following to provide me with a project-specific environment using nix-shell:

{ pkgs ? import <nixpkgs> {} }:

let inherit (pkgs) mkShell; in

mkShell {
  packages = with pkgs; [ mkdocs pandoc texlive.combined.scheme-small ];
}


# Pattern-matching Rules

%.pdf : %.md
Expand All @@ -49,10 +58,15 @@ PANDOC_EPUB_OPTIONS=--to epub3

# Targets and dependencies

.PHONY: all clean
.PHONY: all clean combined.epub
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The target name needs to change either here or in the definition of the target.

Suggested change
.PHONY: all clean combined.epub
.PHONY: all clean epub


all : $(EXPORTED_DOCS) mkdocs

# Target to create an EPUB from arf.md and all the annexes.
epub: check-pandoc
mkdir -p $(BUILD_DIR)/epub
$(PANDOC) $(PANDOC_OPTIONS) $(PANDOC_EPUB_OPTIONS) -o $(EPUB_OUTPUT) $(MD_FILES)

mkdocs:
$(MKDOCS) build

Expand Down