diff --git a/Cargo.toml b/Cargo.toml
index 11902a2..de61b4e 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -24,21 +24,25 @@ edition = "2021"
[dependencies]
clap = { version = "4.5.4", features = ["derive"], optional = true }
-convert_case = {version = "0.6.0", optional = true}
-proc-macro2 = {version = "1.0.79", optional = true}
-quote = {version = "1.0.35", optional = true}
-syn = { version = "2.0.55", features = ["extra-traits", "full", "parsing"], optional = true }
-thiserror = { version = "1.0.58", optional = true}
-pulldown-cmark = {version = "0.10.0", optional = true}
+convert_case = { version = "0.6.0", optional = true }
+proc-macro2 = { version = "1.0.79", optional = true }
+quote = { version = "1.0.35", optional = true }
+syn = { version = "2.0.55", features = [
+ "extra-traits",
+ "full",
+ "parsing",
+], optional = true }
+thiserror = { version = "1.0.58", optional = true }
+pulldown-cmark = { version = "0.10.0", optional = true }
# macros
-prettyplease = {version = "0.2.17", optional = true}
+prettyplease = { version = "0.2.17", optional = true }
# parser
-regex = {version = "1.10.4", optional = true}
+regex = { version = "1.10.4", optional = true }
# types
-libc ={ version = "0.2.153", optional = true}
-log = { version = "0.4.21", optional = true}
+libc = { version = "0.2.153", optional = true }
+log = { version = "0.4.21", optional = true }
[dev-dependencies]
# parser
@@ -49,9 +53,27 @@ pretty_assertions = "1.4.0"
default = ["parser", "types", "macros"]
build-binary = ["parser", "types", "macros", "clap", "pulldown-cmark"]
-parser = [ "regex", "thiserror", "convert_case" ]
-types = [ "parser", "libc", "log", "proc-macro2", "quote", "syn", "thiserror", "convert_case" ]
-macros = [ "parser", "types", "prettyplease", "proc-macro2", "quote", "syn", "convert_case" ]
+parser = ["regex", "thiserror", "convert_case"]
+types = [
+ "parser",
+ "libc",
+ "log",
+ "proc-macro2",
+ "quote",
+ "syn",
+ "thiserror",
+ "convert_case",
+]
+macros = [
+ "parser",
+ "types",
+ "prettyplease",
+ "proc-macro2",
+ "quote",
+ "syn",
+ "convert_case",
+ "pulldown-cmark",
+]
[[bin]]
name = "trixy"
diff --git a/cog.toml b/cog.toml
index 87f4d94..55f5d5b 100644
--- a/cog.toml
+++ b/cog.toml
@@ -18,21 +18,21 @@
# If not, see .
tag_prefix = "v"
-branch_whitelist = [ "main" ]
+branch_whitelist = ["main"]
ignore_merge_commits = false
[commit_types]
pre_bump_hooks = [
- "licensur -p -i" # update the license header in each file
- "nix build", # verify the project builds
- "nix fmt" # format
- "cargo set-version {{version}}", # bump version in Cargo.toml
+ "licensur -p -i", # update the license header in each file
+ "nix build", # verify the project builds
+ "nix fmt", # format
+ "cargo set-version {{version}}", # bump version in Cargo.toml
]
post_bump_hooks = [
- "git push",
- "cargo publish",
- "git push origin v{{version}}", # push the new tag to origin
+ "git push",
+ "cargo publish",
+ "git push origin v{{version}}", # push the new tag to origin
]
[bump_profiles]
@@ -42,20 +42,4 @@ path = "NEWS.md"
remote = "git.nerdcult.net"
repository = "trixy"
owner = "trinitrix"
-authors = [
- { signature = "Soispha", username = "soispha" },
-]
-
-
-[packages]
-trixy-lang_parser = { path = "trixy-lang_parser", changelog_path = "{path}/NEWS.md" }}
-pre_bump_hooks = [
- "nix build", # verify the project builds
- "cargo fmt --all" # format
- "cargo set-version {{version}}", # bump version in Cargo.toml
-]
-post_bump_hooks = [
- "git push",
- "cargo publish",
- "git push origin v{{version}}", # push the new tag to origin
-]
+authors = [{ signature = "Soispha", username = "soispha" }]
diff --git a/scripts/tests.sh b/scripts/tests.sh
index d59651d..781e2a8 100755
--- a/scripts/tests.sh
+++ b/scripts/tests.sh
@@ -2,88 +2,88 @@
# Parts of a shell library {{{
die() {
- error "$1";
+ error "$1"
if [ -n "$2" ]; then
- exit "$2";
+ exit "$2"
else
- exit 1;
+ exit 1
fi
}
print() {
# The direct usage is intended as `print` is rather lowlevel
# shellcheck disable=2059
- printf "$*";
-};
+ printf "$*"
+}
println() {
# The direct usage is intended as `println` is rather lowlevel
# shellcheck disable=2059
- printf "$*\n";
-};
+ printf "$*\n"
+}
eprint() {
- >&2 print "$@";
-};
+ >&2 print "$@"
+}
eprintln() {
- >&2 println "$@";
-};
+ >&2 println "$@"
+}
-if [ -n "$NO_COLOR" ];then
+if [ -n "$NO_COLOR" ]; then
error() {
- eprintln "==> ERROR:" "$*";
- };
+ eprintln "==> ERROR:" "$*"
+ }
warning() {
- eprintln "==> WARNING:" "$*";
- };
+ eprintln "==> WARNING:" "$*"
+ }
debug() {
- [ -n "$SHELL_LIBRARY_DEBUG" ] && eprintln "==> [Debug:]" "$*";
- };
+ [ -n "$SHELL_LIBRARY_DEBUG" ] && eprintln "==> [Debug:]" "$*"
+ }
debug2() {
- [ -n "$SHELL_LIBRARY_DEBUG" ] && eprintln " -> [Debug:]" "$*";
- };
+ [ -n "$SHELL_LIBRARY_DEBUG" ] && eprintln " -> [Debug:]" "$*"
+ }
msg() {
- eprintln "==>" "$*";
- };
+ eprintln "==>" "$*"
+ }
msg2() {
- eprintln " ->" "$*";
- };
+ eprintln " ->" "$*"
+ }
prompt() {
- eprint "..>" "$*";
- };
+ eprint "..>" "$*"
+ }
else
# See https://stackoverflow.com/a/33206814 for ansi codes
error() {
- eprintln "\033[1;91m==> ERROR:\033[0m" "\033[1;93m$*\033[0m";
- };
+ eprintln "\033[1;91m==> ERROR:\033[0m" "\033[1;93m$*\033[0m"
+ }
warning() {
- eprintln "\033[1;91m==> WARNING:\033[0m" "\033[1;93m$*\033[0m";
- };
+ eprintln "\033[1;91m==> WARNING:\033[0m" "\033[1;93m$*\033[0m"
+ }
debug() {
- [ -n "$SHELL_LIBRARY_DEBUG" ] && eprintln "\033[1;94m==> [Debug:]\033[0m" "\033[1;93m$*\033[0m";
- };
+ [ -n "$SHELL_LIBRARY_DEBUG" ] && eprintln "\033[1;94m==> [Debug:]\033[0m" "\033[1;93m$*\033[0m"
+ }
debug2() {
- [ -n "$SHELL_LIBRARY_DEBUG" ] && eprintln "\033[1;94m -> [Debug:]\033[0m" "\033[1;93m$*\033[0m";
- };
+ [ -n "$SHELL_LIBRARY_DEBUG" ] && eprintln "\033[1;94m -> [Debug:]\033[0m" "\033[1;93m$*\033[0m"
+ }
msg() {
- eprintln "\033[1;96m==>\033[0m" "\033[1;93m$*\033[0m";
- };
+ eprintln "\033[1;96m==>\033[0m" "\033[1;93m$*\033[0m"
+ }
msg2() {
- eprintln "\033[1;96m ->\033[0m" "\033[1;93m$*\033[0m";
- };
+ eprintln "\033[1;96m ->\033[0m" "\033[1;93m$*\033[0m"
+ }
prompt() {
- eprint "\033[1;96m..>\033[0m" "\033[1;93m$*\033[0m";
- };
+ eprint "\033[1;96m..>\033[0m" "\033[1;93m$*\033[0m"
+ }
fi
mktmp() {
- ensure_tmp_dir;
- mktemp -p "$SHELL_LIBRARY_TEMP_PREFIX_DIR";
+ ensure_tmp_dir
+ mktemp -p "$SHELL_LIBRARY_TEMP_PREFIX_DIR"
}
ensure_tmp_dir() {
- if ! [ -d "$SHELL_LIBRARY_TEMP_PREFIX_DIR" ];then
- SHELL_LIBRARY_TEMP_PREFIX_DIR="$(mktemp -d)";
+ if ! [ -d "$SHELL_LIBRARY_TEMP_PREFIX_DIR" ]; then
+ SHELL_LIBRARY_TEMP_PREFIX_DIR="$(mktemp -d)"
fi
-};
+}
# A new version of tmp, which allows you to specify the commandline args as normal
# arguments
@@ -92,54 +92,53 @@ tmp() {
warn "Detected an old version of tmp, as there are spaces in the input string!"
fi
- TEMP_DIR_WITH_DEL="$(mktmp)";
- "$@" 1> "$TEMP_DIR_WITH_DEL";
- echo "$TEMP_DIR_WITH_DEL";
-};
+ TEMP_DIR_WITH_DEL="$(mktmp)"
+ "$@" 1>"$TEMP_DIR_WITH_DEL"
+ echo "$TEMP_DIR_WITH_DEL"
+}
# Takes a path to search as argument.
# Also takes further arguments as names to search for.
# Prints the path to a file, if a file matching the given name is found.
search_dir_for_file() {
- [ -d "$1" ] || die "Arg $1 is not a directory";
- directory="$1" && shift 1;
+ [ -d "$1" ] || die "Arg $1 is not a directory"
+ directory="$1" && shift 1
while read -r dir_entry; do
- dir_entry_count=$((dir_entry_count + 1));
- dir_entry_basename="$(basename "$dir_entry")";
+ dir_entry_count=$((dir_entry_count + 1))
+ dir_entry_basename="$(basename "$dir_entry")"
- for name in "$@";do
+ for name in "$@"; do
if [ "$name" = "$dir_entry_basename" ]; then
- println "$dir_entry";
+ println "$dir_entry"
fi
done
- done < "$(tmp fd . "$directory" --type file --max-depth 1)"
- print "";
+ done <"$(tmp fd . "$directory" --type file --max-depth 1)"
+ print ""
}
# Returns the path to the directory which contains all the specified files:
# `search_upward_files file1 file2 file3` returns a path containing file1 ...
search_upward_files() {
- directory="$(pwd)";
- final_directory="";
- output="$(mktmp)";
- while [ "$(wc -l < "$output")" = 0 ]; do
- search_dir_for_file "$directory" "$@" > "$output";
- directory="$(dirname "$directory")";
+ directory="$(pwd)"
+ final_directory=""
+ output="$(mktmp)"
+ while [ "$(wc -l <"$output")" = 0 ]; do
+ search_dir_for_file "$directory" "$@" >"$output"
+ directory="$(dirname "$directory")"
if [ "$directory" = "/" ]; then
- warning "We bailed out, as there seems to be no directory containing $*";
- final_directory="";
- return;
+ warning "We bailed out, as there seems to be no directory containing $*"
+ final_directory=""
+ return
fi
done
- final_directory="$(dirname "$(head -n1 "$output")")";
- print "$final_directory";
+ final_directory="$(dirname "$(head -n1 "$output")")"
+ print "$final_directory"
}
# }}}
-
help() {
- cat << EOF
+ cat < "$test_dir/expected.md"
+ >"$test_dir/expected.md"
else
fd . "$ROOT_DIR/tests" --type directory --max-depth=1 --exec basename | while read -r dir; do
msg2 "Updating $dir.."
@@ -205,25 +204,24 @@ update() {
for arg in "$@"; do
case "$arg" in
- "--help" | "-h")
- help;
- exit 0;
- ;;
+ "--help" | "-h")
+ help
+ exit 0
+ ;;
esac
done
-
case "$1" in
- "update")
- shift 1;
- [ -n "$1" ] && test_name="$1"
- update "$test_name";
- ;;
- "new")
- shift 1;
- test_name="$1";
- [ -z "$test_name" ] && die "You must specify a TESTNAME"
- new "$test_name";
- ;;
+"update")
+ shift 1
+ [ -n "$1" ] && test_name="$1"
+ update "$test_name"
+ ;;
+"new")
+ shift 1
+ test_name="$1"
+ [ -z "$test_name" ] && die "You must specify a TESTNAME"
+ new "$test_name"
+ ;;
esac
# vim: ft=sh
diff --git a/src/bin/trixy/cli.rs b/src/bin/trixy/cli.rs
index f037d84..3a421c3 100644
--- a/src/bin/trixy/cli.rs
+++ b/src/bin/trixy/cli.rs
@@ -79,7 +79,7 @@ pub enum GenCommand {
/// Generate all code for every language
All {
- #[arg(short, long, default_value_t=true)]
+ #[arg(short, long, default_value_t = true)]
/// Don't generate vendored files (like c headers)
no_vendored: bool,
},
diff --git a/src/lib.rs b/src/lib.rs
index d9a07b4..341f438 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -21,10 +21,10 @@
#[cfg(feature = "macros")]
pub mod macros;
-#[cfg(feature = "types")]
-pub mod types;
#[cfg(feature = "parser")]
pub mod parser;
+#[cfg(feature = "types")]
+pub mod types;
pub mod __private {
//! This module contains crates needed for the generated code, it should not be used by humans.
diff --git a/src/macros/generate/convert/auxiliary/c/mod.rs b/src/macros/generate/convert/auxiliary/c/mod.rs
index 1dee304..1554c9b 100644
--- a/src/macros/generate/convert/auxiliary/c/mod.rs
+++ b/src/macros/generate/convert/auxiliary/c/mod.rs
@@ -6,7 +6,6 @@ mod namespace;
mod structure;
mod r#type;
-
// pub use attribute::*;
// pub use enumeration::*;
// pub use function::*;
diff --git a/src/macros/generate/convert/host/mod.rs b/src/macros/generate/convert/host/mod.rs
index 65d76bf..b4e04d1 100644
--- a/src/macros/generate/convert/host/mod.rs
+++ b/src/macros/generate/convert/host/mod.rs
@@ -1,2 +1,2 @@
-pub mod rust;
pub mod c;
+pub mod rust;
diff --git a/src/macros/generate/convert/host/rust/derive/mod.rs b/src/macros/generate/convert/host/rust/derive/mod.rs
index 51b50c3..8bc755d 100644
--- a/src/macros/generate/convert/host/rust/derive/mod.rs
+++ b/src/macros/generate/convert/host/rust/derive/mod.rs
@@ -1,2 +1,2 @@
-pub mod structure;
pub mod enumeration;
+pub mod structure;
diff --git a/src/macros/generate/convert/host/rust/namespace/mod.rs b/src/macros/generate/convert/host/rust/namespace/mod.rs
index 9c719bd..f001641 100644
--- a/src/macros/generate/convert/host/rust/namespace/mod.rs
+++ b/src/macros/generate/convert/host/rust/namespace/mod.rs
@@ -1,2 +1,2 @@
-pub mod path;
pub mod module;
+pub mod path;
diff --git a/src/macros/generate/convert/mod.rs b/src/macros/generate/convert/mod.rs
index 50c2842..c7f43fb 100644
--- a/src/macros/generate/convert/mod.rs
+++ b/src/macros/generate/convert/mod.rs
@@ -1,2 +1,2 @@
-pub mod host;
pub mod auxiliary;
+pub mod host;
diff --git a/src/macros/generate/mod.rs b/src/macros/generate/mod.rs
index 779d053..9059423 100644
--- a/src/macros/generate/mod.rs
+++ b/src/macros/generate/mod.rs
@@ -1,3 +1,3 @@
-pub mod host;
pub mod auxiliary;
pub mod convert;
+pub mod host;
diff --git a/tests/attribute_doc_comments/expected.md b/tests/attribute_doc_comments/expected.md
index 0505887..1c6feee 100644
--- a/tests/attribute_doc_comments/expected.md
+++ b/tests/attribute_doc_comments/expected.md
@@ -1,5 +1,7 @@
# Host files
+
File path: `out/dir/api.rs`
+
```rust
// Host code
/* Rust API */
@@ -45,7 +47,9 @@ pub extern "C" fn trinitrix_hi(
```
# Auxiliary files
+
File path: `dist/interface.h`
+
```c
#if !defined TRIXY_MAIN_HEADER
#define TRIXY_MAIN_HEADER
@@ -70,5 +74,3 @@ const struct trinitrix trinitrix = {
#endif // if !defined TRIXY_MAIN_HEADER
// vim: filetype=c
```
-
-
diff --git a/tests/multiple/expected.md b/tests/multiple/expected.md
index 3e4b2cc..c1d68a1 100644
--- a/tests/multiple/expected.md
+++ b/tests/multiple/expected.md
@@ -1,5 +1,7 @@
# Host files
+
File path: `out/dir/api.rs`
+
```rust
// Host code
/* Rust API */
@@ -32,7 +34,9 @@ pub extern "C" fn name_one_from_second_namespace() -> core::ffi::c_int {
```
# Auxiliary files
+
File path: `dist/interface.h`
+
```c
#if !defined TRIXY_MAIN_HEADER
#define TRIXY_MAIN_HEADER
@@ -59,5 +63,3 @@ const struct name_one name_one = {
#endif // if !defined TRIXY_MAIN_HEADER
// vim: filetype=c
```
-
-
diff --git a/tests/trinitrix_api/input.tri b/tests/trinitrix_api/input.tri
index ea2e5c3..823b9aa 100644
--- a/tests/trinitrix_api/input.tri
+++ b/tests/trinitrix_api/input.tri
@@ -61,7 +61,7 @@ mod trinitrix {
/// Allows you to insert things
Insert,
/// actives the command line
- Command
+ Command,
}
/// Change the active mode