Skip to content

Commit

Permalink
Replace Makefile for docs with a lightweight script.
Browse files Browse the repository at this point in the history
  • Loading branch information
qiuwch committed Jul 15, 2017
1 parent 16f213b commit 191bb6d
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 28 deletions.
28 changes: 0 additions & 28 deletions docs/Makefile

This file was deleted.

55 changes: 55 additions & 0 deletions docs/build_doc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import argparse, subprocess, platform, os

def open_url(url):
''' Utility function '''
system_name = platform.system()
if system_name == 'Darwin':
browser = 'open'
elif system_name == 'Linux':
browser = 'xdg-open'
elif system_name == 'Windows':
browser = 'explorer.exe'
else:
return
subprocess.call([browser, url])


if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('--build_tutorial', action='store_true',
default=False, help='Whether we should run the ipython notebook')
parser.add_argument('--build_doxygen', action='store_true',
default=False)
parser.add_argument('--rtd', action='store_true',
default=False, help='Simulate running on RTD')

args = parser.parse_args()
is_build_tutorial = args.build_tutorial
is_build_doxygen = args.build_doxygen
is_on_rtd = args.rtd

if is_build_doxygen:
try:
subprocess.call(['doxygen', 'Doxyfile'])
except Exception as e:
print('Failed to run doxygen')
print(e)

env = dict(os.environ)
# print(env)
if is_build_tutorial:
env['UNREALCV_BUILD_TUTORIAL'] = 'True'

if is_on_rtd:
env['READTHEDOCS'] = 'True'

cmd = [
'sphinx-build', '-n',
'-b', 'html', # build format
'.', '_build/html', # input, output folder
]
print(cmd)
subprocess.call(cmd, env = env)
# subprocess.call(cmd, env = os.environ)

open_url('_build/html/index.html')

0 comments on commit 191bb6d

Please sign in to comment.