Skip to content

DOC: Fixing some doc warnings #26786

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jun 12, 2019
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions doc/source/reference/indexing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -493,3 +493,18 @@ Methods
PeriodIndex.asfreq
PeriodIndex.strftime
PeriodIndex.to_timestamp

RangeIndex
----------
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking more closely at the log output and our current docs -> RangeIndex is actually already included in the API docs in the "Numeric Index" above (I think it makes sense to have it in the numeric section)

But the question is then: why did we get those warnings in the current doc build on master. It might be that we need to add the attributes here as well (not fully sure)

.. autosummary::
:toctree: api/
:template: autosummary/class_without_autosummary.rst

RangeIndex

Methods
~~~~~~~
.. autosummary::
:toctree: api/

RangeIndex.from_range
1 change: 1 addition & 0 deletions doc/source/reference/series.rst
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,7 @@ strings and apply several methods to it. These can be accessed like
Series.str
Series.cat
Series.dt
Series.sparse
Index.str

.. _api.series.cat:
Expand Down
2 changes: 1 addition & 1 deletion doc/source/user_guide/missing_data.rst
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ at the new values.
.. _missing_data.interp_limits:

Interpolation Limits
^^^^^^^^^^^^^^^^^^^^
--------------------

Like other pandas fill methods, :meth:`~DataFrame.interpolate` accepts a ``limit`` keyword
argument. Use this argument to limit the number of consecutive ``NaN`` values
Expand Down
2 changes: 1 addition & 1 deletion doc/source/user_guide/reshaping.rst
Original file line number Diff line number Diff line change
Expand Up @@ -705,7 +705,7 @@ handling of NaN:
you can use ``df["cat_col"] = pd.Categorical(df["col"])`` or
``df["cat_col"] = df["col"].astype("category")``. For full docs on :class:`~pandas.Categorical`,
see the :ref:`Categorical introduction <categorical>` and the
:ref:`API documentation <api.categorical>`.
:ref:`API documentation <api.arrays.categorical>`.

Examples
--------
Expand Down
4 changes: 2 additions & 2 deletions doc/source/whatsnew/v0.20.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ IntervalIndex

pandas has gained an ``IntervalIndex`` with its own dtype, ``interval`` as well as the ``Interval`` scalar type. These allow first-class support for interval
notation, specifically as a return type for the categories in :func:`cut` and :func:`qcut`. The ``IntervalIndex`` allows some unique indexing, see the
:ref:`docs <indexing.intervallindex>`. (:issue:`7640`, :issue:`8625`)
:ref:`docs <api.intervalindex>`. (:issue:`7640`, :issue:`8625`)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
:ref:`docs <api.intervalindex>`. (:issue:`7640`, :issue:`8625`)
:ref:`docs <advanced.intervalindex>`. (:issue:`7640`, :issue:`8625`)

I think the original intent was to refer to the user guide section, which is moved to "advanced.rst" (we actually shouldn't have renamed that label in the first place ..)


.. warning::

Expand Down Expand Up @@ -1564,7 +1564,7 @@ Removal of prior version deprecations/changes

- The ``pandas.rpy`` module is removed. Similar functionality can be accessed
through the `rpy2 <https://rpy2.readthedocs.io/>`__ project.
See the :ref:`R interfacing docs <rpy>` for more details.
See the :ref:`R interfacing docs <https://pandas.pydata.org/pandas-docs/version/0.20/r_interface.html>`__ for more details.
- The ``pandas.io.ga`` module with a ``google-analytics`` interface is removed (:issue:`11308`).
Similar functionality can be found in the `Google2Pandas <https://github.com/panalysis/Google2Pandas>`__ package.
- ``pd.to_datetime`` and ``pd.to_timedelta`` have dropped the ``coerce`` parameter in favor of ``errors`` (:issue:`13602`)
Expand Down
2 changes: 1 addition & 1 deletion doc/source/whatsnew/v0.25.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ column selection, the values can just be the functions to apply
This type of aggregation is the recommended alternative to the deprecated behavior when passing
a dict to a Series groupby aggregation (:ref:`whatsnew_0200.api_breaking.deprecate_group_agg_dict`).

See :ref:`_groupby.aggregate.named` for more.
See :ref:`groupby.aggregate.named` for more.

.. _whatsnew_0250.enhancements.other:

Expand Down
2 changes: 1 addition & 1 deletion pandas/core/arrays/datetimelike.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ class TimelikeOps:

.. versionadded:: 0.24.0

nonexistent : 'shift_forward', 'shift_backward, 'NaT', timedelta, \
nonexistent : 'shift_forward', 'shift_backward', 'NaT', timedelta, \
default 'raise'
A nonexistent time does not exist in a particular timezone
where clocks moved forward due to DST.
Expand Down
28 changes: 14 additions & 14 deletions pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -10283,8 +10283,8 @@ def _doc_parms(cls):
Returns
-------
%(name1)s or %(name2)s (if level specified)\
%(see_also)s
%(examples)s\
%(see_also)s\
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have an expectation that substituted sections are responsible for line breaks? I feel like this has caused a few issues throughout code base curious if you have thoughts

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@datapythonista I might already have fixed this one in https://github.com/pandas-dev/pandas/pull/26780/files, but by adding a extra newline in the "see also" string instead of here.
My reasoning was that if you do it here, and no see also is introduced, you might get too many empty lines (but didn't try that actually, so not sure this is correct)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is trickier than what it looks, our validation complains if there are two line breaks together, and also a missing line break at the end. And we don't fail the validation, but we get warnings (and incorrect rendering) if the line break is missing before a section title, as the title is not detected.

It took me a while to find a working solution for all the cases, I think the one here is the only possible one, there are many docstrings affected by this.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I trust you here ;-) I only fixed that single case (of min/max I think), and didn't check the interaction with fixing others. But you might need to revert my change to get it working with master.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the change you did was correct and is still needed, it just didn't address all the cases.

%(examples)s
"""

_num_ddof_doc = """
Expand Down Expand Up @@ -10427,7 +10427,8 @@ def _doc_parms(cls):

Returns
-------
%(name1)s or %(name2)s\n
%(name1)s or %(name2)s

See Also
--------
core.window.Expanding.%(accum_func_name)s : Similar functionality
Expand Down Expand Up @@ -10788,10 +10789,10 @@ def _doc_parms(cls):
Series([], dtype: bool)
"""

_shared_docs['stat_func_example'] = """\
_shared_docs['stat_func_example'] = """

Examples
--------

>>> idx = pd.MultiIndex.from_arrays([
... ['warm', 'warm', 'cold', 'cold'],
... ['dog', 'falcon', 'fish', 'spider']],
Expand Down Expand Up @@ -10820,8 +10821,7 @@ def _doc_parms(cls):
blooded
warm {level_output_0}
cold {level_output_1}
Name: legs, dtype: int64
"""
Name: legs, dtype: int64"""

_sum_examples = _shared_docs['stat_func_example'].format(
stat_func='sum',
Expand All @@ -10831,6 +10831,7 @@ def _doc_parms(cls):
level_output_1=8)

_sum_examples += """

By default, the sum of an empty or all-NA Series is ``0``.

>>> pd.Series([]).sum() # min_count=0 is the default
Expand All @@ -10849,8 +10850,7 @@ def _doc_parms(cls):
0.0

>>> pd.Series([np.nan]).sum(min_count=1)
nan
"""
nan"""

_max_examples = _shared_docs['stat_func_example'].format(
stat_func='max',
Expand All @@ -10867,6 +10867,7 @@ def _doc_parms(cls):
level_output_1=0)

_stat_func_see_also = """

See Also
--------
Series.sum : Return the sum.
Expand All @@ -10878,10 +10879,10 @@ def _doc_parms(cls):
DataFrame.min : Return the minimum over the requested axis.
DataFrame.max : Return the maximum over the requested axis.
DataFrame.idxmin : Return the index of the minimum over the requested axis.
DataFrame.idxmax : Return the index of the maximum over the requested axis.
"""
DataFrame.idxmax : Return the index of the maximum over the requested axis."""

_prod_examples = """

_prod_examples = """\
Examples
--------
By default, the product of an empty or all-NA Series is ``1``
Expand All @@ -10901,8 +10902,7 @@ def _doc_parms(cls):
1.0

>>> pd.Series([np.nan]).prod(min_count=1)
nan
"""
nan"""

_min_count_stub = """\
min_count : int, default 0
Expand Down
6 changes: 0 additions & 6 deletions pandas/core/indexes/range.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,6 @@ class RangeIndex(Int64Index):
copy : bool, default False
Unused, accepted for homogeneity with other index types.

Attributes
----------
start
stop
step
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why remove those?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

those are not actual attributes for what I saw, I'll revert here anyway, and let's take care of RangeIndex in a separate PR

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They recently got added as actual attributes, IIRC

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you're right, I think I didn't test in master


Methods
-------
from_range
Expand Down