Skip to content

Commit

Permalink
docs: add remaining documentation and enforce missing_docs
Browse files Browse the repository at this point in the history
- Added documentation for all remaining structs, enums, and methods.
- Enabled the `missing_docs` attribute to enforce documentation.
  • Loading branch information
AndrielFR committed Jan 3, 2025
1 parent 8064768 commit 713b36f
Show file tree
Hide file tree
Showing 26 changed files with 230 additions and 65 deletions.
2 changes: 2 additions & 0 deletions src/client.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// SPDX-License-Identifier: MIT
// Copyright (c) 2022-2025 Andriel Ferreira <https://github.com/AndrielFR>

//! This module contains the `Client` struct and its related types.
use serde::Deserialize;
use std::time::Duration;

Expand Down
6 changes: 5 additions & 1 deletion src/error.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
// SPDX-License-Identifier: MIT
// Copyright (c) 2022-2025 Andriel Ferreira <https://github.com/AndrielFR>

//! This module contains the `Error` enum.
use thiserror::Error as TError;

/// A specialized `Result` type for operations that can return an `Error`.
///
/// This is defined as a convenience to avoid writing out `std::result::Result`
/// with the `Error` type repeatedly.
/// with the `rust_anilist::Error` type repeatedly.
pub type Result<T> = std::result::Result<T, Error>;

/// Represents the various errors that can occur in the application.
Expand All @@ -15,8 +17,10 @@ pub type Result<T> = std::result::Result<T, Error>;
/// such as invalid IDs and API errors.
#[derive(TError, Debug)]
pub enum Error {
/// An error indicating that the ID is invalid.
#[error("invalid ID")]
InvalidId,
/// An error indicating that the API returned an error.
#[error("api error: `{0}`")]
ApiError(String),
}
11 changes: 4 additions & 7 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
// SPDX-License-Identifier: MIT
// Copyright (c) 2022-2025 Andriel Ferreira <https://github.com/AndrielFR>

// #![deny(missing_docs)]
#![allow(clippy::let_and_return)] // TODO: Remove this
#![allow(dead_code)] // TODO: Remove this
#![allow(unused_mut)] // TODO: Remove this
#![allow(unused_variables)] // TODO: Remove this
//! This crate provides a Rust library for interacting with the AniList API.
#![deny(missing_docs)]

#[macro_use]
pub mod models;
mod client;
mod error;
pub mod models;

pub use client::Client;
pub use error::{Error, Result};
19 changes: 15 additions & 4 deletions src/models/anime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,17 @@ impl Anime {
/// # Panics
///
/// Panics if the anime is already fully loaded.
///
/// # Example
///
/// ```no_run
/// # use rust_anilist::{models::Anime, Result};
/// #
/// # async fn f(anime: Anime) -> Result<()> {
/// let anime = anime.load_full().await?;
/// # Ok(())
/// # }
/// ```
pub async fn load_full(self) -> Result<Self> {
if !self.is_full_loaded {
self.client.get_anime(self.id).await
Expand All @@ -192,13 +203,13 @@ impl Anime {
#[derive(Debug, Clone, PartialEq, Deserialize, Serialize)]
pub struct AiringSchedule {
/// The ID of the airing schedule.
id: i64,
pub id: i64,
/// The airing date.
#[serde(rename = "airingAt")]
at: i64,
pub at: i64,
/// Time until the airing.
#[serde(rename = "timeUntilAiring")]
time_until: i64,
pub time_until: i64,
/// The airing episode.
episode: i64,
pub episode: i64,
}
33 changes: 25 additions & 8 deletions src/models/character.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
// SPDX-License-Identifier: MIT
// Copyright (c) 2022-2025 Andriel Ferreira <https://github.com/AndrielFR>

use serde::Deserialize;
use serde::Serialize;
//! This module contains the `Character` struct and its related types.
use crate::models::Date;
use crate::models::Gender;
use crate::models::Image;
use crate::models::Name;
use crate::models::Person;
use serde::{Deserialize, Serialize};

use super::{Date, Gender, Image, Name, Person};
use crate::{Client, Result};

/// Represents a character.
Expand Down Expand Up @@ -66,6 +62,16 @@ impl Character {
/// # Panics
///
/// Panics if the character is already fully loaded.
///
/// # Example
///
/// ```no_run
/// # use rust_anilist::{models::Character, Result};
/// #
/// # async fn f(character: Character) -> Result<()> {
/// let character = character.load_full().await?;
/// # Ok(())
/// # }
pub async fn load_full(self) -> Result<Self> {
if !self.is_full_loaded {
self.client.get_character(self.id).await
Expand All @@ -82,7 +88,18 @@ impl Character {
///
/// # Type Parameters
///
/// * `T` - The type of the media.
/// * `T` - The type of the media to be returned.
///
/// # Example
///
/// ```no_run
/// # use rust_anilist::{models::{Manga, Character}, Result};
/// #
/// # async fn f(character: Character) -> Result<()> {
/// let char_mangas = character.get_medias::<Manga>().await?;
/// # Ok(())
/// # }
/// ```
pub async fn get_medias<T>(&self) -> Result<T> {
unimplemented!()
}
Expand Down
2 changes: 2 additions & 0 deletions src/models/color.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// SPDX-License-Identifier: MIT
// Copyright (c) 2022-2025 Andriel Ferreira <https://github.com/AndrielFR>

//! This module contains the `Color` struct.
use serde::{Deserialize, Serialize};

/// Represents a color with various predefined options and a custom hex value.
Expand Down
2 changes: 2 additions & 0 deletions src/models/cover.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// SPDX-License-Identifier: MIT
// Copyright (c) 2022-2025 Andriel Ferreira <https://github.com/AndrielFR>

//! This module contains the `Cover` struct.
use serde::{Deserialize, Serialize};

use crate::models::Color;
Expand Down
7 changes: 5 additions & 2 deletions src/models/date.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
// SPDX-License-Identifier: MIT
// Copyright (c) 2022-2025 Andriel Ferreira <https://github.com/AndrielFR>

//! This module contains the `Date` struct.
use chrono::{Datelike, NaiveDate};
use serde::{Deserialize, Serialize};

/// A date.
/// Represents a date.
#[derive(Debug, Default, Clone, PartialEq, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct Date {
Expand Down Expand Up @@ -50,7 +52,8 @@ impl Date {
///
/// # Example
///
/// ```
/// ```no_run
/// # use rust_anilist::models::Date;
/// let date = Date { year: Some(2023), month: Some(10), day: Some(5) };
/// let formatted = date.format("{yyyy}-{mm}-{dd}");
/// assert_eq!(formatted, "2023-10-05");
Expand Down
2 changes: 2 additions & 0 deletions src/models/format.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// SPDX-License-Identifier: MIT
// Copyright (c) 2022-2025 Andriel Ferreira <https://github.com/AndrielFR>

//! This module contains the `Format` struct.
use serde::{Deserialize, Serialize};

/// Represents the format of a media item.
Expand Down
2 changes: 2 additions & 0 deletions src/models/gender.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// SPDX-License-Identifier: MIT
// Copyright (c) 2022-2025 Andriel Ferreira <https://github.com/AndrielFR>

//! This module contains the `Gender` enum.
use serde::{Deserialize, Serialize};

/// Represents the gender of a person.
Expand Down
2 changes: 2 additions & 0 deletions src/models/image.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// SPDX-License-Identifier: MIT
// Copyright (c) 2022-2025 Andriel Ferreira <https://github.com/AndrielFR>

//! This module contains the `Image` struct.
use serde::{Deserialize, Serialize};

/// Represents an image with different sizes.
Expand Down
2 changes: 2 additions & 0 deletions src/models/language.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// SPDX-License-Identifier: MIT
// Copyright (c) 2022-2025 Andriel Ferreira <https://github.com/AndrielFR>

//! This module contains the `Language` enum.
use serde::{Deserialize, Serialize};

/// Represents a language with various options.
Expand Down
2 changes: 2 additions & 0 deletions src/models/link.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// SPDX-License-Identifier: MIT
// Copyright (c) 2022-2025 Andriel Ferreira <https://github.com/AndrielFR>

//! This module contains the `Link` struct.
use serde::{Deserialize, Serialize};

use super::{Color, Language};
Expand Down
13 changes: 13 additions & 0 deletions src/models/manga.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// SPDX-License-Identifier: MIT
// Copyright (c) 2022-2025 Andriel Ferreira <https://github.com/AndrielFR>

//! This module contains the `Manga` struct and its related types.
use serde::{Deserialize, Serialize};

use super::{
Expand Down Expand Up @@ -152,6 +154,17 @@ impl Manga {
/// # Panics
///
/// Panics if the manga is already fully loaded.
///
/// # Example
///
/// ```no_run
/// # use rust_anilist::{models::Manga, Result};
/// #
/// # async fn f(manga: Manga) -> Result<()> {
/// let manga = manga.load_full().await?;
/// # Ok(())
/// # }
/// ```
pub async fn load_full(self) -> Result<Self> {
if !self.is_full_loaded {
self.client.get_manga(self.id).await
Expand Down
2 changes: 2 additions & 0 deletions src/models/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// SPDX-License-Identifier: MIT↴
// Copyright (c) 2022-2025 Andriel Ferreira <https://github.com/AndrielFR>↴

//! This module contains various models and structures used in the library.
mod anime;
mod character;
mod color;
Expand Down
2 changes: 2 additions & 0 deletions src/models/name.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// SPDX-License-Identifier: MIT
// Copyright (c) 2022-2025 Andriel Ferreira <https://github.com/AndrielFR>

//! This module contains the `Name` struct.
use serde::{Deserialize, Serialize};

/// Represents a name.
Expand Down
3 changes: 3 additions & 0 deletions src/models/notification.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
// SPDX-License-Identifier: MIT
// Copyright (c) 2022-2025 Andriel Ferreira <https://github.com/AndrielFR>

//! This module contains the `Notification` struct and its related types.
use serde::{Deserialize, Serialize};

/// Represents a notification.
#[derive(Debug, Default, Clone, PartialEq, Deserialize, Serialize)]
pub struct Notification {}

Expand Down
41 changes: 37 additions & 4 deletions src/models/person.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,17 @@ impl Person {
/// # Panics
///
/// Panics if the person is already fully loaded.
///
/// # Example
///
/// ```no_run
/// # use rust_anilist::{models::Person, Result};
/// #
/// # async fn f(person: Person) -> Result<()> {
/// let person = person.load_full().await?;
/// # Ok(())
/// # }
/// ```
pub async fn load_full(self) -> Result<Self> {
if !self.is_full_loaded {
self.client.get_person(self.id).await
Expand All @@ -86,8 +97,19 @@ impl Person {
///
/// # Type Parameters
///
/// * `T` - The type of the media.
pub async fn get_medias<T>() -> Result<T> {
/// * `T` - The type of the media to be returned.
///
/// # Example
///
/// ```no_run
/// # use rust_anilist::{models::{Anime, Person}, Result};
/// #
/// # async fn f(person: Person) -> Result<()> {
/// let animes = person.get_medias::<Anime>().await?;
/// # Ok(())
/// # }
/// ```
pub async fn get_medias<T>(&self) -> Result<T> {
unimplemented!()
}

Expand All @@ -103,8 +125,19 @@ impl Person {
///
/// # Type Parameters
///
/// * `T` - The type of the media.
pub async fn get_character_medias<T>(_character_id: i64) -> Result<T> {
/// * `T` - The type of the media to be returned.
///
/// # Example
///
/// ```no_run
/// # use rust_anilist::{models::{Manga, Person}, Result};
/// #
/// # async fn f(person: Person) -> Result<()> {
/// let char_mangas = person.get_character_medias::<Manga>(1).await?;
/// # Ok(())
/// # }
/// ```
pub async fn get_character_medias<T>(&self, _character_id: i64) -> Result<T> {
unimplemented!()
}
}
2 changes: 2 additions & 0 deletions src/models/relation.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// SPDX-License-Identifier: MIT
// Copyright (c) 2022-2025 Andriel Ferreira <https://github.com/AndrielFR>

//! This module contains the `Relation` struct and its related types.
use serde::{Deserialize, Serialize};

use super::{Anime, Manga, MediaType};
Expand Down
3 changes: 3 additions & 0 deletions src/models/season.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// SPDX-License-Identifier: MIT↴↴
// Copyright (c) 2022-2025 Andriel Ferreira <https://github.com/AndrielFR>↴↴

//! This module contains the `Season` enum.
use serde::{Deserialize, Serialize};

/// Represents the four seasons of the year.
Expand Down Expand Up @@ -35,6 +37,7 @@ impl Season {
/// # Example
///
/// ```
/// # use rust_anilist::models::Season;
/// let season = Season::Winter;
/// assert_eq!(season.name(), "Winter");
/// ```
Expand Down
2 changes: 2 additions & 0 deletions src/models/source.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// SPDX-License-Identifier: MIT
// Copyright (c) 2022-2025 Andriel Ferreira <https://github.com/AndrielFR>

//! This module contains the `Source` enum.
use serde::{Deserialize, Serialize};

/// Represents the source of a media.
Expand Down
Loading

0 comments on commit 713b36f

Please sign in to comment.