Skip to content

Commit f5cc28d

Browse files
committed
DOC: use substitution decorator for business month classes (pandas-dev#25828)
1 parent f2bcb9f commit f5cc28d

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

doc/source/whatsnew/v0.25.0.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ Other Enhancements
3535
- :class:`RangeIndex` has gained :attr:`~RangeIndex.start`, :attr:`~RangeIndex.stop`, and :attr:`~RangeIndex.step` attributes (:issue:`25710`)
3636
- :class:`datetime.timezone` objects are now supported as arguments to timezone methods and constructors (:issue:`25065`)
3737
- :meth:`DataFrame.query` and :meth:`DataFrame.eval` now supports quoting column names with backticks to refer to names with spaces (:issue:`6508`)
38+
- :class:`CustomBusinessMonthBegin` and :class:`CustomBusinessMonthEnd` now use the substitution pattern for docstring sharing
3839

3940
.. _whatsnew_0250.api_breaking:
4041

pandas/tseries/offsets.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import pandas.compat as compat
1717
from pandas.compat import range
1818
from pandas.errors import AbstractMethodError
19-
from pandas.util._decorators import cache_readonly
19+
from pandas.util._decorators import cache_readonly, Substitution, Appender
2020

2121
from pandas.core.dtypes.generic import ABCPeriod
2222

@@ -973,7 +973,7 @@ class BusinessMonthBegin(MonthOffset):
973973
class _CustomBusinessMonth(_CustomMixin, BusinessMixin, MonthOffset):
974974
"""
975975
DateOffset subclass representing one custom business month, incrementing
976-
between [BEGIN/END] of month dates.
976+
between %(bound)s of month dates.
977977
978978
Parameters
979979
----------
@@ -1053,18 +1053,15 @@ def apply(self, other):
10531053
return result
10541054

10551055

1056+
@Substitution(bound="end")
1057+
@Appender(_CustomBusinessMonth.__doc__)
10561058
class CustomBusinessMonthEnd(_CustomBusinessMonth):
1057-
# TODO(py27): Replace condition with Subsitution after dropping Py27
1058-
if _CustomBusinessMonth.__doc__:
1059-
__doc__ = _CustomBusinessMonth.__doc__.replace('[BEGIN/END]', 'end')
10601059
_prefix = 'CBM'
10611060

10621061

1062+
@Substitution(bound="beginning")
1063+
@Appender(_CustomBusinessMonth.__doc__)
10631064
class CustomBusinessMonthBegin(_CustomBusinessMonth):
1064-
# TODO(py27): Replace condition with Subsitution after dropping Py27
1065-
if _CustomBusinessMonth.__doc__:
1066-
__doc__ = _CustomBusinessMonth.__doc__.replace('[BEGIN/END]',
1067-
'beginning')
10681065
_prefix = 'CBMS'
10691066

10701067

0 commit comments

Comments
 (0)