29
29
30
30
import matplotlib
31
31
32
-
33
32
# debug that building expected version
34
33
print (f"Building Documentation for Matplotlib: { matplotlib .__version__ } " )
35
34
@@ -852,6 +851,58 @@ def linkcode_resolve(domain, info):
852
851
extensions .append ('sphinx.ext.viewcode' )
853
852
854
853
854
+ def generate_ScalarMappable_docs ():
855
+
856
+ import matplotlib .colorizer
857
+ from numpydoc .docscrape_sphinx import get_doc_object
858
+ from pathlib import Path
859
+ import textwrap
860
+ from sphinx .util .inspect import stringify_signature
861
+ target_file = Path (__file__ ).parent / 'api' / 'scalarmappable.gen_rst'
862
+ with open (target_file , 'w' ) as fout :
863
+ fout .write ("""
864
+ .. class:: ScalarMappable(colorizer, **kwargs)
865
+ :canonical: matplotlib.colorizer._ScalarMappable
866
+
867
+ """ )
868
+ for meth in [
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
+ if isinstance (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
+
855
906
# -----------------------------------------------------------------------------
856
907
# Sphinx setup
857
908
# -----------------------------------------------------------------------------
@@ -865,3 +916,4 @@ def setup(app):
865
916
app .connect ('autodoc-process-bases' , autodoc_process_bases )
866
917
if sphinx .version_info [:2 ] < (7 , 1 ):
867
918
app .connect ('html-page-context' , add_html_cache_busting , priority <
376E
span class=pl-c1>=1000 )
919
+ generate_ScalarMappable_docs ()
0 commit comments