{ "template": { "doc": ["Create a pandoc template with arguments"] , "string_fields": ["name", "args"] , "target_fields": ["data", "lua filters"] , "field_doc": { "name": ["Name of the template to use"] , "args": ["Additional pandoc arguments"] , "data": ["Template data files"] , "lua filters": ["Files that should be used as lua filters"] } , "expression": { "type": "let*" , "bindings": [ [ "data" , { "type": "disjoint_map_union" , "msg": "Data files may not conflict" , "$1": { "type": "foreach" , "var": "x" , "range": {"type": "FIELD", "name": "data"} , "body": { "type": "map_union" , "$1": [ {"type": "DEP_RUNFILES", "dep": {"type": "var", "name": "x"}} , { "type": "DEP_ARTIFACTS" , "dep": {"type": "var", "name": "x"} } ] } } } ] , [ "lua filters" , { "type": "disjoint_map_union" , "msg": "Lua filters may not conflict" , "$1": { "type": "foreach" , "var": "x" , "range": {"type": "FIELD", "name": "lua filters"} , "body": { "type": "map_union" , "$1": [ {"type": "DEP_RUNFILES", "dep": {"type": "var", "name": "x"}} , { "type": "DEP_ARTIFACTS" , "dep": {"type": "var", "name": "x"} } ] } } } ] ] , "body": { "type": "RESULT" , "artifacts": {"type": "var", "name": "data"} , "runfiles": {"type": "var", "name": "data"} , "provides": { "type": "map_union" , "$1": [ { "type": "singleton_map" , "key": "template-name" , "value": {"type": "join", "$1": {"type": "FIELD", "name": "name"}} } , { "type": "singleton_map" , "key": "template-args" , "value": {"type": "FIELD", "name": "args"} } , { "type": "singleton_map" , "key": "lua filters" , "value": {"type": "var", "name": "lua filters"} } ] } } } } , "metadata": { "doc": ["Generate a file with meta data from data provided through context"] , "config_vars": ["SOURCE_DATE_EPOCH", "DATE_FORMAT"] , "config_doc": { "SOURCE_DATE_EPOCH": [ "The timestamp to include (in seconds since Jan 1, 1970 00:00 UTC);" , "ignored if unset or value is 0." ] , "DATE_FORMAT": ["The format to use for time stamps (defaults to \"%Y-%m-%d %H:%M\")."] } , "expression": { "type": "let*" , "bindings": [ [ "script" , { "type": "join" , "separator": "\n" , "$1": { "type": "++" , "$1": [ ["echo", "echo ---"] , { "type": "if" , "cond": {"type": "var", "name": "SOURCE_DATE_EPOCH"} , "then": [ { "type": "join_cmd" , "$1": [ "date" , "-d" , { "type": "join" , "$1": [ "@" , { "type": "json_encode" , "$1": {"type": "var", "name": "SOURCE_DATE_EPOCH"} } ] } , { "type": "join" , "$1": [ "+date: \"" , { "type": "var" , "name": "DATE_FORMAT" , "default": "%Y-%m-%d %H:%M" } , "\"" ] } ] } ] } , ["echo ---", "echo\n"] ] } } ] , [ "data" , { "type": "ACTION" , "cmd": ["sh", "-c", "sh ./generate > metadata.yaml"] , "outs": ["metadata.yaml"] , "inputs": { "type": "singleton_map" , "key": "generate" , "value": {"type": "BLOB", "data": {"type": "var", "name": "script"}} } } ] ] , "body": {"type": "RESULT", "artifacts": {"type": "var", "name": "data"}} } } , "standalone": { "doc": ["Create a standalone document from the given inputs"] , "target_fields": ["srcs", "template", "data", "meta data files"] , "string_fields": ["out", "meta data", "via"] , "field_doc": { "srcs": [ "The files to build the document from, in order." , "Honors the order within a [\"files\", \"ordered\"] target." ] , "data": ["Additional files needed for building (e.g., images)"] , "out": ["The name of the output file.", "Must not conflict with input files."] , "template": ["The template definition to use"] , "meta data": [ "Additional meta data to be set. Each entry has to have the" , "form \"key=value\"." ] , "meta data files": ["Additional meta data files to be taken into account"] , "via": [ "If a non-empty string is given, first convert all input files to this" , "format, if not of this format already." , "(entries in this field are concatenated)" ] } , "config_vars": ["env", "TYPESETTING_EXECUTION_PROPERTIES"] , "config_doc": { "env": [ "Any override to the default environment which sets only" , "PATH, SOURCE_DATE_EPOCH, and TEXINPUTS" ] , "TYPESETTING_EXECUTION_PROPERTIES": [ "Map of additional remote-execution properties to add for the typesetting" , "actions; defaults to the empty map." ] } , "implicit": {"metadata": [["./", ".", "metadata"]]} , "imports": { "src names": ["./", "../files", "order"] , "stage": ["./", "..", "stage_singleton_field"] } , "expression": { "type": "let*" , "bindings": [ [ "out" , { "type": "assert_non_empty" , "msg": "A valid output name has to be provided" , "$1": {"type": "join", "$1": {"type": "FIELD", "name": "out"}} } ] , [ "env" , { "type": "map_union" , "$1": [ { "type": "singleton_map" , "key": "PATH" , "value": "/bin:/usr/bin:/usr/local/bin" } , { "type": "singleton_map" , "key": "SOURCE_DATE_EPOCH" , "value": "0" } , {"type": "singleton_map", "key": "TEXINPUTS", "value": "data:"} , {"type": "var", "name": "env", "default": {"type": "empty_map"}} ] } ] , [ "srcs" , { "type": "disjoint_map_union" , "msg": "Sources may not conflict" , "$1": { "type": "foreach" , "var": "x" , "range": {"type": "FIELD", "name": "srcs"} , "body": { "type": "map_union" , "$1": [ {"type": "DEP_RUNFILES", "dep": {"type": "var", "name": "x"}} , { "type": "DEP_ARTIFACTS" , "dep": {"type": "var", "name": "x"} } ] } } } ] , [ "extra" , { "type": "disjoint_map_union" , "msg": "Data files may not conflict" , "$1": { "type": "foreach" , "var": "x" , "range": {"type": "FIELD", "name": "data"} , "body": { "type": "map_union" , "$1": [ {"type": "DEP_RUNFILES", "dep": {"type": "var", "name": "x"}} , { "type": "DEP_ARTIFACTS" , "dep": {"type": "var", "name": "x"} } ] } } } ] , [ "extra" , { "type": "to_subdir" , "subdir": "data" , "$1": {"type": "var", "name": "extra"} } ] , ["via", {"type": "join", "$1": {"type": "FIELD", "name": "via"}}] , [".via", {"type": "join", "$1": [".", {"type": "var", "name": "via"}]}] , [ "srcs" , { "type": "if" , "cond": {"type": "var", "name": "via"} , "else": {"type": "var", "name": "srcs"} , "then": { "type": "disjoint_map_union" , "msg": "Converted files must not overlap" , "$1": { "type": "foreach_map" , "range": {"type": "var", "name": "srcs"} , "body": { "type": "let*" , "bindings": [ [ "old" , { "type": "singleton_map" , "key": {"type": "var", "name": "_"} , "value": {"type": "var", "name": "$_"} } ] , [ "new_name" , { "type": "change_ending" , "ending": {"type": "var", "name": ".via"} , "$1": {"type": "var", "name": "_"} } ] ] , "body": { "type": "if" , "cond": { "type": "==" , "$1": {"type": "var", "name": "_"} , "$2": {"type": "var", "name": "new_name"} } , "then": {"type": "var", "name": "old"} , "else": { "type": "ACTION" , "inputs": { "type": "map_union" , "$1": [ {"type": "var", "name": "extra"} , {"type": "var", "name": "old"} ] } , "outs": [{"type": "var", "name": "new_name"}] , "env": {"type": "var", "name": "env"} , "cmd": [ "pandoc" , "-o" , {"type": "var", "name": "new_name"} , {"type": "var", "name": "_"} ] , "execution properties": { "type": "var" , "name": "TYPESETTING_EXECUTION_PROPERTIES" , "default": {"type": "empty_map"} } } } } } } } ] , [ "srcs" , { "type": "to_subdir" , "subdir": "srcs" , "$1": {"type": "var", "name": "srcs"} } ] , [ "data" , { "type": "disjoint_map_union" , "msg": "Template files may not conflict" , "$1": { "type": "foreach" , "var": "x" , "range": {"type": "FIELD", "name": "template"} , "body": { "type": "map_union" , "$1": [ {"type": "DEP_RUNFILES", "dep": {"type": "var", "name": "x"}} , { "type": "DEP_ARTIFACTS" , "dep": {"type": "var", "name": "x"} } ] } } } ] , [ "data" , { "type": "to_subdir" , "subdir": "data" , "$1": { "type": "disjoint_map_union" , "msg": "Template may not contain a \"data\" directory" , "$1": [ {"type": "var", "name": "data"} , {"type": "var", "name": "extra"} ] } } ] , [ "lua filters" , { "type": "disjoint_map_union" , "msg": "Lua filters may not conflict" , "$1": { "type": "foreach" , "var": "x" , "range": {"type": "FIELD", "name": "template"} , "body": { "type": "DEP_PROVIDES" , "provider": "lua filters" , "dep": {"type": "var", "name": "x"} } } } ] , [ "lua filters" , { "type": "to_subdir" , "subdir": "lua" , "$1": {"type": "var", "name": "lua filters"} } ] , [ "template-name" , { "type": "join" , "$1": { "type": "foreach" , "var": "x" , "range": {"type": "FIELD", "name": "template"} , "body": { "type": "DEP_PROVIDES" , "dep": {"type": "var", "name": "x"} , "provider": "template-name" , "default": "default" } } } ] , [ "template-args" , { "type": "++" , "$1": { "type": "foreach" , "var": "x" , "range": {"type": "FIELD", "name": "template"} , "body": { "type": "DEP_PROVIDES" , "dep": {"type": "var", "name": "x"} , "provider": "template-args" } } } ] , [ "_" , { "type": "if" , "cond": { "type": "lookup" , "map": {"type": "var", "name": "srcs"} , "key": {"type": "var", "name": "out"} } , "then": { "type": "fail" , "msg": [ "Output must be disjoint from inputs." , "Output file name is" , {"type": "var", "name": "out"} , "input files are" , {"type": "keys", "$1": {"type": "var", "name": "srcs"}} ] } } ] , ["src names", {"type": "CALL_EXPRESSION", "name": "src names"}] , [ "src names" , { "type": "if" , "cond": {"type": "var", "name": "via"} , "else": {"type": "var", "name": "src names"} , "then": { "type": "foreach" , "range": {"type": "var", "name":"src names"} , "body": { "type": "change_ending" , "ending": {"type": "var", "name": ".via"} , "$1": {"type": "var", "name": "_"} } } } ] , [ "src names" , { "type": "foreach" , "var": "name" , "range": {"type": "var", "name": "src names"} , "body": {"type": "join", "$1": ["srcs/", {"type": "var", "name": "name"}]} } ] , [ "meta data args" , { "type": "++" , "$1": { "type": "foreach" , "var": "x" , "range": {"type": "FIELD", "name": "meta data"} , "body": ["-M", {"type": "var", "name": "x"}] } } ] , [ "filter args" , { "type": "++" , "$1": { "type": "foreach" , "var": "x" , "range": {"type": "keys", "$1": {"type": "var", "name": "lua filters"}} , "body": ["--lua-filter", {"type": "var", "name": "x"}] } } ] , [ "metadata" , { "type": "let*" , "bindings": [["fieldname", "metadata"], ["location", "metadata.yaml"]] , "body": {"type": "CALL_EXPRESSION", "name": "stage"} } ] , [ "extra metadata files" , { "type": "++" , "$1": { "type": "foreach" , "range": {"type": "FIELD", "name": "meta data files"} , "body": { "type": "values" , "$1": {"type": "DEP_ARTIFACTS", "dep": {"type": "var", "name": "_"}} } } } ] , [ "staged extra metadata" , { "type": "map_union" , "$1": { "type": "foreach_map" , "range": { "type": "enumerate" , "$1": {"type": "var", "name": "extra metadata files"} } , "body": { "type": "singleton_map" , "key": { "type": "join" , "$1": ["metadta", {"type": "var", "name": "_"}, ".yaml"] } , "value": {"type": "var", "name": "$_"} } } } ] , [ "generated" , { "type": "ACTION" , "inputs": { "type": "map_union" , "$1": [ {"type": "var", "name": "srcs"} , {"type": "var", "name": "data"} , {"type": "var", "name": "lua filters"} , {"type": "var", "name": "metadata"} , {"type": "var", "name": "staged extra metadata"} ] } , "outs": [{"type": "var", "name": "out"}] , "env": {"type": "var", "name": "env"} , "cmd": { "type": "++" , "$1": [ [ "pandoc" , "--data-dir=./data" , "--resource-path=./data" , "-o" , {"type": "var", "name": "out"} , "-s" , "-N" ] , { "type": "if" , "cond": {"type": "var", "name": "template-name"} , "then": ["--template", {"type": "var", "name": "template-name"}] } , ["--metadata-file", "metadata.yaml"] , { "type": "++" , "$1": { "type": "foreach" , "range": { "type": "keys" , "$1": {"type": "var", "name": "staged extra metadata"} } , "body": ["--metadata-file", {"type": "var", "name": "_"}] } } , {"type": "var", "name": "template-args"} , {"type": "var", "name": "filter args"} , {"type": "var", "name": "meta data args"} , {"type": "var", "name": "src names"} ] } , "execution properties": { "type": "var" , "name": "TYPESETTING_EXECUTION_PROPERTIES" , "default": {"type": "empty_map"} } } ] ] , "body": {"type": "RESULT", "artifacts": {"type": "var", "name": "generated"}} } } }