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 96c3520
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 35 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')
15 changes: 8 additions & 7 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,13 @@
sys.path.insert(0, doc_dir)

# If runs on ReadTheDocs environment
on_rtd = os.environ.get('READTHEDOCS', None) == 'True'

# Hack for lacking git-lfs support ReadTheDocs
on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
if on_rtd:
print('Fetching files with git_lfs for %s' % project_dir)
from git_lfs import fetch
fetch(project_dir)

subprocess.call('doxygen Doxyfile', shell=True)
subprocess.call(['doxygen', 'Doxyfile'])
# Generate xml from doxygen

import sphinx_rtd_theme
Expand All @@ -38,7 +36,6 @@
'download_section_examples': False,
'download_all_examples': False,
}
# plot_gallery = False, this is not useful because it will use the no picture version

for i in range(len(sphinx_gallery_conf['examples_dirs'])):
gallery_dir = sphinx_gallery_conf['gallery_dirs'][i]
Expand All @@ -60,8 +57,12 @@ def get_md5sum(src_file):
src_md5 = hashlib.md5(src_content).hexdigest()
return src_md5

tutorial_files = [ './tutorials_source/generate_images_tutorial.py']
if on_rtd:
# if tags.has('build_tutorial'):
if os.environ.get('UNREALCV_BUILD_TUTORIAL'):
print('Build tutorials')
else:
print('Skip tutorials')
tutorial_files = [ './tutorials_source/generate_images_tutorial.py']
for f in tutorial_files:
md5_file = f.replace('_source', '') + '.md5'
with open(md5_file, 'w') as file_checksum:
Expand Down

0 comments on commit 96c3520

Please sign in to comment.