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

Allow rustdoc to scrape examples #240

Closed
wants to merge 4 commits into from
Closed
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
23 changes: 20 additions & 3 deletions crates/parry2d-f64/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,28 @@ maintenance = { status = "actively-developed" }
[features]
default = ["required-features", "std"]
required-features = ["dim2", "f64"]
std = ["nalgebra/std", "slab", "rustc-hash", "simba/std", "arrayvec/std", "spade", "thiserror"]
std = [
"nalgebra/std",
"slab",
"rustc-hash",
"simba/std",
"arrayvec/std",
"spade",
"thiserror",
]
dim2 = []
f64 = []
serde-serialize = ["serde", "nalgebra/serde-serialize", "arrayvec/serde", "bitflags/serde"]
rkyv-serialize = ["rkyv/validation", "nalgebra/rkyv-serialize", "simba/rkyv-serialize"]
serde-serialize = [
"serde",
"nalgebra/serde-serialize",
"arrayvec/serde",
"bitflags/serde",
]
rkyv-serialize = [
"rkyv/validation",
"nalgebra/rkyv-serialize",
"simba/rkyv-serialize",
]
bytemuck-serialize = ["bytemuck", "nalgebra/convert-bytemuck"]
simd-stable = ["simba/wide", "simd-is-enabled"]
simd-nightly = ["simba/portable_simd", "simd-is-enabled"]
Expand Down
116 changes: 112 additions & 4 deletions crates/parry2d/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,28 @@ maintenance = { status = "actively-developed" }
[features]
default = ["required-features", "std"]
required-features = ["dim2", "f32"]
std = ["nalgebra/std", "slab", "rustc-hash", "simba/std", "arrayvec/std", "spade", "thiserror"]
std = [
"nalgebra/std",
"slab",
"rustc-hash",
"simba/std",
"arrayvec/std",
"spade",
"thiserror",
]
dim2 = []
f32 = []
serde-serialize = ["serde", "nalgebra/serde-serialize", "arrayvec/serde", "bitflags/serde"]
rkyv-serialize = ["rkyv/validation", "nalgebra/rkyv-serialize", "simba/rkyv-serialize"]
serde-serialize = [
"serde",
"nalgebra/serde-serialize",
"arrayvec/serde",
"bitflags/serde",
]
rkyv-serialize = [
"rkyv/validation",
"nalgebra/rkyv-serialize",
"simba/rkyv-serialize",
]
bytemuck-serialize = ["bytemuck", "nalgebra/convert-bytemuck"]
simd-stable = ["simba/wide", "simd-is-enabled"]
simd-nightly = ["simba/portable_simd", "simd-is-enabled"]
Expand Down Expand Up @@ -68,4 +85,95 @@ simba = { version = "0.9", default-features = false }
oorandom = "11"
ptree = "0.4.0"
rand = { version = "0.8" }
macroquad = "0.4"
macroquad = "0.4"

[package.metadata.docs.rs]
rustdoc-args = ["-Zunstable-options", "--cfg", "docsrs"]
all-features = true
cargo-args = ["-Zunstable-options", "-Zrustdoc-scrape-examples"]

[[example]]
name = "aabb2d"
path = "examples/aabb2d.rs"
doc-scrape-examples = true

[[example]]
name = "ball2d"
path = "examples/ball2d.rs"
doc-scrape-examples = true

[[example]]
name = "bounding_sphere2d"
path = "examples/bounding_sphere2d.rs"
doc-scrape-examples = true

[[example]]
name = "contact_query2d"
path = "examples/contact_query2d.rs"
doc-scrape-examples = true

[[example]]
name = "convex2d"
path = "examples/convex2d.rs"
doc-scrape-examples = true

[[example]]
name = "convex_hull2d"
path = "examples/convex_hull2d.rs"
doc-scrape-examples = true

[[example]]
name = "convex_try_new2d"
path = "examples/convex_try_new2d.rs"
doc-scrape-examples = true

[[example]]
name = "cuboid2d"
path = "examples/cuboid2d.rs"
doc-scrape-examples = true

[[example]]
name = "distance_query2d"
path = "examples/distance_query2d.rs"
doc-scrape-examples = true

[[example]]
name = "plane2d"
path = "examples/plane2d.rs"
doc-scrape-examples = true

[[example]]
name = "point_in_poly2d"
path = "examples/point_in_poly2d.rs"
doc-scrape-examples = true

[[example]]
name = "polygons_intersection2d"
path = "examples/polygons_intersection2d.rs"
doc-scrape-examples = true

[[example]]
name = "polyline2d"
path = "examples/polyline2d.rs"
doc-scrape-examples = true

[[example]]
name = "proximity_query2d"
path = "examples/proximity_query2d.rs"
doc-scrape-examples = true

[[example]]
name = "solid_point_query2d"
path = "examples/solid_point_query2d.rs"
doc-scrape-examples = true

[[example]]
name = "solid_ray_cast2d"
path = "examples/solid_ray_cast2d.rs"
doc-scrape-examples = true

[[example]]
name = "time_of_impact_query2d"
path = "examples/time_of_impact_query2d.rs"
doc-scrape-examples = true

2 changes: 1 addition & 1 deletion crates/parry2d/examples/ball2d.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use parry2d::shape::Ball;

fn main() {
let ball = Ball::new(1.0f32);
let ball = Ball::new(1.0);
assert!(ball.radius == 1.0);
}
2 changes: 1 addition & 1 deletion crates/parry2d/examples/convex2d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use parry2d::shape::ConvexPolygon;

fn main() {
let points = [
Point2::new(-1.0f32, 1.0),
Point2::new(-1.0, 1.0),
Point2::new(-0.5, -0.5),
Point2::new(0.0, 0.5),
Point2::new(0.5, -0.5),
Expand Down
2 changes: 1 addition & 1 deletion crates/parry2d/examples/convex_try_new2d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use parry2d::shape::ConvexPolygon;

fn main() {
let points = vec![
Point2::new(-1.0f32, 1.0),
Point2::new(-1.0, 1.0),
Point2::new(-0.5, -0.5),
Point2::new(0.5, -0.5),
Point2::new(1.0, 1.0),
Expand Down
2 changes: 1 addition & 1 deletion crates/parry2d/examples/cuboid2d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use na::Vector2;
use parry2d::shape::Cuboid;

fn main() {
let cuboid = Cuboid::new(Vector2::new(2.0f32, 1.0));
let cuboid = Cuboid::new(Vector2::new(2.0, 1.0));

assert!(cuboid.half_extents.x == 2.0);
assert!(cuboid.half_extents.y == 1.0);
Expand Down
16 changes: 14 additions & 2 deletions crates/parry3d-f64/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,23 @@ maintenance = { status = "actively-developed" }
[features]
default = ["required-features", "std"]
required-features = ["dim3", "f64"]
std = ["nalgebra/std", "slab", "rustc-hash", "simba/std", "arrayvec/std", "spade", "thiserror"]
std = [
"nalgebra/std",
"slab",
"rustc-hash",
"simba/std",
"arrayvec/std",
"spade",
"thiserror",
]
dim3 = []
f64 = []
serde-serialize = ["serde", "nalgebra/serde-serialize", "bitflags/serde"]
rkyv-serialize = ["rkyv/validation", "nalgebra/rkyv-serialize", "simba/rkyv-serialize"]
rkyv-serialize = [
"rkyv/validation",
"nalgebra/rkyv-serialize",
"simba/rkyv-serialize",
]
bytemuck-serialize = ["bytemuck", "nalgebra/convert-bytemuck"]
simd-stable = ["simba/wide", "simd-is-enabled"]
simd-nightly = ["simba/portable_simd", "simd-is-enabled"]
Expand Down
122 changes: 120 additions & 2 deletions crates/parry3d/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,23 @@ maintenance = { status = "actively-developed" }
[features]
default = ["required-features", "std"]
required-features = ["dim3", "f32"]
std = ["nalgebra/std", "slab", "rustc-hash", "simba/std", "arrayvec/std", "spade", "thiserror"]
std = [
"nalgebra/std",
"slab",
"rustc-hash",
"simba/std",
"arrayvec/std",
"spade",
"thiserror",
]
dim3 = []
f32 = []
serde-serialize = ["serde", "nalgebra/serde-serialize", "bitflags/serde"]
rkyv-serialize = ["rkyv/validation", "nalgebra/rkyv-serialize", "simba/rkyv-serialize"]
rkyv-serialize = [
"rkyv/validation",
"nalgebra/rkyv-serialize",
"simba/rkyv-serialize",
]
bytemuck-serialize = ["bytemuck", "nalgebra/convert-bytemuck"]

simd-stable = ["simba/wide", "simd-is-enabled"]
Expand Down Expand Up @@ -68,3 +80,109 @@ thiserror = { version = "1", optional = true }
oorandom = "11"
ptree = "0.4.0"
rand = { version = "0.8" }

[package.metadata.docs.rs]
rustdoc-args = ["-Zunstable-options", "--cfg", "docsrs"]
all-features = true
cargo-args = ["-Zunstable-options", "-Zrustdoc-scrape-examples"]

[[example]]
name = "aabb3d"
path = "examples/aabb3d.rs"
doc-scrape-examples = true

[[example]]
name = "ball3d"
path = "examples/ball3d.rs"
doc-scrape-examples = true

[[example]]
name = "bounding_sphere3d"
path = "examples/bounding_sphere3d.rs"
doc-scrape-examples = true

[[example]]
name = "capsule"
path = "examples/capsule.rs"
doc-scrape-examples = true

[[example]]
name = "cone"
path = "examples/cone.rs"
doc-scrape-examples = true

[[example]]
name = "contact_query3d"
path = "examples/contact_query3d.rs"
doc-scrape-examples = true

[[example]]
name = "convex3d"
path = "examples/convex3d.rs"
doc-scrape-examples = true

[[example]]
name = "convex_hull3d"
path = "examples/convex_hull3d.rs"
doc-scrape-examples = true

[[example]]
name = "convex_try_new3d"
path = "examples/convex_try_new3d.rs"
doc-scrape-examples = true

[[example]]
name = "cuboid3d"
path = "examples/cuboid3d.rs"
doc-scrape-examples = true

[[example]]
name = "cylinder"
path = "examples/cylinder.rs"
doc-scrape-examples = true

[[example]]
name = "distance_query3d"
path = "examples/distance_query3d.rs"
doc-scrape-examples = true

[[example]]
name = "getting_started"
path = "examples/getting_started.rs"
doc-scrape-examples = true

[[example]]
name = "mesh3d"
path = "examples/mesh3d.rs"
doc-scrape-examples = true

[[example]]
name = "plane3d"
path = "examples/plane3d.rs"
doc-scrape-examples = true

[[example]]
name = "polyline3d"
path = "examples/polyline3d.rs"
doc-scrape-examples = true

[[example]]
name = "proximity_query3d"
path = "examples/proximity_query3d.rs"
doc-scrape-examples = true

[[example]]
name = "solid_point_query3d"
path = "examples/solid_point_query3d.rs"
doc-scrape-examples = true

[[example]]
name = "solid_ray_cast3d"
path = "examples/solid_ray_cast3d.rs"
doc-scrape-examples = true

[[example]]
name = "time_of_impact_query3d"
path = "examples/time_of_impact_query3d.rs"
doc-scrape-examples = true

9 changes: 9 additions & 0 deletions publish.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,33 @@ cp -r LICENSE README.md $tmp/.

### Publish the 2D version.
sed 's#\.\./\.\./src#src#g' crates/parry2d/Cargo.toml > $tmp/Cargo.toml
rm -rf $tmp/examples
cp -r crates/parry2d/examples $tmp/examples
currdir=`pwd`
cd $tmp && cargo publish
cd $currdir

### Publish the 2D f64 version.
sed 's#\.\./\.\./src#src#g' crates/parry2d-f64/Cargo.toml > $tmp/Cargo.toml
rm -rf $tmp/examples
cp -r crates/parry2d/examples $tmp/examples
find $tmp/examples | xargs sed 's/parry2d:/parry2d_f64:/g
cd $tmp && cargo publish
cd $currdir


### Publish the 3D version.
sed 's#\.\./\.\./src#src#g' crates/parry3d/Cargo.toml > $tmp/Cargo.toml
rm -rf $tmp/examples
cp -r crates/parry3d/examples $tmp/examples
cp -r LICENSE README.md $tmp/.
cd $tmp && cargo publish
cd $currdir

### Publish the 3D f64 version.
sed 's#\.\./\.\./src#src#g' crates/parry3d-f64/Cargo.toml > $tmp/Cargo.toml
rm -rf $tmp/examples
cp -r crates/parry3d/examples $tmp/examples
cp -r LICENSE README.md $tmp/.
cd $tmp && cargo publish

Expand Down
Loading