Skip to content

Commit 702de0f

Browse files
authored
feat: add a main crate to provide a clean user API (#160)
* add new member with subcrates re-exports * explicitly re-export core items instead of using its prelude * add documentation for the new crate * add nightly feature documentation it should work the way this is fixed: rust-lang/rust#96166 * exclude user crate from coverage CI * fix copypaste mistake in CI * add links to important items in crate-level doc
1 parent 5992043 commit 702de0f

File tree

5 files changed

+131
-3
lines changed

5 files changed

+131
-3
lines changed

.github/workflows/coverage.yml

+12-2
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,22 @@ jobs:
3232
# generate raw coverage data
3333
# excluding the benchmark / example crates to remove some bias
3434
- name: Build code
35-
run: cargo build --all-features --workspace --exclude honeycomb-benches --exclude honeycomb-examples --exclude honeycomb-render
35+
run: |
36+
cargo build --all-features --workspace \
37+
--exclude honeycomb \
38+
--exclude honeycomb-benches \
39+
--exclude honeycomb-examples \
40+
--exclude honeycomb-render
3641
env:
3742
RUSTFLAGS: "-Cinstrument-coverage"
3843
LLVM_PROFILE_FILE: "cargo-test-%p-%m.profraw"
3944
- name: Run tests
40-
run: cargo test --all-features --workspace --exclude honeycomb-benches --exclude honeycomb-examples --exclude honeycomb-render
45+
run: |
46+
cargo test --all-features --workspace \
47+
--exclude honeycomb \
48+
--exclude honeycomb-benches \
49+
--exclude honeycomb-examples \
50+
--exclude honeycomb-render
4151
env:
4252
RUSTFLAGS: "-Cinstrument-coverage"
4353
LLVM_PROFILE_FILE: "cargo-test-%p-%m.profraw"

Cargo.toml

+3-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
resolver = "2"
44
members = [
55
"benches",
6+
"honeycomb",
67
"honeycomb-core",
78
"honeycomb-kernels",
89
"honeycomb-render",
@@ -26,6 +27,7 @@ authors = [
2627

2728
[workspace.dependencies]
2829
# members
30+
honeycomb = { version = "0.5.0", path = "./honeycomb" }
2931
honeycomb-benches = { version = "0.5.0", path = "./benches" }
3032
honeycomb-core = { version = "0.5.0", path = "./honeycomb-core" }
3133
honeycomb-kernels = { version = "0.5.0", path = "./honeycomb-kernels" }
@@ -59,4 +61,4 @@ debug = true
5961

6062
[profile.profiling]
6163
inherits = "release"
62-
debug = true
64+
debug = true

honeycomb/Cargo.toml

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
[package]
2+
name = "honeycomb"
3+
edition.workspace = true
4+
license.workspace = true
5+
version.workspace = true
6+
homepage.workspace = true
7+
repository.workspace = true
8+
readme.workspace = true
9+
description.workspace = true
10+
categories.workspace = true
11+
keywords.workspace = true
12+
authors.workspace = true
13+
publish = true
14+
15+
[features]
16+
default = ["kernels"]
17+
kernels = ["dep:honeycomb-kernels"]
18+
render = ["dep:honeycomb-render"]
19+
20+
[dependencies]
21+
honeycomb-core = { workspace = true, features = ["io", "utils"] }
22+
honeycomb-kernels = { workspace = true, optional = true }
23+
honeycomb-render = { workspace = true, optional = true }

honeycomb/src/build.rs

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#[rustversion::nightly]
2+
fn set_rustc_channel_cfg() -> &'static str {
3+
"nightly"
4+
}
5+
6+
#[rustversion::beta]
7+
fn set_rustc_channel_cfg() -> &'static str {
8+
"beta"
9+
}
10+
11+
#[rustversion::stable]
12+
fn set_rustc_channel_cfg() -> &'static str {
13+
"stable"
14+
}
15+
16+
fn main() {
17+
println!("cargo:rustc-cfg={}", set_rustc_channel_cfg());
18+
}

honeycomb/src/lib.rs

+75
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
//! # honeycomb
2+
//!
3+
//! Honeycomb aims to provide a safe, efficient and scalable implementation of combinatorial maps
4+
//! for meshing applications. More specifically, the goal is to converge towards a (or multiple)
5+
//! structure(s) adapted to algorithms exploiting GPU and many-core architectures.
6+
//!
7+
//! ## Structure
8+
//!
9+
//! This crate acts as the user-facing API, re-exporting components and items implemented in the
10+
//! following sub-crates:
11+
//!
12+
//! - `honeycomb_core` -- core structures implementations
13+
//! - `honeycomb_kernels` -- algorithm implementations
14+
//! - `honeycomb_render` -- visual debugging tool
15+
//!
16+
//! ## Features
17+
//!
18+
//! Two features can be enabled to control which implementations are exposed:
19+
//!
20+
//! - `kernels` -- content from the `honeycomb_kernels` crate
21+
//! - `render` -- content from the `honeycomb_render` crate
22+
//!
23+
//! Note that:
24+
//! - the `kernels` feature is enabled by default since it does not require any more dependencies
25+
//! than the core crate.
26+
//! - the `render` feature is disabled by default; enabling it significantly lengthen the
27+
//! dependency tree as well as the compilation time.
28+
//!
29+
//! ## Quickstart
30+
//!
31+
//! For usage examples, refer to examples hosted in the repository; there also are documentation
32+
//! examples for important items:
33+
//!
34+
//! - [`CMap2`][honeycomb_core::cmap::CMap2]
35+
//! - [`CMapBuilder`][honeycomb_core::cmap::CMapBuilder]
36+
//! - [`grisubal`][`honeycomb_kernels::grisubal`]
37+
38+
// --- enable doc_auto_cfg feature if compiling in nightly
39+
#![allow(unexpected_cfgs)]
40+
#![cfg_attr(nightly, feature(doc_auto_cfg))]
41+
42+
pub use honeycomb_core as core;
43+
44+
#[cfg(feature = "kernels")]
45+
pub use honeycomb_kernels as kernels;
46+
47+
#[cfg(feature = "render")]
48+
pub use honeycomb_render as render;
49+
50+
/// commonly used items
51+
///
52+
/// This module contains all items commonly used to write a program using combinatorial maps.
53+
/// These items are re-exported from their original crates for ease of use and should cover
54+
/// all basic use cases.
55+
pub mod prelude {
56+
// ------ CORE RE-EXPORTS
57+
58+
pub use honeycomb_core::attributes::{AttributeBind, AttributeUpdate};
59+
pub use honeycomb_core::cmap::{
60+
BuilderError, CMap2, CMapBuilder, CMapError, DartIdentifier, EdgeIdentifier,
61+
FaceIdentifier, GridDescriptor, Orbit2, OrbitPolicy, VertexIdentifier, VolumeIdentifier,
62+
NULL_DART_ID, NULL_EDGE_ID, NULL_FACE_ID, NULL_VERTEX_ID, NULL_VOLUME_ID,
63+
};
64+
pub use honeycomb_core::geometry::{CoordsError, CoordsFloat, Vector2, Vertex2};
65+
66+
// ------ KERNELS RE-EXPORTS
67+
68+
#[cfg(feature = "kernels")]
69+
pub use honeycomb_kernels::grisubal;
70+
71+
// ------ RENDER RE-EXPORTS
72+
73+
#[cfg(feature = "render")]
74+
pub use honeycomb_render::App;
75+
}

0 commit comments

Comments
 (0)