Skip to content

Commit 6015877

Browse files
author
codegen-bot
committed
added py_noapidocs for the TS specific methods?
1 parent 33fc194 commit 6015877

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed

src/codegen/sdk/core/codebase.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
from codegen.sdk.typescript.symbol import TSSymbol
7575
from codegen.sdk.typescript.type_alias import TSTypeAlias
7676
from codegen.sdk.utils import determine_project_language
77-
from codegen.shared.decorators.docs import apidoc, noapidoc
77+
from codegen.shared.decorators.docs import apidoc, noapidoc, py_noapidoc
7878
from codegen.shared.exceptions.control_flow import MaxAIRequestsError
7979
from codegen.shared.performance.stopwatch_utils import stopwatch
8080
from codegen.visualizations.visualization_manager import VisualizationManager
@@ -266,8 +266,10 @@ def imports(self) -> list[TImport]:
266266
TImport can be PyImport for Python codebases or TSImport for TypeScript codebases.
267267
"""
268268
return self.G.get_nodes(NodeType.IMPORT)
269+
269270

270271
@property
272+
@py_noapidoc
271273
def exports(self: 'Codebase[TSFile, Directory, TSSymbol, TSClass, TSFunction, TSImport, TSAssignment, TSInterface, TSTypeAlias, TSParameter, TSCodeBlock]') -> list[TSExport]:
272274
"""Returns a list of all Export nodes in the codebase.
273275
@@ -1176,5 +1178,3 @@ def from_repo(cls, repo_name: str, *, tmp_dir: str | None = None, commit: str |
11761178
CodebaseType = Codebase[SourceFile, Directory, Symbol, Class, Function, Import, Assignment, Interface, TypeAlias, Parameter, CodeBlock]
11771179
PyCodebaseType = Codebase[PyFile, Directory, PySymbol, PyClass, PyFunction, PyImport, PyAssignment, Interface, TypeAlias, PyParameter, PyCodeBlock]
11781180
TSCodebaseType = Codebase[TSFile, Directory, TSSymbol, TSClass, TSFunction, TSImport, TSAssignment, TSInterface, TSTypeAlias, TSParameter, TSCodeBlock]
1179-
1180-

src/codegen/sdk/core/directory.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from pathlib import Path
44
from typing import TYPE_CHECKING, Generic, Self, TypeVar
55

6-
from codegen.shared.decorators.docs import apidoc
6+
from codegen.shared.decorators.docs import apidoc, py_noapidoc
77

88
if TYPE_CHECKING:
99
from codegen.sdk.core.assignment import Assignment
@@ -144,6 +144,7 @@ def functions(self) -> list[TFunction]:
144144
return list(chain.from_iterable(f.functions for f in self.files))
145145

146146
@property
147+
@py_noapidoc
147148
def exports(self: "Directory[TSFile, TSSymbol, TSImportStatement, TSGlobalVar, TSClass, TSFunction, TSImport]") -> "list[TSExport]":
148149
"""Get a recursive list of all exports in the directory and its subdirectories."""
149150
return list(chain.from_iterable(f.exports for f in self.files))
@@ -196,6 +197,7 @@ def get_file(self, filename: str, ignore_case: bool = False) -> TFile | None:
196197
return next((f for name, f in self.items.items() if name.lower() == filename.lower() and isinstance(f, File)), None)
197198
return self.items.get(filename, None)
198199

200+
@py_noapidoc
199201
def get_export(self: "Directory[TSFile, TSSymbol, TSImportStatement, TSGlobalVar, TSClass, TSFunction, TSImport]", name: str) -> "TSExport | None":
200202
"""Get an export by name in the directory and its subdirectories (supports only typescript)."""
201203
return next((s for s in self.exports if s.name == name), None)

src/codegen/shared/decorators/docs.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,19 @@ def noapidoc(obj: T) -> T:
7070
return obj
7171

7272

73+
py_no_apidoc_objects: list[DocumentedObject] = []
74+
py_no_apidoc_signatures: set[str] = set()
75+
76+
77+
def py_noapidoc(obj: T) -> T:
78+
"""Decorator for things that are hidden from the Python API documentation for AI-agent prompts."""
79+
obj._py_apidoc = False
80+
obj._api_doc_lang = "python"
81+
if doc_obj := get_documented_object(obj):
82+
bisect.insort(py_no_apidoc_objects, doc_obj)
83+
py_no_apidoc_signatures.add(doc_obj.signature())
84+
return obj
85+
7386
def get_documented_object(obj) -> DocumentedObject | None:
7487
module = inspect.getmodule(obj)
7588
module_name = module.__name__ if module else ""

0 commit comments

Comments
 (0)