[mod] auf ivaldi umgestellt
This commit is contained in:
parent
a47f272040
commit
4de54b516b
44
ivaldi.json
Normal file
44
ivaldi.json
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
{
|
||||
"version": "1",
|
||||
"name": "sd",
|
||||
"libs": {
|
||||
"plankton": [
|
||||
"base",
|
||||
"call",
|
||||
"list",
|
||||
"json",
|
||||
"file",
|
||||
"string",
|
||||
"xml",
|
||||
"args"
|
||||
]
|
||||
},
|
||||
"core": [
|
||||
"base.ts",
|
||||
"objects/base.ts",
|
||||
"objects/implementations/text.ts",
|
||||
"objects/implementations/code.ts",
|
||||
"objects/implementations/link.ts",
|
||||
"objects/implementations/group.ts",
|
||||
"objects/implementations/section.ts",
|
||||
"objects/implementations/list.ts",
|
||||
"objects/implementations/table.ts",
|
||||
"document.ts",
|
||||
"outputs/base.ts",
|
||||
"outputs/implementations/json.ts",
|
||||
"outputs/implementations/markdown.ts",
|
||||
"outputs/implementations/html.ts",
|
||||
"outputs/implementations/tex.ts"
|
||||
],
|
||||
"apps": [
|
||||
{
|
||||
"name": "main",
|
||||
"sources": [
|
||||
"main.ts"
|
||||
],
|
||||
"destination": "sd",
|
||||
"head": "#!/usr/bin/env node",
|
||||
"executable": true
|
||||
}
|
||||
]
|
||||
}
|
||||
28
misc/conv
28
misc/conv
|
|
@ -1,15 +1,33 @@
|
|||
#!/usr/bin/env node
|
||||
|
||||
function main(args)
|
||||
function read_stdin()
|
||||
{
|
||||
return (
|
||||
new Promise(
|
||||
(resolve, reject) => {
|
||||
process.stdin.on(
|
||||
"data",
|
||||
(data) => {
|
||||
resolve(data.toString());
|
||||
}
|
||||
);
|
||||
}
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
async function main(args)
|
||||
{
|
||||
// args
|
||||
const path_transform = ((args.length >= 0) ? args.shift() : "transform.js");
|
||||
const path_data = ((args.length >= 0) ? args.shift() : "data.json");
|
||||
// const path_data = ((args.length >= 0) ? args.shift() : "data.json");
|
||||
|
||||
// exec
|
||||
const _fs = require("fs");
|
||||
const data = JSON.parse(_fs.readFileSync(path_data).toString());
|
||||
const transformation_code = _fs.readFileSync(path_transform).toString()
|
||||
// const data = JSON.parse(_fs.readFileSync(path_data).toString());
|
||||
const data = JSON.parse(await read_stdin());
|
||||
const transformation_code = _fs.readFileSync(path_transform).toString();
|
||||
const sd = eval(transformation_code)(data);
|
||||
|
||||
// output
|
||||
|
|
@ -18,4 +36,4 @@ function main(args)
|
|||
}
|
||||
|
||||
|
||||
main(process.argv.slice(2));
|
||||
main(process.argv.slice(2)).catch(console.error);
|
||||
|
|
|
|||
11
readme.md
11
readme.md
|
|
@ -3,6 +3,11 @@
|
|||
zum Erzeugen von Dokumenten anhand von JSON-Daten
|
||||
|
||||
|
||||
## Erstellung
|
||||
|
||||
- `tools/ivaldi build` ausführen
|
||||
|
||||
|
||||
## Nutzung
|
||||
|
||||
Am beigefügten Beispiel `polyhedra`:
|
||||
|
|
@ -17,12 +22,12 @@ Folgende Abwandlungen sind möglich:
|
|||
|
||||
```sh
|
||||
# Markdown-Tabelle
|
||||
misc/conv misc/examples/polyhedra/transform-table.js misc/examples/polyhedra/data.json | build/sd -o markdown > /tmp/polyhedra-table.md
|
||||
cat misc/examples/polyhedra/data.json | misc/conv misc/examples/polyhedra/transform-table.js | build/sd -o markdown > /tmp/polyhedra-table.md
|
||||
|
||||
# HTML-Liste
|
||||
misc/conv misc/examples/polyhedra/transform-default.js misc/examples/polyhedra/data.json | build/sd -o html > /tmp/polyhedra-default.html
|
||||
cat misc/examples/polyhedra/data.json | misc/conv misc/examples/polyhedra/transform-default.js | build/sd -o html > /tmp/polyhedra-default.html
|
||||
|
||||
# HTML-Tabelle
|
||||
misc/conv misc/examples/polyhedra/transform-table.js misc/examples/polyhedra/data.json | build/sd -o html > /tmp/polyhedra-table.html
|
||||
cat misc/examples/polyhedra/data.json | misc/conv misc/examples/polyhedra/transform-table.js | build/sd -o html > /tmp/polyhedra-table.html
|
||||
```
|
||||
|
||||
|
|
|
|||
40
tools/build
40
tools/build
|
|
@ -1,40 +0,0 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import os as _os
|
||||
import argparse as _argparse
|
||||
|
||||
|
||||
def string_coin(template, arguments):
|
||||
result = template
|
||||
for (key, value, ) in arguments.items():
|
||||
result = result.replace("{{%s}}" % key, value)
|
||||
return result
|
||||
|
||||
|
||||
def main():
|
||||
## args
|
||||
argument_parser = _argparse.ArgumentParser()
|
||||
argument_parser.add_argument(
|
||||
"-o",
|
||||
"--output-directory",
|
||||
type = str,
|
||||
default = "build",
|
||||
metavar = "<output-directory>",
|
||||
)
|
||||
args = argument_parser.parse_args()
|
||||
|
||||
## exec
|
||||
_os.system(
|
||||
string_coin(
|
||||
"make --file={{path_makefile}} dir_build={{dir_build}}",
|
||||
{
|
||||
"path_makefile": "tools/makefile",
|
||||
"dir_build": args.output_directory,
|
||||
}
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
main()
|
||||
|
||||
|
||||
5821
tools/ivaldi
Executable file
5821
tools/ivaldi
Executable file
File diff suppressed because it is too large
Load diff
|
|
@ -1,52 +0,0 @@
|
|||
## vars
|
||||
|
||||
dir_lib := lib
|
||||
dir_source := source
|
||||
dir_temp := temp
|
||||
dir_build := build
|
||||
|
||||
|
||||
## commands
|
||||
|
||||
cmd_mkdir := mkdir --parents
|
||||
cmd_log := echo "--"
|
||||
cmd_tsc := tsc
|
||||
cmd_chmod := chmod
|
||||
cmd_echo := echo
|
||||
cmd_cat := cat
|
||||
|
||||
|
||||
## rules
|
||||
|
||||
.PHONY: _default
|
||||
_default: ${dir_build}/sd
|
||||
|
||||
${dir_temp}/sd-unlinked.js: \
|
||||
${dir_lib}/plankton/plankton.d.ts \
|
||||
${dir_source}/base.ts \
|
||||
${dir_source}/objects/base.ts \
|
||||
${dir_source}/objects/implementations/text.ts \
|
||||
${dir_source}/objects/implementations/code.ts \
|
||||
${dir_source}/objects/implementations/link.ts \
|
||||
${dir_source}/objects/implementations/group.ts \
|
||||
${dir_source}/objects/implementations/section.ts \
|
||||
${dir_source}/objects/implementations/list.ts \
|
||||
${dir_source}/objects/implementations/table.ts \
|
||||
${dir_source}/document.ts \
|
||||
${dir_source}/outputs/base.ts \
|
||||
${dir_source}/outputs/implementations/json.ts \
|
||||
${dir_source}/outputs/implementations/markdown.ts \
|
||||
${dir_source}/outputs/implementations/html.ts \
|
||||
${dir_source}/outputs/implementations/tex.ts \
|
||||
${dir_source}/main.ts
|
||||
@ ${cmd_log} "compiling …"
|
||||
@ ${cmd_mkdir} $(dir $@)
|
||||
@ ${cmd_tsc} --lib es2020 $^ --outFile $@
|
||||
|
||||
${dir_build}/sd: ${dir_lib}/plankton/plankton.js ${dir_temp}/sd-unlinked.js
|
||||
@ ${cmd_log} "linking …"
|
||||
@ ${cmd_mkdir} $(dir $@)
|
||||
@ ${cmd_echo} "#!/usr/bin/env node" > $@
|
||||
@ ${cmd_cat} $^ >> $@
|
||||
@ ${cmd_chmod} +x $@
|
||||
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
#!/usr/bin/env sh
|
||||
|
||||
## consts
|
||||
|
||||
dir="lib/plankton"
|
||||
|
||||
|
||||
## vars
|
||||
|
||||
modules=""
|
||||
modules="${modules} base"
|
||||
modules="${modules} call"
|
||||
modules="${modules} list"
|
||||
modules="${modules} json"
|
||||
modules="${modules} file"
|
||||
modules="${modules} args"
|
||||
modules="${modules} string"
|
||||
modules="${modules} xml"
|
||||
|
||||
|
||||
## exec
|
||||
|
||||
mkdir --parents ${dir}
|
||||
cd ${dir}
|
||||
ptk bundle node ${modules}
|
||||
cd - > /dev/null
|
||||
Loading…
Reference in a new issue