MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / run

Function run

lib/matplotlib/sphinxext/plot_directive.py:784–1010  ·  view source on GitHub ↗
(arguments, content, options, state_machine, state, lineno)

Source from the content-addressed store, hash-verified

782
783
784def run(arguments, content, options, state_machine, state, lineno):
785 document = state_machine.document
786 env = document.settings.env
787 config = env.config
788 nofigs = 'nofigs' in options
789
790 if config.plot_srcset and setup.app.builder.name == 'singlehtml':
791 raise ExtensionError(
792 'plot_srcset option not compatible with single HTML writer')
793
794 formats = get_plot_formats(config)
795 default_fmt = formats[0][0]
796
797 options.setdefault('include-source', config.plot_include_source)
798 options.setdefault('show-source-link', config.plot_html_show_source_link)
799 options.setdefault('filename-prefix', None)
800
801 if 'class' in options:
802 # classes are parsed into a list of string, and output by simply
803 # printing the list, abusing the fact that RST guarantees to strip
804 # non-conforming characters
805 options['class'] = ['plot-directive'] + options['class']
806 else:
807 options.setdefault('class', ['plot-directive'])
808 keep_context = 'context' in options
809 context_opt = None if not keep_context else options['context']
810
811 rst_file = document.attributes['source']
812 rst_dir = os.path.dirname(rst_file)
813
814 if len(arguments):
815 if not config.plot_basedir:
816 source_file_name = os.path.join(setup.app.builder.srcdir,
817 directives.uri(arguments[0]))
818 else:
819 source_file_name = os.path.join(setup.confdir, config.plot_basedir,
820 directives.uri(arguments[0]))
821 # If there is content, it will be passed as a caption.
822 caption = '\n'.join(content)
823
824 # Enforce unambiguous use of captions.
825 if "caption" in options:
826 if caption:
827 raise ValueError(
828 'Caption specified in both content and options.'
829 ' Please remove ambiguity.'
830 )
831 # Use caption option
832 caption = options["caption"]
833
834 # If the optional function name is provided, use it
835 if len(arguments) == 2:
836 function_name = arguments[1]
837 else:
838 function_name = None
839
840 code = Path(source_file_name).read_text(encoding='utf-8')
841 if options['filename-prefix']:

Callers 1

runMethod · 0.70

Calls 10

get_plot_formatsFunction · 0.85
PathClass · 0.85
check_output_base_nameFunction · 0.85
contains_doctestFunction · 0.85
render_figuresFunction · 0.85
joinMethod · 0.80
valuesMethod · 0.80
getMethod · 0.45
removeMethod · 0.45
renderMethod · 0.45

Tested by

no test coverage detected