Skip to content

Commit

Permalink
Refactor the Makefile
Browse files Browse the repository at this point in the history
1. `regenerate` recipe was using `-r/--autoreload` which doesn't make any
sense with the `regenerate` recipe. `-r/--autoreload` functionality is
included with `serve` recipe, so isn't needed anymore. `html` does
the same thing then.

2. Refactor `devserver` to serve. There is no UX reason to serve content
without regeneration.

3. Made the commands more verbose

4. Write the recipes the way they are supposed to be

Signed-off-by: Nabarun Pal <[email protected]>
  • Loading branch information
palnabarun committed May 25, 2020
1 parent c39b36a commit 8a40546
Showing 1 changed file with 19 additions and 28 deletions.
47 changes: 19 additions & 28 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,44 +11,35 @@ PUBLISHCONF=$(BASEDIR)/publishconf.py
PORT ?= 8000
BIND ?= 127.0.0.1

DEBUG ?= 0
ifeq ($(DEBUG), 1)
DEBUG ?= False
ifeq ($(DEBUG), True)
PELICANOPTS += -D
endif

help:
@echo 'Makefile for a pelican Web site '
@echo ' '
@echo 'Usage: '
@echo ' make html (re)generate the web site '
@echo ' make clean remove the generated files '
@echo ' make regenerate regenerate files upon modification '
@echo ' make publish generate using production settings '
@echo ' make serve [PORT=8000] serve site at http://localhost:8000'
@echo ' '
@echo 'Set the DEBUG variable to 1 to enable debugging, e.g. make DEBUG=1 html'
@echo ' '

html:
$(PELICAN) $(INPUTDIR) -o $(OUTPUTDIR) -s $(CONFFILE) $(PELICANOPTS)
@echo 'Makefile for a pelican Web site '
@echo ' '
@echo 'Usage: '
@echo ' make html (re)generate the web site '
@echo ' make clean remove the generated files '
@echo ' make publish generate using production settings '
@echo ' make serve [PORT=8000] serve site at http://localhost:8000 '
@echo ' '
@echo 'Set the DEBUG variable to True to enable debugging, e.g. make html DEBUG=True'
@echo ' '

html: $(INPUTDIR) $(CONFFILE) $(OUTPUTDIR)

$(OUTPUTDIR):
$(PELICAN) $(INPUTDIR) --output $(OUTPUTDIR) --settings $(CONFFILE) $(PELICANOPTS)

clean:
[ ! -d $(OUTPUTDIR) ] || rm -rf $(OUTPUTDIR)

regenerate:
$(PELICAN) -r $(INPUTDIR) -o $(OUTPUTDIR) -s $(CONFFILE) $(PELICANOPTS)

serve:
ifdef PORT
cd $(OUTPUTDIR) && $(PY) -m pelican.server $(PORT)
else
cd $(OUTPUTDIR) && $(PY) -m pelican.server 8000
endif

devserver:
$(PELICAN) --listen --autoreload $(INPUTDIR) --settings $(CONFFILE) --port $(PORT) --bind $(BIND) $(PELICANOPTS)

publish:
$(PELICAN) $(INPUTDIR) -o $(OUTPUTDIR) -s $(PUBLISHCONF) $(PELICANOPTS)
$(PELICAN) $(INPUTDIR) --output $(OUTPUTDIR) --settings $(PUBLISHCONF) $(PELICANOPTS)

.PHONY: html help clean regenerate serve devserver publish
.PHONY: html help clean serve publish

0 comments on commit 8a40546

Please sign in to comment.