-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
114 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
# cache | ||
/docs/.yummy | ||
# experiments | ||
/docs/content/xxx* | ||
/docs/content/yyy* | ||
# built site | ||
/docs/_site | ||
# man pages | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,66 +1,88 @@ | ||
######################################################################## | ||
# Introspect filesystem and files's front-matter to build metadata | ||
# Introspection of filesystem and files's front-matter | ||
######################################################################## | ||
|
||
# Imported variables: | ||
# Metadata | ||
# Content | ||
# Destination | ||
# Exported variables: | ||
# ? | ||
# HomePage | ||
# Pages | ||
# OtherPages | ||
# ... | ||
|
||
# Destination directory | ||
$(Destination): | ||
$(info ==> $@) | ||
@mkdir $@ >/dev/null 2>&1 || true | ||
# Markdown documents found in the filesystem (only .md extensions) | ||
_documents := $(sort $(shell find $(Content) -type f -a -name '*.md')) | ||
|
||
# Markdown document found in the filesystem (only .md extensions) | ||
_documents := $(shell find $(Content) -type f -a -name '*.md') | ||
# Tree structure of directories | ||
# Unique paths to documents directories | ||
_paths := $(sort $(dir $(_documents))) | ||
|
||
# Pages to be generated, and related JSON | ||
define fsys_pages = | ||
$(patsubst %.md,%.$1,$(patsubst $(Content)%,$2%,$(_documents))) | ||
endef | ||
# Paths to create at $(Destination) | ||
_paths_destination := $(patsubst $(Content)%,$(Destination)%,$(_paths)) | ||
|
||
define fsys_tree = | ||
$(patsubst $(Content)%,$1%,$(_paths)) | ||
endef | ||
# Paths to nodes at $(Metadata) | ||
_paths_meta_nodes := $(patsubst $(Content)%,$(Metadata)/nodes%,$(_paths)) | ||
|
||
# All sections and subsections, removing home page node | ||
define fsys_nodes = | ||
$(call rest,$(patsubst %/,%$1,$2)) | ||
endef | ||
# Paths to pages at $(Metadata) | ||
_paths_meta_pages := $(patsubst $(Content)%,$(Metadata)/pages%,$(_paths)) | ||
|
||
# | ||
PagesHTML := $(call fsys_pages,html,$(Destination)) | ||
PagesJSON := $(call fsys_pages,json,$(Metadata)/pages) | ||
fsys_tree_site := $(call fsys_tree,$(Destination)) | ||
fsys_tree_page := $(call fsys_tree,$(Metadata)/pages) | ||
fsys_tree_node := $(call fsys_tree,$(Metadata)/nodes) | ||
NodesJSON := $(call fsys_nodes,.json,$(fsys_tree_node)) | ||
NodesHTML := $(call fsys_nodes,/index.html,$(fsys_tree_site)) | ||
|
||
# Make directories | ||
$(fsys_tree_site): $(Destination)/% : $(Content)/% | ||
# | ||
|
||
$(Destination): | ||
$(info ==> $@) | ||
@mkdir $@ >/dev/null 2>&1 || true | ||
$(fsys_tree_page): $(Metadata)/pages/% : $(Content)/% | ||
|
||
$(_paths_destination): $(Destination)/% : $(Content)/% | ||
@mkdir $@ >/dev/null 2>&1 || true | ||
|
||
$(_paths_meta_pages): $(Metadata)/pages/% : $(Content)/% | ||
@mkdir $@ >/dev/null 2>&1 || true | ||
$(fsys_tree_node): $(Metadata)/nodes/% : $(Content)/% | ||
|
||
$(_paths_meta_nodes): $(Metadata)/nodes/% : $(Content)/% | ||
@mkdir $@ >/dev/null 2>&1 || true | ||
|
||
# | ||
# Global names defined | ||
# | ||
|
||
# Home page | ||
HomePage := $(Destination)/index.html | ||
|
||
# Pages to generate at $(Destination) | ||
Pages := $(patsubst %.md,%.html,$(patsubst $(Content)%,$(Destination)%,$(_documents))) | ||
OtherPages := $(filter-out $(HomePage),$(Pages)) | ||
|
||
# JSON for each page to generate at $(Metadata)/pages | ||
PagesJSON := $(patsubst %.md,%.json,$(patsubst $(Content)%,$(Metadata)/pages%,$(_documents))) | ||
|
||
# Nodes to generate at $(Destination) | ||
NodesHTML := $(call rest,$(patsubst %/,%/index.html,$(_paths_destination)))) | ||
|
||
# JSON for each node to generate at $(Metadata)/nodes | ||
NodesJSON := $(call rest,$(patsubst %/,%.json,$(_paths_meta_nodes)))) | ||
|
||
######################################################################### | ||
# Test | ||
intro: | ||
@echo 'Metadata: $(Metadata)' | ||
@echo 'Content: $(Content)' | ||
@echo 'Destination: $(Destination)' | ||
@echo | ||
@echo '_documents: $(_documents)' | ||
@echo '_paths: $(_paths)' | ||
@echo 'PagesHTML: $(PagesHTML)' | ||
@echo | ||
@echo '_paths_meta_nodes: $(_paths_meta_nodes)' | ||
@echo '_paths_meta_pages: $(_paths_meta_pages)' | ||
@echo '_paths_destination: $(_paths_destination)' | ||
@echo | ||
@echo 'HomePage: $(HomePage)' | ||
@echo 'Pages: $(Pages)' | ||
@echo 'OtherPages: $(OtherPages)' | ||
@echo 'PagesJSON: $(PagesJSON)' | ||
@echo 'fsys_tree_site: $(fsys_tree_site)' | ||
@echo 'fsys_tree_page: $(fsys_tree_page)' | ||
@echo 'fsys_tree_node: $(fsys_tree_node)' | ||
@echo 'NodesJSON: $(NodesJSON)' | ||
@echo 'NodesHTML: $(NodesHTML)' | ||
@echo 'NodesJSON: $(NodesJSON)' | ||
|
||
# vim:ai:sw=8:ts=8:noet:fileencoding=utf8:syntax=make |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters