Skip to content

Commit c830204

Browse files
committed
Fix doc tests
1 parent 710b22c commit c830204

File tree

2 files changed

+21
-27
lines changed

2 files changed

+21
-27
lines changed

src/indexes.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1679,25 +1679,25 @@ impl<Http: HttpClient> Index<Http> {
16791679
///
16801680
/// # Example
16811681
///
1682-
/// ```
1682+
/// ```no_run
16831683
/// # use serde::{Serialize, Deserialize};
16841684
/// # use meilisearch_sdk::{client::*, indexes::*, similar::*};
16851685
/// #
16861686
/// # let MEILISEARCH_URL = option_env!("MEILISEARCH_URL").unwrap_or("http://localhost:7700");
16871687
/// # let MEILISEARCH_API_KEY = option_env!("MEILISEARCH_API_KEY").unwrap_or("masterKey");
16881688
/// #
1689-
/// #[derive(Serialize, Deserialize, Debug)]
1690-
/// struct Movie {
1691-
/// name: String,
1692-
/// description: String,
1693-
/// }
1689+
/// # #[derive(Serialize, Deserialize, Debug)]
1690+
/// # struct Movie {
1691+
/// # name: String,
1692+
/// # description: String,
1693+
/// # }
16941694
/// # tokio::runtime::Builder::new_current_thread().enable_all().build().unwrap().block_on(async {
16951695
/// # let client = Client::new(MEILISEARCH_URL, Some(MEILISEARCH_API_KEY)).unwrap();
1696-
/// let movies = client.index("execute_query");
1697-
///
1698-
/// // add some documents
1696+
/// # let movies = client.index("similar_query");
1697+
/// #
1698+
/// # // add some documents
16991699
/// # movies.add_or_replace(&[Movie{name:String::from("Interstellar"), description:String::from("Interstellar chronicles the adventures of a group of explorers who make use of a newly discovered wormhole to surpass the limitations on human space travel and conquer the vast distances involved in an interstellar voyage.")},Movie{name:String::from("Unknown"), description:String::from("Unknown")}], Some("name")).await.unwrap().wait_for_completion(&client, None, None).await.unwrap();
1700-
///
1700+
/// #
17011701
/// let query = SimilarQuery::new(&movies, "1", "default").build();
17021702
/// let results = movies.similar_query::<Movie>(&query).await.unwrap();
17031703
///

src/similar.rs

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -47,34 +47,28 @@ pub struct SimilarResults<T> {
4747
///
4848
/// # Examples
4949
///
50-
/// ```
50+
/// ```no_run
5151
/// # use serde::{Serialize, Deserialize};
52-
/// # use meilisearch_sdk::{client::Client, search::*, indexes::Index};
52+
/// # use meilisearch_sdk::{client::Client, search::*, indexes::Index, similar::SimilarQuery};
5353
/// #
5454
/// # let MEILISEARCH_URL = option_env!("MEILISEARCH_URL").unwrap_or("http://localhost:7700");
5555
/// # let MEILISEARCH_API_KEY = option_env!("MEILISEARCH_API_KEY").unwrap_or("masterKey");
5656
/// #
57-
/// #[derive(Serialize, Deserialize, Debug)]
58-
/// struct Movie {
59-
/// name: String,
60-
/// description: String,
61-
/// }
57+
/// # #[derive(Serialize, Deserialize, Debug)]
58+
/// # struct Movie {
59+
/// # name: String,
60+
/// # description: String,
61+
/// # }
62+
/// #
6263
/// # tokio::runtime::Builder::new_current_thread().enable_all().build().unwrap().block_on(async {
6364
/// # let client = Client::new(MEILISEARCH_URL, Some(MEILISEARCH_API_KEY)).unwrap();
64-
/// # let index = client
65-
/// # .create_index("similar_query_builder", None)
66-
/// # .await
67-
/// # .unwrap()
68-
/// # .wait_for_completion(&client, None, None)
69-
/// # .await.unwrap()
70-
/// # .try_make_index(&client)
71-
/// # .unwrap();
72-
///
65+
/// # let index = client.index("similar_query_builder");
66+
/// #
7367
/// let mut res = SimilarQuery::new(&index, "100", "default")
7468
/// .execute::<Movie>()
7569
/// .await
7670
/// .unwrap();
77-
///
71+
/// #
7872
/// # index.delete().await.unwrap().wait_for_completion(&client, None, None).await.unwrap();
7973
/// # });
8074
/// ```

0 commit comments

Comments
 (0)