meilisearch/meilisearch-rust

Add documentation on builder methods.

bidoubiwa opened this issue ยท 5 comments

Currently some builder methods across the code base do not have any documentation. See for example:

pub fn with_query<'b>(&'b mut self, query: &'a str) -> &'b mut SearchQuery<'a> {
self.query = Some(query);
self
}
pub fn with_offset<'b>(&'b mut self, offset: usize) -> &'b mut SearchQuery<'a> {
self.offset = Some(offset);
self
}
pub fn with_limit<'b>(&'b mut self, limit: usize) -> &'b mut SearchQuery<'a> {
self.limit = Some(limit);
self
}
pub fn with_filter<'b>(&'b mut self, filter: &'a str) -> &'b mut SearchQuery<'a> {
self.filter = Some(Filter::new(Either::Left(filter)));
self
}

It would be better if each of these methods are explained and showcase an example. As for example here

/// Define the new primary_key to set on the [Index]
///
/// # Example
///
/// ```
/// # use meilisearch_sdk::{client::*, indexes::*, task_info::*, tasks::{Task, SucceededTask}};
/// #
/// # let MEILISEARCH_URL = option_env!("MEILISEARCH_URL").unwrap_or("http://localhost:7700");
/// # let MEILISEARCH_API_KEY = option_env!("MEILISEARCH_API_KEY").unwrap_or("masterKey");
/// #
/// # futures::executor::block_on(async move {
/// # let client = Client::new(MEILISEARCH_URL, MEILISEARCH_API_KEY);
/// # let index = client
/// # .create_index("index_updater_with_primary_key", None)
/// # .await
/// # .unwrap()
/// # .wait_for_completion(&client, None, None)
/// # .await
/// # .unwrap()
/// # // Once the task finished, we try to create an `Index` out of it
/// # .try_make_index(&client)
/// # .unwrap();
///
/// let task = IndexUpdater::new("index_updater_with_primary_key", &client)
/// .with_primary_key("special_id")
/// .execute()
/// .await
/// .unwrap()
/// .wait_for_completion(&client, None, None)
/// .await
/// .unwrap();
///
/// let index = client.get_index("index_updater_with_primary_key").await.unwrap();
/// assert_eq!(index.primary_key, Some("special_id".to_string()));
/// # index.delete().await.unwrap().wait_for_completion(&client, None, None).await.unwrap();
/// # });
/// ```
pub fn with_primary_key(&mut self, primary_key: impl AsRef<str>) -> &mut Self {
self.primary_key = Some(primary_key.as_ref().to_string());
self
}

๐Ÿ™‹๐Ÿปโ€โ™‚๏ธ

If this issue is available for the public to pick up, I'd like to take it ๐Ÿ˜„.

I have read your contribution guidelines, and have contributed similar work for projects like tabled and mirrord.

Hey @IsaacCloos, that would be awesome if you do :) ๐Ÿ™
We are not assigning to avoid blocking the PR in case the contributor does not make the PR after all, but it would be a very valuable addition

Sorry for the delay! I was just able to sit down with this, and now have some preliminary research I'd like to clarify.

The targets

Currently some builder methods across the code base do not have any documentation. See for example:

Here is the list I've assembled (having found three instances of #[allow(missing_docs)]:

  • TaskQuery (19 methods)
  • Settings (11 methods)
  • SearchQuery (21 methods)

If there are others you'd like to add, please let me know!

The template

It would be better if each of these methods are explained and showcase an example. As for example here

/// { concise description }
///
/// # Example
///
/// ```rust
/// { runnable, doc-friendly example }
/// ```

If you'd like to standardize any other aspects into this template before I take a stab at this issue, please let me know!

Your feedback is much appreciated ๐Ÿ˜„

If there are others you'd like to add, please let me know!

I don't see any other.

Your template answers all our needs :) Thanks a lot. I don't have anything to add or change.

chrome_CKY0BbzUE9

Lesson learned ๐Ÿ˜ฌ

Please reopen this issue. I will be more careful in the future.