d3011c3b1540706f894cdd80df9fd4484452aba3 — Phil Hagelberg 16 days ago 068bf2e + 5a09db7
Merge pull request #19 from christoph-frick/generate-version-indices

Generate version indices
2 files changed, 24 insertions(+), 8 deletions(-)

M main.fnl
M makefile
M main.fnl => main.fnl +6 -0
@@ 101,6 101,12 @@ [:li {} "The" [:a {:href "/changelog"} "Changelog"]
                   "describes how Fennel has evolved with time."]]
  
+                [:p {} "Looking for other versions?  Docs are generated for:"]
+                (let [version-links [:ul {}]]
+                  (each [i version (ipairs arg)]
+                        (table.insert version-links [:li {} [:a {:href version} version]]))
+                  version-links)
+ 
                 [:h2 {} "Development"]
                 [:p {} "Fennel's repository is on "
                  [:a {:href "https://github.com/bakpakin/Fennel"} "GitHub"]

M makefile => makefile +18 -8
@@ 1,8 1,11 @@-index.html: main.fnl sample.html ; fennel/fennel main.fnl > index.html
- fennelview.lua: fennel/fennelview.fnl ; fennel/fennel --compile $^ > $@
- generate.lua: fennel/generate.fnl ; fennel/fennel --compile $^ > $@
- 
  .DEFAULT_GOAL := build
+ 
+ TAGS := $(shell git --git-dir=./fennel/.git tag -l | grep '^[0-9]' | tac)
+ TAGDIRS := master $(foreach tag, $(TAGS), v${tag})
+ 
+ # which fennel/$.md files build a tag index
+ TAGSOURCES := changelog reference api
+ 
  HTML := tutorial.html api.html reference.html lua-primer.html changelog.html
  LUA := generate.lua fennelview.lua
  


@@ 10,17 13,24 @@ PANDOC=pandoc --syntax-definition fennel-syntax.xml \
  	-H head.html -A foot.html -T "Fennel"
  
+ index.html: main.fnl sample.html ; fennel/fennel main.fnl $(TAGDIRS) > index.html
+ fennelview.lua: fennel/fennelview.fnl ; fennel/fennel --compile $^ > $@
+ generate.lua: fennel/generate.fnl ; fennel/fennel --compile $^ > $@
+ 
  %.html: fennel/%.md ; $(PANDOC) -o $@ $^
  
- TAGS := 0.1.0 0.1.1 0.2.0 0.2.1
- TAGDIRS := $(foreach tag, $(TAGS), v${tag}) master
+ # TODO: for now all master and tags are generated the same;
+ # there might be time, when we have "generations" of fennel
+ # TODO: dedupe v% and master setup here
  v%/fennel: ; git clone --branch $* fennel $@
+ v%/index.html: $(foreach md, $(TAGSOURCES), v%/fennel/${md}.md); $(PANDOC) -o $@ $^
  master/fennel: ; git clone --branch master fennel $@
+ master/index.html: $(foreach md, $(TAGSOURCES), master/fennel/${md}.md); $(PANDOC) -o $@ $^
+ 
  tagdirs: ; $(foreach tagdir, $(TAGDIRSS), mkdir -p ${tagdir})
  cleantagdirs: ; $(foreach tagdir, $(TAGDIRS), rm -rf ${tagdir})
  tags: tagdirs $(foreach tagdir, $(TAGDIRS), ${tagdir}/fennel)
- 
- TAGDOCS := $(foreach tagdir, $(TAGDIRS), $(addprefix ${tagdir}/, $(HTML)))
+ TAGDOCS := $(foreach tagdir, $(TAGDIRS), $(addprefix ${tagdir}/, index.html))
  
  build: html lua tagdocs
  html: $(HTML) index.html