Browse files

working on it

  • Loading branch information...
mortenvp committed May 14, 2018
1 parent 3b6c207 commit ecd144ebafb01e5363d8e5660b94cb4ec67734a4
@@ -1,8 +1,15 @@
from . import command
from . import commandline
from . import git_run
from . import git_url_parser
from . import cache
from . import run_error
from . import sphinx
from . import sphinx_config
from . import sphinx_environment
from . import virtualenv
from . import tasks
from . import build_info
import click
import tempfile
@@ -31,7 +38,7 @@ def __init__(self, git, git_url_parser, log):
# A unique name computed based on the git URL
self.unique_name = None
def prepare(self, repository, clone_path):
def clone(self, repository, clone_path):
assert repository
assert os.path.isdir(clone_path)
@@ -72,15 +79,6 @@ def branches(self):
return remote
class BuildProperties(object):
def environement(self):
def docs_path(self):
@@ -94,43 +92,58 @@ def cli(repository, clone_path, build_path):
git = git_run.GitRun(git_binary='git',
parser = git_url_parser.GitUrlParser()
# sphinx = cache.Sphinx(
venv = virtualenv.VirtualEnv.from_git(
git=git, clone_path=os.path.join(clone_path, 'local-virtualenv'),
venv = virtualenv.NameToPathAdapter(
virtualenv_root_path=os.path.join(clone_path, 'build_environements'))
environment = sphinx_environment.SphinxEnvironment(
prompt=commandline.Prompt(), virtualenv=venv)
config = sphinx_config.SphinxConfig()
spnx = sphinx.Sphinx(sphinx_config=config,
# repo = Repository(git=git, git_url_parser=parser, log="ok")
repo = Repository(git=git, git_url_parser=parser, log="ok")
# repo.prepare(repository=repository, clone_path=clone_path)
repo.clone(repository=repository, clone_path=clone_path)
# with cache.Cache(cache_path=build_path, unique_name=repo.unique_name) as cas:
with cache.Cache(cache_path=build_path, unique_name=repo.unique_name) as cas:
# workingtree_generator = cache.WorkingtreeGenerator(
# repository=repo,
# build_path=build_path, sphinx=sphinx)
workingtree_generator = tasks.WorkingtreeGenerator(
build_path=build_path, sphinx=spnx)
# git_branch_generator = cache.GitBranchGenerator(
# repository=repo,
# build_path=build_path, sphinx=sphinx, git=git, cache=cas)
git_branch_generator = tasks.GitBranchGenerator(
build_path=build_path, sphinx=spnx, git=git, cache=cas)
# git_tag_generator = cache.GitTagGenerator(
# repository=repo,
# build_path=build_path, sphinx=sphinx, git=git, cache=cas)
# git_tag_generator = tasks.GitTagGenerator(
# repository=repo,
# build_path=build_path, sphinx=sphinx, git=git, cache=cas)
# task_generator = cache.TaskFactory()
# task_generator.add_generator(generator=workingtree_generator)
# task_generator.add_generator(generator=git_branch_generator)
# task_generator.add_generator(generator=git_tag_generator)
task_generator = tasks.TaskFactory()
# task_generator.add_generator(generator=git_tag_generator)
# tasks = task_generator.tasks()
tsk = task_generator.tasks()
# for task in tasks:
for task in tsk:
# try:
# result =
# print(result)
bi = build_info.BuildInfo()
result =
# except run_error.RunError as re:
# log.debug(re)
except RuntimeError as re:
if __name__ == "__main__":
@@ -0,0 +1,73 @@
#! /usr/bin/env python
# encoding: utf-8
import os
class BuildInfo(object):
""" Stores information about a specific build.
Information is added by different steps in the build process in a
write once fashion. Such that we avoid accidental overwrites.
valid_keys = {
"config_file": "filename of the Sphinx configuration \
file as a string",
"config_dir": "The directory containing the config_file \
as a string",
"config_file_path": "The full path to the config_file \
as a string",
"sphinx_env": "Dict like os.environ, but where the PATH and PYTHONPATH \
variables have been modified to contains the necessary tools \
for building the docs.",
"slug": "Human readable name for a specific version of the docs",
"repository_path": "Path to the repsository",
"source_path": "Path to the documentation sources",
"output_path": "Path to the output",
"type": "The type of build"
def __init__(self):
# Because we override __setattr__ we have to call the
# __setattr__ in the base to avoid recursion
object.__setattr__(self, 'info', {})
def __getattr__(self, attribute):
""" Return the value corresponding to the attribute.
:param attribute: The name of the attribute to return as a string.
:return: The attribute value, if the attribute does not exist
return None
if attribute in
raise AttributeError("No key {} in BuildInfo".format(attribute))
def __setattr__(self, attribute, value):
""" Sets a dependency attribute.
:param attribute: The name of the attribute as a string
:param value: The value of the attribute
if attribute in
raise AttributeError("Attribute {} read-only.".format(attribute))
else:[attribute] = value
def __contains__(self, attribute):
""" Checks if the attribute is available.
:return: True if the attribute is available otherwise False
return (attribute in
def _check_key(self, attribute):
if attribute not in BuildInfo.valid_keys.keys():
raise AttributeError("Invalid attribute key {} valid {}".format(
attribute, BuildInfo.valid_keys.keys()))
Oops, something went wrong.

0 comments on commit ecd144e

Please sign in to comment.