def build_docs(branch):
    os.chdir(os.path.join(gitdname, 'docs'))
    retcode = subprocess.call("make clean", shell=True,
                              stdout=sys.stdout, stderr=sys.stderr)
    if retcode != 0:
        os.chdir(dname)
        msg = """Could not clean the html docs for branch %s""" % branch
        raise Exception(msg)
    #NOTE: The python call in the below makes sure that it uses the Python
    # that is referenced after entering the virtualenv
    sphinx_call = " ".join(['make', 'html', "SPHINXBUILD=' python "
                            "/usr/local/bin/sphinx-build'"])
    activate = os.path.join(virtual_dir, "bin", "activate")
    activate_virtualenv = ". " + activate
    #NOTE: You have to enter virtualenv in the same call. As soon as the
    # child process is done, the env variables from activate are lost.
    # getting the correct env from bin/activate and passing to env is
    # annoying
    retcode = subprocess.call(" && ".join([activate_virtualenv, sphinx_call]),
                              shell=True, env=env, stdout=sys.stdout,
                              stderr=sys.stderr)

    if retcode != 0:
        os.chdir(dname)
        msg = """Could not build the html docs for branch %s""" % branch
        raise Exception(msg)
    os.chdir(dname)
Changes into gitdname and builds the docs using BUILDENV virtualenv
dataset/ETHPy150Open statsmodels/statsmodels/tools/update_web.py/build_docs