Skip to content
Merged
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
6 changes: 4 additions & 2 deletions scripts/codegen/config/docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,13 @@
),
"query_selector": (
"Return a handle for the first element matching `selector`, or `None`. "
"The element's `innerHTML`/`outerHTML` are fetched only with `html=True`."
"The element's `innerHTML`/`outerHTML` are fetched only with `html=True`; "
"reading `inner_html` or `outer_html` without it raises `BAPValueError`."
),
"query_selector_all": (
"Return handles for every element matching `selector`. "
"The elements' `innerHTML`/`outerHTML` are fetched only with `html=True`."
"The elements' `innerHTML`/`outerHTML` are fetched only with `html=True`; "
"reading `inner_html` or `outer_html` without it raises `BAPValueError`."
),
}

Expand Down
5 changes: 5 additions & 0 deletions scripts/codegen/emit_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,11 @@ def _class_page(identifier: str, title: str, class_: Class) -> str:
"",
)
)
property_summary = _summary(
member.docstring.value if member.docstring else None
)
if property_summary:
lines.extend((property_summary, ""))
continue
if not isinstance(member, Function):
continue
Expand Down
4 changes: 2 additions & 2 deletions src/browserless_bap/_page_generated.py
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,7 @@ async def query_selector(
visible: bool | UnsetType = UNSET,
html: bool | UnsetType = UNSET,
) -> ElementHandle | None:
"Return a handle for the first element matching `selector`, or `None`. The element's `innerHTML`/`outerHTML` are fetched only with `html=True`."
"Return a handle for the first element matching `selector`, or `None`. The element's `innerHTML`/`outerHTML` are fetched only with `html=True`; reading `inner_html` or `outer_html` without it raises `BAPValueError`."
args = drop_unset(
{
"selector": selector,
Expand Down Expand Up @@ -661,7 +661,7 @@ async def query_selector_all(
visible: bool | UnsetType = UNSET,
html: bool | UnsetType = UNSET,
) -> list[ElementHandle]:
"Return handles for every element matching `selector`. The elements' `innerHTML`/`outerHTML` are fetched only with `html=True`."
"Return handles for every element matching `selector`. The elements' `innerHTML`/`outerHTML` are fetched only with `html=True`; reading `inner_html` or `outer_html` without it raises `BAPValueError`."
args = drop_unset(
{
"selector": selector,
Expand Down
5 changes: 2 additions & 3 deletions src/browserless_bap/page.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,9 +344,8 @@ async def response(
body: bool | UnsetType = UNSET,
body_encoding: bool | UnsetType = UNSET,
) -> list[ResponseResponse]:
"""List responses; fetch bodies only with body=True.

body_encoding=True implies body=True and adds the base64Encoded flag.
"""List responses. Bodies are fetched only with body=True or body_encoding=True;
body_encoding=True also adds the base64Encoded flag.
"""
args = _drop_unset(
{
Expand Down
4 changes: 2 additions & 2 deletions src/browserless_bap/sync_api/_page_generated.py
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ def query_selector(
visible: bool | UnsetType = UNSET,
html: bool | UnsetType = UNSET,
) -> ElementHandle | None:
"Return a handle for the first element matching `selector`, or `None`. The element's `innerHTML`/`outerHTML` are fetched only with `html=True`."
"Return a handle for the first element matching `selector`, or `None`. The element's `innerHTML`/`outerHTML` are fetched only with `html=True`; reading `inner_html` or `outer_html` without it raises `BAPValueError`."
return cast(
"ElementHandle | None",
self._invoke(
Expand All @@ -499,7 +499,7 @@ def query_selector_all(
visible: bool | UnsetType = UNSET,
html: bool | UnsetType = UNSET,
) -> list[ElementHandle]:
"Return handles for every element matching `selector`. The elements' `innerHTML`/`outerHTML` are fetched only with `html=True`."
"Return handles for every element matching `selector`. The elements' `innerHTML`/`outerHTML` are fetched only with `html=True`; reading `inner_html` or `outer_html` without it raises `BAPValueError`."
return cast(
"list[ElementHandle]",
self._invoke(
Expand Down
2 changes: 2 additions & 0 deletions src/browserless_bap/sync_api/element_handle.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
class ElementHandle(SyncBase[Any]):
@property
def inner_html(self) -> str | None:
"""Element HTML. Requires html=True on the query that produced this handle."""
return cast(str | None, self._impl.inner_html)

@property
Expand All @@ -33,6 +34,7 @@ def local_name(self) -> str | None:

@property
def outer_html(self) -> str | None:
"""Element markup. Requires html=True on the query that produced this handle."""
return cast(str | None, self._impl.outer_html)

@property
Expand Down
5 changes: 2 additions & 3 deletions src/browserless_bap/sync_api/page.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,8 @@ def response(
body: bool | UnsetType = UNSET,
body_encoding: bool | UnsetType = UNSET,
) -> list[ResponseResponse]:
"""List responses; fetch bodies only with body=True.

body_encoding=True implies body=True and adds the base64Encoded flag.
"""List responses. Bodies are fetched only with body=True or body_encoding=True;
body_encoding=True also adds the base64Encoded flag.
"""
return cast(
list[ResponseResponse],
Expand Down
10 changes: 10 additions & 0 deletions tests/test_codegen_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,16 @@ def test_docs_cli_emits_deterministic_docusaurus_reference(tmp_path: Path) -> No
assert "## `closed`" in before[Path("sync-page.mdx")]
assert "## `inner_html`" in before[Path("async-element-handle.mdx")]
assert "## `selector`" in before[Path("sync-element-handle.mdx")]
for page in ("async-element-handle.mdx", "sync-element-handle.mdx"):
assert (
"Requires html=True on the query that produced this handle."
in before[Path(page)]
)
for page in ("async-page.mdx", "sync-page.mdx"):
assert (
"body_encoding=True also adds the base64Encoded flag." in before[Path(page)]
)
assert "raises `BAPValueError`" in before[Path(page)]
assert "listener_count(event: str) -> int" in before[Path("sync-page.mdx")]
assert "Wait for the next event payload" in before[Path("async-page.mdx")]
assert "Start tracking" in before[Path("sync-page.mdx")]
Expand Down
Loading