Spaces:
Sleeping
Sleeping
| cases: | |
| - id: "api_documentation" | |
| question: "Create documentation for a REST API endpoint that handles user authentication" | |
| reference_doc: | | |
| # User Authentication API | |
| ## POST /api/auth/login | |
| Authenticates a user and returns a JWT token. | |
| ### Request Body | |
| ```json | |
| { | |
| "username": "string", | |
| "password": "string" | |
| } | |
| ``` | |
| ### Response | |
| ```json | |
| { | |
| "token": "string", | |
| "expires_in": 3600, | |
| "user": { | |
| "id": 1, | |
| "username": "string", | |
| "email": "string" | |
| } | |
| } | |
| ``` | |
| ### Status Codes | |
| - `200 OK`: Authentication successful | |
| - `401 Unauthorized`: Invalid credentials | |
| - `400 Bad Request`: Missing or invalid request body | |
| difficulty: "medium" | |
| description: "API endpoint documentation" | |
| - id: "function_documentation" | |
| question: "Create documentation for a Python function that calculates the factorial of a number" | |
| reference_doc: | | |
| ## factorial(n) | |
| Calculates the factorial of a given number. | |
| ### Parameters | |
| - `n` (int): The number to calculate factorial for. Must be non-negative. | |
| ### Returns | |
| - `int`: The factorial of n | |
| ### Raises | |
| - `ValueError`: If n is negative | |
| ### Examples | |
| ```python | |
| >>> factorial(5) | |
| 120 | |
| >>> factorial(0) | |
| 1 | |
| >>> factorial(-1) | |
| ValueError: Factorial is not defined for negative numbers | |
| ``` | |
| difficulty: "easy" | |
| description: "Function documentation with examples" | |
| - id: "class_documentation" | |
| question: "Create documentation for a Python class that represents a bank account" | |
| reference_doc: | | |
| ## BankAccount | |
| A class representing a bank account with basic operations. | |
| ### Attributes | |
| - `balance` (float): The current account balance | |
| - `account_number` (str): Unique account identifier | |
| ### Methods | |
| #### `__init__(self, account_number: str, initial_balance: float = 0.0)` | |
| Initialize a new bank account. | |
| #### `deposit(self, amount: float) -> bool` | |
| Deposit money into the account. | |
| - **Parameters**: `amount` (float): Amount to deposit (must be positive) | |
| - **Returns**: `bool`: True if successful, False otherwise | |
| #### `withdraw(self, amount: float) -> bool` | |
| Withdraw money from the account. | |
| - **Parameters**: `amount` (float): Amount to withdraw (must be positive and <= balance) | |
| - **Returns**: `bool`: True if successful, False otherwise | |
| #### `get_balance(self) -> float` | |
| Get the current account balance. | |
| - **Returns**: `float`: Current balance | |
| difficulty: "medium" | |
| description: "Class documentation with methods" | |
| - id: "installation_guide" | |
| question: "Create installation and setup documentation for a Python package" | |
| reference_doc: | | |
| # Installation Guide | |
| ## Prerequisites | |
| - Python 3.8 or higher | |
| - pip (Python package installer) | |
| ## Installation | |
| ### Using pip | |
| ```bash | |
| pip install my-package | |
| ``` | |
| ### From source | |
| ```bash | |
| git clone https://github.com/user/my-package.git | |
| cd my-package | |
| pip install -e . | |
| ``` | |
| ## Configuration | |
| Create a configuration file `config.yaml`: | |
| ```yaml | |
| database: | |
| host: localhost | |
| port: 5432 | |
| name: myapp | |
| api: | |
| base_url: https://api.example.com | |
| timeout: 30 | |
| ``` | |
| ## Quick Start | |
| ```python | |
| from my_package import MyClass | |
| # Initialize | |
| app = MyClass() | |
| # Use the application | |
| result = app.process_data("input") | |
| print(result) | |
| ``` | |
| difficulty: "hard" | |
| description: "Complete installation and setup guide" | |