PreviewerHTML: fixed an issue raised by Sphinx when converting .rst files to .html.

Mon, 24 Aug 2020 18:12:22 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Mon, 24 Aug 2020 18:12:22 +0200
changeset 7675
7d23e502fe85
parent 7674
60fdbaf3508f
child 7676
0f67b4562d98

PreviewerHTML: fixed an issue raised by Sphinx when converting .rst files to .html.

eric6/UI/Previewers/PreviewerHTML.py file | annotate | diff | comparison | revisions
diff -r 60fdbaf3508f -r 7d23e502fe85 eric6/UI/Previewers/PreviewerHTML.py
--- a/eric6/UI/Previewers/PreviewerHTML.py	Sun Aug 23 14:40:12 2020 +0200
+++ b/eric6/UI/Previewers/PreviewerHTML.py	Mon Aug 24 18:12:22 2020 +0200
@@ -580,10 +580,12 @@
                 """<p>Alternatively you may disable Sphinx usage"""
                 """ on the Editor, Filehandling configuration page.</p>""")
         
-        tempDir = tempfile.mkdtemp(prefix='eric-rest-')
+        srcTempDir = tempfile.mkdtemp(prefix="eric-rest-src-")
+        outTempDir = tempfile.mkdtemp(prefix="eric-rest-out-")
+        doctreeTempDir = tempfile.mkdtemp(prefix="eric-rest-doctree-")
         try:
             filename = 'sphinx_preview'
-            basePath = os.path.join(tempDir, filename)
+            basePath = os.path.join(srcTempDir, filename)
             fh = open(basePath + '.rst', 'w', encoding='utf-8')
             fh.write(text)
             fh.close()
@@ -595,17 +597,20 @@
                          'html_use_modindex': False,
                          'html_use_smartypants': True,
                          'master_doc': filename}
-            app = Sphinx(srcdir=tempDir, confdir=None, outdir=tempDir,
-                         doctreedir=tempDir, buildername='html',
+            app = Sphinx(srcdir=srcTempDir, confdir=None, outdir=outTempDir,
+                         doctreedir=doctreeTempDir, buildername='html',
                          confoverrides=overrides, status=None,
                          warning=io.StringIO())
             app.build(force_all=True, filenames=None)
 
+            basePath = os.path.join(outTempDir, filename)
             fh = open(basePath + '.html', 'r', encoding='utf-8')
             html = fh.read()
             fh.close()
         finally:
-            shutil.rmtree(tempDir)
+            shutil.rmtree(srcTempDir)
+            shutil.rmtree(outTempDir)
+            shutil.rmtree(doctreeTempDir)
         
         return html
     

eric ide

mercurial