
import os
from subprocess import Popen, PIPE
import shutil

docs_folder_path = os.path.join(os.path.dirname(__file__))
p1 = Popen(u'sphinx-build -M html {src} {dst}'.format(
    src=docs_folder_path, dst=os.path.join(docs_folder_path, u'_build')
), shell=True, stdin=PIPE, stdout=PIPE)

result = p1.communicate()[0]
if not result or u'build succeeded' not in result:
    raise RuntimeError(u'sphinx-build failed')

final_folder_path = os.path.join(docs_folder_path, u'documentation')
shutil.rmtree(final_folder_path)
shutil.copytree(os.path.join(docs_folder_path, u'_build', u'html') , final_folder_path)


import os
from subprocess import Popen, PIPE
import shutil

docs_folder_path = os.path.abspath(os.path.dirname(__file__))
p1 = Popen('python -m sphinx -v -b html {src} {dst}'.format(
    src=docs_folder_path, dst=os.path.join(docs_folder_path, '_build')
), shell=True, stdin=PIPE, stdout=PIPE)

result = p1.communicate()[0].decode('utf-8')
if not result or 'build succeeded' not in result:
    raise RuntimeError('sphinx-build failed')

final_folder_path = os.path.join(docs_folder_path, 'documentation')
if os.path.isdir(final_folder_path):
    shutil.rmtree(final_folder_path)
shutil.copytree(os.path.join(docs_folder_path, '_build') , final_folder_path)

Fix documentation generating script to work with Python 3
Fix documentation generating script to work with Python 3


  
  import os
  from subprocess import Popen, PIPE
  import shutil
  
- docs_folder_path = os.path.join(os.path.dirname(__file__))
+ docs_folder_path = os.path.abspath(os.path.dirname(__file__))
- p1 = Popen(u'sphinx-build -M html {src} {dst}'.format(
+ p1 = Popen('python -m sphinx -v -b html {src} {dst}'.format(
-     src=docs_folder_path, dst=os.path.join(docs_folder_path, u'_build')
+     src=docs_folder_path, dst=os.path.join(docs_folder_path, '_build')
  ), shell=True, stdin=PIPE, stdout=PIPE)
  
- result = p1.communicate()[0]
+ result = p1.communicate()[0].decode('utf-8')
- if not result or u'build succeeded' not in result:
+ if not result or 'build succeeded' not in result:
-     raise RuntimeError(u'sphinx-build failed')
+     raise RuntimeError('sphinx-build failed')
  
- final_folder_path = os.path.join(docs_folder_path, u'documentation')
+ final_folder_path = os.path.join(docs_folder_path, 'documentation')
+ if os.path.isdir(final_folder_path):
- shutil.rmtree(final_folder_path)
+     shutil.rmtree(final_folder_path)
- shutil.copytree(os.path.join(docs_folder_path, u'_build', u'html') , final_folder_path)
+ shutil.copytree(os.path.join(docs_folder_path, '_build') , final_folder_path)
  
Fix documentation generating script to work with Python 3
## Code Before:

import os
from subprocess import Popen, PIPE
import shutil

docs_folder_path = os.path.join(os.path.dirname(__file__))
p1 = Popen(u'sphinx-build -M html {src} {dst}'.format(
    src=docs_folder_path, dst=os.path.join(docs_folder_path, u'_build')
), shell=True, stdin=PIPE, stdout=PIPE)

result = p1.communicate()[0]
if not result or u'build succeeded' not in result:
    raise RuntimeError(u'sphinx-build failed')

final_folder_path = os.path.join(docs_folder_path, u'documentation')
shutil.rmtree(final_folder_path)
shutil.copytree(os.path.join(docs_folder_path, u'_build', u'html') , final_folder_path)

## Instruction:
Fix documentation generating script to work with Python 3
## Code After:

import os
from subprocess import Popen, PIPE
import shutil

docs_folder_path = os.path.abspath(os.path.dirname(__file__))
p1 = Popen('python -m sphinx -v -b html {src} {dst}'.format(
    src=docs_folder_path, dst=os.path.join(docs_folder_path, '_build')
), shell=True, stdin=PIPE, stdout=PIPE)

result = p1.communicate()[0].decode('utf-8')
if not result or 'build succeeded' not in result:
    raise RuntimeError('sphinx-build failed')

final_folder_path = os.path.join(docs_folder_path, 'documentation')
if os.path.isdir(final_folder_path):
    shutil.rmtree(final_folder_path)
shutil.copytree(os.path.join(docs_folder_path, '_build') , final_folder_path)
