Skip to content

Commit 00c2cb8

Browse files
format route's docstring as a markdown for Swagger
1 parent e3eecba commit 00c2cb8

1 file changed

Lines changed: 27 additions & 20 deletions

File tree

main.py

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -74,26 +74,33 @@ async def get_textified_wd(
7474
qualifiers: bool = True,
7575
fallback_lang: str = 'en'
7676
):
77-
"""Return normalized Wikidata entities in JSON, text, or triplet format.
78-
79-
Args:
80-
request (Request): Incoming request object (currently unused).
81-
background_tasks (BackgroundTasks): Background task queue for periodic cache cleanup.
82-
id (str): Comma-separated entity IDs (for example, ``"Q42,Q2"``).
83-
pid (str): Optional comma-separated property IDs used to filter claims.
84-
lang (str): Preferred language code for labels and formatted values.
85-
format (str): Output format: ``"json"``, ``"text"``, or ``"triplet"``.
86-
external_ids (bool): Whether to include claims with the ``external-id`` datatype.
87-
references (bool): Whether to include references in claim values.
88-
all_ranks (bool): Whether to include all statement ranks (preferred, normal, deprecated).
89-
qualifiers (bool): Whether to include qualifiers in claim values.
90-
fallback_lang (str): Fallback language when ``lang`` is unavailable.
91-
92-
Returns:
93-
dict[str, object | None]: Mapping of requested QIDs to their normalized payloads.
94-
95-
Raises:
96-
HTTPException: If an entity is not found, an upstream request fails, or internal processing fails.
77+
"""Retrieve Wikidata entities as structured JSON, natural text, or triplet lines.
78+
79+
This endpoint fetches one or more entities, resolves missing labels, and normalizes
80+
claims into a compact representation suitable for downstream LLM use.
81+
82+
**Args:**
83+
84+
- **id** (str): Comma-separated Wikidata IDs to fetch (for example: `"Q42"` or `"Q42,Q2"`).
85+
- **pid** (str, optional): Comma-separated property IDs used to filter returned claims (for example: `"P31,P279"`).
86+
- **lang** (str): Preferred language code for labels and formatted values.
87+
- **format** (str): Output format. One of `"json"`, `"text"`, or `"triplet"`.
88+
- **external_ids** (bool): If `true`, include claims with datatype `external-id`.
89+
- **references** (bool): If `true`, include references in claim values (JSON output only).
90+
- **all_ranks** (bool): If `true`, include preferred, normal, and deprecated statement ranks.
91+
- **qualifiers** (bool): If `true`, include qualifiers for claim values.
92+
- **fallback_lang** (str): Fallback language used when `lang` is unavailable.
93+
- **request** (Request): FastAPI request context object.
94+
- **background_tasks** (BackgroundTasks): Background task manager used for cache cleanup.
95+
96+
**Returns:**
97+
98+
A dictionary keyed by requested entity ID (for example, `"Q42"`).
99+
Each value depends on `format`:
100+
101+
- **json**: Structured entity payload with label, description, aliases, and claims.
102+
- **text**: Human-readable summary text.
103+
- **triplet**: Triplet-style text lines with labels and IDs.
97104
"""
98105
try:
99106
filter_pids = []

0 commit comments

Comments
 (0)