2015-04-10 08:39:09 -07:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								#!/usr/bin/env python
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								# Build the documentation.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								from __future__ import print_function
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								import os, shutil, tempfile
							 | 
						
					
						
							
								
									
										
										
										
											2015-05-20 11:10:16 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								from subprocess import check_call, CalledProcessError, Popen, PIPE
							 | 
						
					
						
							
								
									
										
										
										
											2015-04-10 08:39:09 -07:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								def pip_install(package, commit=None):
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  "Install package using pip."
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  if commit:
							 | 
						
					
						
							
								
									
										
										
										
											2015-05-20 11:10:16 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    cmd = ['pip', 'show', package.split('/')[1]]
							 | 
						
					
						
							
								
									
										
										
										
											2015-05-20 11:45:16 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    p = Popen(cmd, stdout=PIPE, stderr=PIPE)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    stdout, stderr = p.communicate()
							 | 
						
					
						
							
								
									
										
										
										
											2015-05-20 11:10:16 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    if p.returncode != 0:
							 | 
						
					
						
							
								
									
										
										
										
											2015-05-20 11:45:16 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      # Check if pip supports the show command.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      if 'No command by the name pip show' not in stderr:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        raise CalledProcessError(p.returncode, cmd)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    elif stdout:
							 | 
						
					
						
							
								
									
										
										
										
											2015-05-19 08:13:13 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      return # Already installed
							 | 
						
					
						
							
								
									
										
										
										
											2015-04-10 08:39:09 -07:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    package = 'git+git://github.com/{0}.git@{1}'.format(package, commit)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  check_call(['pip', 'install', '-q', package])
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2015-05-20 08:06:12 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								def build_docs():
							 | 
						
					
						
							
								
									
										
										
										
											2015-04-10 08:39:09 -07:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  # Create virtualenv.
							 | 
						
					
						
							
								
									
										
										
										
											2015-05-20 08:06:12 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  doc_dir = os.path.dirname(os.path.realpath(__file__))
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  virtualenv_dir = os.path.join(doc_dir, 'virtualenv')
							 | 
						
					
						
							
								
									
										
										
										
											2015-04-10 08:39:09 -07:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  check_call(['virtualenv', virtualenv_dir])
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  activate_this_file = os.path.join(virtualenv_dir, 'bin', 'activate_this.py')
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  execfile(activate_this_file, dict(__file__=activate_this_file))
							 | 
						
					
						
							
								
									
										
										
										
											2015-05-19 08:13:13 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  # Install Sphinx and Breathe.
							 | 
						
					
						
							
								
									
										
										
										
											2015-05-18 07:24:33 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  pip_install('sphinx==1.3.1')
							 | 
						
					
						
							
								
									
										
										
										
											2015-06-03 18:21:01 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  pip_install('michaeljones/breathe', '511b0887293e7c6b12310bb61b3659068f48f0f4')
							 | 
						
					
						
							
								
									
										
										
										
											2015-04-10 08:39:09 -07:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  # Build docs.
							 | 
						
					
						
							
								
									
										
										
										
											2015-05-20 08:06:12 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  cmd = ['doxygen', '-']
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  p = Popen(cmd, stdin=PIPE, cwd=doc_dir)
							 | 
						
					
						
							
								
									
										
										
										
											2015-04-10 08:39:09 -07:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  p.communicate(input=r'''
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      PROJECT_NAME      = C++ Format
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      GENERATE_LATEX    = NO
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      GENERATE_MAN      = NO
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      GENERATE_RTF      = NO
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      CASE_SENSE_NAMES  = NO
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      INPUT             = {0}/format.h
							 | 
						
					
						
							
								
									
										
										
										
											2015-05-24 07:48:22 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      EXCLUDE_SYMBOLS   = fmt::internal::*
							 | 
						
					
						
							
								
									
										
										
										
											2015-04-10 08:39:09 -07:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      QUIET             = YES
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      JAVADOC_AUTOBRIEF = YES
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      AUTOLINK_SUPPORT  = NO
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      GENERATE_HTML     = NO
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      GENERATE_XML      = YES
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      XML_OUTPUT        = doxyxml
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      ALIASES           = "rst=\verbatim embed:rst"
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      ALIASES          += "endrst=\endverbatim"
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      PREDEFINED        = _WIN32=1 \
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                          FMT_USE_VARIADIC_TEMPLATES=1 \
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                          FMT_USE_RVALUE_REFERENCES=1
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      EXCLUDE_SYMBOLS   = fmt::internal::* StringValue write_str
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    '''.format(os.path.dirname(doc_dir)))
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  if p.returncode != 0:
							 | 
						
					
						
							
								
									
										
										
										
											2015-05-20 08:06:12 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    raise CalledProcessError(p.returncode, cmd)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  check_call(['sphinx-build', '-D', 'breathe_projects.format=doxyxml',
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								              '-b', 'html', '.', 'html'], cwd=doc_dir)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  check_call(['lessc', '--clean-css', '--include-path=bootstrap', 'cppformat.less',
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								              'html/_static/cppformat.css'], cwd=doc_dir)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  return os.path.join(doc_dir, 'html')
							 | 
						
					
						
							
								
									
										
										
										
											2015-04-10 08:39:09 -07:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2015-05-20 08:06:12 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								if __name__ == '__main__':
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  build_docs()
							 |