Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Initial spike of teeing files out.

  • Loading branch information...
commit ff31583324533e8a11d912db0f930cd69e345d71 1 parent 283b182
@ericholscher ericholscher authored
View
27 readthedocs/doc_builder/backends/sphinx.py
@@ -79,7 +79,7 @@ class Builder(BaseBuilder):
Also handles the default sphinx output of html.
"""
- def _whitelisted(self):
+ def _whitelisted(self, **kwargs):
"""Modify the given ``conf.py`` file from a whitelisted user's project.
"""
project = self.version.project
@@ -97,7 +97,7 @@ def _whitelisted(self):
rtd_string = Template(RTD_CONF_ADDITIONS).render(rtd_ctx)
outfile.write(rtd_string)
- def clean(self):
+ def clean(self, **kwargs):
log.info("Project whitelisted")
try:
self._whitelisted()
@@ -106,23 +106,30 @@ def clean(self):
return ('', 'Conf file not found. Error writing to disk.', -1)
@restoring_chdir
- def build(self):
+ def build(self, id, **kwargs):
+ id_dir = "/tmp/"
+ id_file = "docs-build-%s" % id
+ id_path = os.path.join(id_dir, id_file)
project = self.version.project
os.chdir(project.conf_dir(self.version.slug))
force_str = " -E " if self.force else ""
if project.use_virtualenv:
- build_command = '%s %s -b html . _build/html' % (project.venv_bin(
- version=self.version.slug, bin='sphinx-build'), force_str)
+ build_command = "%s %s -b html . _build/html | tee %s" % (
+ project.venv_bin( version=self.version.slug, bin='sphinx-build'),
+ force_str,
+ id_path,
+ )
else:
- build_command = "sphinx-build %s -b html . _build/html" % force_str
- build_results = run(build_command)
+ build_command = "sphinx-build %s -b html . _build/html | tee %s " % (force_str, id_path)
+ build_results = run(build_command, shell=True)
+ remove_results = run('rm %s' % id_path)
self._zip_html()
if 'no targets are out of date.' in build_results[1]:
self._changed = False
return build_results
@restoring_chdir
- def _zip_html(self):
+ def _zip_html(self, **kwargs):
from_path = self.version.project.full_build_path(self.version.slug)
from_file = os.path.join(from_path, '%s.zip' % self.version.project.slug)
to_path = self.version.project.checkout_path(self.version.slug)
@@ -136,14 +143,14 @@ def _zip_html(self):
for file in files:
to_write = os.path.join(root, file)
archive.write(
- filename=to_write,
+ filename=to_write,
arcname=os.path.join("%s-%s" % (self.version.project.slug, self.version.slug), to_write)
)
archive.close()
return to_file
- def move(self):
+ def move(self, **kwargs):
project = self.version.project
if project.full_build_path(self.version.slug):
#Copy the html files.
View
4 readthedocs/doc_builder/backends/sphinx_epub.py
@@ -12,7 +12,7 @@
class Builder(HtmlBuilder):
@restoring_chdir
- def build(self):
+ def build(self, **kwargs):
project = self.version.project
os.chdir(project.conf_dir(self.version.slug))
if project.use_virtualenv:
@@ -23,7 +23,7 @@ def build(self):
build_results = run(build_command)
return build_results
- def move(self):
+ def move(self, **kwargs):
project = self.version.project
outputted_path = os.path.join(project.conf_dir(self.version.slug),
'_build', 'epub')
View
4 readthedocs/doc_builder/backends/sphinx_htmldir.py
@@ -13,7 +13,7 @@
class Builder(HtmlBuilder):
@restoring_chdir
- def build(self):
+ def build(self, **kwargs):
project = self.version.project
os.chdir(self.version.project.conf_dir(self.version.slug))
if project.use_virtualenv:
@@ -26,7 +26,7 @@ def build(self):
self._changed = False
return build_results
- def move(self):
+ def move(self, **kwargs):
project = self.version.project
if project.full_build_path(self.version.slug):
target = project.rtd_build_path(self.version.slug)
View
4 readthedocs/doc_builder/backends/sphinx_man.py
@@ -12,7 +12,7 @@
class Builder(ManpageBuilder):
@restoring_chdir
- def build(self):
+ def build(self, **kwargs):
project = self.version.project
os.chdir(self.version.project.conf_dir(self.version.slug))
if project.use_virtualenv:
@@ -23,7 +23,7 @@ def build(self):
build_results = run(build_command)
return build_results
- def move(self):
+ def move(self, **kwargs):
project = self.version.project
outputted_path = os.path.join(project.conf_dir(self.version.slug),
'_build', 'man')
View
4 readthedocs/doc_builder/backends/sphinx_pdf.py
@@ -18,7 +18,7 @@
class Builder(BaseBuilder):
@restoring_chdir
- def build(self):
+ def build(self, **kwargs):
project = self.version.project
os.chdir(project.conf_dir(self.version.slug))
#Default to this so we can return it always.
@@ -57,7 +57,7 @@ def build(self):
return (latex_results, pdf_results)
- def move(self):
+ def move(self, **kwargs):
#This needs to be thought about more because of all the state above.
#We could just shove the filename on the instance or something.
return True
View
10 readthedocs/doc_builder/base.py
@@ -29,21 +29,21 @@ class BaseBuilder(object):
def __init__(self, version):
self.version = version
- def run(self):
+ def run(self, **kwargs):
for step in self.workflow:
fn = getattr(self, step)
result = fn()
assert result
@restoring_chdir
- def force(self):
+ def force(self, **kwargs):
"""
An optional step to force a build even when nothing has changed.
"""
log.info("Forcing a build")
self.force = True
- def clean(self):
+ def clean(self, **kwargs):
"""
Clean up the version so it's ready for usage.
@@ -54,13 +54,13 @@ def clean(self):
"""
raise NotImplementedError
- def build(self):
+ def build(self, id=None, **kwargs):
"""
Do the actual building of the documentation.
"""
raise NotImplementedError
- def move(self):
+ def move(self, **kwargs):
"""
Move the documentation from it's generated place to its final home.
View
4 readthedocs/projects/tasks.py
@@ -65,7 +65,7 @@ def update_docs(pk, record=True, pdf=True, man=True, epub=True, version_pk=None,
Primary key of the project to update
`record`
- Whether or not to keep a record of the update in the database. Useful
+ Whether or not to keep a record of the update in the database. Useful
for preventing changes visible to the end-user when running commands from
the shell, for example.
"""
@@ -338,7 +338,7 @@ def build_docs(project, build, version, pdf, man, epub, record, force, update_ou
if force:
html_builder.force()
html_builder.clean()
- html_output = html_builder.build()
+ html_output = html_builder.build(id=build['id'])
successful = (html_output[0] == 0)
if successful:
html_builder.move()
View
13 readthedocs/projects/utils.py
@@ -27,7 +27,7 @@ def find_file(file):
return matches
-def run(*commands):
+def run(*commands, **kwargs):
"""
Run one or more commands, and return ``(status, out, err)``.
If more than one command is given, then this is equivalent to
@@ -45,14 +45,23 @@ def run(*commands):
cwd = os.getcwd()
if not commands:
raise ValueError("run() requires one or more command-line strings")
+ shell = kwargs.get('shell', False)
for command in commands:
+ if shell:
+ log.info("Running commands in a shell")
+ run_command = command
+ else:
+ run_command = command.split()
log.info("Running: '%s'" % command)
try:
- p = subprocess.Popen(command.split(), shell=False, cwd=cwd,
+ output = ''
+ p = subprocess.Popen(run_command, shell=shell, cwd=cwd,
stdout=subprocess.PIPE, stderr=subprocess.PIPE,
env=environment)
+ while p.poll() is None:
+ print p.stdout.readline()
out, err = p.communicate()
ret = p.returncode
except:
Please sign in to comment.
Something went wrong with that request. Please try again.