Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

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

Sign up
Appearance settings

Commit5deb9aa

Browse files
tacaswellksunden
authored andcommitted
DOC: auto-generate ScalarMappable in conf.py
This is a hack, but not the _worst_ hack.
1 parent32e2b4d commit5deb9aa

File tree

3 files changed

+55
-51
lines changed

3 files changed

+55
-51
lines changed

‎doc/api/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
scalarmappable.gen_rst

‎doc/api/cm_api.rst

Lines changed: 1 addition & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -7,53 +7,4 @@
77
:undoc-members:
88
:show-inheritance:
99

10-
11-
..class::ScalarMappable(colorizer, **kwargs)
12-
:canonical: matplotlib.colorizer._ScalarMappable
13-
14-
..attribute::colorbar
15-
..method::changed
16-
17-
Call this whenever the mappable is changed to notify all the
18-
callbackSM listeners to the 'changed' signal.
19-
20-
..method::set_array(A)
21-
22-
Set the value array from array-like *A*.
23-
24-
25-
:Parameters:
26-
27-
**A** : array-like or None
28-
The values that are mapped to colors.
29-
30-
The base class `.ScalarMappable` does not make any assumptions on
31-
the dimensionality and shape of the value array *A*.
32-
33-
34-
35-
..method::set_cmap(A)
36-
37-
Set the colormap for luminance data.
38-
39-
40-
:Parameters:
41-
42-
**cmap** : `.Colormap` or str or None
43-
..
44-
45-
46-
..method::set_clim(vmin=None, vmax=None)
47-
48-
Set the norm limits for image scaling.
49-
50-
51-
:Parameters:
52-
53-
**vmin, vmax** : float
54-
The limits.
55-
56-
For scalar data, the limits may also be passed as a
57-
tuple (*vmin*, *vmax*) as a single positional argument.
58-
59-
.. ACCEPTS: (vmin: float, vmax: float)
10+
..include::scalarmappable.gen_rst

‎doc/conf.py

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929

3030
importmatplotlib
3131

32-
3332
# debug that building expected version
3433
print(f"Building Documentation for Matplotlib:{matplotlib.__version__}")
3534

@@ -852,6 +851,58 @@ def linkcode_resolve(domain, info):
852851
extensions.append('sphinx.ext.viewcode')
853852

854853

854+
defgenerate_ScalarMappable_docs():
855+
856+
importmatplotlib.colorizer
857+
fromnumpydoc.docscrape_sphinximportget_doc_object
858+
frompathlibimportPath
859+
importtextwrap
860+
fromsphinx.util.inspectimportstringify_signature
861+
target_file=Path(__file__).parent/'api'/'scalarmappable.gen_rst'
862+
withopen(target_file,'w')asfout:
863+
fout.write("""
864+
.. class:: ScalarMappable(colorizer, **kwargs)
865+
:canonical: matplotlib.colorizer._ScalarMappable
866+
867+
""")
868+
formethin [
869+
matplotlib.colorizer._ScalarMappable.autoscale,
870+
matplotlib.colorizer._ScalarMappable.autoscale_None,
871+
matplotlib.colorizer._ScalarMappable.changed,
872+
"""
873+
.. attribute:: colorbar
874+
875+
The last colorbar associated with this ScalarMappable. May be None.
876+
""",
877+
matplotlib.colorizer._ScalarMappable.get_alpha,
878+
matplotlib.colorizer._ScalarMappable.get_array,
879+
matplotlib.colorizer._ScalarMappable.get_clim,
880+
matplotlib.colorizer._ScalarMappable.get_cmap,
881+
"""
882+
.. property:: norm
883+
""",
884+
matplotlib.colorizer._ScalarMappable.set_array,
885+
matplotlib.colorizer._ScalarMappable.set_clim,
886+
matplotlib.colorizer._ScalarMappable.set_cmap,
887+
matplotlib.colorizer._ScalarMappable.set_norm,
888+
matplotlib.colorizer._ScalarMappable.to_rgba,
889+
]:
890+
ifisinstance(meth,str):
891+
fout.write(meth)
892+
else:
893+
name=meth.__name__
894+
sig=stringify_signature(inspect.signature(meth))
895+
docstring=textwrap.indent(
896+
str(get_doc_object(meth)),
897+
' '
898+
).rstrip()
899+
fout.write(f"""
900+
.. method::{name}{sig}
901+
{docstring}
902+
903+
""")
904+
905+
855906
# -----------------------------------------------------------------------------
856907
# Sphinx setup
857908
# -----------------------------------------------------------------------------
@@ -865,3 +916,4 @@ def setup(app):
865916
app.connect('autodoc-process-bases',autodoc_process_bases)
866917
ifsphinx.version_info[:2]< (7,1):
867918
app.connect('html-page-context',add_html_cache_busting,priority=1000)
919+
generate_ScalarMappable_docs()

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp