Skip to content

Commit d057d04

Browse files
authored
Add modified core docs to website, Partially flatten navbar (#238)
* docs: add core modules to mkdocs auto-generation * docs: fix griffe warnings (mostly unnecessary type fields); minor rewrite of some docs
1 parent f593626 commit d057d04

File tree

11 files changed

+33
-170
lines changed

11 files changed

+33
-170
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1313

1414
### Changed
1515

16+
- Docs: `core` modules included in documentation reference section. Slight modifications were done, mostly to remove warnings. @Kajmany
17+
1618
### Removed
1719

1820
## [0.15.2] - 2025-11-29

mkdocs.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,17 @@ nav:
2222
- Reading API responses: tutorials/api-responses.md
2323
- Playing with CDP: tutorials/cdp.md
2424
- Reference:
25+
- core:
26+
- browser: reference/core/browser.md
27+
- cloudflare: reference/core/cloudflare.md
28+
- config: reference/core/config.md
29+
- connection: reference/core/connection.md
30+
- element: reference/core/element.md
31+
- expect: reference/core/expect.md
32+
- intercept: reference/core/intercept.md
33+
- keys: reference/core/keys.md
34+
- tab: reference/core/tab.md
35+
- util: reference/core/util.md
2536
- cdp:
2637
- accessibility: reference/cdp/accessibility.md
2738
- animation: reference/cdp/animation.md

scripts/mkdocs_generate_reference.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@ def clean_reference_docs_dir() -> None:
3030
def get_documented_modules() -> list[Path]:
3131
return [
3232
path.relative_to(PACKAGE_ROOT)
33-
for path in sorted(PACKAGE_ROOT.rglob("cdp/*.py"))
33+
for path in (
34+
sorted(PACKAGE_ROOT.rglob("core/*.py"))
35+
+ sorted(PACKAGE_ROOT.rglob("cdp/*.py"))
36+
)
3437
if not path.stem.startswith("_")
3538
]
3639

zendriver/core/__init__.py

Whitespace-only changes.

zendriver/core/browser.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ async def get(
264264
:param new_tab: open new tab
265265
:param new_window: open new window
266266
:return: Page
267-
:raises: asyncio.TimeoutError
267+
:raises asyncio.TimeoutError:
268268
"""
269269
if not self.connection:
270270
raise RuntimeError("Browser not yet started. use await browser.start()")
@@ -685,7 +685,6 @@ async def get_all(
685685
get all cookies
686686
687687
:param requests_cookie_format: when True, returns python http.cookiejar.Cookie objects, compatible with requests library and many others.
688-
:type requests_cookie_format: bool
689688
:return:
690689
:rtype:
691690
@@ -723,7 +722,6 @@ async def set_all(self, cookies: List[cdp.network.CookieParam]) -> None:
723722
set cookies
724723
725724
:param cookies: list of cookies
726-
:type cookies:
727725
:return:
728726
:rtype:
729727
"""
@@ -745,7 +743,6 @@ async def save(self, file: PathLike = ".session.dat", pattern: str = ".*") -> No
745743
save all cookies (or a subset, controlled by `pattern`) to a file to be restored later
746744
747745
:param file:
748-
:type file:
749746
:param pattern: regex style pattern string.
750747
any cookie that has a domain, key or value field which matches the pattern will be included.
751748
default = ".*" (all)
@@ -754,7 +751,6 @@ async def save(self, file: PathLike = ".session.dat", pattern: str = ".*") -> No
754751
- have a string "cf" (cloudflare)
755752
- have ".com" in them, in either domain, key or value field.
756753
- contain "nowsecure"
757-
:type pattern: str
758754
:return:
759755
:rtype:
760756
"""
@@ -799,7 +795,6 @@ async def load(self, file: PathLike = ".session.dat", pattern: str = ".*") -> No
799795
load all cookies (or a subset, controlled by `pattern`) from a file created by :py:meth:`~save_cookies`.
800796
801797
:param file:
802-
:type file:
803798
:param pattern: regex style pattern string.
804799
any cookie that has a domain, key or value field which matches the pattern will be included.
805800
default = ".*" (all)
@@ -808,7 +803,6 @@ async def load(self, file: PathLike = ".session.dat", pattern: str = ".*") -> No
808803
- have a string "cf" (cloudflare)
809804
- have ".com" in them, in either domain, key or value field.
810805
- contain "nowsecure"
811-
:type pattern: str
812806
:return:
813807
:rtype:
814808
"""

zendriver/core/config.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -67,24 +67,13 @@ def __init__(
6767
:param browser: which browser to use. Can be "chrome", "brave" or "auto". Default is "auto".
6868
:param browser_args: forwarded to browser executable. eg : ["--some-chromeparam=somevalue", "some-other-param=someval"]
6969
:param sandbox: disables sandbox
70-
:param autodiscover_targets: use autodiscovery of targets
7170
:param lang: language string to use other than the default "en-US,en;q=0.9"
7271
:param user_agent: custom user-agent string
7372
:param expert: when set to True, enabled "expert" mode.
7473
This conveys, the inclusion of parameters: --disable-web-security ----disable-site-isolation-trials,
7574
as well as some scripts and patching useful for debugging (for example, ensuring shadow-root is always in "open" mode)
7675
7776
:param kwargs:
78-
79-
:type user_data_dir: PathLike
80-
:type headless: bool
81-
:type browser_executable_path: PathLike
82-
:type browser: BrowserType
83-
:type browser_args: list[str]
84-
:type sandbox: bool
85-
:type lang: str
86-
:type user_agent: str
87-
:type kwargs: dict
8877
"""
8978

9079
if not browser_args:
@@ -184,7 +173,6 @@ def add_extension(self, extension_path: PathLike) -> None:
184173
to a folder (containing the manifest), or extension file (crx)
185174
186175
:param extension_path:
187-
:type extension_path:
188176
:return:
189177
:rtype:
190178
"""

zendriver/core/connection.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -353,9 +353,7 @@ def add_handler(
353353
the next time you make network traffic you will see your console print like crazy.
354354
355355
:param event_type_or_domain:
356-
:type event_type_or_domain:
357356
:param handler:
358-
:type handler:
359357
360358
:return:
361359
:rtype:
@@ -417,7 +415,6 @@ def remove_handlers(
417415
async def aopen(self) -> None:
418416
"""
419417
opens the websocket connection. should not be called manually by users
420-
:param kw:
421418
:return:
422419
"""
423420

@@ -469,7 +466,6 @@ def feed_cdp(self, cdp_obj: Generator[dict[str, Any], dict[str, Any], T]) -> Non
469466
note: this is not an async method, just a regular method!
470467
471468
:param cdp_obj:
472-
:type cdp_obj:
473469
:return:
474470
:rtype:
475471
"""
@@ -481,7 +477,6 @@ async def wait(self, t: int | float | None = None) -> None:
481477
when `t` is provided, ensures waiting for `t` seconds, no matter what.
482478
483479
:param t:
484-
:type t:
485480
:return:
486481
:rtype:
487482
"""

zendriver/core/element.py

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,9 @@ def create(
3232
we don't need to fetch it for every single element.
3333
3434
:param node: cdp dom node representation
35-
:type node: cdp.dom.Node
3635
:param tab: the target object to which this element belongs
37-
:type tab: Tab
3836
:param tree: [Optional] the full node tree to which <node> belongs, enhances performance.
3937
when not provided, you need to call `await elem.update()` before using .children / .parent
40-
:type tree:
4138
"""
4239

4340
elem = Element(node, tab, tree)
@@ -51,9 +48,7 @@ def __init__(self, node: cdp.dom.Node, tab: Tab, tree: cdp.dom.Node | None = Non
5148
Represents an (HTML) DOM Element
5249
5350
:param node: cdp dom node representation
54-
:type node: cdp.dom.Node
5551
:param tab: the target object to which this element belongs
56-
:type tab: Tab
5752
"""
5853
if not node:
5954
raise Exception("node cannot be None")
@@ -218,7 +213,6 @@ def get(self, name: str) -> str | None:
218213
href = element.get("href")
219214
220215
:param name: The name of the attribute to retrieve.
221-
:type name: str
222216
:return: The value of the attribute, or None if it does not exist.
223217
:rtype: str | None
224218
"""
@@ -455,7 +449,6 @@ def __call__(self, js_method: str) -> typing.Any:
455449
calling the element object will call a js method on the object
456450
eg, element.play() in case of a video element, it will call .play()
457451
:param js_method:
458-
:type js_method:
459452
:return:
460453
:rtype:
461454
"""
@@ -477,11 +470,8 @@ async def apply(
477470
- function myFunction(elem) { alert(elem) }
478471
479472
:param js_function: the js function definition which received this element.
480-
:type js_function: str
481473
:param return_by_value:
482-
:type return_by_value:
483474
:param await_promise: when True, waits for the promise to resolve before returning
484-
:type await_promise: bool
485475
:return:
486476
:rtype:
487477
"""
@@ -619,16 +609,11 @@ async def mouse_drag(
619609
drag an element to another element or target coordinates. dragging of elements should be supported by the site of course
620610
621611
622-
:param destination: another element where to drag to, or a tuple (x,y) of ints representing coordinate
623-
:type destination: Element or coordinate as x,y tuple
624-
612+
:param destination: target Element or coordinates (x,y) to drag to
625613
:param relative: when True, treats coordinate as relative. for example (-100, 200) will move left 100px and down 200px
626-
:type relative:
627-
628614
:param steps: move in <steps> points, this could make it look more "natural" (default 1),
629615
but also a lot slower.
630616
for very smooth action use 50-100
631-
:type steps: int
632617
:return:
633618
:rtype:
634619
"""
@@ -758,13 +743,7 @@ async def send_keys(
758743
759744
hint, if you ever get stuck where using py:meth:`~click`
760745
does not work, sending the keystroke \\n or \\r\\n or a spacebar work wonders!
761-
762-
when special_characters is True, it will use grapheme clusters to send the text:
763-
if the character is in the printable ASCII range, it sends it using dispatch_key_event.
764-
otherwise, it uses insertText, which handles special characters more robustly.
765-
766746
:param text: text to send
767-
:param special_characters: when True, uses grapheme clusters to send the text.
768747
:return: None
769748
"""
770749
await self.apply("(elem) => elem.focus()")
@@ -897,7 +876,6 @@ async def screenshot_b64(
897876
When the element is hidden, or has no size, or is otherwise not capturable, a RuntimeError is raised
898877
899878
:param format: jpeg or png (defaults to jpeg)
900-
:type format: str
901879
:param scale: the scale of the screenshot, eg: 1 = size as is, 2 = double, 0.5 is half
902880
:return: screenshot data as base64 encoded
903881
:rtype: str
@@ -938,9 +916,7 @@ async def save_screenshot(
938916
When the element is hidden, or has no size, or is otherwise not capturable, a RuntimeError is raised
939917
940918
:param filename: uses this as the save path
941-
:type filename: PathLike
942919
:param format: jpeg or png (defaults to jpeg)
943-
:type format: str
944920
:param scale: the scale of the screenshot, eg: 1 = size as is, 2 = double, 0.5 is half
945921
:return: the path/filename of saved screenshot
946922
:rtype: str
@@ -977,10 +953,7 @@ async def flash(self, duration: typing.Union[float, int] = 0.5) -> None:
977953
"""
978954
displays for a short time a red dot on the element (only if the element itself is visible)
979955
980-
:param coords: x,y
981-
:type coords: x,y
982956
:param duration: seconds (default 0.5)
983-
:type duration:
984957
:return:
985958
:rtype:
986959
"""

zendriver/core/expect.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@ class BaseRequestExpectation:
1313
based on a URL pattern. It sets up handlers for request and response events and provides
1414
properties to access the request, response, and response body.
1515
:param tab: The Tab instance to monitor.
16-
:type tab: Tab
1716
:param url_pattern: The URL pattern to match requests and responses.
18-
:type url_pattern: Union[str, re.Pattern[str]]
1917
"""
2018

2119
def __init__(self, tab: Connection, url_pattern: Union[str, re.Pattern[str]]):
@@ -36,7 +34,6 @@ async def _request_handler(self, event: cdp.network.RequestWillBeSent) -> None:
3634
"""
3735
Internal handler for request events.
3836
:param event: The request event.
39-
:type event: cdp.network.RequestWillBeSent
4037
"""
4138
if re.fullmatch(self.url_pattern, event.request.url):
4239
self._remove_request_handler()
@@ -47,7 +44,6 @@ async def _response_handler(self, event: cdp.network.ResponseReceived) -> None:
4744
"""
4845
Internal handler for response events.
4946
:param event: The response event.
50-
:type event: cdp.network.ResponseReceived
5147
"""
5248
if event.request_id == self.request_id:
5349
self._remove_response_handler()
@@ -59,7 +55,6 @@ async def _loading_finished_handler(
5955
"""
6056
Internal handler for loading finished events.
6157
:param event: The loading finished event.
62-
:type event: cdp.network.LoadingFinished
6358
"""
6459
if event.request_id == self.request_id:
6560
self._remove_loading_finished_handler()
@@ -159,9 +154,7 @@ class RequestExpectation(BaseRequestExpectation):
159154
Class for handling request expectations.
160155
This class extends `BaseRequestExpectation` and provides a property to access the matched request.
161156
:param tab: The Tab instance to monitor.
162-
:type tab: Tab
163157
:param url_pattern: The URL pattern to match requests.
164-
:type url_pattern: Union[str, re.Pattern[str]]
165158
"""
166159

167160
@property
@@ -179,9 +172,7 @@ class ResponseExpectation(BaseRequestExpectation):
179172
Class for handling response expectations.
180173
This class extends `BaseRequestExpectation` and provides a property to access the matched response.
181174
:param tab: The Tab instance to monitor.
182-
:type tab: Tab
183175
:param url_pattern: The URL pattern to match responses.
184-
:type url_pattern: Union[str, re.Pattern[str]]
185176
"""
186177

187178
@property

0 commit comments

Comments
 (0)