Skip to content

Commit feb0e6e

Browse files
authored
DOC: Inline ScalarMappable reStructuredText entries (matplotlib#31625)
There is nothing that is dynamic here, so there's no need to generate this with code.
2 parents 8564197 + b1dfa09 commit feb0e6e

3 files changed

Lines changed: 17 additions & 55 deletions

File tree

doc/api/.gitignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

doc/api/cm_api.rst

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,20 @@
77
:undoc-members:
88
:show-inheritance:
99

10-
.. include:: scalarmappable.gen_rst
10+
.. class:: ScalarMappable(colorizer, **kwargs)
11+
:canonical: matplotlib.colorizer._ScalarMappable
12+
13+
.. automethod:: autoscale
14+
.. automethod:: autoscale_None
15+
.. automethod:: changed
16+
.. autoproperty:: colorbar
17+
.. automethod:: get_alpha
18+
.. automethod:: get_array
19+
.. automethod:: get_clim
20+
.. automethod:: get_cmap
21+
.. autoproperty:: norm
22+
.. automethod:: set_array
23+
.. automethod:: set_clim
24+
.. automethod:: set_cmap
25+
.. automethod:: set_norm
26+
.. automethod:: to_rgba

doc/conf.py

Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -837,58 +837,6 @@ def linkcode_resolve(domain, info):
837837
extensions.append('sphinx.ext.viewcode')
838838

839839

840-
def generate_ScalarMappable_docs():
841-
842-
import matplotlib.colorizer
843-
from numpydoc.docscrape_sphinx import get_doc_object
844-
from pathlib import Path
845-
import textwrap
846-
from sphinx.util.inspect import stringify_signature
847-
target_file = Path(__file__).parent / 'api' / 'scalarmappable.gen_rst'
848-
with open(target_file, 'w') as fout:
849-
fout.write("""
850-
.. class:: ScalarMappable(colorizer, **kwargs)
851-
:canonical: matplotlib.colorizer._ScalarMappable
852-
853-
""")
854-
for meth in [
855-
matplotlib.colorizer._ScalarMappable.autoscale,
856-
matplotlib.colorizer._ScalarMappable.autoscale_None,
857-
matplotlib.colorizer._ScalarMappable.changed,
858-
"""
859-
.. attribute:: colorbar
860-
861-
The last colorbar associated with this ScalarMappable. May be None.
862-
""",
863-
matplotlib.colorizer._ScalarMappable.get_alpha,
864-
matplotlib.colorizer._ScalarMappable.get_array,
865-
matplotlib.colorizer._ScalarMappable.get_clim,
866-
matplotlib.colorizer._ScalarMappable.get_cmap,
867-
"""
868-
.. property:: norm
869-
""",
870-
matplotlib.colorizer._ScalarMappable.set_array,
871-
matplotlib.colorizer._ScalarMappable.set_clim,
872-
matplotlib.colorizer._ScalarMappable.set_cmap,
873-
matplotlib.colorizer._ScalarMappable.set_norm,
874-
matplotlib.colorizer._ScalarMappable.to_rgba,
875-
]:
876-
if isinstance(meth, str):
877-
fout.write(meth)
878-
else:
879-
name = meth.__name__
880-
sig = stringify_signature(inspect.signature(meth))
881-
docstring = textwrap.indent(
882-
str(get_doc_object(meth)),
883-
' '
884-
).rstrip()
885-
fout.write(f"""
886-
.. method:: {name}{sig}
887-
{docstring}
888-
889-
""")
890-
891-
892840
# -----------------------------------------------------------------------------
893841
# Sphinx setup
894842
# -----------------------------------------------------------------------------
@@ -902,5 +850,4 @@ def setup(app):
902850
app.connect('autodoc-process-bases', autodoc_process_bases)
903851
if sphinx.version_info[:2] < (7, 1):
904852
app.connect('html-page-context', add_html_cache_busting, priority=1000)
905-
generate_ScalarMappable_docs()
906853
app.config.autodoc_use_legacy_class_based = True

0 commit comments

Comments
 (0)