Skip to content

Libdoc: Using python decorator for keyword generates incorrect documentation #4058

@amittendulkar

Description

@amittendulkar

I am using a python library with a decorator for the purpose of logging all arguments passed to any keyword like below (using RobotFramework 4.0.1),

# MyLib.py
from robot.api.logger import info, debug

def log_func(func):
  def inner1(*args, **kwargs):
    info(f'Inside {func.__name__}')
    debug(f'Arguments: {args}, {kwargs}')
    r_val = func(*args, **kwargs)
    info(f'Exiting {func.__name__}')
    return r_val

  return inner1


class MyLib:
  @staticmethod
  @log_func
  def activate_config_file(arg1: str = 'val1', arg2: int = 0):
    # Do something with the arguments

  # other keywords

When I try to generate the documentation for activate_config_file keyword I get the following documentation,
image

It seems the decorator is coming in the way while deciding the arguments. How can we overcome this issue?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions