Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The source file of New Context in the documentation is wrong #2382

Closed
mardukbp opened this issue Oct 18, 2022 · 7 comments
Closed

The source file of New Context in the documentation is wrong #2382

mardukbp opened this issue Oct 18, 2022 · 7 comments

Comments

@mardukbp
Copy link

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.

@aaltat
Copy link
Collaborator

aaltat commented Oct 18, 2022

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.

@allcontributors
Copy link
Contributor

@aaltat

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

@mardukbp already contributed before to bug

@d-biehl
Copy link

d-biehl commented Oct 18, 2022

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
Copy link

d-biehl commented Oct 18, 2022

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.

@aaltat
Copy link
Collaborator

aaltat commented Oct 24, 2022

sorry for delayed answer.

Could you provide PR in the PLC side?

@aaltat
Copy link
Collaborator

aaltat commented Nov 5, 2022

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

@aaltat aaltat closed this as completed Nov 5, 2022
@aaltat
Copy link
Collaborator

aaltat commented Nov 5, 2022

New PLC will be used in next release #2412

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants