Skip to content

DOC: Shared doc string in render methods #45548

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 4 commits into from
Jan 25, 2022
Merged
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
27 changes: 15 additions & 12 deletions pandas/io/formats/style.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,15 @@ def _mpl(func: Callable):
color = """color : str, default 'yellow'
Background color to use for highlighting."""

buf = """buf : str, path object, file-like object, optional
String, path object (implementing ``os.PathLike[str]``), or file-like
object implementing a string ``write()`` function. If `None`, the result is
returned as a string."""

encoding = """encoding : str, optional
Character encoding setting for file output (and meta tags if available).
Defaults to ``pandas.options.styler.render.encoding`` value of "utf-8"."""

#
###

Expand Down Expand Up @@ -1053,6 +1062,7 @@ def to_latex(
latex, buf=buf, encoding=None if buf is None else encoding
)

@Substitution(buf=buf, encoding=encoding)
def to_html(
self,
buf: FilePath | WriteBuffer[str] | None = None,
Expand All @@ -1077,10 +1087,7 @@ def to_html(

Parameters
----------
buf : str, path object, file-like object, or None, default None
String, path object (implementing ``os.PathLike[str]``), or file-like
object implementing a string ``write()`` function. If None, the result is
returned as a string.
%(buf)s
table_uuid : str, optional
Id attribute assigned to the <table> HTML element in the format:

Expand Down Expand Up @@ -1127,9 +1134,7 @@ def to_html(
which is 262144 (18 bit browser rendering).

.. versionadded:: 1.4.0
encoding : str, optional
Character encoding setting for file output, and HTML meta tags.
Defaults to ``pandas.options.styler.render.encoding`` value of "utf-8".
%(encoding)s
doctype_html : bool, default False
Whether to output a fully structured HTML file including all
HTML elements, or just the core ``<style>`` and ``<table>`` elements.
Expand Down Expand Up @@ -1189,6 +1194,7 @@ def to_html(
html, buf=buf, encoding=(encoding if buf is not None else None)
)

@Substitution(buf=buf, encoding=encoding)
def to_string(
self,
buf=None,
Expand All @@ -1207,11 +1213,8 @@ def to_string(

Parameters
----------
buf : str, Path, or StringIO-like, optional, default None
Buffer to write to. If ``None``, the output is returned as a string.
encoding : str, optional
Character encoding setting for file output.
Defaults to ``pandas.options.styler.render.encoding`` value of "utf-8".
%(buf)s
%(encoding)s
sparse_index : bool, optional
Whether to sparsify the display of a hierarchical index. Setting to False
will display each explicit level element in a hierarchical key for each row.
Expand Down