From ec3e5474daa02444b695ca876b71b339e7bc4916 Mon Sep 17 00:00:00 2001 From: hellmanj Date: Thu, 15 Jan 2015 11:26:06 -0500 Subject: [PATCH 1/3] clean up how libdoc is generated a bit --- robotpageobjects/base.py | 6 +----- robotpageobjects/page.py | 11 +++++++++-- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/robotpageobjects/base.py b/robotpageobjects/base.py index b364ec1..ef760ea 100755 --- a/robotpageobjects/base.py +++ b/robotpageobjects/base.py @@ -16,9 +16,6 @@ from .context import Context from .optionhandler import OptionHandler -# determine if libdoc is running to avoid generating docs for automatically generated aliases -ld = 'libdoc' -in_ld = any([ld in str(x) for x in inspect.stack()]) class _Keywords(object): """ @@ -89,8 +86,7 @@ def get_robot_aliases(cls, name, pageobject_name): ret.append(cls._aliases[name].replace(cls._alias_delimiter, "_" + pageobject_name + "_")) else: # If not aliased, add the keyword name with the page object name at the end. - if not in_ld: - ret.append("%s_%s" % (name, pageobject_name)) + ret.append("%s_%s" % (name, pageobject_name)) # Add the plain name of the keyword. ret.append(name) diff --git a/robotpageobjects/page.py b/robotpageobjects/page.py index f4a7266..810a6f0 100755 --- a/robotpageobjects/page.py +++ b/robotpageobjects/page.py @@ -30,6 +30,10 @@ from .base import _ComponentsManagerMeta, not_keyword, robot_alias, _BaseActions, _Keywords, Override, _SelectorsManager, _ComponentsManager +# determine if libdoc is running to avoid generating docs for automatically generated aliases +ld = 'libdoc' +in_ld = any([ld in str(x) for x in inspect.stack()]) + class _PageMeta(_ComponentsManagerMeta): """Meta class that allows decorating of all page object methods with must_return decorator. This ensures that all page object @@ -193,7 +197,7 @@ def get_keyword_names(self): # Note that this will not check those classes' ancestors. # TODO: Check all S2L's ancestors. DCLT- for base in Selenium2Library.__bases__: - if func in base.__dict__.values(): + if name in [getattr(y, '__name__', None) for y in base.__dict__.values()]: in_s2l_base = True # Don't add methods belonging to S2L to the exposed keywords. if in_s2l_base: @@ -201,7 +205,10 @@ def get_keyword_names(self): elif inspect.ismethod(obj) and not name.startswith("_") and not _Keywords.is_method_excluded(name): # Add all methods that don't start with an underscore and were not marked with the # @not_keyword decorator. - keywords += _Keywords.get_robot_aliases(name, self._underscore(self.name)) + if not in_ld: + keywords += _Keywords.get_robot_aliases(name, self._underscore(self.name)) + else: + keywords.append(name) return keywords def _attempt_screenshot(self): From 2e6c65fad8bd1e326556438178d0216e431f167e Mon Sep 17 00:00:00 2001 From: hellmanj Date: Thu, 15 Jan 2015 11:56:20 -0500 Subject: [PATCH 2/3] fix for overrides in Page which are called by alias --- robotpageobjects/page.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/robotpageobjects/page.py b/robotpageobjects/page.py index 810a6f0..80c78f2 100755 --- a/robotpageobjects/page.py +++ b/robotpageobjects/page.py @@ -197,8 +197,12 @@ def get_keyword_names(self): # Note that this will not check those classes' ancestors. # TODO: Check all S2L's ancestors. DCLT- for base in Selenium2Library.__bases__: - if name in [getattr(y, '__name__', None) for y in base.__dict__.values()]: - in_s2l_base = True + if in_ld: + if name in [getattr(y, '__name__', None) for y in base.__dict__.values()]: + in_s2l_base = True + else: + if func in base.__dict__.values(): + in_s2l_base = True # Don't add methods belonging to S2L to the exposed keywords. if in_s2l_base: continue From 1cbf1a98f63acfe9aa165e3a066790aa26330544 Mon Sep 17 00:00:00 2001 From: hellmanj Date: Thu, 15 Jan 2015 14:48:03 -0500 Subject: [PATCH 3/3] don't remove s2l wrappers, but highlight wrapper in docstrings --- robotpageobjects/base.py | 4 ++-- robotpageobjects/page.py | 9 +++------ 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/robotpageobjects/base.py b/robotpageobjects/base.py index ef760ea..509d2d5 100755 --- a/robotpageobjects/base.py +++ b/robotpageobjects/base.py @@ -1039,8 +1039,8 @@ def _vars_match_template(template, vars): def location_should_be(self, expected_url): """ - Override Selenium2Library's location_should_be() method and intelligently - determine if the current browser url matches with the ending url or full url passed in the method. + Wrapper for Selenium2Library's location_should_be() method. Allows matching against the + baseurl if a partial url is given. :param url: Either complete url or partial url to be validated against :type url: str diff --git a/robotpageobjects/page.py b/robotpageobjects/page.py index 80c78f2..553ed9b 100755 --- a/robotpageobjects/page.py +++ b/robotpageobjects/page.py @@ -197,12 +197,8 @@ def get_keyword_names(self): # Note that this will not check those classes' ancestors. # TODO: Check all S2L's ancestors. DCLT- for base in Selenium2Library.__bases__: - if in_ld: - if name in [getattr(y, '__name__', None) for y in base.__dict__.values()]: - in_s2l_base = True - else: - if func in base.__dict__.values(): - in_s2l_base = True + if func in base.__dict__.values(): + in_s2l_base = True # Don't add methods belonging to S2L to the exposed keywords. if in_s2l_base: continue @@ -298,6 +294,7 @@ def get_keyword_documentation(self, kwname): if kwname in _Keywords._aliases: alias = '*Alias: %s*\n\n' % _Keywords.get_robot_aliases(kwname, self._underscore(self.name))[0].replace('_', ' ').title() docstring = kw.__doc__ if kw.__doc__ else '' + docstring = re.sub(r'(wrapper)', r'*\1*', docstring, flags=re.I) return alias + docstring @not_keyword