ruffen-docs.py — anthropic-sdk-python Source File
Architecture documentation for ruffen-docs.py, a python file in the anthropic-sdk-python codebase. 7 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 3965d879_b0ae_9368_c20d_7ddc509b318b["ruffen-docs.py"] cc059f4f_d2bd_7056_9086_eaeec58cbdc0["re"] 3965d879_b0ae_9368_c20d_7ddc509b318b --> cc059f4f_d2bd_7056_9086_eaeec58cbdc0 42faf450_4542_3635_bb7f_62cffcc3e979["sys"] 3965d879_b0ae_9368_c20d_7ddc509b318b --> 42faf450_4542_3635_bb7f_62cffcc3e979 3cba0a71_906c_e93b_34e4_d1643541e9fc["argparse"] 3965d879_b0ae_9368_c20d_7ddc509b318b --> 3cba0a71_906c_e93b_34e4_d1643541e9fc dec001f7_2aeb_2548_ceab_5980c16cc233["textwrap"] 3965d879_b0ae_9368_c20d_7ddc509b318b --> dec001f7_2aeb_2548_ceab_5980c16cc233 c98b2067_811f_0505_6d3f_bde955212221["contextlib"] 3965d879_b0ae_9368_c20d_7ddc509b318b --> c98b2067_811f_0505_6d3f_bde955212221 8e0310a5_0ae6_173e_96e6_4f50b1a4d25a["subprocess"] 3965d879_b0ae_9368_c20d_7ddc509b318b --> 8e0310a5_0ae6_173e_96e6_4f50b1a4d25a 89ddcdd7_3ae1_4c7b_41bb_9f1e25f16875["typing"] 3965d879_b0ae_9368_c20d_7ddc509b318b --> 89ddcdd7_3ae1_4c7b_41bb_9f1e25f16875 style 3965d879_b0ae_9368_c20d_7ddc509b318b fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
# fork of https://github.com/asottile/blacken-docs adapted for ruff
from __future__ import annotations
import re
import sys
import argparse
import textwrap
import contextlib
import subprocess
from typing import Match, Optional, Sequence, Generator, NamedTuple, cast
MD_RE = re.compile(
r"(?P<before>^(?P<indent> *)```\s*python\n)" r"(?P<code>.*?)" r"(?P<after>^(?P=indent)```\s*$)",
re.DOTALL | re.MULTILINE,
)
MD_PYCON_RE = re.compile(
r"(?P<before>^(?P<indent> *)```\s*pycon\n)" r"(?P<code>.*?)" r"(?P<after>^(?P=indent)```.*$)",
re.DOTALL | re.MULTILINE,
)
PYCON_PREFIX = ">>> "
PYCON_CONTINUATION_PREFIX = "..."
PYCON_CONTINUATION_RE = re.compile(
rf"^{re.escape(PYCON_CONTINUATION_PREFIX)}( |$)",
)
DEFAULT_LINE_LENGTH = 100
class CodeBlockError(NamedTuple):
offset: int
exc: Exception
def format_str(
src: str,
) -> tuple[str, Sequence[CodeBlockError]]:
errors: list[CodeBlockError] = []
@contextlib.contextmanager
def _collect_error(match: Match[str]) -> Generator[None, None, None]:
try:
yield
except Exception as e:
errors.append(CodeBlockError(match.start(), e))
def _md_match(match: Match[str]) -> str:
code = textwrap.dedent(match["code"])
with _collect_error(match):
code = format_code_block(code)
code = textwrap.indent(code, match["indent"])
return f"{match['before']}{code}{match['after']}"
def _pycon_match(match: Match[str]) -> str:
code = ""
fragment = cast(Optional[str], None)
def finish_fragment() -> None:
nonlocal code
nonlocal fragment
if fragment is not None:
// ... (108 more lines)
Domain
Subdomains
Classes
Dependencies
- argparse
- contextlib
- re
- subprocess
- sys
- textwrap
- typing
Source
Frequently Asked Questions
What does ruffen-docs.py do?
ruffen-docs.py is a source file in the anthropic-sdk-python codebase, written in python. It belongs to the AnthropicClient domain, SyncAPI subdomain.
What functions are defined in ruffen-docs.py?
ruffen-docs.py defines 5 function(s): SystemExit, format_code_block, format_file, format_str, main.
What does ruffen-docs.py depend on?
ruffen-docs.py imports 7 module(s): argparse, contextlib, re, subprocess, sys, textwrap, typing.
Where is ruffen-docs.py in the architecture?
ruffen-docs.py is located at scripts/utils/ruffen-docs.py (domain: AnthropicClient, subdomain: SyncAPI, directory: scripts/utils).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free