Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

PoC: Document each rcParam individually #28930

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
Loading
from
Draft
Show file tree
Hide file tree
Changes from all 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
3 changes: 2 additions & 1 deletion 3 doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,9 @@ def _parse_skip_subdirs_file():
'sphinxext.math_symbol_table',
'sphinxext.missing_references',
'sphinxext.mock_gui_toolkits',
'sphinxext.skip_deprecated',
'sphinxext.rcparams',
'sphinxext.redirect_from',
'sphinxext.skip_deprecated',
'sphinx_copybutton',
'sphinx_design',
'sphinx_tags',
Expand Down
62 changes: 62 additions & 0 deletions 62 doc/sphinxext/rcparams.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import enum

from docutils.parsers.rst import Directive

from matplotlib import rcParams, rcParamsDefault, rcsetup


def determine_type(validator):
if isinstance(validator, enum.EnumType):
return f'`~._enums.{validator.__name__}`'
elif docstr := getattr(validator, '__doc__'):
return docstr
else:
return str(validator)


def run(state_machine):
lines = []
current_section = None
for rc in sorted(rcParams.keys()):
if rc[0] == '_':
continue

# This would be much easier with #25617.
section = rc.rsplit('.', maxsplit=1)[0]
if section != current_section:
lines.append(f'.. _rc-{section}:')
current_section = section

type_str = determine_type(rcsetup._validators[rc])
if rc in rcParamsDefault and rc != "backend":
default = f', default: {rcParamsDefault[rc]!r}'
else:
default = ''
lines += [
f'.. _rc-{rc}:',
'',
rc,
'^' * len(rc),
f'{type_str}{default}',
f' Documentation for {rc}.'
]
state_machine.insert_input(lines, "rcParams table")
return []


class RcParamsDirective(Directive):
has_content = False
required_arguments = 0
optional_arguments = 0
final_argument_whitespace = False
option_spec = {}

def run(self):
return run(self.state_machine)


def setup(app):
app.add_directive("rcparams", RcParamsDirective)

metadata = {'parallel_read_safe': True, 'parallel_write_safe': True}
return metadata
17 changes: 8 additions & 9 deletions 17 galleries/users_explain/customizing.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,10 @@ def plotting_function():
# ignored in style sheets see `matplotlib.style.use`.
#
# There are a number of pre-defined styles :doc:`provided by Matplotlib
# </gallery/style_sheets/style_sheets_reference>`. For
# example, there's a pre-defined style called "ggplot", which emulates the
# aesthetics of ggplot_ (a popular plotting package for R_). To use this
# style, add:
# </gallery/style_sheets/style_sheets_reference>`. For example, there's a pre-defined
# style called "ggplot", which emulates the aesthetics of `ggplot
# <https://ggplot2.tidyverse.org/>`_ (a popular plotting package for `R
# <https://www.r-project.org/>`_). To use this style, add:

plt.style.use('ggplot')

Expand Down Expand Up @@ -259,11 +259,10 @@ def plotting_function():
#
# .. _matplotlibrc-sample:
#
# The default :file:`matplotlibrc` file
# -------------------------------------
# Available ``rcParams``
# ----------------------
#
# .. literalinclude:: ../../../lib/matplotlib/mpl-data/matplotlibrc
#
# .. rcparams::
#
#
# .. _ggplot: https://ggplot2.tidyverse.org/
# .. _R: https://www.r-project.org/
Loading
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.