Skip to content

Commit

Permalink
chore: add missing methods and use a set for it (#184)
Browse files Browse the repository at this point in the history
* chore: add missing methods and use a set for it

* fix: exit script as failure if methods are missing
  • Loading branch information
mxschmitt authored Sep 3, 2020
1 parent 4d367d9 commit f5f9614
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 2 deletions.
9 changes: 9 additions & 0 deletions playwright/async_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -810,6 +810,15 @@ class ElementHandle(JSHandle):
def __init__(self, obj: ElementHandleImpl):
super().__init__(obj)

def toString(self) -> str:
"""ElementHandle.toString
Returns
-------
str
"""
return mapping.from_maybe_impl(self._impl_obj.toString())

def asElement(self) -> typing.Union["ElementHandle", NoneType]:
"""ElementHandle.asElement
Expand Down
3 changes: 3 additions & 0 deletions playwright/element_handle.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ def __init__(
) -> None:
super().__init__(parent, type, guid, initializer)

def toString(self) -> str:
return self._preview

def asElement(self) -> Optional["ElementHandle"]:
return self

Expand Down
9 changes: 9 additions & 0 deletions playwright/sync_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -830,6 +830,15 @@ class ElementHandle(JSHandle):
def __init__(self, obj: ElementHandleImpl):
super().__init__(obj)

def toString(self) -> str:
"""ElementHandle.toString
Returns
-------
str
"""
return mapping.from_maybe_impl(self._impl_obj.toString())

def asElement(self) -> typing.Union["ElementHandle", NoneType]:
"""ElementHandle.asElement
Expand Down
35 changes: 33 additions & 2 deletions scripts/documentation_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,29 @@
},
}

expected_mismatches = [
"Download.createReadStream",
"Browser.startTracing",
"Browser.stopTracing",
"Logger.log",
"BrowserContext.setHTTPCredentials", # deprecated
"BrowserContext.serviceWorkers", # CR only (and the following)
"BrowserContext.backgroundPages",
"Browser.newBrowserCDPSession",
"Page.coverage",
"Coverage.startCSSCoverage",
"Coverage.stopCSSCoverage",
"Coverage.startJSCoverage",
"Coverage.stopJSCoverage",
"BrowserContext.newCDPSession",
"Logger.isEnabled",
"BrowserServer.kill", # not relevant for RPC clients (and the following)
"BrowserType.launchServer",
"BrowserServer.close",
"BrowserServer.process",
"BrowserServer.wsEndpoint",
]


class DocumentationProvider:
def __init__(self) -> None:
Expand Down Expand Up @@ -371,6 +394,7 @@ def rewrite_param_name(self, fqname: str, method_name: str, name: str) -> str:
return name

def print_remainder(self) -> None:
remainders = set()
for [class_name, value] in self.api.items():
class_name = re.sub(r"Chromium(.*)", r"\1", class_name)
class_name = re.sub(r"WebKit(.*)", r"\1", class_name)
Expand All @@ -379,8 +403,15 @@ def print_remainder(self) -> None:
if method["kind"] == "event":
continue
entry = f"{class_name}.{method_name}"
if entry not in self.printed_entries:
print(f"Method not implemented: {entry}", file=stderr)
if (
entry not in self.printed_entries
and entry not in expected_mismatches
):
remainders.add(f"Method not implemented: {entry}")
for remainder in remainders:
print(remainder, file=stderr)
if len(remainders) > 0:
exit(1)


if __name__ == "__main__":
Expand Down
1 change: 1 addition & 0 deletions scripts/generate_async_api.py
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/usr/bin/env python
# Copyright (c) Microsoft Corporation.
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
1 change: 1 addition & 0 deletions scripts/generate_sync_api.py
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/usr/bin/env python
# Copyright (c) Microsoft Corporation.
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down

0 comments on commit f5f9614

Please sign in to comment.