aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorQrius <[email protected]>2025-04-30 21:02:51 +0200
committerQrius <[email protected]>2025-04-30 21:03:06 +0200
commite5c14ab3ff2622315235bd6b64eb5a8c9da00a5f (patch)
tree0b713411fb411d6c94b66b59e2fbe12f3509e257
parent0212bb26feb485ad9b66bfcf63262b489e1ad3e5 (diff)
downloadskaldpress-e5c14ab3ff2622315235bd6b64eb5a8c9da00a5f.tar.gz
skaldpress-e5c14ab3ff2622315235bd6b64eb5a8c9da00a5f.zip
Update man pages, remove unused parameter
-rw-r--r--skaldpress.141
-rw-r--r--smp.1108
-rw-r--r--src/skaldpress/main.py3
-rw-r--r--src/smp/macro_processor.py4
4 files changed, 99 insertions, 57 deletions
diff --git a/skaldpress.1 b/skaldpress.1
index a0cf224..d274b1c 100644
--- a/skaldpress.1
+++ b/skaldpress.1
@@ -6,7 +6,8 @@ Skaldpress \- Templating engine
.SH DESCRIPTION
.B smp
-smp is a macro processor, made specifically for a usecase when doing templating of websites.
+is a macro processor, made specifically for a usecase when doing templating of websites.
+But it is useful for many other things as well.
Macros which are available using skaldpress, in addition to the builtin smp(1)-macros
@@ -16,34 +17,6 @@ Will output all documents which had the specified tag, using the specified templ
If a field to sort by is specified, it will output ascending based on that field,
or reversed if a fourth argument \fBreversed\fR is specified.
-.PP
-All input files can have a metadata-block at the beginning.
-Any keys will be defined as macros as \fBMETADATA_<key>\fR.
-There are a few special keys which has a specific effect:
-
-.IP "\fBtags\fR"
-This is a list, and all files with entries here will be registered during the first compilation round.
-During the second compilation, macros like \fBall_tagged_by\fR will then
-make all files with the relevant content available and compile it in.
-
-.IP "\fBtarget_filename\fR"
-By default, a file will have the same name in the \fIoutput\fR-directory (unless a template has a different extension).
-This overrides the output-filename, but it keeps the file in the same directory, and it will not affect the extension.
-
-.IP "\fBtemplate\fR"
-If specified, the file will be compiled using a template.
-In the template, all \fBMETADATA_<key>\fR macros will be available,
-additionally templates can use the \fBCONTENT\fR-macro to get the expanded content of the file.
-This is recursive, meaning that templates can use other templates, with their own metadata-block,
-since it is recursive, any metadata in templates will overwrite any metadata from their children,
-but will keep metadata that is not overwritten.
-This means templates can add additional context.
-
-.IP "\fBkeep_states\fR"
-List or string where every listed state/variable will be kept for subsequenct compilations.
-Meaning that you can e.g. construct a array in the first compilation, which is then used the second time around.
-Setting this, means that the file will always be recompiled, regardeless of other instances (unless a \fB--filter\fR is set).
-
.SH OPTIONS
.IP "\fB-o, --out, --output\fR \fIpath\fR
Specifies the directory to output the compiled files to, defaults to \fIbuild\fR.
@@ -65,10 +38,20 @@ will be compiled.
Comma-separated list of files to exclude, if not specified, all files in \fB--source\fR
will be compiled.
+.IP "\fB-x, --xclude\fR \fIfilter\fR
+Comma-separated list of static files to exclude, if not specified, all files in \fB--static\fR
+will be compiled.
+
.IP "\fB-m, --metadata\fR \fIkey\fR=\fIvalue\fR
Metadata to add to compiled file, this can e.g. set a template for all files if you don't want to manually add YAML-blocks.
Specify multiple times, to set multiple fields.
+.IP "\fB-D, --define\fR \fIkey\fR=\fIvalue\fR
+Define macros, these will be interpreted as strings.
+
+.IP "\fB-P, --prefix-builtins\fR
+Prefix all builtin macros with `smp_`
+
.SH EXAMPLES
To run skaldpress on a simple project, simply call it with no arguments
diff --git a/smp.1 b/smp.1
index 1b616e4..33a96dc 100644
--- a/smp.1
+++ b/smp.1
@@ -2,7 +2,7 @@
.SH name
Skaldpress Macro Processor \- Macro processor
.SH SYNOPSIS
-.B smp [\fIinput_file\fB]
+.B smp [OPTION]... [\fIinput_file\fB]
.SH DESCRIPTION
.B smp
@@ -22,6 +22,9 @@ This defines a macro, optionally with some content.
The optional content will be expanded immediately,
and later the already processed content will be included in the output.
+.IP "\fBundefine(<macro_name>)\fR"
+Delete the macro.
+
.IP "\fBifdef(<macro_name>, <output if defined> [, <output if not defined>])\fR"
.IP "\fBifndef(<macro_name>, <output if not defined> [, <output if defined>])\fR"
@@ -33,6 +36,9 @@ and later the already processed content will be included in the output.
.IP "\fBshell(<command>)\fR"
Runs command on shell, and includes the command output in the output
+.IP "\fBeval(<python>)\fR"
+Run a python command, write return value to output.
+
.IP "\fBexpr(<arg1>, <arg2>, ..., <argN>)\fR"
Shorthand for running the expr command, expands all arguments, and executes it on the shell.
@@ -63,43 +69,95 @@ It will process it's input twice before actually doing the conversion. This is t
So you should probably always quote arguments to this.
.IP "\fBwodl(<url>)\fR"
-If compiled with \fBdeadlinks\fR, this macro will always return it's argument.
+This macro will always return it's argument.
But it will also perform a request to the link, and emit a warning if it it doesn't return HTTP 200 OK.
This will significantly slow down compile times!
-.SS "\fBCompile-Time Feature Flags\fR"
-There are some compile-time flags that can enable/disable features, most are enabled by default,
-and exist either because they trigger a external dependency, or because they are unlikely to work without glibc.
+.IP "\fBtemplate(<filename>, <content>)\fR"
+Will read the file in \fIfilename\fR, and process it replacing \fBCONTENT\fR with the \fIcontent\fR.
+
+.IP "\fBiftruthy(<content>)\fR"
+Returns python True if content is evaluated to \fItruthy\fR.
+
+.IP "\fBindent(<spaces>, <content>)\fR"
+Indents each line of the \fIcontent\fR with \fIspaces\R spaces.
+
+.IP "\fBdumpenv\fR"
+Debugging macro for printing smp internals.
+
+.SS "\fBSpecial macros\fR"
+There is a syntax for special macros, which takes more data in once.
+
+.IP "\fB@template \fI<template>\fR"
+Passes the rest of the file as content to the \fBtemplate\fR-macro.
+
+.IP "\fB@html_from_markdown\fR"
+Passes the rest of the file as content to the \fBhtml_from_markdown\fR-macro.
-.IP "\fBreadline\fR" 2
-\fBEnabled by default\fR.
-Enables the use of libc readline in REPL mode. If not enabled, normal stdio will be used for input.
-Requires readline to be installed on the system.
+.SS "\fBBuiltin macro options\fR"
+There are some macros flags that can enable/disable features,
+They will be prefixed by `smp_` if \fB-P\fR is set.
-.IP "\fBtime\fR" 2
-\fBEnabled by default\fR.
-Enables the \fIformat_time\fR-macro, this will compile the chrono dependency to format time.
+.IP "\fBparse_file_yaml\fR" 2
+\fB\fItruthy\fR\fB by default\fR.
+If set to a truthy value, metadata blocks in the start of files will be parsed, otherwise it will be treated as normal input.
-.IP "\fBmarkdown\fR" 2
-\fBEnabled by default\fR.
-Enabled the \fIhtml_from_markdown\fR-macro, this will compile the markdown dependency. And can convert markdown into html.
+.IP "\fBdraft\fR" 2
+\fB\fIfalsy\fR\fB by default\fR.
+If set to a truthy value, some macros may skip expensive steps to save compilation time (e.g. network calls).
-.IP "\fBdeadlinks\fR" 2
-\fBEnabled by default\fR.
-Enabled the \fIwodl\fR-macro, this will compile the minreq dependency.
-Allows testing the return code of links, and warns when the request is unsuccessful.
+.IP "\fBtemplate_prefix\fR" 2
+\fB\fItemplates/\fR\fB by default\fR.
+The path to search for templates in, this affects metadata wrapping, as well as macros using the template macro.
-.IP "\fBguile\fR" 2
-If compiled with guile, the macro processor supports running guile-code inline.
-This is enabled with \fI%()%\fR in the input, and anything inside the parantheses will be evaluated as guile.
+.IP "\fBmetadata_prefix\fR" 2
+\fB\fIMETADATA_\fR\fB by default\fR.
+The prefix used for defining metadata for macros defined in blocks.
-Requires libguile-3.0 to be installed on the system.
+.IP "\fBsmp_debug\fR" 2
+\fB\fI4\fR\fB by default\fR.
+Sets the debug level for the parser, higher number means more verbosity.
+Level 1 and 2 is the most basic error messaging, 5 and up will print parser internals.
+
+.IP "\fBsynclines\fR" 2
+\fB\fIfalsy\fR\fB by default\fR.
+If truthy, synclines will be included in output, along with filename.
+
+.SS Metadata block
+All input files can have a metadata-block at the beginning.
+Any keys will be defined as macros as \fBMETADATA_<key>\fR.
+There are a few special keys which has a specific effect:
+
+.IP "\fBtarget_filename\fR"
+By default, a file will have the same name in the \fIoutput\fR-directory (unless a template has a different extension).
+This overrides the output-filename, but it keeps the file in the same directory, and it will not affect the extension.
+
+.IP "\fBtemplate\fR"
+If specified, the file will be compiled using a template.
+In the template, all \fBMETADATA_<key>\fR macros will be available,
+additionally templates can use the \fBCONTENT\fR-macro to get the expanded content of the file.
+This is recursive, meaning that templates can use other templates, with their own metadata-block,
+since it is recursive, any metadata in templates will overwrite any metadata from their children,
+but will keep metadata that is not overwritten.
+This means templates can add additional context.
+
+.IP "\fBkeep_states\fR"
+List or string where every listed state/variable will be kept for subsequenct compilations.
+Meaning that you can e.g. construct a array in the first compilation, which is then used the second time around.
+Setting this, means that the file will always be recompiled, regardeless of other instances (unless a \fB--filter\fR is set).
-\fBExperimental feature!\fR
.SH OPTIONS
+
+.IP "\fBinput_file\fR
If a input file is provided, that will be processed.
-If not, a sort of interactive REPL will be started instead.
+If it is `-`, or not specified and something is piped, it will process stdin.
+
+.IP "\fB-D, --define\fR \fIkey\fR=\fIvalue\fR
+Define macros, these will be interpreted as strings.
+
+.IP "\fB-P, --prefix-builtins\fR
+Prefix all builtin macros with `smp_`
.SH SEE ALSO
skaldpress(1)
diff --git a/src/skaldpress/main.py b/src/skaldpress/main.py
index 9efb919..eebe3e8 100644
--- a/src/skaldpress/main.py
+++ b/src/skaldpress/main.py
@@ -196,9 +196,6 @@ def main():
"-m", "--metadata", nargs="+", metavar="key=value", default=[], action="extend"
)
parser.add_argument(
- "-c", "--compilefilter", metavar="filter", default=[], type=comma_arg
- )
- parser.add_argument(
"-x",
"--xclude",
metavar="filter",
diff --git a/src/smp/macro_processor.py b/src/smp/macro_processor.py
index 2519255..b95dfd1 100644
--- a/src/smp/macro_processor.py
+++ b/src/smp/macro_processor.py
@@ -322,6 +322,10 @@ class MacroProcessor:
)
if c == "\n":
+ if smp.builtins.smp_builtin_iftruthy(
+ self._get_macro_builtin("synclines", default="false")
+ ):
+ output.extend(f"\n#line {linenr} {file}")
linenr += 1
linestart = i + 1
self.file_stack[-1][1] = linenr