[Numpy-svn] r8680 - branches/1.5.x/doc/sphinxext

numpy-svn@scip... numpy-svn@scip...
Thu Sep 2 15:32:43 CDT 2010


Author: ptvirtan
Date: 2010-09-02 15:32:43 -0500 (Thu, 02 Sep 2010)
New Revision: 8680

Modified:
   branches/1.5.x/doc/sphinxext/plot_directive.py
Log:
sphinxext: (backport r8605) bug fix + some features in plot_directive

Modified: branches/1.5.x/doc/sphinxext/plot_directive.py
===================================================================
--- branches/1.5.x/doc/sphinxext/plot_directive.py	2010-09-01 23:22:30 UTC (rev 8679)
+++ branches/1.5.x/doc/sphinxext/plot_directive.py	2010-09-02 20:32:43 UTC (rev 8680)
@@ -64,6 +64,9 @@
         that determine the file format and the DPI. For entries whose
         DPI was omitted, sensible defaults are chosen.
 
+    plot_html_show_formats
+        Whether to show links to the files in HTML.
+
 TODO
 ----
 
@@ -96,6 +99,7 @@
     app.add_config_value('plot_include_source', False, True)
     app.add_config_value('plot_formats', ['png', 'hires.png', 'pdf'], True)
     app.add_config_value('plot_basedir', None, True)
+    app.add_config_value('plot_html_show_formats', True, True)
 
     app.add_directive('plot', plot_directive, True, (0, 1, False),
                       **plot_directive_options)
@@ -174,19 +178,24 @@
           {{ option }}
           {% endfor %}
     
-          (
           {%- if not source_code -%}
-            `Source code <{{source_link}}>`__
+            (`Source code <{{source_link}}>`__
+            {%- if html_show_formats -%}
             {%- for fmt in img.formats -%} 
             , `{{ fmt }} <{{ dest_dir }}/{{ img.basename }}.{{ fmt }}>`__
             {%- endfor -%}
+            {%- endif -%}
+            )
           {%- else -%}
+            {%- if html_show_formats -%}
+            (
             {%- for fmt in img.formats -%} 
             {%- if not loop.first -%}, {% endif -%}
             `{{ fmt }} <{{ dest_dir }}/{{ img.basename }}.{{ fmt }}>`__
             {%- endfor -%}
+            )
+            {%- endif -%}
           {%- endif -%}
-          )
        {% endfor %}
 
 {{ only_latex }}
@@ -321,12 +330,12 @@
         only_latex=only_latex,
         options=opts,
         images=images,
-        source_code=source_code)
+        source_code=source_code,
+        html_show_formats=config.plot_html_show_formats)
 
     lines = result.split("\n")
     if len(lines):
-        state_machine.insert_input(
-            lines, state_machine.input_lines.source(0))
+        state_machine.insert_input(lines, source=source_file_name)
 
     # copy image files to builder's output directory
     if not os.path.exists(dest_dir):



More information about the Numpy-svn mailing list