Skip to content

DOC: document subclasses in API docs with selection of specific methods/attributes #18202

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 34 commits into from
Nov 15, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
500ab71
DOC: Remove numpydoc hack, list methods explicitly
TomAugspurger Nov 9, 2017
257fc8a
[WIP]: API doc
TomAugspurger Nov 9, 2017
d59c0b5
More explicit methods
TomAugspurger Nov 10, 2017
cb57504
More updates
TomAugspurger Nov 10, 2017
5e4cf6d
typos
TomAugspurger Nov 10, 2017
346a73b
Merge remote-tracking branch 'upstream/master' into api-doc-methods
TomAugspurger Nov 11, 2017
b5902ff
more
TomAugspurger Nov 12, 2017
af1e866
Merge remote-tracking branch 'upstream/master' into api-doc-methods
TomAugspurger Nov 12, 2017
874aefe
Add accessors to hidden
TomAugspurger Nov 12, 2017
32c2816
Remove dupe section
TomAugspurger Nov 12, 2017
38673bd
Added Categorical
TomAugspurger Nov 12, 2017
e30335e
More fixups
TomAugspurger Nov 13, 2017
38efdcb
More cleanups
TomAugspurger Nov 13, 2017
5e8bcbe
PEP8
TomAugspurger Nov 13, 2017
8695727
Hide more items
TomAugspurger Nov 13, 2017
4476a5f
Fixups
TomAugspurger Nov 13, 2017
a5005e1
Matching NaT
TomAugspurger Nov 13, 2017
aa92592
Fix typo
TomAugspurger Nov 13, 2017
8841035
Merge remote-tracking branch 'upstream/master' into api-doc-methods
TomAugspurger Nov 13, 2017
1527cdb
PEP8
TomAugspurger Nov 13, 2017
7ca3434
Fix ordering, escaping
TomAugspurger Nov 14, 2017
5a0e10e
Add notes on contributing
TomAugspurger Nov 14, 2017
c8504d1
Fix kwds again
TomAugspurger Nov 14, 2017
f7ed015
Wording
TomAugspurger Nov 14, 2017
094f6f6
Fix ref
TomAugspurger Nov 14, 2017
1c2160f
Another fixup
TomAugspurger Nov 14, 2017
6e99be2
Series of dtype category
TomAugspurger Nov 14, 2017
3bd03db
Move more methods to hidden
TomAugspurger Nov 14, 2017
ba257cc
Hide get_loc
TomAugspurger Nov 14, 2017
169e833
Merge remote-tracking branch 'upstream/master' into api-doc-methods
TomAugspurger Nov 14, 2017
f846713
Just hide attributes
TomAugspurger Nov 14, 2017
141107a
Cleanup hidden
TomAugspurger Nov 14, 2017
3a224be
remove some methods from api.rst
jorisvandenbossche Nov 15, 2017
34834fa
fix warning for float64index
jorisvandenbossche Nov 15, 2017
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
Prev Previous commit
Next Next commit
Add notes on contributing
  • Loading branch information
TomAugspurger committed Nov 14, 2017
commit 5a0e10e5dc7787df94cd55cf25622f07703513f9
20 changes: 6 additions & 14 deletions doc/source/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,6 @@ Binary operator functions

Series.add
Series.sub
Series.subtract
Series.mul
Series.div
Series.truediv
Expand Down Expand Up @@ -715,20 +714,21 @@ a :class:`pandas.api.types.CategoricalDtype`.
api.types.CategoricalDtype.categories
api.types.CategoricalDtype.ordered

Categorical data can be stored in a :class:``pandas.Categorical``
Categorical data can be stored in a :class:`pandas.Categorical`

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

Categorical
Copy link
Member

Choose a reason for hiding this comment

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

Is there a reason you remove the 'class_without_autosummary' for Categorical?

The reason it was there before was to not document everything of Categorical, as IMO we don't want to encourage people to use Categorical directly apart from some very specific functionality (eg from_codes)

(so to not document all the methods that are there for compatibility with eg numpy)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll revert that.

I do consider Categorical a useful data structure in its own right, but we can revisit that later.


The following two ``Categorical`` constructors are considered API but should only be used when
adding ordering information or special categories is need at creation time of the categorical data:

The alternative :ref:`Categorical.from_codes` constructor can be used when you
have the categories and integer codes already:

.. autosummary::
:toctree: generated/

Categorical.categories
Categorical.from_codes

The dtype information is available on the ``Categorical``
Expand Down Expand Up @@ -2617,6 +2617,7 @@ Scalar introspection
generated/pandas.Series.ix
generated/pandas.Series.notnull.rst
generated/pandas.Series.set_value
generated/pandas.Series.subtract

generated/pandas.Series.cat
generated/pandas.Series.dt
Expand All @@ -2625,15 +2626,6 @@ Scalar introspection
generated/pandas.Timestamp.offset
generated/pandas.Timestamp.to_datetime

generated/pandas.Categorical.base.rst
generated/pandas.Categorical.itemsize.rst
generated/pandas.Categorical.labels.rst
generated/pandas.Categorical.nbytes.rst
generated/pandas.Categorical.ndim.rst
generated/pandas.Categorical.shape.rst
generated/pandas.Categorical.size.rst
generated/pandas.Categorical.T.rst

generated/pandas.DataFrame.subtract
generated/pandas.DataFrame.multiply
generated/pandas.DataFrame.divide
Expand Down
21 changes: 21 additions & 0 deletions doc/source/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,27 @@ Some other important things to know about the docs:
doc build. This approach means that code examples will always be up to date,
but it does make the doc building a bit more complex.

- Our API documentation in ``doc/source/api.rst`` houses the auto-generated
documentation from the docstrings. For classes, there are a few subtleties
around controlling which methods and attributes have pages auto-generated.

We have two autosummary templates for classes.

1. ``_templates/autosummary/class.rst``. Use this when you want to
automatically autogenerate a page for public method and attribute on the
class. The class should include the regular ``Parameters`` section, but
need not include ``Attributes`` or ``Methods``. Those sections will be
automatically added to the rendered documentation by numpydoc.

2. ``_templates/autosummary/class_without_autosummary``. Use this when you
want to pick a subset of methods / attributes to auto-generate pages for.
When using this template, you should include an ``Attributes`` and
``Methods`` section in the class docstring. See ``CategoricalIndex`` for an
example.

Every method should be included in a ``toctree`` in ``api.rst``, else Sphinx
will emit a warning.

.. note::

The ``.rst`` files are used to automatically generate Markdown and HTML versions
Expand Down
5 changes: 5 additions & 0 deletions pandas/core/categorical.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,11 @@ class Categorical(PandasObject):

.. versionadded:: 0.21.0

Methods
-------
from_codes
__array__

Raises
------
ValueError
Expand Down
8 changes: 4 additions & 4 deletions pandas/core/indexes/category.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,6 @@ class CategoricalIndex(Index, accessor.PandasDelegate):
categories
ordered

See Also
--------
Categorical, Index

Methods
-------
rename_categories
Expand All @@ -67,6 +63,10 @@ class CategoricalIndex(Index, accessor.PandasDelegate):
as_ordered
as_unordered
map

See Also
--------
Categorical, Index
"""

_typ = 'categoricalindex'
Expand Down