Skip to content

Commit

Permalink
Move the module folder
Browse files Browse the repository at this point in the history
  • Loading branch information
sharkdp authored and David Peter committed Sep 21, 2023
1 parent 107863f commit ac5a051
Show file tree
Hide file tree
Showing 34 changed files with 10 additions and 13 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ readline interface, including all the usual features like a command history, Ctr
<p></p>

The whole system of physical dimensions and units is specified Numbats standard library, which is
[written in the Numbat language](https://github.com/sharkdp/numbat/tree/master/modules) itself. It is therefore
[written in the Numbat language](https://github.com/sharkdp/numbat/tree/master/numbat/modules) itself. It is therefore
easily extensible by [providing a `init.nbt` file](https://numbat.dev/doc/cli-customization.html). For example,
a single line (`unit bathtub = 150 L`) is usually enough to add a new unit. Users can even choose to write their
own `prelude` module, allowing for arbitrary modifications to the unit system.
Expand Down Expand Up @@ -158,10 +158,10 @@ cargo test

### Working on the `prelude`

If you are working on [Numbats standard library](modules/), it is convenient to point
the `NUMBAT_MODULES_PATH` environment variable to the `modules/` folder. This way,
If you are working on [Numbats standard library](numbat/modules/), it is convenient to point
the `NUMBAT_MODULES_PATH` environment variable to the `numbat/modules/` folder. This way,
you don't have to recompile Numbat to see your changes.

Alternatively, you can create a symlink from `~/.config/numbat/modules` to the `modules/`
Alternatively, you can create a symlink from `~/.config/numbat/modules` to the `numbat/modules/`
folder in the repository (see [this page](https://numbat.dev/doc/cli-customization.html#module-paths)
for the standard paths on other operating systems.
2 changes: 1 addition & 1 deletion book/src/cli-customization.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,4 @@ use custom::finance::functions
```

In fact, the `custom` folder is just a convention to avoid name clashes with the
[standard library](https://github.com/sharkdp/numbat/tree/master/modules).
[standard library](https://github.com/sharkdp/numbat/tree/master/numbat/modules).
2 changes: 1 addition & 1 deletion create_release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ mkdir /tmp/numbat
cp target/release/numbat /tmp/numbat/
strip /tmp/numbat/numbat

cp -r modules/ /tmp/numbat/
cp -r numbat/modules/ /tmp/numbat/
cp -r examples/ /tmp/numbat/
cp LICENSE-APACHE LICENSE-MIT README.md /tmp/numbat

Expand Down
4 changes: 1 addition & 3 deletions numbat-cli/tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ use std::path::Path;
use assert_cmd::Command;

fn numbat() -> Command {
let module_path = Path::new(&std::env::var_os("CARGO_MANIFEST_DIR").unwrap())
.join("..")
.join("modules");
let module_path = Path::new(&std::env::var_os("CARGO_MANIFEST_DIR").unwrap()).join("modules");
std::env::set_var("NUMBAT_MODULES_PATH", module_path);

let mut cmd = Command::cargo_bin("numbat").unwrap();
Expand Down
2 changes: 1 addition & 1 deletion numbat/examples/unit_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use numbat::{module_importer::FileSystemImporter, resolver::CodeSource, Context}

fn main() {
let mut importer = FileSystemImporter::default();
importer.add_path("modules");
importer.add_path("numbat/modules");
let mut ctx = Context::new(importer);
let result = ctx
.interpret("use prelude\nuse units::currencies", CodeSource::Internal)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion numbat/src/module_importer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ impl ModuleImporter for FileSystemImporter {
}

#[derive(RustEmbed)]
#[folder = "$CARGO_MANIFEST_DIR/../modules/"]
#[folder = "$CARGO_MANIFEST_DIR/modules/"]
struct BuiltinAssets;

#[derive(Debug, Clone, Default)]
Expand Down
1 change: 0 additions & 1 deletion numbat/tests/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ pub fn get_test_context_without_prelude() -> Context {
&std::env::var_os("CARGO_MANIFEST_DIR")
.expect("CARGO_MANIFEST_DIR variable should be set when calling 'cargo test'"),
)
.join("..")
.join("modules");

let mut importer = FileSystemImporter::default();
Expand Down
2 changes: 1 addition & 1 deletion numbat/tests/prelude_and_examples.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ fn run_for_each_file(glob_pattern: &str, f: impl Fn(&str)) {

#[test]
fn modules_are_self_consistent() {
run_for_each_file("../modules/**/*.nbt", assert_runs_without_prelude);
run_for_each_file("modules/**/*.nbt", assert_runs_without_prelude);
}

#[test]
Expand Down

0 comments on commit ac5a051

Please sign in to comment.