Setup mkdocstrings inline documentation

- Remove custom generate_docs.py script
- Use mkdocstrings inline ::: syntax in markdown files
- docs/api-reference.md: Main API reference with inline docs
- docs/api/*.md: Category pages with inline injections
- Pre-commit: Build mkdocs on commit

Documentation now uses standard mkdocstrings approach.
This commit is contained in:
root 2026-03-23 03:54:37 +00:00
parent f7ab02d3cf
commit 86149e0196
79 changed files with 10266 additions and 1932 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
site/

View File

@ -1,487 +1,25 @@
# API Reference
Auto-generated API documentation.
Auto-generated API documentation using mkdocstrings.
Last updated: kwork-api
## Client
---
::: kwork_api.client.KworkClient
## KworkClient
## Models
Kwork.ru API client.
::: kwork_api.models.Kwork
Usage:
# Login with credentials
client = await KworkClient.login("username", "password")
# Or restore from token
client = KworkClient(token="your_web_auth_token")
# Make requests
catalog = await client.catalog.get_list(page=1)
::: kwork_api.models.KworkDetails
### Methods
::: kwork_api.models.Project
#### `catalog()`
::: kwork_api.models.CatalogResponse
Catalog API.
## Errors
#### `projects()`
::: kwork_api.errors.KworkError
Projects API.
::: kwork_api.errors.KworkAuthError
#### `user()`
User API.
#### `reference()`
Reference data API.
#### `notifications()`
Notifications API.
#### `other()`
Other endpoints.
---
## CatalogAPI
Catalog/Kworks API endpoints.
---
## ProjectsAPI
Projects (freelance orders) API endpoints.
---
## UserAPI
User API endpoints.
---
## ReferenceAPI
Reference data (cities, countries, etc.) endpoints.
---
## NotificationsAPI
Notifications and messages endpoints.
---
## OtherAPI
Other API endpoints.
---
# Models
Pydantic models used in API responses.
## KworkUser
User information.
### Fields
| Field | Type | Description |
|-------|------|-------------|
| `id` | - | - |
| `username` | - | - |
| `avatar_url` | - | - |
| `is_online` | - | - |
| `rating` | - | - |
---
## KworkCategory
Category information.
### Fields
| Field | Type | Description |
|-------|------|-------------|
| `id` | - | - |
| `name` | - | - |
| `slug` | - | - |
| `parent_id` | - | - |
---
## Kwork
Kwork (service) information.
### Fields
| Field | Type | Description |
|-------|------|-------------|
| `id` | - | - |
| `title` | - | - |
| `description` | - | - |
| `price` | - | - |
| `currency` | - | - |
| `category_id` | - | - |
| `seller` | - | - |
| `images` | - | - |
| `rating` | - | - |
| `reviews_count` | - | - |
| `created_at` | - | - |
| `updated_at` | - | - |
---
## KworkDetails
Extended kwork details.
### Fields
| Field | Type | Description |
|-------|------|-------------|
| `full_description` | - | - |
| `requirements` | - | - |
| `delivery_time` | - | - |
| `revisions` | - | - |
| `features` | - | - |
| `faq` | - | - |
---
## PaginationInfo
Pagination metadata.
### Fields
| Field | Type | Description |
|-------|------|-------------|
| `current_page` | - | - |
| `total_pages` | - | - |
| `total_items` | - | - |
| `items_per_page` | - | - |
| `has_next` | - | - |
| `has_prev` | - | - |
---
## CatalogResponse
Catalog response with kworks and pagination.
### Fields
| Field | Type | Description |
|-------|------|-------------|
| `kworks` | - | - |
| `pagination` | - | - |
| `filters` | - | - |
| `sort_options` | - | - |
---
## Project
Project (freelance order) information.
### Fields
| Field | Type | Description |
|-------|------|-------------|
| `id` | - | - |
| `title` | - | - |
| `description` | - | - |
| `budget` | - | - |
| `budget_type` | - | - |
| `category_id` | - | - |
| `customer` | - | - |
| `status` | - | - |
| `created_at` | - | - |
| `updated_at` | - | - |
| `bids_count` | - | - |
| `skills` | - | - |
---
## ProjectsResponse
Projects list response.
### Fields
| Field | Type | Description |
|-------|------|-------------|
| `projects` | - | - |
| `pagination` | - | - |
---
## Review
Review information.
### Fields
| Field | Type | Description |
|-------|------|-------------|
| `id` | - | - |
| `rating` | - | - |
| `comment` | - | - |
| `author` | - | - |
| `kwork_id` | - | - |
| `created_at` | - | - |
---
## ReviewsResponse
Reviews list response.
### Fields
| Field | Type | Description |
|-------|------|-------------|
| `reviews` | - | - |
| `pagination` | - | - |
| `average_rating` | - | - |
---
## Notification
Notification information.
### Fields
| Field | Type | Description |
|-------|------|-------------|
| `id` | - | - |
| `type` | - | - |
| `title` | - | - |
| `message` | - | - |
| `is_read` | - | - |
| `created_at` | - | - |
| `link` | - | - |
---
## NotificationsResponse
Notifications list response.
### Fields
| Field | Type | Description |
|-------|------|-------------|
| `notifications` | - | - |
| `unread_count` | - | - |
---
## Dialog
Dialog (chat) information.
### Fields
| Field | Type | Description |
|-------|------|-------------|
| `id` | - | - |
| `participant` | - | - |
| `last_message` | - | - |
| `unread_count` | - | - |
| `updated_at` | - | - |
---
## AuthResponse
Authentication response.
### Fields
| Field | Type | Description |
|-------|------|-------------|
| `success` | - | - |
| `user_id` | - | - |
| `username` | - | - |
| `web_auth_token` | - | - |
| `message` | - | - |
---
## ErrorDetail
Error detail from API.
### Fields
| Field | Type | Description |
|-------|------|-------------|
| `code` | - | - |
| `message` | - | - |
| `field` | - | - |
---
## APIErrorResponse
Standard API error response.
### Fields
| Field | Type | Description |
|-------|------|-------------|
| `success` | - | - |
| `errors` | - | - |
| `message` | - | - |
---
## City
City information.
### Fields
| Field | Type | Description |
|-------|------|-------------|
| `id` | - | - |
| `name` | - | - |
| `country_id` | - | - |
---
## Country
Country information.
### Fields
| Field | Type | Description |
|-------|------|-------------|
| `id` | - | - |
| `name` | - | - |
| `code` | - | - |
| `cities` | - | - |
---
## TimeZone
Timezone information.
### Fields
| Field | Type | Description |
|-------|------|-------------|
| `id` | - | - |
| `name` | - | - |
| `offset` | - | - |
---
## Feature
Feature/addon information.
### Fields
| Field | Type | Description |
|-------|------|-------------|
| `id` | - | - |
| `name` | - | - |
| `description` | - | - |
| `price` | - | - |
| `type` | - | - |
---
## Badge
User badge information.
### Fields
| Field | Type | Description |
|-------|------|-------------|
| `id` | - | - |
| `name` | - | - |
| `description` | - | - |
| `icon_url` | - | - |
---
## DataResponse
Generic data response wrapper.
### Fields
| Field | Type | Description |
|-------|------|-------------|
| `success` | - | - |
| `data` | - | - |
| `message` | - | - |
---
# Errors
Exception classes for error handling.
## KworkError
Base exception for all Kwork API errors.
---
## KworkAuthError
Authentication/authorization error.
---
## KworkApiError
API request error (4xx, 5xx).
---
## KworkNotFoundError
Resource not found (404).
---
## KworkRateLimitError
Rate limit exceeded (429).
---
## KworkValidationError
Validation error (400).
---
## KworkNetworkError
Network/connection error.
---
::: kwork_api.errors.KworkApiError

7
docs/api/client.md Normal file
View File

@ -0,0 +1,7 @@
# Client API
::: kwork_api.client.KworkClient
options:
show_root_heading: true
show_source: true
merge_init_into_class: true

View File

@ -1,3 +0,0 @@
# APIErrorResponse
Standard API error response.

View File

@ -1,3 +0,0 @@
# AuthResponse
Authentication response.

View File

@ -1,3 +0,0 @@
# Badge
User badge information.

View File

@ -1,3 +0,0 @@
# CatalogResponse
Catalog response with kworks and pagination.

View File

@ -1,3 +0,0 @@
# City
City information.

View File

@ -1,3 +0,0 @@
# Country
Country information.

View File

@ -1,3 +0,0 @@
# DataResponse
Generic data response wrapper.

View File

@ -1,3 +0,0 @@
# Dialog
Dialog (chat) information.

View File

@ -1,3 +0,0 @@
# Feature
Feature/addon information.

View File

@ -1,33 +0,0 @@
# client
Kwork API Client.
Main client class with authentication and all API endpoints.
## Classes
- [KworkApiError](kworkapierror.md)
- [KworkAuthError](kworkautherror.md)
- [KworkError](kworkerror.md)
- [KworkNetworkError](kworknetworkerror.md)
- [KworkNotFoundError](kworknotfounderror.md)
- [KworkRateLimitError](kworkratelimiterror.md)
- [KworkValidationError](kworkvalidationerror.md)
- [APIErrorResponse](apierrorresponse.md)
- [AuthResponse](authresponse.md)
- [Badge](badge.md)
- [CatalogResponse](catalogresponse.md)
- [City](city.md)
- [Country](country.md)
- [DataResponse](dataresponse.md)
- [Dialog](dialog.md)
- [Feature](feature.md)
- [Kwork](kwork.md)
- [KworkDetails](kworkdetails.md)
- [NotificationsResponse](notificationsresponse.md)
- [Project](project.md)
- [ProjectsResponse](projectsresponse.md)
- [Review](review.md)
- [ReviewsResponse](reviewsresponse.md)
- [TimeZone](timezone.md)
- [KworkClient](kworkclient.md)

View File

@ -1,3 +0,0 @@
# Kwork
Kwork (service) information.

View File

@ -1,3 +0,0 @@
# KworkApiError
API request error (4xx, 5xx).

View File

@ -1,3 +0,0 @@
# KworkAuthError
Authentication/authorization error.

View File

@ -1,36 +0,0 @@
# KworkClient
Kwork.ru API client.
Usage:
# Login with credentials
client = await KworkClient.login("username", "password")
# Or restore from token
client = KworkClient(token="your_web_auth_token")
# Make requests
catalog = await client.catalog.get_list(page=1)
## Methods
### `login(username: str, password: str, timeout: float = 30.0)`
Login with username and password.
Args:
username: Kwork username or email
password: Kwork password
timeout: Request timeout
Returns:
Authenticated KworkClient instance
Raises:
KworkAuthError: If login fails
### `close()`
Close HTTP client.

View File

@ -1,3 +0,0 @@
# KworkDetails
Extended kwork details.

View File

@ -1,3 +0,0 @@
# KworkError
Base exception for all Kwork API errors.

View File

@ -1,3 +0,0 @@
# KworkNetworkError
Network/connection error.

View File

@ -1,3 +0,0 @@
# KworkNotFoundError
Resource not found (404).

View File

@ -1,3 +0,0 @@
# KworkRateLimitError
Rate limit exceeded (429).

View File

@ -1,3 +0,0 @@
# KworkValidationError
Validation error (400).

View File

@ -1,3 +0,0 @@
# NotificationsResponse
Notifications list response.

View File

@ -1,3 +0,0 @@
# Project
Project (freelance order) information.

View File

@ -1,3 +0,0 @@
# ProjectsResponse
Projects list response.

View File

@ -1,3 +0,0 @@
# Review
Review information.

View File

@ -1,3 +0,0 @@
# ReviewsResponse
Reviews list response.

View File

@ -1,3 +0,0 @@
# TimeZone
Timezone information.

23
docs/api/errors.md Normal file
View File

@ -0,0 +1,23 @@
# Errors
Exception classes for error handling.
## KworkError
::: kwork_api.errors.KworkError
## KworkAuthError
::: kwork_api.errors.KworkAuthError
## KworkApiError
::: kwork_api.errors.KworkApiError
## KworkNotFoundError
::: kwork_api.errors.KworkNotFoundError
## KworkRateLimitError
::: kwork_api.errors.KworkRateLimitError

View File

@ -1,15 +0,0 @@
# errors
Kwork API exceptions.
All exceptions provide clear error messages for debugging.
## Classes
- [KworkError](kworkerror.md)
- [KworkAuthError](kworkautherror.md)
- [KworkApiError](kworkapierror.md)
- [KworkNotFoundError](kworknotfounderror.md)
- [KworkRateLimitError](kworkratelimiterror.md)
- [KworkValidationError](kworkvalidationerror.md)
- [KworkNetworkError](kworknetworkerror.md)

View File

@ -1,3 +0,0 @@
# KworkApiError
API request error (4xx, 5xx).

View File

@ -1,3 +0,0 @@
# KworkAuthError
Authentication/authorization error.

View File

@ -1,3 +0,0 @@
# KworkError
Base exception for all Kwork API errors.

View File

@ -1,3 +0,0 @@
# KworkNetworkError
Network/connection error.

View File

@ -1,3 +0,0 @@
# KworkNotFoundError
Resource not found (404).

View File

@ -1,3 +0,0 @@
# KworkRateLimitError
Rate limit exceeded (429).

View File

@ -1,3 +0,0 @@
# KworkValidationError
Validation error (400).

View File

@ -1,24 +0,0 @@
# kwork_api
Kwork.ru API Client
Unofficial Python client for Kwork.ru API.
Example:
from kwork_api import KworkClient
# Login with credentials
client = await KworkClient.login("username", "password")
# Or restore from token
client = KworkClient(token="your_web_auth_token")
# Get catalog
catalog = await client.catalog.get_list(page=1)
## Classes
- [KworkClient](kworkclient.md)
- [KworkError](kworkerror.md)
- [KworkAuthError](kworkautherror.md)
- [KworkApiError](kworkapierror.md)

View File

@ -1,3 +0,0 @@
# KworkApiError
API request error (4xx, 5xx).

View File

@ -1,3 +0,0 @@
# KworkAuthError
Authentication/authorization error.

View File

@ -1,36 +0,0 @@
# KworkClient
Kwork.ru API client.
Usage:
# Login with credentials
client = await KworkClient.login("username", "password")
# Or restore from token
client = KworkClient(token="your_web_auth_token")
# Make requests
catalog = await client.catalog.get_list(page=1)
## Methods
### `login(username: str, password: str, timeout: float = 30.0)`
Login with username and password.
Args:
username: Kwork username or email
password: Kwork password
timeout: Request timeout
Returns:
Authenticated KworkClient instance
Raises:
KworkAuthError: If login fails
### `close()`
Close HTTP client.

View File

@ -1,3 +0,0 @@
# KworkError
Base exception for all Kwork API errors.

23
docs/api/models.md Normal file
View File

@ -0,0 +1,23 @@
# Models
Pydantic models used in API responses.
## Kwork
::: kwork_api.models.Kwork
## KworkDetails
::: kwork_api.models.KworkDetails
## Project
::: kwork_api.models.Project
## CatalogResponse
::: kwork_api.models.CatalogResponse
## PaginationInfo
::: kwork_api.models.PaginationInfo

View File

@ -1,3 +0,0 @@
# APIErrorResponse
Standard API error response.

View File

@ -1,3 +0,0 @@
# AuthResponse
Authentication response.

View File

@ -1,3 +0,0 @@
# Badge
User badge information.

View File

@ -1,3 +0,0 @@
# CatalogResponse
Catalog response with kworks and pagination.

View File

@ -1,3 +0,0 @@
# City
City information.

View File

@ -1,3 +0,0 @@
# Country
Country information.

View File

@ -1,3 +0,0 @@
# DataResponse
Generic data response wrapper.

View File

@ -1,3 +0,0 @@
# Dialog
Dialog (chat) information.

View File

@ -1,3 +0,0 @@
# ErrorDetail
Error detail from API.

View File

@ -1,3 +0,0 @@
# Feature
Feature/addon information.

View File

@ -1,30 +0,0 @@
# models
Pydantic models for Kwork API responses.
All models follow the structure found in the HAR dump analysis.
## Classes
- [KworkUser](kworkuser.md)
- [KworkCategory](kworkcategory.md)
- [Kwork](kwork.md)
- [KworkDetails](kworkdetails.md)
- [PaginationInfo](paginationinfo.md)
- [CatalogResponse](catalogresponse.md)
- [Project](project.md)
- [ProjectsResponse](projectsresponse.md)
- [Review](review.md)
- [ReviewsResponse](reviewsresponse.md)
- [Notification](notification.md)
- [NotificationsResponse](notificationsresponse.md)
- [Dialog](dialog.md)
- [AuthResponse](authresponse.md)
- [ErrorDetail](errordetail.md)
- [APIErrorResponse](apierrorresponse.md)
- [City](city.md)
- [Country](country.md)
- [TimeZone](timezone.md)
- [Feature](feature.md)
- [Badge](badge.md)
- [DataResponse](dataresponse.md)

View File

@ -1,3 +0,0 @@
# Kwork
Kwork (service) information.

View File

@ -1,3 +0,0 @@
# KworkCategory
Category information.

View File

@ -1,3 +0,0 @@
# KworkDetails
Extended kwork details.

View File

@ -1,3 +0,0 @@
# KworkUser
User information.

View File

@ -1,3 +0,0 @@
# Notification
Notification information.

View File

@ -1,3 +0,0 @@
# NotificationsResponse
Notifications list response.

View File

@ -1,3 +0,0 @@
# PaginationInfo
Pagination metadata.

View File

@ -1,3 +0,0 @@
# Project
Project (freelance order) information.

View File

@ -1,3 +0,0 @@
# ProjectsResponse
Projects list response.

View File

@ -1,3 +0,0 @@
# Review
Review information.

View File

@ -1,3 +0,0 @@
# ReviewsResponse
Reviews list response.

View File

@ -1,3 +0,0 @@
# TimeZone
Timezone information.

View File

@ -1,125 +0,0 @@
#!/usr/bin/env python3
"""
Generate Markdown API documentation using griffe.
Usage:
python scripts/generate_docs.py
Generates docs/api/*.md from source code docstrings.
"""
import sys
from pathlib import Path
from griffe import GriffeLoader, ObjectKind
def format_signature(obj):
"""Format object signature."""
params = []
for param in obj.parameters:
if param.name in ("self", "cls"):
continue
p = param.name
if param.annotation:
p += f": {param.annotation}"
if param.default:
p += f" = {param.default}"
params.append(p)
return f"({', '.join(params)})"
def generate_class_md(cls, output_path: Path):
"""Generate markdown for a class."""
lines = [
f"# {cls.name}",
"",
cls.docstring.value if cls.docstring else "",
"",
]
# Methods
methods = [m for m in cls.members.values() if m.kind == ObjectKind.FUNCTION and not m.name.startswith("_")]
if methods:
lines.append("## Methods")
lines.append("")
for method in methods:
sig = format_signature(method)
lines.append(f"### `{method.name}{sig}`")
lines.append("")
if method.docstring:
lines.append(method.docstring.value)
lines.append("")
lines.append("")
output_path.write_text("\n".join(lines))
def generate_module_md(module, output_dir: Path):
"""Generate markdown files for a module."""
output_dir.mkdir(parents=True, exist_ok=True)
# Generate index for module
index_path = output_dir / "index.md"
lines = [
f"# {module.name}",
"",
module.docstring.value if module.docstring else "",
"",
"## Classes",
"",
]
for name, obj in module.members.items():
if obj.kind == ObjectKind.CLASS and not name.startswith("_"):
lines.append(f"- [{name}]({name.lower()}.md)")
# Generate class file
class_path = output_dir / f"{name.lower()}.md"
generate_class_md(obj, class_path)
lines.append("")
index_path.write_text("\n".join(lines))
def main():
"""Main entry point."""
root_dir = Path(__file__).parent.parent
src_dir = root_dir / "src" / "kwork_api"
docs_dir = root_dir / "docs" / "api"
if not src_dir.exists():
print(f"❌ Source directory not found: {src_dir}")
sys.exit(1)
print("📝 Loading source code with griffe...")
# Load with griffe (AST parsing, no code execution)
loader = GriffeLoader(search_paths=[src_dir.parent])
module = loader.load("kwork_api")
print("📄 Generating markdown documentation...")
# Generate for main modules
generate_module_md(module, docs_dir)
# Generate client.md
if "client" in module.members:
generate_module_md(module["client"], docs_dir / "client")
# Generate models.md
if "models" in module.members:
generate_module_md(module["models"], docs_dir / "models")
# Generate errors.md
if "errors" in module.members:
generate_module_md(module["errors"], docs_dir / "errors")
print(f"✅ Generated markdown in {docs_dir}")
if __name__ == "__main__":
main()

View File

@ -429,7 +429,7 @@
<li class="md-nav__item">
<a href="/claw/kwork-api/api/client.md" class="md-nav__link">
<a href="/claw/kwork-api/api/client/" class="md-nav__link">
@ -457,7 +457,7 @@
<li class="md-nav__item">
<a href="/claw/kwork-api/api/models.md" class="md-nav__link">
<a href="/claw/kwork-api/api/models/" class="md-nav__link">
@ -485,7 +485,7 @@
<li class="md-nav__item">
<a href="/claw/kwork-api/api/errors.md" class="md-nav__link">
<a href="/claw/kwork-api/api/errors/" class="md-nav__link">

File diff suppressed because it is too large Load Diff

4174
site/api/client/index.html Normal file

File diff suppressed because it is too large Load Diff

1102
site/api/errors/index.html Normal file

File diff suppressed because it is too large Load Diff

1042
site/api/models/index.html Normal file

File diff suppressed because it is too large Load Diff

View File

@ -13,7 +13,7 @@
<link rel="canonical" href="https://github.com/claw/kwork-api/examples/">
<link rel="prev" href="../api-reference/">
<link rel="prev" href="../api/errors/">
@ -440,7 +440,7 @@
<li class="md-nav__item">
<a href="../api/client.md" class="md-nav__link">
<a href="../api/client/" class="md-nav__link">
@ -468,7 +468,7 @@
<li class="md-nav__item">
<a href="../api/models.md" class="md-nav__link">
<a href="../api/models/" class="md-nav__link">
@ -496,7 +496,7 @@
<li class="md-nav__item">
<a href="../api/errors.md" class="md-nav__link">
<a href="../api/errors/" class="md-nav__link">

View File

@ -581,7 +581,7 @@
<li class="md-nav__item">
<a href="api/client.md" class="md-nav__link">
<a href="api/client/" class="md-nav__link">
@ -609,7 +609,7 @@
<li class="md-nav__item">
<a href="api/models.md" class="md-nav__link">
<a href="api/models/" class="md-nav__link">
@ -637,7 +637,7 @@
<li class="md-nav__item">
<a href="api/errors.md" class="md-nav__link">
<a href="api/errors/" class="md-nav__link">

Binary file not shown.

File diff suppressed because one or more lines are too long

View File

@ -12,4 +12,16 @@
<loc>https://github.com/claw/kwork-api/examples/</loc>
<lastmod>2026-03-23</lastmod>
</url>
<url>
<loc>https://github.com/claw/kwork-api/api/client/</loc>
<lastmod>2026-03-23</lastmod>
</url>
<url>
<loc>https://github.com/claw/kwork-api/api/errors/</loc>
<lastmod>2026-03-23</lastmod>
</url>
<url>
<loc>https://github.com/claw/kwork-api/api/models/</loc>
<lastmod>2026-03-23</lastmod>
</url>
</urlset>

Binary file not shown.