import webbrowser
from sys import exit


parser = DevilryAdmArgumentParser()
parser.add_argument('-b', '--openbrowser', action='store_true',
                    help='Open the docs in your default browser after building.')
parser.add_argument('--completionlist', action='store_true',
                   help='Print completionlist for bash completion.')
args = parser.parse_args()

if args.completionlist:
    print "--openbrowser"
    exit(0)

os.chdir(get_docsdir())
call(['make', 'html'])


indexpath = join(get_docs_buildhtml_dir(), 'index.html')

print '********************************************************************'
print 'HTML documentation for python code built successfully. View it here:'
print
print '   ', indexpath
print
print 'Use devilryadmin.py docs_upload_to_website to upload them to'
print 'the website if you have push permission on devilry/devilry-django/'
print '********************************************************************'

if args.openbrowser:
#!/usr/bin/env python
# Autogenerate documentation for the RESTful API for student, examiner and administrator.

from os.path import exists, join
from common import get_docsdir
from os import mkdir
from shutil import rmtree

from devilry.restful.createdocs import RestfulDocs
from devilry.apps.administrator.restful import administrator_restful
from devilry.apps.student.restful import student_restful
from devilry.apps.examiner.restful import examiner_restful

outdir = join(get_docsdir(), 'restfulapi')
if exists(outdir):
    rmtree(outdir)
mkdir(outdir)

for directory, restfulmanager, indextitle in (('administrator',
                                               administrator_restful,
                                               'Administrator'),
                                              ('examiner', examiner_restful,
                                               'Examiner'), ('student',
                                                             student_restful,
                                                             'Student')):
    subdir = join(outdir, directory)
    mkdir(subdir)
    RestfulDocs().create_in_directory(
        subdir,
        indexpageref='restful_api{0}'.format(directory),
        indextitle=indextitle,
#!/usr/bin/env python
# Autogenerate documentation for the RESTful API for student, examiner and administrator.

from os.path import exists, join
from common import get_docsdir
from os import mkdir
from shutil import rmtree

from devilry.restful.createdocs import RestfulDocs
from devilry.apps.administrator.restful import administrator_restful
from devilry.apps.student.restful import student_restful
from devilry.apps.examiner.restful import examiner_restful


outdir = join(get_docsdir(), 'restfulapi')
if exists(outdir):
    rmtree(outdir)
mkdir(outdir)


for directory, restfulmanager, indextitle in (('administrator', administrator_restful, 'Administrator'),
                                              ('examiner', examiner_restful, 'Examiner'),
                                              ('student', student_restful, 'Student')):
    subdir = join(outdir, directory)
    mkdir(subdir)
    RestfulDocs().create_in_directory(subdir,
                                      indexpageref = 'restful_api{0}'.format(directory),
                                      indextitle = indextitle,
                                      restfulmanager = restfulmanager)
print "Autogenerated RESTful docs in ", outdir