-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
replace go-term-markdown with glamour, pre-render Markdown files to r…
…educe runtime dependencies, revamp docs
- Loading branch information
Showing
250 changed files
with
5,008 additions
and
1,602 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module go.xrstf.de/rudi/cmd/example | ||
|
||
go 1.18 | ||
|
||
require go.xrstf.de/rudi v0.2.1-0.20231205152938-7272c971e798 | ||
|
||
replace go.xrstf.de/rudi => ../../ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"log" | ||
|
||
"go.xrstf.de/rudi" | ||
"go.xrstf.de/rudi/pkg/coalescing" | ||
) | ||
|
||
const script = `(set! .foo 42) (+ $myvar 42 .foo)` | ||
|
||
func main() { | ||
// Rudi programs are meant to manipulate a document (path expressions like | ||
// ".foo" resolve within that document). The document can be anything, | ||
// but is most often a JSON object. | ||
documentData := map[string]any{"foo": 9000} | ||
|
||
// parse the script (the name is used when generating error strings) | ||
program, err := rudi.Parse("myscript", script) | ||
if err != nil { | ||
log.Fatalf("The script is invalid: %v", err) | ||
} | ||
|
||
// evaluate the program; | ||
// this returns an evaluated value, which is the result of the last expression | ||
// that was evaluated, plus the final document state (the updatedData) after | ||
// the script has finished. | ||
updatedData, result, err := program.Run( | ||
documentData, | ||
// setup the set of variables available by default in the script | ||
rudi.NewVariables().Set("myvar", 42), | ||
// Likewise, setup the functions available (note that this includes | ||
// functions like "if" and "and", so running with an empty function set | ||
// is generally not advisable). | ||
rudi.NewBuiltInFunctions(), | ||
// Decide what kind of type strictness you would like; pedantic, strict | ||
// or humane; choose your own adventure (strict is default if you use nil | ||
// here; humane allows conversions like 1 == "1"). | ||
coalescing.NewStrict(), | ||
) | ||
if err != nil { | ||
log.Fatalf("Script failed: %v", err) | ||
} | ||
|
||
fmt.Println(result) // => 126 | ||
fmt.Println(updatedData) // => {"foo": 42} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
// SPDX-FileCopyrightText: 2023 Christoph Mewes | ||
// SPDX-License-Identifier: MIT | ||
|
||
package batteries | ||
|
||
import ( | ||
coalescemod "go.xrstf.de/rudi/pkg/builtin/coalesce" | ||
coalescedocs "go.xrstf.de/rudi/pkg/builtin/coalesce/docs" | ||
comparemod "go.xrstf.de/rudi/pkg/builtin/compare" | ||
comparedocs "go.xrstf.de/rudi/pkg/builtin/compare/docs" | ||
coremod "go.xrstf.de/rudi/pkg/builtin/core" | ||
coredocs "go.xrstf.de/rudi/pkg/builtin/core/docs" | ||
datetimemod "go.xrstf.de/rudi/pkg/builtin/datetime" | ||
datetimedocs "go.xrstf.de/rudi/pkg/builtin/datetime/docs" | ||
encodingmod "go.xrstf.de/rudi/pkg/builtin/encoding" | ||
encodingdocs "go.xrstf.de/rudi/pkg/builtin/encoding/docs" | ||
hashingmod "go.xrstf.de/rudi/pkg/builtin/hashing" | ||
hashingdocs "go.xrstf.de/rudi/pkg/builtin/hashing/docs" | ||
listsmod "go.xrstf.de/rudi/pkg/builtin/lists" | ||
listsdocs "go.xrstf.de/rudi/pkg/builtin/lists/docs" | ||
logicmod "go.xrstf.de/rudi/pkg/builtin/logic" | ||
logicdocs "go.xrstf.de/rudi/pkg/builtin/logic/docs" | ||
mathmod "go.xrstf.de/rudi/pkg/builtin/math" | ||
mathdocs "go.xrstf.de/rudi/pkg/builtin/math/docs" | ||
stringsmod "go.xrstf.de/rudi/pkg/builtin/strings" | ||
stringsdocs "go.xrstf.de/rudi/pkg/builtin/strings/docs" | ||
typesmod "go.xrstf.de/rudi/pkg/builtin/types" | ||
typesdocs "go.xrstf.de/rudi/pkg/builtin/types/docs" | ||
"go.xrstf.de/rudi/pkg/docs" | ||
|
||
semvermod "go.xrstf.de/rudi-contrib/semver" | ||
semverdocs "go.xrstf.de/rudi-contrib/semver/docs" | ||
uuidmod "go.xrstf.de/rudi-contrib/uuid" | ||
uuiddocs "go.xrstf.de/rudi-contrib/uuid/docs" | ||
yamlmod "go.xrstf.de/rudi-contrib/yaml" | ||
yamldocs "go.xrstf.de/rudi-contrib/yaml/docs" | ||
) | ||
|
||
var ( | ||
// BuiltInModules look alphabetically sorted, except that "core" is always the first item, | ||
// because it's the most important module and should be first in the documentation. Order here | ||
// does not matter otherwise anyway. | ||
BuiltInModules = []docs.Module{ | ||
{ | ||
Name: "core", | ||
Functions: coremod.Functions, | ||
Documentation: coredocs.Functions, | ||
}, | ||
{ | ||
Name: "coalesce", | ||
Functions: coalescemod.Functions, | ||
Documentation: coalescedocs.Functions, | ||
}, | ||
{ | ||
Name: "compare", | ||
Functions: comparemod.Functions, | ||
Documentation: comparedocs.Functions, | ||
}, | ||
{ | ||
Name: "datetime", | ||
Functions: datetimemod.Functions, | ||
Documentation: datetimedocs.Functions, | ||
}, | ||
{ | ||
Name: "encoding", | ||
Functions: encodingmod.Functions, | ||
Documentation: encodingdocs.Functions, | ||
}, | ||
{ | ||
Name: "hashing", | ||
Functions: hashingmod.Functions, | ||
Documentation: hashingdocs.Functions, | ||
}, | ||
{ | ||
Name: "lists", | ||
Functions: listsmod.Functions, | ||
Documentation: listsdocs.Functions, | ||
}, | ||
{ | ||
Name: "logic", | ||
Functions: logicmod.Functions, | ||
Documentation: logicdocs.Functions, | ||
}, | ||
{ | ||
Name: "math", | ||
Functions: mathmod.Functions, | ||
Documentation: mathdocs.Functions, | ||
}, | ||
{ | ||
Name: "strings", | ||
Functions: stringsmod.Functions, | ||
Documentation: stringsdocs.Functions, | ||
}, | ||
{ | ||
Name: "types", | ||
Functions: typesmod.Functions, | ||
Documentation: typesdocs.Functions, | ||
}, | ||
} | ||
|
||
ExtendedModules = []docs.Module{ | ||
{ | ||
Name: "semver", | ||
Functions: semvermod.Functions, | ||
Documentation: semverdocs.Functions, | ||
}, | ||
{ | ||
Name: "uuid", | ||
Functions: uuidmod.Functions, | ||
Documentation: uuiddocs.Functions, | ||
}, | ||
{ | ||
Name: "yaml", | ||
Functions: yamlmod.Functions, | ||
Documentation: yamldocs.Functions, | ||
}, | ||
} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.