Skip to content

Fix doctest#4

Merged
hdoo42 merged 5 commits into
masterfrom
fix_doctest
Oct 22, 2025
Merged

Fix doctest#4
hdoo42 merged 5 commits into
masterfrom
fix_doctest

Conversation

@hdoo42

@hdoo42 hdoo42 commented Oct 22, 2025

Copy link
Copy Markdown
Owner

This pull request refines documentation and adds a new binary to the libft-api project. The main focus is on improving example code snippets throughout the API modules to ensure they are more robust and user-friendly, particularly by updating authentication handling and streamlining test and example code. Additionally, it introduces a new binary for campus user queries and enhances the flexibility of group queries.

Documentation and Example Improvements

  • Updated all API example code snippets to use a more robust authentication pattern: replacing AuthInfo::build_from_env()? with AuthInfo::build_from_env().unwrap() and updating token retrieval to handle errors more transparently. This makes the examples easier to copy and run, especially for beginners. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14]
  • Modernized and clarified several example blocks by removing outdated or redundant code, grouping code for clarity, and using more explicit variable names and assertions. [1] [2] [3] [4] [5] [6] [7]

New Features and API Enhancements

  • Added a new binary target piscine_users to the project for specialized campus user queries, making it easier to run specific user-related tasks from the command line.
  • Enhanced the groups API endpoint to support filtering by user_id, allowing more flexible group queries and improving test coverage for this feature. [1] [2]

Testing and Internal Cleanups

  • Refactored test functions to use consistent error handling and assertions, ensuring that tests are easier to maintain and debug. [1] [2]
  • Removed redundant or outdated example blocks from documentation, focusing on concise and relevant examples. [1] [2] [3]

These changes collectively improve the usability and maintainability of the API documentation and codebase, making it easier for new and existing users to get started and for developers to extend functionality.

This commit addresses numerous issues with the documentation tests (doctests) across the `libft-api` crate, ensuring they are correct, runnable, and pass CI.

Key changes include:
- Wrapping example code in `async fn` and using a `tokio` runtime to allow `await` syntax in doctests.
- Updating API calls in examples to reflect recent changes in request/response structures and function signatures.
- Replacing placeholder examples with runnable code snippets.
- Improving error handling in tests and examples by using `ClientResult` and the `?` operator instead of `.unwrap()`.
- Renaming `TokenError::TempTokenNotFound` to `NoTempToken` for clarity.
- Changing the error type of `AuthInfo::build_from_env` to `std::env::VarError`.

BREAKING CHANGE: The `AuthInfo::build_from_env` function now returns `Result<AuthInfo, std::env::VarError>` instead of `Result<AuthInfo, String>`. The `TokenError::TempTokenNotFound` enum variant has been renamed to `TokenError::NoTempToken`.
This commit introduces a new binary, `piscine_users`, for fetching
users from a specific piscine session at the Gyeongsan campus.

The binary parallelizes API requests to efficiently gather user data
within a predefined date range and saves the results to a JSON file.
@hdoo42 hdoo42 merged commit e30a86e into master Oct 22, 2025
1 check passed
@hdoo42 hdoo42 deleted the fix_doctest branch October 22, 2025 04:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant