Skip to content

Commit 23597cd

Browse files
committed
Merge pull request #4 from ncbi/better-libdoc
make libdoc work a bit better
2 parents 1437329 + bac7d12 commit 23597cd

File tree

3 files changed

+20
-14
lines changed

3 files changed

+20
-14
lines changed

deploy-ghpages.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
dir = mkdtemp()
3030
check_call("git clone --branch %s %s %s" % (deploy_branch, repo, dir), shell=True)
3131
chdir(dir)
32-
check_call("python -m robot.libdoc robotpageobjects.page.Page index.html", shell=True)
32+
check_call("python -m robot.libdoc robotpageobjects.Page index.html", shell=True)
3333
print "Docs built successfully"
3434
check_call("git config user.name '%s'" % getenv('GIT_NAME'), shell=True)
3535
check_call("git config user.email '%s'" % getenv('GIT_EMAIL'), shell=True)

robotpageobjects/base.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,12 @@ def get_robot_aliases(cls, name, pageobject_name):
8383
"""
8484
ret = []
8585

86-
# Look through the alias dict if not in libdoc. If there is an alias, add the aliased version to what is returned.
87-
if not in_ld:
88-
if name in cls._aliases:
89-
ret.append(cls._aliases[name].replace(cls._alias_delimiter, "_" + pageobject_name + "_"))
90-
else:
91-
# If not aliased, add the keyword name with the page object name at the end.
86+
# Look through the alias dict. If there is an alias, add the aliased version to what is returned.
87+
if name in cls._aliases:
88+
ret.append(cls._aliases[name].replace(cls._alias_delimiter, "_" + pageobject_name + "_"))
89+
else:
90+
# If not aliased, add the keyword name with the page object name at the end.
91+
if not in_ld:
9292
ret.append("%s_%s" % (name, pageobject_name))
9393

9494
# Add the plain name of the keyword.

robotpageobjects/page.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,6 @@ class Page(_BaseActions, _SelectorsManager, _ComponentsManager):
120120
"""
121121
__metaclass__ = _PageMeta
122122

123-
124123
def __init__(self):
125124
"""
126125
Initializes the pageobject_name variable, which is used by the _Keywords class
@@ -144,7 +143,12 @@ def __init__(self):
144143
@staticmethod
145144
@not_keyword
146145
def _titleize(str):
147-
return re.sub(r"(\w)([A-Z])", r"\1 \2", str)
146+
"""
147+
Converts camel case to title case
148+
:param str: camel case string
149+
:return: title case string
150+
"""
151+
return re.sub('([a-z0-9])([A-Z])', r'\1 \2', re.sub(r"(.)([A-Z][a-z]+)", r'\1 \2', str))
148152

149153
@staticmethod
150154
@not_keyword
@@ -271,16 +275,18 @@ def get_keyword_documentation(self, kwname):
271275
:return: a documentation string for kwname
272276
"""
273277
if kwname == '__intro__':
274-
doc = """\n
278+
docstring = self.__doc__ if self.__doc__ else ''
279+
s2l_link = """\n
275280
All keywords listed in the Selenium2Library documentation are also available in this Page Object.
276281
See http://rtomac.github.io/robotframework-selenium2library/doc/Selenium2Library.html
277282
"""
278-
return self.__doc__ + doc
283+
return docstring + s2l_link
279284
kw = getattr(self, kwname, None)
280-
doc = kw.__doc__ if kw.__doc__ else ''
285+
alias = ''
281286
if kwname in _Keywords._aliases:
282-
doc = '*Alias: %s*\n\n' % _Keywords.get_robot_aliases(kwname, self._underscore(self.name))[0].replace('_', ' ').title() + doc
283-
return doc
287+
alias = '*Alias: %s*\n\n' % _Keywords.get_robot_aliases(kwname, self._underscore(self.name))[0].replace('_', ' ').title()
288+
docstring = kw.__doc__ if kw.__doc__ else ''
289+
return alias + docstring
284290

285291
@not_keyword
286292
def get_keyword_arguments(self, kwname):

0 commit comments

Comments
 (0)