Skip to content

Commit 0605458

Browse files
authored
[TST]: fix Rust doc tests, add cargo test --doc to CI (#5813)
1 parent 609e8e6 commit 0605458

File tree

3 files changed

+21
-19
lines changed

3 files changed

+21
-19
lines changed

.github/workflows/_rust-tests.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ jobs:
2424
run: cargo build --bin chroma
2525
- name: Test
2626
run: cargo nextest run --profile ci
27+
- name: Doc test
28+
run: cargo test --doc
2729
test-long:
2830
runs-on: blacksmith-8vcpu-ubuntu-2404
2931
env:

rust/chroma/src/collection.rs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ use crate::{client::ChromaHttpClientError, ChromaHttpClient};
4141
/// # Examples
4242
///
4343
/// ```
44-
/// # use chroma::collection::ChromaCollection;
44+
/// # use chroma::ChromaCollection;
4545
/// # use chroma::client::ChromaHttpClientError;
4646
/// # async fn example(collection: ChromaCollection) -> Result<(), ChromaHttpClientError> {
4747
/// let count = collection.count().await?;
@@ -97,7 +97,7 @@ impl ChromaCollection {
9797
/// # Examples
9898
///
9999
/// ```
100-
/// # use chroma::collection::ChromaCollection;
100+
/// # use chroma::ChromaCollection;
101101
/// # fn example(collection: ChromaCollection) {
102102
/// assert_eq!(collection.name(), "my_collection");
103103
/// # }
@@ -111,7 +111,7 @@ impl ChromaCollection {
111111
/// # Examples
112112
///
113113
/// ```
114-
/// # use chroma::collection::ChromaCollection;
114+
/// # use chroma::ChromaCollection;
115115
/// # fn example(collection: ChromaCollection) {
116116
/// let id = collection.id();
117117
/// println!("Collection ID: {}", id);
@@ -128,7 +128,7 @@ impl ChromaCollection {
128128
/// # Examples
129129
///
130130
/// ```
131-
/// # use chroma::collection::ChromaCollection;
131+
/// # use chroma::ChromaCollection;
132132
/// # fn example(collection: ChromaCollection) {
133133
/// let version = collection.version();
134134
/// assert!(version >= 0);
@@ -147,7 +147,7 @@ impl ChromaCollection {
147147
/// # Examples
148148
///
149149
/// ```
150-
/// # use chroma::collection::ChromaCollection;
150+
/// # use chroma::ChromaCollection;
151151
/// # async fn example(collection: ChromaCollection) -> Result<(), Box<dyn std::error::Error>> {
152152
/// let count = collection.count().await?;
153153
/// assert!(count >= 0);
@@ -178,7 +178,7 @@ impl ChromaCollection {
178178
/// # Examples
179179
///
180180
/// ```
181-
/// # use chroma::collection::ChromaCollection;
181+
/// # use chroma::ChromaCollection;
182182
/// # use chroma_types::Metadata;
183183
/// # async fn example(mut collection: ChromaCollection) -> Result<(), Box<dyn std::error::Error>> {
184184
/// let mut metadata = Metadata::new();
@@ -237,7 +237,7 @@ impl ChromaCollection {
237237
/// # Examples
238238
///
239239
/// ```
240-
/// # use chroma::collection::ChromaCollection;
240+
/// # use chroma::ChromaCollection;
241241
/// # use chroma_types::IncludeList;
242242
/// # async fn example(collection: ChromaCollection) -> Result<(), Box<dyn std::error::Error>> {
243243
/// let response = collection.get(
@@ -289,7 +289,7 @@ impl ChromaCollection {
289289
/// # Examples
290290
///
291291
/// ```
292-
/// # use chroma::collection::ChromaCollection;
292+
/// # use chroma::ChromaCollection;
293293
/// # async fn example(collection: ChromaCollection) -> Result<(), Box<dyn std::error::Error>> {
294294
/// let query = vec![vec![0.1, 0.2, 0.3]];
295295
/// let results = collection.query(
@@ -350,7 +350,7 @@ impl ChromaCollection {
350350
/// use chroma_types::plan::SearchPayload;
351351
/// use chroma_types::operator::{RankExpr, QueryVector, Key};
352352
///
353-
/// # async fn example(collection: &chroma::collection::ChromaCollection) -> Result<(), Box<dyn std::error::Error>> {
353+
/// # async fn example(collection: &chroma::ChromaCollection) -> Result<(), Box<dyn std::error::Error>> {
354354
/// // Search with a query vector
355355
/// let search = SearchPayload::default()
356356
/// .rank(RankExpr::Knn {
@@ -374,7 +374,7 @@ impl ChromaCollection {
374374
/// use chroma_types::plan::SearchPayload;
375375
/// use chroma_types::operator::{RankExpr, QueryVector, Key};
376376
///
377-
/// # async fn example(collection: &chroma::collection::ChromaCollection) -> Result<(), Box<dyn std::error::Error>> {
377+
/// # async fn example(collection: &chroma::ChromaCollection) -> Result<(), Box<dyn std::error::Error>> {
378378
/// // Filter by category and year, then rank by similarity
379379
/// let search = SearchPayload::default()
380380
/// .r#where(
@@ -402,7 +402,7 @@ impl ChromaCollection {
402402
/// use chroma_types::plan::SearchPayload;
403403
/// use chroma_types::operator::{RankExpr, QueryVector, Key};
404404
///
405-
/// # async fn example(collection: &chroma::collection::ChromaCollection) -> Result<(), Box<dyn std::error::Error>> {
405+
/// # async fn example(collection: &chroma::ChromaCollection) -> Result<(), Box<dyn std::error::Error>> {
406406
/// // Combine two KNN searches with weights
407407
/// let dense_knn = RankExpr::Knn {
408408
/// query: QueryVector::Dense(vec![0.1, 0.2, 0.3]),
@@ -439,7 +439,7 @@ impl ChromaCollection {
439439
/// use chroma_types::plan::SearchPayload;
440440
/// use chroma_types::operator::{RankExpr, QueryVector, Key};
441441
///
442-
/// # async fn example(collection: &chroma::collection::ChromaCollection) -> Result<(), Box<dyn std::error::Error>> {
442+
/// # async fn example(collection: &chroma::ChromaCollection) -> Result<(), Box<dyn std::error::Error>> {
443443
/// // Run multiple searches in one request
444444
/// let searches = vec![
445445
/// SearchPayload::default()
@@ -500,7 +500,7 @@ impl ChromaCollection {
500500
/// # Examples
501501
///
502502
/// ```
503-
/// # use chroma::collection::ChromaCollection;
503+
/// # use chroma::ChromaCollection;
504504
/// # async fn example(collection: ChromaCollection) -> Result<(), Box<dyn std::error::Error>> {
505505
/// let response = collection.add(
506506
/// vec!["doc1".to_string(), "doc2".to_string()],
@@ -550,7 +550,7 @@ impl ChromaCollection {
550550
/// # Examples
551551
///
552552
/// ```
553-
/// # use chroma::collection::ChromaCollection;
553+
/// # use chroma::ChromaCollection;
554554
/// # async fn example(collection: ChromaCollection) -> Result<(), Box<dyn std::error::Error>> {
555555
/// let response = collection.update(
556556
/// vec!["doc1".to_string()],
@@ -601,7 +601,7 @@ impl ChromaCollection {
601601
/// # Examples
602602
///
603603
/// ```
604-
/// # use chroma::collection::ChromaCollection;
604+
/// # use chroma::ChromaCollection;
605605
/// # async fn example(collection: ChromaCollection) -> Result<(), Box<dyn std::error::Error>> {
606606
/// let response = collection.upsert(
607607
/// vec!["doc1".to_string(), "doc2".to_string()],
@@ -651,7 +651,7 @@ impl ChromaCollection {
651651
/// # Examples
652652
///
653653
/// ```
654-
/// # use chroma::collection::ChromaCollection;
654+
/// # use chroma::ChromaCollection;
655655
/// # async fn example(collection: ChromaCollection) -> Result<(), Box<dyn std::error::Error>> {
656656
/// let response = collection.delete(
657657
/// Some(vec!["doc1".to_string(), "doc2".to_string()]),
@@ -695,7 +695,7 @@ impl ChromaCollection {
695695
/// # Examples
696696
///
697697
/// ```
698-
/// # use chroma::collection::ChromaCollection;
698+
/// # use chroma::ChromaCollection;
699699
/// # async fn example(collection: ChromaCollection) -> Result<(), Box<dyn std::error::Error>> {
700700
/// let forked = collection.fork("experimental_version").await?;
701701
/// assert_eq!(forked.name(), "experimental_version");

rust/types/src/collection_schema.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1996,7 +1996,7 @@ impl Schema {
19961996
///
19971997
/// # Examples
19981998
/// ```
1999-
/// use chroma_types::{Schema, VectorIndexConfig, StringInvertedIndexConfig, Space};
1999+
/// use chroma_types::{Schema, VectorIndexConfig, StringInvertedIndexConfig, Space, SchemaBuilderError};
20002000
///
20012001
/// # fn main() -> Result<(), SchemaBuilderError> {
20022002
/// let schema = Schema::default()
@@ -2077,7 +2077,7 @@ impl Schema {
20772077
///
20782078
/// # Examples
20792079
/// ```
2080-
/// use chroma_types::{Schema, StringInvertedIndexConfig};
2080+
/// use chroma_types::{Schema, StringInvertedIndexConfig, SchemaBuilderError};
20812081
///
20822082
/// # fn main() -> Result<(), SchemaBuilderError> {
20832083
/// let schema = Schema::default()

0 commit comments

Comments
 (0)