Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tooling improvements: docs, CI, wasm #280

Merged
merged 5 commits into from
Dec 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,30 @@ jobs:
run: |
cd book
bash build.sh
if [ -n "$(git status --porcelain)" ]; then
if [ -n "$(git status --porcelain)" ]; then
echo "Documentation not up to date."
echo "Make sure to run 'build.sh' in the documentation/ folder"
exit 1
fi

wasm:
name: WASM version
runs-on: ubuntu-20.04
steps:
- uses: dtolnay/rust-toolchain@stable
- uses: actions/checkout@v3
- name: Install wasm-pack
run: |
curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
- name: Build WASM version
run: |
cd numbat-wasm
bash build.sh
- name: Test WASM version
run: |
cd numbat-wasm
bash test.sh

min_version:
name: Minimum supported rust version
runs-on: ubuntu-20.04
Expand Down
3 changes: 3 additions & 0 deletions book/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,7 @@ generate_example xkcd_2812 "XKCD 2812" true

generate_example numbat_syntax "Syntax overview" false


cargo run --example=inspect > "${SCRIPT_DIR}/src/list-units.md"

mdbook build
7 changes: 4 additions & 3 deletions book/src/list-units.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<!-- NOTE! This file is auto-generated -->
# List of supported units

See also: [Unit notation](./unit-notation.md).
Expand Down Expand Up @@ -31,13 +32,13 @@ and — where sensible — units allow for [binary prefixes](https://en.wikipedi
| `Dot` | [Dot](https://en.wikipedia.org/wiki/Dots_per_inch) | `dot`, `dots` |
| `Dot / Length` | [Dots per inch](https://en.wikipedia.org/wiki/Dots_per_inch) | `dpi` |
| `DynamicViscosity` | [Poise](https://en.wikipedia.org/wiki/Poise_(unit)) | `poise` |
| `ElectricCharge` | [Ampere-hour](https://en.wikipedia.org/wiki/Ampere_hour) | `Ah`, `amperehour` |
| `ElectricCharge` | [Coulomb](https://en.wikipedia.org/wiki/Coulomb) | `C`, `coulomb`, `coulombs` |
| `ElectricCharge` | [Ampere-Hour](https://en.wikipedia.org/wiki/Ampere_hour) | `Ah`, `amperehour`, `amperehours` |
| `ElectricConductance` | [Siemens](https://en.wikipedia.org/wiki/Siemens_(unit)) | `S`, `siemens` |
| `ElectricResistance` | [Ohm](https://en.wikipedia.org/wiki/Ohm) | `ohm`, `ohms`, `Ω` |
| `Energy` | [British thermal unit](https://en.wikipedia.org/wiki/British_thermal_unit) | `BTU`, `Btu` |
| `Energy` | [Calorie](https://en.wikipedia.org/wiki/Calorie) | `cal`, `calorie`, `calories` |
| `Energy` | [Electronvolt](https://en.wikipedia.org/wiki/Electronvolt) | `electronvolt`, `electronvolts`, `eV` |
| `Energy` | [Electron volt](https://en.wikipedia.org/wiki/Electronvolt) | `electronvolt`, `electronvolts`, `eV` |
| `Energy` | [Erg](https://en.wikipedia.org/wiki/Erg) | `erg`, `ergs` |
| `Energy` | [Hartree](https://en.wikipedia.org/wiki/Hartree) | `hartree`, `hartrees` |
| `Energy` | [Joule](https://en.wikipedia.org/wiki/Joule) | `J`, `joule`, `joules` |
Expand All @@ -59,7 +60,7 @@ and — where sensible — units allow for [binary prefixes](https://en.wikipedi
| `Illuminance` | [Lux](https://en.wikipedia.org/wiki/Lux) | `lux`, `lx` |
| `Inductance` | [Henry](https://en.wikipedia.org/wiki/Henry_(unit)) | `H`, `henries`, `henry`, `henrys` |
| `KinematicViscosity` | [Stokes](https://en.wikipedia.org/wiki/Stokes_(unit)) | `St`, `stokes` |
| `Length` | [Ångström](https://en.wikipedia.org/wiki/Angstrom) | `angstrom`, `angstroms`, `Å` |
| `Length` | [Ångström](https://en.wikipedia.org/wiki/Angstrom) | `angstrom`, `angstroms`, `Å`, `Å` |
| `Length` | [Astronomical unit](https://en.wikipedia.org/wiki/Astronomical_unit) | `astronomicalunit`, `astronomicalunits`, `au`, `AU` |
| `Length` | [Bohr](https://en.wikipedia.org/wiki/Hartree_atomic_units) | `bohr` |
| `Length` | [Fathom](https://en.wikipedia.org/wiki/Fathom) | `fathom`, `fathoms` |
Expand Down
2 changes: 1 addition & 1 deletion numbat-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ impl Cli {
println!();
}
_ => {
if let Some(keyword) = line.strip_prefix("info") {
if let Some(keyword) = line.strip_prefix("info ") {
let help = self
.context
.lock()
Expand Down
5 changes: 4 additions & 1 deletion numbat-exchange-rates/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,8 @@ license = "MIT OR Apache-2.0"
rust-version = "1.70"

[dependencies]
attohttpc = { version = "0.26.0", default-features = false, features = ["tls-rustls-webpki-roots"] }
attohttpc = { version = "0.26.0", default-features = false, features = ["tls-rustls-webpki-roots"], optional = true }
quick-xml = "0.31.0"

[features]
fetch-exchangerates = ["dep:attohttpc"]
4 changes: 4 additions & 0 deletions numbat-exchange-rates/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,22 @@ pub fn parse_exchange_rates(xml_content: &str) -> Option<ExchangeRates> {
Some(rates)
}

#[cfg(feature = "fetch-exchangerates")]
const ECB_XML_URL: &str = "https://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml";

#[cfg(feature = "fetch-exchangerates")]
fn fetch_ecb_xml() -> Option<String> {
attohttpc::get(ECB_XML_URL).send().ok()?.text().ok()
}

#[cfg(feature = "fetch-exchangerates")]
pub fn fetch_exchange_rates() -> Option<ExchangeRates> {
let xml_content = fetch_ecb_xml()?;
parse_exchange_rates(&xml_content)
}

#[cfg(test)]
#[cfg(feature = "fetch-exchangerates")]
mod tests {
use super::*;

Expand Down
Loading