Document that feature needs to be enabled, and require macros feature for tests

This commit is contained in:
Andreas Longva 2021-04-30 17:06:59 +02:00
parent eeab4db69a
commit 0bde07f95c
3 changed files with 19 additions and 4 deletions

View File

@ -111,4 +111,4 @@ lto = true
[package.metadata.docs.rs] [package.metadata.docs.rs]
# Enable certain features when building docs for docs.rs # Enable certain features when building docs for docs.rs
features = [ "proptest-support", "compare" ] features = [ "proptest-support", "compare", "macros" ]

View File

@ -1,3 +1,8 @@
//! Macros for `nalgebra`.
//!
//! This crate is not intended for direct consumption. Instead, the macros are re-exported by
//! `nalgebra` if the `macros` feature is enabled (enabled by default).
extern crate proc_macro; extern crate proc_macro;
use syn::{Expr}; use syn::{Expr};
@ -95,6 +100,8 @@ impl Parse for Matrix {
/// Construct a fixed-size matrix directly from data. /// Construct a fixed-size matrix directly from data.
/// ///
/// **Note: Requires the `macro` feature to be enabled (enabled by default)**.
///
/// This macro facilitates easy construction of matrices when the entries of the matrix are known /// This macro facilitates easy construction of matrices when the entries of the matrix are known
/// (either as constants or expressions). This macro produces an instance of `SMatrix`. This means /// (either as constants or expressions). This macro produces an instance of `SMatrix`. This means
/// that the data of the matrix is stored on the stack, and its dimensions are fixed at /// that the data of the matrix is stored on the stack, and its dimensions are fixed at
@ -146,6 +153,8 @@ pub fn matrix(stream: TokenStream) -> TokenStream {
/// Construct a dynamic matrix directly from data. /// Construct a dynamic matrix directly from data.
/// ///
/// **Note: Requires the `macro` feature to be enabled (enabled by default)**.
///
/// The syntax is exactly the same as for [`matrix!`], but instead of producing instances of /// The syntax is exactly the same as for [`matrix!`], but instead of producing instances of
/// `SMatrix`, it produces instances of `DMatrix`. At the moment it is not usable /// `SMatrix`, it produces instances of `DMatrix`. At the moment it is not usable
/// in `const fn` contexts. /// in `const fn` contexts.
@ -213,6 +222,8 @@ impl Parse for Vector {
/// Construct a fixed-size column vector directly from data. /// Construct a fixed-size column vector directly from data.
/// ///
/// **Note: Requires the `macro` feature to be enabled (enabled by default)**.
///
/// Similarly to [`matrix!`], this macro facilitates easy construction of fixed-size vectors. /// Similarly to [`matrix!`], this macro facilitates easy construction of fixed-size vectors.
/// However, whereas the [`matrix!`] macro expects each row to be separated by a semi-colon, /// However, whereas the [`matrix!`] macro expects each row to be separated by a semi-colon,
/// the syntax of this macro is instead similar to `vec!`, in that the elements of the vector /// the syntax of this macro is instead similar to `vec!`, in that the elements of the vector
@ -243,6 +254,8 @@ pub fn vector(stream: TokenStream) -> TokenStream {
/// Construct a dynamic column vector directly from data. /// Construct a dynamic column vector directly from data.
/// ///
/// **Note: Requires the `macro` feature to be enabled (enabled by default)**.
///
/// The syntax is exactly the same as for [`vector!`], but instead of producing instances of /// The syntax is exactly the same as for [`vector!`], but instead of producing instances of
/// `SVector`, it produces instances of `DVector`. At the moment it is not usable /// `SVector`, it produces instances of `DVector`. At the moment it is not usable
/// in `const fn` contexts. /// in `const fn` contexts.

View File

@ -1,7 +1,7 @@
#[cfg(not(all(feature = "debug", feature = "compare", feature = "rand")))] #[cfg(not(all(feature = "debug", feature = "compare", feature = "rand", feature = "macros")))]
compile_error!( compile_error!(
"Please enable the `debug`, `compare`, and `rand` features in order to compile and run the tests. "Please enable the `debug`, `compare`, `rand` and `macros` features in order to compile and run the tests.
Example: `cargo test --features debug,compare,rand`" Example: `cargo test --features debug,compare,rand,macros`"
); );
#[cfg(feature = "abomonation-serialize")] #[cfg(feature = "abomonation-serialize")]
@ -25,6 +25,8 @@ mod linalg;
#[cfg(feature = "proptest-support")] #[cfg(feature = "proptest-support")]
mod proptest; mod proptest;
mod macros;
//#[cfg(all(feature = "debug", feature = "compare", feature = "rand"))] //#[cfg(all(feature = "debug", feature = "compare", feature = "rand"))]
//#[cfg(feature = "sparse")] //#[cfg(feature = "sparse")]
//mod sparse; //mod sparse;