Skip to content

Commit

Permalink
Include macros when generatin manpages
Browse files Browse the repository at this point in the history
  • Loading branch information
fadado committed Dec 4, 2018
1 parent ab85325 commit 1422101
Show file tree
Hide file tree
Showing 10 changed files with 51 additions and 94 deletions.
27 changes: 9 additions & 18 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ SHELL := /bin/bash
# exits with a nonzero exit status.
.DELETE_ON_ERROR:

# Debug utility
print-%: ; @echo $* = $($*)

########################################################################
# Targets and variables
########################################################################
Expand Down Expand Up @@ -145,40 +148,28 @@ list:
echo ' datadir = $(datadir)'; \
echo ' mandir = $(mandir)'

########################################################################
# Generate help text
########################################################################

# Independent target: helps generating text for `jqt -h`
# Needs explicit call: `make /tmp/help`
/tmp/help: $(CONTENT)/help.text
$(info ==> $@)
jqt -P MarkDown -I$(DOCS) < $< \
| pandoc --from markdown --to plain - \
| sed '1,7b;/^$$/d;s/_\([A-Z]\+\)_/\1/g;/^[^A-Z]/s/^/ /' \
> $@

clean:: ; @rm -f /tmp/help

########################################################################
# Generate man page for jqt
########################################################################

# gpp for the man page (to be build without calling jqt!)
# gpp for the man page (to be built without calling jqt!)
GPP_MD := gpp \
-U '<%' '>' '\B' '\B' '\W>' '<' '>' '$$' '' \
-M '<%' '>' '\B' '\B' '\W>' '<' '>' \
+sccc '&\n' '' '' \
+sccc '\\n' '' '' \
+sccc '<\#' '\#>\n' '' \
+sccc '<\#' '\#>' '' \
+siqi "'" "'" '\' \
+siQi '"' '"' '\' \
+ssss '<!--' '-->' '' \
+ssss '`' '`' '' \
+ssss '\n```' '\n```' '' \
+ssss '\n~~~' '\n~~~' '' \
-I${datadir}/jqt \
--nostdinc \
--include lib.md.m

# Man page: jqt(1) sake(1)
jqt.1.gz: $(CONTENT)/opt/*.txt
$(ManPages): %.1.gz : $(CONTENT)/%.1.text
$(info ==> $@)
@$(GPP_MD) -I$(DOCS) < $< \
Expand Down
17 changes: 8 additions & 9 deletions bin/sake
Original file line number Diff line number Diff line change
Expand Up @@ -53,26 +53,24 @@ list() {
sort --unique |
sed 's/:\+$//' |
pr --omit-pagination --width=50 --columns=4 --across
}
} 1>&2

help() {
echo 'Usage: sake [command] [[options] [variable=definition] ...]'
echo -e '\nCommands, builtin and user defined:\n'
list
echo -e '\nSee the manpage for full documentation.'
}
} 1>&2

dag()
{
dag() {
make -f Sakefile -Bdn \
| sed -n \
-e "s/'//g" \
-e 's/\.$//' \
-e 's/Considering target file //p'
}

new()
{
new() {
local name=$1 kind=$2
echo 1>&2 "sake: Target \`new\` not implemented."
}
Expand All @@ -96,11 +94,11 @@ alias _sake='exec make "${makeflags[@]}"'

# Run _sake
case $1 in
help) help
help) help; exit 0
;;
list) list
list) list; exit 0
;;
dag) dag
dag) dag; exit 0
;;
new)
shift
Expand All @@ -113,6 +111,7 @@ case $1 in
esac
done
new $name $kind
exit 0
;;
touch)
touch $CONFIGURATION_FILE
Expand Down
2 changes: 1 addition & 1 deletion docs/content/content.md
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ is, the ampersand and the newline are removed and effectively ignored).
variant, with the <a href="http://pandoc.org/MANUAL.html#extension-pandoc_title_block">title block extension</a>
disabled, and produces by default transitional HTML. When running `jqt` all
long options specified in the command line will be forwarded
untouched to `pandoc`, but some are reserved or have no meaning.
untouched to `pandoc` (as for example with `--help`), but some are reserved or have no meaning.

<%cite Pandoc> options used internally by <%cite jqt> (do not play with them):

Expand Down
40 changes: 27 additions & 13 deletions docs/content/engine.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,27 +52,41 @@ arguments. The usage possibilities are:

### Options

<%include content/opt/4.txt>
<%include content/opt/C.txt>
#### Preprocessor options

<%include content/opt/D.txt>
<%include content/opt/d.txt>
<%include content/opt/e.txt>
<%include content/opt/H.txt>
<%include content/opt/h.txt>
<%include content/opt/I.txt>
<%include content/opt/P.txt>

#### Template options

<%include content/opt/L.txt>
<%include content/opt/i.txt>
<%include content/opt/j.txt>
<%include content/opt/L.txt>

#### Document options

<%include content/opt/4.txt>
<%include content/opt/d.txt>
<%include content/opt/w.txt>

#### Data options

<%include content/opt/M.txt>
<%include content/opt/m.txt>
<%include content/opt/P.txt>
<%include content/opt/p.txt>
<%include content/opt/r.txt>
<%include content/opt/S.txt>
<%include content/opt/T.txt>
<%include content/opt/t.txt>

#### Debugging options

<%include content/opt/C.txt>
<%include content/opt/H.txt>
<%include content/opt/S.txt>

#### Information options

<%include content/opt/h.txt>
<%include content/opt/p.txt>
<%include content/opt/V.txt>
<%include content/opt/w.txt>

## Preprocessing

Expand Down
48 changes: 0 additions & 48 deletions docs/content/help.text

This file was deleted.

3 changes: 2 additions & 1 deletion docs/content/jqt.1.text
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

# SYNOPSIS

| **jqt** [**-h** | **--help** | **-p** | **-V** | **--version**]
| **jqt** [**-h** | **-p** | **-V** ]
| **jqt** [options] < infile > result
| **jqt** [options] infile > result
| **jqt** [options] infile result
Expand All @@ -21,6 +21,7 @@ where HTML is mixed with **jq** snippets to implement the transformation logic.

# OPTIONS

<%include content/macros.m>&
<%include content/opt/4.txt>
<%include content/opt/C.txt>
<%include content/opt/D.txt>
Expand Down
2 changes: 1 addition & 1 deletion docs/content/opt/L.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-L DIRECTORY
: Appends *DIRECTORY* to the end of the _jq_ list of directories to be searched
: Appends *DIRECTORY* to the end of the <%cite jq> list of directories to be searched
for included and imported modules.
<#
vim:ts=4:sw=4:ai:et:fileencoding=utf8:syntax=markdown
Expand Down
2 changes: 1 addition & 1 deletion docs/content/opt/S.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-S
: Stops template processing before the render stage (outputs the _jq_ script).
: Stops template processing before the render stage (outputs the <%cite jq> script).
<#
vim:ts=4:sw=4:ai:et:fileencoding=utf8:syntax=markdown
#>
2 changes: 1 addition & 1 deletion docs/content/opt/i.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-i MODULE
: Includes the _jq_ *MODULE* in the render stage.
: Includes the <%cite jq> *MODULE* in the render stage.
<#
vim:ts=4:sw=4:ai:et:fileencoding=utf8:syntax=markdown
#>
2 changes: 1 addition & 1 deletion docs/content/opt/j.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-j NAME:MODULE
: Imports the _jq_ *MODULE* in the render stage and define helper function
: Imports the <%cite jq> *MODULE* in the render stage and define helper function
named *NAME* if *MODULE* is a data module and has the suffix `.json`.
<#
vim:ts=4:sw=4:ai:et:fileencoding=utf8:syntax=markdown
Expand Down

0 comments on commit 1422101

Please sign in to comment.