From 6007593e2621b780f84581bade47f0a64d16b439 Mon Sep 17 00:00:00 2001 From: hellmanj Date: Fri, 21 Nov 2014 17:30:23 -0500 Subject: [PATCH 1/2] make libdoc work a bit better --- deploy-ghpages.py | 2 +- robotpageobjects/base.py | 12 ++++++------ robotpageobjects/page.py | 22 ++++++++++++++-------- 3 files changed, 21 insertions(+), 15 deletions(-) diff --git a/deploy-ghpages.py b/deploy-ghpages.py index f601923..794cb8e 100755 --- a/deploy-ghpages.py +++ b/deploy-ghpages.py @@ -29,7 +29,7 @@ dir = mkdtemp() check_call("git clone --branch %s %s %s" % (deploy_branch, repo, dir), shell=True) chdir(dir) -check_call("python -m robot.libdoc robotpageobjects.page.Page index.html", shell=True) +check_call("python -m robot.libdoc robotpageobjects.Page index.html", shell=True) print "Docs built successfully" check_call("git config user.name '%s'" % getenv('GIT_NAME'), shell=True) check_call("git config user.email '%s'" % getenv('GIT_EMAIL'), shell=True) diff --git a/robotpageobjects/base.py b/robotpageobjects/base.py index 98cdae9..a4e71b3 100755 --- a/robotpageobjects/base.py +++ b/robotpageobjects/base.py @@ -83,12 +83,12 @@ def get_robot_aliases(cls, name, pageobject_name): """ ret = [] - # Look through the alias dict if not in libdoc. If there is an alias, add the aliased version to what is returned. - if not in_ld: - if name in cls._aliases: - 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. + # Look through the alias dict. If there is an alias, add the aliased version to what is returned. + if name in cls._aliases: + 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)) # Add the plain name of the keyword. diff --git a/robotpageobjects/page.py b/robotpageobjects/page.py index 0558de0..a520caf 100755 --- a/robotpageobjects/page.py +++ b/robotpageobjects/page.py @@ -27,7 +27,7 @@ from sig import get_method_sig from .context import Context from . import exceptions -from .base import _ComponentsManagerMeta, not_keyword, robot_alias, _BaseActions, _Keywords, Override, _SelectorsManager, _ComponentsManager +from .base import _ComponentsManagerMeta, not_keyword, _BaseActions, _Keywords, _SelectorsManager, _ComponentsManager class _PageMeta(_ComponentsManagerMeta): @@ -120,7 +120,6 @@ class Page(_BaseActions, _SelectorsManager, _ComponentsManager): """ __metaclass__ = _PageMeta - def __init__(self): """ Initializes the pageobject_name variable, which is used by the _Keywords class @@ -144,7 +143,12 @@ def __init__(self): @staticmethod @not_keyword def _titleize(str): - return re.sub(r"(\w)([A-Z])", r"\1 \2", str) + """ + Converts camel case to title case + :param str: camel case string + :return: title case string + """ + return re.sub('([a-z0-9])([A-Z])', r'\1 \2', re.sub(r"(.)([A-Z][a-z]+)", r'\1 \2', str)) @staticmethod @not_keyword @@ -271,16 +275,18 @@ def get_keyword_documentation(self, kwname): :return: a documentation string for kwname """ if kwname == '__intro__': - doc = """\n + docstring = self.__doc__ if self.__doc__ else '' + s2l_link = """\n All keywords listed in the Selenium2Library documentation are also available in this Page Object. See http://rtomac.github.io/robotframework-selenium2library/doc/Selenium2Library.html """ - return self.__doc__ + doc + return docstring + s2l_link kw = getattr(self, kwname, None) - doc = kw.__doc__ if kw.__doc__ else '' + alias = '' if kwname in _Keywords._aliases: - doc = '*Alias: %s*\n\n' % _Keywords.get_robot_aliases(kwname, self._underscore(self.name))[0].replace('_', ' ').title() + doc - return doc + alias = '*Alias: %s*\n\n' % _Keywords.get_robot_aliases(kwname, self._underscore(self.name))[0].replace('_', ' ').title() + docstring = kw.__doc__ if kw.__doc__ else '' + return alias + docstring @not_keyword def get_keyword_arguments(self, kwname): From bac7d125eb39aadd04b6274e88c857f82c4d3ca5 Mon Sep 17 00:00:00 2001 From: hellmanj Date: Fri, 21 Nov 2014 17:49:50 -0500 Subject: [PATCH 2/2] oops guess we do need that --- robotpageobjects/page.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/robotpageobjects/page.py b/robotpageobjects/page.py index a520caf..35c52f8 100755 --- a/robotpageobjects/page.py +++ b/robotpageobjects/page.py @@ -27,7 +27,7 @@ from sig import get_method_sig from .context import Context from . import exceptions -from .base import _ComponentsManagerMeta, not_keyword, _BaseActions, _Keywords, _SelectorsManager, _ComponentsManager +from .base import _ComponentsManagerMeta, not_keyword, robot_alias, _BaseActions, _Keywords, Override, _SelectorsManager, _ComponentsManager class _PageMeta(_ComponentsManagerMeta):