Skip to content

Commit 10e0944

Browse files
committed
build: Doc test README using macro
1 parent 54056f7 commit 10e0944

File tree

4 files changed

+18
-10
lines changed

4 files changed

+18
-10
lines changed

README.md

+1-8
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,7 @@ pyo3 = "0.7"
6060
numpy = "0.6.0"
6161
```
6262

63-
``` rust
64-
extern crate numpy;
65-
extern crate pyo3;
66-
63+
```rust
6764
use numpy::{PyArray1, get_array_module};
6865
use pyo3::prelude::{ObjectProtocol, PyResult, Python};
6966
use pyo3::types::PyDict;
@@ -110,10 +107,6 @@ features = ["extension-module"]
110107
```
111108

112109
```rust
113-
extern crate ndarray;
114-
extern crate numpy;
115-
extern crate pyo3;
116-
117110
use ndarray::{ArrayD, ArrayViewD, ArrayViewMutD};
118111
use numpy::{IntoPyArray, PyArrayDyn};
119112
use pyo3::prelude::{pymodule, Py, PyModule, PyResult, Python};

appveyor.yml

-1
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,4 @@ build_script:
2323

2424
test_script:
2525
- cargo test --verbose --features %FEATURES% -- --test-threads=1
26-
- rustdoc --test README.md -L native="%PYTHON%\\libs" -L target/debug/deps/
2726
- cd examples/simple-extension && python setup.py install && python setup.py test

ci/travis/test.sh

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ set -ex
44

55
cargo build --verbose --features $FEATURES
66
cargo test --verbose --features $FEATURES -- --test-threads=1
7-
rustdoc -L target/debug/deps/ --test README.md
87

98
for example in examples/*; do
109
if [ $example != 'examples/linalg' ]; then

src/lib.rs

+17
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,20 @@ pub use crate::error::{ArrayShape, ErrorKind, IntoPyErr, IntoPyResult};
5252
pub use crate::npyffi::{PY_ARRAY_API, PY_UFUNC_API};
5353
pub use crate::types::{c32, c64, NpyDataType, TypeNum};
5454
pub use ndarray::{Ix1, Ix2, Ix3, Ix4, Ix5, Ix6, IxDyn};
55+
56+
/// Test readme
57+
#[doc(hidden)]
58+
pub mod doc_test {
59+
macro_rules! doc_comment {
60+
($x:expr, $($tt:tt)*) => {
61+
#[doc = $x]
62+
$($tt)*
63+
};
64+
}
65+
macro_rules! doctest {
66+
($x: literal, $y:ident) => {
67+
doc_comment!(include_str!($x), mod $y {});
68+
};
69+
}
70+
doctest!("../README.md", readme_md);
71+
}

0 commit comments

Comments
 (0)