Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Docs] Fix Duplicate Entry for RealtimeClientProtocol #789

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions autogen/_website/generate_api_references.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from pathlib import Path
from typing import Any, Iterator, Optional

from ..doc_utils import _PDOC_PLACEHOLDER
from ..import_utils import optional_import_block, require_optional_import

with optional_import_block():
Expand Down Expand Up @@ -83,6 +84,16 @@
# print(f"Skipping {obj.__module__}.{obj.__name__} because it is not from {module_name}")
module.__pdoc__[name] = False

if (
hasattr(obj, "__module__")
and obj.__module__.startswith(_PDOC_PLACEHOLDER)
and obj.__module__.replace(_PDOC_PLACEHOLDER, "") == module_name
):
module.__pdoc__[name] = False

Check warning on line 92 in autogen/_website/generate_api_references.py

View check run for this annotation

Codecov / codecov/patch

autogen/_website/generate_api_references.py#L92

Added line #L92 was not covered by tests

module_without_placeholder = obj.__module__.replace(_PDOC_PLACEHOLDER, "")
setattr(obj, "__module__", module_without_placeholder)

Check warning on line 95 in autogen/_website/generate_api_references.py

View check run for this annotation

Codecov / codecov/patch

autogen/_website/generate_api_references.py#L94-L95

Added lines #L94 - L95 were not covered by tests


@require_optional_import("pdoc", "docs")
def generate_markdown(path: Path) -> None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
class GeminiRealtimeClient:
"""(Experimental) Client for Gemini Realtime API."""

__exported_module__: str = ""

def __init__(
self,
*,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
class OpenAIRealtimeClient:
"""(Experimental) Client for OpenAI Realtime API."""

__exported_module__: str = ""

def __init__(
self,
*,
Expand Down
5 changes: 5 additions & 0 deletions autogen/doc_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,16 @@

T = TypeVar("T")

_PDOC_PLACEHOLDER = "__ADD_MODULE_TO_PDOC_AND_SET_FALSE__"


def export_module(module: str) -> Callable[[T], T]:
def decorator(cls: T) -> T:
if hasattr(cls, "_set__exported_module__"):
cls._set__exported_module__(module)
if not cls._get__exported_module__():
original_module = getattr(cls, "__module__")
setattr(cls, "__module__", f"{_PDOC_PLACEHOLDER}{original_module}")
return cls
setattr(cls, "__exported_module__", module)
return cls
Expand Down
Loading