The source file of New Context in the documentation is wrong
Describe the bug
In the documentation generated with libdoc (in JSON or libspec format), the source file for the keyword New Context is Browser/utils/deprecated.py.
To Reproduce Steps to reproduce the behavior:
- Execute
libdoc Browser browser.json - Search for "name": "New Context" and then for "source":
Expected behavior
The source of the keyword New Context is Browser/keywords/playwright_state.py
Screenshots If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
- OS: Windows 10
- Browser Chrome
- Version 103
Smartphone (please complete the following information):
- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]
Additional context
The keyword New Context has the following definition
@keyword(tags=("Setter", "BrowserControl"))
@attribute_warning(
old_args=("videosPath", "videoSize"), new_args=("recordVideo", "recordVideo")
)
def new_context(
self,
...
)
Apparently, libdoc expects that the line after the keyword decorator is a function definition.
Thank you for reporting problem, the bug most likely relies on the PLC side and I raised issue also there.
@allcontributors please add @mardukbp for bugs.
After some investigation from my side, maybe it's not a problem of BrowserLibrary, I think it is more a problem of PythonLibCore.
Your attribute_warning decorator uses functool.wrap to but it is not handled in PythonLibCore
This line https://github.com/robotframework/PythonLibCore/blob/ef35336fbc895d3d329a6d61be52501c2a5a54d4/src/robotlibcore.py#L142 must unwrap the method using inspect.unwrap like this. And maybe it should also use inspect.getsourcefile instead of inspect.getfile because getsourcefile returns only returns sources not compiled files
changing the given line to
return os.path.normpath(inspect.getsourcefile(inspect.unwrap(method)))
should do the trick and it is also the same like robotframework gets the source for a keyword.
sorry for delayed answer.
Could you provide PR in the PLC side?
This should be now fixed in PLC side, closing this issue too.
New PLC will be used in next release #2412