robotframework-browser icon indicating copy to clipboard operation
robotframework-browser copied to clipboard

The source file of New Context in the documentation is wrong

Open mardukbp opened this issue 3 years ago • 4 comments

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:

  1. Execute libdoc Browser browser.json
  2. 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.

mardukbp avatar Oct 18 '22 14:10 mardukbp

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.

aaltat avatar Oct 18 '22 14:10 aaltat

@aaltat

I've put up a pull request to add @you! :tada:

@mardukbp already contributed before to bug

allcontributors[bot] avatar Oct 18 '22 14:10 allcontributors[bot]

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

d-biehl avatar Oct 18 '22 14:10 d-biehl

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.

d-biehl avatar Oct 18 '22 14:10 d-biehl

sorry for delayed answer.

Could you provide PR in the PLC side?

aaltat avatar Oct 24 '22 20:10 aaltat

This should be now fixed in PLC side, closing this issue too.

aaltat avatar Nov 05 '22 16:11 aaltat

New PLC will be used in next release #2412

aaltat avatar Nov 05 '22 17:11 aaltat