From b22cd8be1dcb1fc7299723b527d1ca672f10a14a Mon Sep 17 00:00:00 2001 From: Alex Date: Sun, 27 Oct 2024 21:30:46 +0000 Subject: [PATCH 1/2] docs: improve documentation --- examples/todo/README.md | 2 +- src/ids.rs | 4 ++++ src/lib.rs | 20 ++++++++++++++++++++ src/models/search.rs | 1 + 4 files changed, 26 insertions(+), 1 deletion(-) diff --git a/examples/todo/README.md b/examples/todo/README.md index b22d08b..13ba76e 100644 --- a/examples/todo/README.md +++ b/examples/todo/README.md @@ -2,7 +2,7 @@ This example is builds a todo list using a notion database. -## Setup your notion api token +## Setup your Notion API token Create an `internal` integration here: https://www.notion.so/my-integrations diff --git a/src/ids.rs b/src/ids.rs index 611212e..3bbd420 100644 --- a/src/ids.rs +++ b/src/ids.rs @@ -1,9 +1,13 @@ +//! Identification types, traits and utilities. +//! use std::fmt::Display; use std::fmt::Error; +/// A wrapper for arbitrary identification types pub trait Identifier: Display { fn value(&self) -> &str; } + /// Meant to be a helpful trait allowing anything that can be /// identified by the type specified in `ById`. pub trait AsIdentifier { diff --git a/src/lib.rs b/src/lib.rs index b836a45..175957a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,3 +1,23 @@ +//! A client API for Notion. +//! +//! ### Example +//! ```rust +//! use rusticnotion; +//! use rusticnotion::models::search::*; +//! use rusticnotion::models::*; +//! use std::env; +//! let notion_api_token = env::var("NOTION_API_TOKEN").expect("NOTION_API_TOKEN env var not set"); +//! let notion = rusticnotion::NotionApi::new(notion_api_token).unwrap(); +//! +//! // List all databases +//! let databases = notion.search(NotionSearch::filter_by_databases()).await.unwrap(); +//! +//! // List all pages +//! let pages = notion.search(NotionSearch::filter_by_pages()).await.unwrap(); +//! +//! // See examples for more +//! ``` + use crate::ids::{BlockId, DatabaseId}; use crate::models::error::ErrorResponse; use crate::models::search::{DatabaseQuery, SearchRequest}; diff --git a/src/models/search.rs b/src/models/search.rs index 1fadc91..8bd59b7 100644 --- a/src/models/search.rs +++ b/src/models/search.rs @@ -334,6 +334,7 @@ impl Pageable for DatabaseQuery { } } +/// Parameters for search #[derive(Debug, Eq, PartialEq)] pub enum NotionSearch { /// When supplied, limits which pages are returned by comparing the query to the page title. From 5256a52879ebb0d725fd19b05b87719f19e5c111 Mon Sep 17 00:00:00 2001 From: Alex <1221721+atcol@users.noreply.github.com> Date: Mon, 28 Oct 2024 19:22:17 +0000 Subject: [PATCH 2/2] docs: ignore Rust example --- src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 175957a..6ca76d6 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,7 +1,7 @@ //! A client API for Notion. //! //! ### Example -//! ```rust +//! ```rust,ignore //! use rusticnotion; //! use rusticnotion::models::search::*; //! use rusticnotion::models::*;