Skip to content

Commit

Permalink
DOC: scale parameters
Browse files Browse the repository at this point in the history
Scales that subclass a private class did not get the
superclass parameters documented unless the private
class was @documented too.
  • Loading branch information
has2k1 committed Nov 8, 2017
1 parent 5338d54 commit 9d2176b
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 9 deletions.
5 changes: 2 additions & 3 deletions plotnine/doctools.py
Original file line number Diff line number Diff line change
Expand Up @@ -502,10 +502,9 @@ def document(cls):
if cls.__doc__ is None:
return cls

end = cls.__name__.find('_')
basename = cls.__name__[:end]
baseclass_name = cls.mro()[-2].__name__

try:
return DOC_FUNCTIONS[basename](cls)
return DOC_FUNCTIONS[baseclass_name](cls)
except KeyError:
return cls
15 changes: 10 additions & 5 deletions plotnine/scales/scale_manual.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,14 @@
from .scale import scale_discrete


@document
class _scale_manual(scale_discrete):
"""
Abstract class for manual scales
Parameters
----------
{superclass_parameters}
"""
def __init__(self, values, **kwargs):
self.palette = manual_pal(values)
Expand All @@ -24,7 +29,7 @@ class scale_color_manual(_scale_manual):
Parameters
----------
values : array_like
Colors that make up the palette
Colors that make up the palette.
{superclass_parameters}
"""
aesthetics = ['color']
Expand All @@ -38,7 +43,7 @@ class scale_fill_manual(_scale_manual):
Parameters
----------
values : array_like
Colors that make up the palette
Colors that make up the palette.
{superclass_parameters}
"""
aesthetics = ['fill']
Expand Down Expand Up @@ -72,7 +77,7 @@ class scale_linetype_manual(_scale_manual):
Parameters
----------
values : array_like
Linetypes that make up the palette
Linetypes that make up the palette.
{superclass_parameters}
See Also
Expand All @@ -91,7 +96,7 @@ class scale_alpha_manual(_scale_manual):
----------
values : array_like
Alpha values (in the [0, 1] range) that make up
the palette
the palette.
{superclass_parameters}
"""
aesthetics = ['alpha']
Expand All @@ -105,7 +110,7 @@ class scale_size_manual(_scale_manual):
Parameters
----------
values : array_like
Sizes that make up the palette
Sizes that make up the palette.
{superclass_parameters}
"""
aesthetics = ['size']
Expand Down
10 changes: 10 additions & 0 deletions plotnine/scales/scale_xy.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,14 @@
# scale_position_discrete and scale_position_continuous
# are intermediate base classes where the required overriding
# is done
@document
class scale_position_discrete(scale_discrete):
"""
Base class for discrete position scales
Parameters
----------
{superclass_parameters}
"""
# All positions have no guide
guide = None
Expand Down Expand Up @@ -106,9 +111,14 @@ def dimension(self, expand=(0, 0, 0, 0)):
return a.min(), a.max()


@document
class scale_position_continuous(scale_continuous):
"""
Base class for continuous position scales
Parameters
----------
{superclass_parameters}
"""
# All positions have no guide
guide = None
Expand Down
2 changes: 1 addition & 1 deletion plotnine/tests/test_doctools.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class mixin(object):


@document
class scale_expand_earth(scale_expand, mixin):
class scale_expand_earth(mixin, scale_expand):
"""
Expand Earth
Expand Down

0 comments on commit 9d2176b

Please sign in to comment.