-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsources.py
More file actions
64 lines (50 loc) · 1.7 KB
/
sources.py
File metadata and controls
64 lines (50 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
"""Source configuration for documentation tracking.
Defines all documentation sources with their URLs, patterns, and settings.
"""
from __future__ import annotations
from dataclasses import dataclass
from typing import Dict
@dataclass(frozen=True)
class Source:
"""Configuration for a documentation source."""
key: str
name: str
index_url: str
url_pattern: str
prompt_file: str
base_url: str
@property
def docs_dir(self) -> str:
"""Directory name for storing docs (e.g., 'claude-code', 'api')."""
return self.key
@property
def output_dir(self) -> str:
"""Directory name for output changelogs."""
return self.key
SOURCES: Dict[str, Source] = {
"claude-code": Source(
key="claude-code",
name="Claude Code CLI",
index_url="https://code.claude.com/docs/llms.txt",
url_pattern=r"https://code\.claude\.com/docs/en/[\w-]+\.md",
prompt_file="lib/prompts/claude_code.md",
base_url="https://code.claude.com/docs",
),
"api": Source(
key="api",
name="Claude API",
index_url="https://platform.claude.com/llms.txt",
url_pattern=r"https://platform\.claude\.com/docs/en/[\w/-]+\.md",
prompt_file="lib/prompts/api.md",
base_url="https://platform.claude.com/docs",
),
}
def get_source(key: str) -> Source:
"""Get a source by key, raising ValueError if not found."""
if key not in SOURCES:
valid_keys = ", ".join(SOURCES.keys())
raise ValueError(f"Unknown source: {key}. Valid sources: {valid_keys}")
return SOURCES[key]
def get_all_sources() -> list[Source]:
"""Get all configured sources."""
return list(SOURCES.values())