Skip to content

Commit

Permalink
Names more in "common" style.
Browse files Browse the repository at this point in the history
  • Loading branch information
fadado committed Sep 2, 2016
1 parent f2b682b commit 8517887
Show file tree
Hide file tree
Showing 14 changed files with 44 additions and 32 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# cache
/docs/.jqt
/docs/.yummy
# output of templates expansion
tests/generated/*.jqe
tests/generated/*.jqs
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ $(error GNU Make version $(MAKE_VERSION); version >= 3.82 is needed)
endif

# Paranoia
ifeq (0,$(shell id --user))
ifeq (,$(filter install uninstall,$(MAKECMDGOALS)))
ifeq (0,$(shell id --user))
$(error Root only can make "(un)install" targets)
endif
SUDO :=
Expand Down
9 changes: 4 additions & 5 deletions bin/jqt
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ function fork_yaml
# Markup document
########################################################################

declare DOCUMENT='' DOCUMENT_ID='stdin' HTML_VERSION='html'
declare DOCUMENT='(standard input)' HTML_VERSION='html'
declare -a PANDOC_OPTS=( '--from=markdown-pandoc_title_block' )

# < stdin > stdout
Expand Down Expand Up @@ -410,7 +410,7 @@ declare -A JSON_DATA_DOT=() YAML_DATA_DOT=()
# .page ...
# .page._content
# .page._highlight
# .page._id
# .page._path
# .page._toc

# < stdin > stdout
Expand All @@ -424,7 +424,7 @@ function merge
echo '(. / "<!--JQT-->") as [$body, $toc, $css] |'
# page
echo "{ $DOCUMENT_METADATA_NAME: ("; yaml2json < $FRONT_MATTER
echo "+ { _id: \"${DOCUMENT_ID}\","' _content: $body, _toc: $toc, _highlight: $css })}'
echo "+ { _path: \"${DOCUMENT}\", "'_content: $body, _toc: $toc, _highlight: $css })}'
# additional data
for key in "${!YAML_DATA[@]}"; do
echo "+{ $key:"
Expand Down Expand Up @@ -627,7 +627,6 @@ while getopts :hVD:I:P:L:i:j:45d:eprtn:m:M:T:CHS-: opt; do
;;
d) [[ -e $OPTARG ]] || usage "File '$OPTARG' does not exists"
DOCUMENT=$OPTARG
DOCUMENT_ID=${DOCUMENT%.md}
;;
e) extract=1
;;
Expand Down Expand Up @@ -762,7 +761,7 @@ elif (( flagH )); then expand_md | markup
elif (( flagC )); then
declare -r FRONT_MATTER=$(mkpipe)
expand_md | fork_yaml $FRONT_MATTER | markup | merge $FRONT_MATTER
elif [[ -z $DOCUMENT ]]; then
elif [[ $DOCUMENT == '(standard input)' ]]; then
# equivalent to flagH
expand_md | markup
else
Expand Down
33 changes: 17 additions & 16 deletions docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -50,22 +50,22 @@ SHELL := /bin/bash
########################################################################

# Output directories
Meta := .jqt
Meta := .yummy
Destination := /tmp/jqt

# Directories for input files
Assets := ./assets
Content := ./content
Presentation := ./presentation
Structure := ./structure
Styles := ./styles
Layouts := ./layouts

# Common sources for all targets
Common := \
$(Meta)/config.json \
$(Meta)/snippets.json \
$(Structure)/default.html \
$(Structure)/head.html \
$(Structure)/footer.html \
$(Layouts)/default.html \
$(Layouts)/head.html \
$(Layouts)/footer.html \
$(Content)/LINKS.txt \
filters.jq \
macros.m \
Expand All @@ -87,7 +87,7 @@ Targets := \
# The template engine (.site and .snippets defined in the jqt call)
JQT = jqt $(JQTFLAGS)
JQTFLAGS := \
-I$(Structure) \
-I$(Layouts) \
-I$(Content) \
-ifilters \
-msite:$(Meta)/config.json \
Expand All @@ -98,6 +98,7 @@ JQTFLAGS := \
XHTMLValid := test -f /etc/xml/xhtml1-dtds.xml \
&& xmllint --noout --valid $(Destination)/*.html \
&& echo 'XHTML valid!'
# Uncomment to disable XML validation
#XHTMLValid := :

########################################################################
Expand All @@ -114,11 +115,11 @@ $(Meta) $(Destination): ; mkdir $@ >/dev/null 2>&1 || true
# Metad files
$(Meta)/config.json: config.yaml \
| $(Meta)
yaml2json < $< > $@
yaml2json <$< >$@

$(Meta)/snippets.json: $(Content)/snippets.yaml \
| $(Meta)
jqt -T -- $< | yaml2json > $@
jqt -T -- <$< | yaml2json > $@

# Target files
$(Destination)/README.md: $(Assets)/README.md \
Expand All @@ -129,34 +130,34 @@ $(Destination)/README.md: $(Assets)/README.md \
$(Destination)/index.html: $(Content)/home.md $(Common) \
| $(Destination)
$(info ==> $@)
$(JQT) -d $< $(Structure)/default.html > $@
$(JQT) -d $< $(Layouts)/default.html > $@

$(foreach p,$(Pages),$(Destination)/$(p).html): $(Content)/FLOW.txt $(Content)/opt/*.txt
$(Destination)/index.html $(Destination)/structure.html: $(Content)/EXAMPLE.txt

define Target
$(Destination)/$(1).html: $(Content)/$(1).md $(Structure)/$(2).html $(Common) \
$(Destination)/$(1).html: $(Content)/$(1).md $(Layouts)/$(2).html $(Common) \
| $(Destination)
$$(info ==> $$@)
$(JQT) -d $$< $(Structure)/$(2).html > $$@
$(JQT) -d $$< $(Layouts)/$(2).html > $$@
endef

$(foreach p,$(Pages),$(eval $(call Target,$(p),page)))

$(Destination)/jqt.css: $(Presentation)/jqt.css $(Presentation)/github.css
$(Destination)/jqt.css: $(Styles)/jqt.css $(Styles)/github.css
$(info ==> $@)
jqt -P CSS-min -I$(Presentation) $< > $@
jqt -P CSS-min -I$(Styles) <$< >$@

# Man page
$(ManPage): $(Content)/jqt.1.markdown
$(info ==> $@)
jqt -P MarkDown -I$(Content) $< \
jqt -P MarkDown -I$(Content) <$< \
| pandoc --standalone --from markdown --to man \
| gzip > $@

# Help text
/tmp/help: $(Content)/help.markdown
jqt -P MarkDown -I$(Content) $< \
jqt -P MarkDown -I$(Content) <$< \
| pandoc --from markdown --to plain - \
| sed '1,7b;/^$$/d;s/_\([A-Z]\+\)_/\1/g;/^[^A-Z]/s/^/ /' \
> $@
Expand Down
10 changes: 6 additions & 4 deletions docs/config.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
#
# jqt docs configuration
#
Expand All @@ -18,16 +19,17 @@ author:

menu:
- URL: ./engine.html
id: content/engine
path: content/engine.md
name: Engine
- URL: ./structure.html
id: content/structure
path: content/structure.md
name: Structure
- URL: ./content.html
id: content/content
path: content/content.md
name: Content
- URL: ./data.html
id: content/data
path: content/data.md
name: Data

# vim:ts=2:sw=2:ai:et:fileencoding=utf8:syntax=yaml
...
9 changes: 5 additions & 4 deletions docs/content/content.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,12 @@ and injects it into the render stage under a global JSON object named `.page`.

### Body

Pandoc will convert the document body to HTML,
and _jqt_ will inject it into the render stage under the global JSON scalar
Pandoc converts the document body to HTML,
and _jqt_ injects it into the render stage under the global JSON scalar
`.page._content`. If the document contains fenced code blocks specifying the language of
the code block, the highlight code will be in the scalar `.page._css`. Also, the
table of contents will be in the scalar `.page._toc`.
the code block, the highlight code will be in the scalar `.page._highlight`. Also, the
table of contents is available in the scalar `.page._toc`, and the path to the document
file in the scalar `.page._path`.

## Document syntax

Expand Down
9 changes: 9 additions & 0 deletions docs/content/data.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,15 @@ data and influence JSON preprocessing:
Document front matter metadata and additional input YAML files are converted to
JSON and merged to be the `jq` input in the render stage.

The front matter content is available in the global object `.page`. The object
member names prefixed with the underline character (`_`) are reserved, and the following
are provided:

* `.page._content`: the rendered input document.
* `.page._highlight`: CSS styles for highlighted code.
* `.page._path`: the input document pathname as provided to `jqt`.
* `.page._toc`: the rendered input document table of contents.

### JSON

Additional JSON files can be provided and are merged with front matter metadata
Expand Down
2 changes: 1 addition & 1 deletion docs/structure/default.html → docs/layouts/default.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<body>
<ul id="MENU">
{# logo #}<li class="logo"><a href="index.html">{{.site.logo}}</a><span>v<%include "../VERSION"></span></li>
{% .site.menu[] %}<li><a {{if .id==$M.page._id then "class='current'" else "" end}} href="{{.URL}}">{{.name}}</a></li>
{% .site.menu[] %}<li><a {{if .path==$M.page._path then "class='current'" else "" end}} href="{{.URL}}">{{.name}}</a></li>
</ul>

<%ifndef BODY_TITLE>&
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 8517887

Please sign in to comment.