def update_site(env): env.fmt_repo.update(fmt_repo_url) doc_repo = Git(os.path.join(env.build_dir, 'fmtlib.github.io')) doc_repo.update('[email protected]:fmtlib/fmtlib.github.io') for version in ['1.0.0', '1.1.0', '2.0.0', '3.0.0']: clean_checkout(env.fmt_repo, version) target_doc_dir = os.path.join(env.fmt_repo.dir, 'doc') # Remove the old theme. for entry in os.listdir(target_doc_dir): path = os.path.join(target_doc_dir, entry) if os.path.isdir(path): shutil.rmtree(path) # Copy the new theme. for entry in ['_static', '_templates', 'basic-bootstrap', 'bootstrap', 'conf.py', 'fmt.less']: src = os.path.join(env.fmt_dir, 'doc', entry) dst = os.path.join(target_doc_dir, entry) copy = shutil.copytree if os.path.isdir(src) else shutil.copyfile copy(src, dst) # Rename index to contents. contents = os.path.join(target_doc_dir, 'contents.rst') if not os.path.exists(contents): os.rename(os.path.join(target_doc_dir, 'index.rst'), contents) # Fix issues in reference.rst/api.rst. for filename in ['reference.rst', 'api.rst']: pattern = re.compile('doxygenfunction.. (bin|oct|hexu|hex)$', re.M) with rewrite(os.path.join(target_doc_dir, filename)) as b: b.data = b.data.replace('std::ostream &', 'std::ostream&') b.data = re.sub(pattern, r'doxygenfunction:: \1(int)', b.data) b.data = b.data.replace('std::FILE*', 'std::FILE *') b.data = b.data.replace('unsigned int', 'unsigned') # Fix a broken link in index.rst. index = os.path.join(target_doc_dir, 'index.rst') with rewrite(index) as b: b.data = b.data.replace( 'doc/latest/index.html#format-string-syntax', 'syntax.html') # Build the docs. html_dir = os.path.join(env.build_dir, 'html') if os.path.exists(html_dir): shutil.rmtree(html_dir) include_dir = env.fmt_repo.dir if LooseVersion(version) >= LooseVersion('3.0.0'): include_dir = os.path.join(include_dir, 'fmt') import build build.build_docs(version, doc_dir=target_doc_dir, include_dir=include_dir, work_dir=env.build_dir) shutil.rmtree(os.path.join(html_dir, '.doctrees')) # Create symlinks for older versions. for link, target in {'index': 'contents', 'api': 'reference'}.items(): link = os.path.join(html_dir, link) + '.html' target += '.html' if os.path.exists(os.path.join(html_dir, target)) and \ not os.path.exists(link): os.symlink(target, link) # Copy docs to the website. version_doc_dir = os.path.join(doc_repo.dir, version) shutil.rmtree(version_doc_dir) shutil.move(html_dir, version_doc_dir)
def update_site(env): env.fmt_repo.update(fmt_repo_url) doc_repo = Git(os.path.join(env.build_dir, 'fmtlib.github.io')) doc_repo.update('[email protected]:fmtlib/fmtlib.github.io') for version in env.versions: clean_checkout(env.fmt_repo, version) target_doc_dir = os.path.join(env.fmt_repo.dir, 'doc') # Remove the old theme. for entry in os.listdir(target_doc_dir): path = os.path.join(target_doc_dir, entry) if os.path.isdir(path): shutil.rmtree(path) # Copy the new theme. for entry in [ '_static', '_templates', 'basic-bootstrap', 'bootstrap', 'conf.py', 'fmt.less' ]: src = os.path.join(env.fmt_dir, 'doc', entry) dst = os.path.join(target_doc_dir, entry) copy = shutil.copytree if os.path.isdir(src) else shutil.copyfile copy(src, dst) # Rename index to contents. contents = os.path.join(target_doc_dir, 'contents.rst') if not os.path.exists(contents): os.rename(os.path.join(target_doc_dir, 'index.rst'), contents) # Fix issues in reference.rst/api.rst. for filename in ['reference.rst', 'api.rst', 'index.rst']: pattern = re.compile('doxygenfunction.. (bin|oct|hexu|hex)$', re.M) with rewrite(os.path.join(target_doc_dir, filename)) as b: b.data = b.data.replace('std::ostream &', 'std::ostream&') b.data = re.sub(pattern, r'doxygenfunction:: \1(int)', b.data) b.data = b.data.replace('std::FILE*', 'std::FILE *') b.data = b.data.replace('unsigned int', 'unsigned') #b.data = b.data.replace('operator""_', 'operator"" _') b.data = b.data.replace(', size_t', ', std::size_t') b.data = b.data.replace('aa long', 'a long') b.data = b.data.replace('serveral', 'several') if version.startswith('6.2.'): b.data = b.data.replace( 'vformat(const S&, basic_format_args<' + 'buffer_context<Char>>)', 'vformat(const S&, basic_format_args<' + 'buffer_context<type_identity_t<Char>>>)') # Fix a broken link in index.rst. index = os.path.join(target_doc_dir, 'index.rst') with rewrite(index) as b: b.data = b.data.replace( 'doc/latest/index.html#format-string-syntax', 'syntax.html') # Build the docs. html_dir = os.path.join(env.build_dir, 'html') if os.path.exists(html_dir): shutil.rmtree(html_dir) include_dir = env.fmt_repo.dir if LooseVersion(version) >= LooseVersion('5.0.0'): include_dir = os.path.join(include_dir, 'include', 'fmt') elif LooseVersion(version) >= LooseVersion('3.0.0'): include_dir = os.path.join(include_dir, 'fmt') import build build.build_docs(version, doc_dir=target_doc_dir, include_dir=include_dir, work_dir=env.build_dir) shutil.rmtree(os.path.join(html_dir, '.doctrees')) # Create symlinks for older versions. for link, target in {'index': 'contents', 'api': 'reference'}.items(): link = os.path.join(html_dir, link) + '.html' target += '.html' if os.path.exists(os.path.join(html_dir, target)) and \ not os.path.exists(link): os.symlink(target, link) # Copy docs to the website. version_doc_dir = os.path.join(doc_repo.dir, version) try: shutil.rmtree(version_doc_dir) except OSError as e: if e.errno != errno.ENOENT: raise shutil.move(html_dir, version_doc_dir)
shutil.rmtree(dir) except OSError as e: if e.errno == errno.ENOENT: pass build = os.environ['BUILD'] if build == 'Doc': travis = 'TRAVIS' in os.environ # Install dependencies. if travis: check_call(['sudo', 'apt-get', 'install', 'python-virtualenv', 'doxygen', 'node-less']) os.symlink('/usr/lib/node_modules/', os.path.expanduser('~/.node_libraries')) cppformat_dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) sys.path.insert(0, os.path.join(cppformat_dir, 'doc')) import build html_dir = build.build_docs() # Clone the cppformat.github.io repo. repo = 'cppformat.github.io' rmtree_if_exists(repo) git_url = 'https://github.com/' if travis else '[email protected]:' check_call(['git', 'clone', git_url + 'cppformat/{}.git'.format(repo)]) # Copy docs to the repo. target_dir = os.path.join(repo, 'dev') rmtree_if_exists(target_dir) shutil.copytree(html_dir, target_dir, ignore=shutil.ignore_patterns('.*')) if travis: check_call(['git', 'config', '--global', 'user.name', 'amplbot']) check_call(['git', 'config', '--global', 'user.email', '*****@*****.**']) # Push docs to GitHub pages. check_call(['git', 'add', '--all'], cwd=repo) if call(['git', 'diff-index', '--quiet', 'HEAD'], cwd=repo):
'http://mirrors.kernel.org/ubuntu/pool/main/d/doxygen/' + deb_file, deb_file) check_call(['sudo', 'dpkg', '-i', deb_file]) fmt_dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) build = os.environ['BUILD'] if build == 'Doc': travis = 'TRAVIS' in os.environ if travis: install_dependencies() sys.path.insert(0, os.path.join(fmt_dir, 'doc')) import build build.create_build_env() html_dir = build.build_docs() repo = 'fmtlib.github.io' if travis and 'KEY' not in os.environ: # Don't update the repo if building on Travis from an account that # doesn't have push access. print('Skipping update of ' + repo) exit(0) # Clone the fmtlib.github.io repo. rmtree_if_exists(repo) git_url = 'https://github.com/' if travis else '[email protected]:' check_call(['git', 'clone', git_url + 'fmtlib/{}.git'.format(repo)]) # Copy docs to the repo. target_dir = os.path.join(repo, 'dev') rmtree_if_exists(target_dir) shutil.copytree(html_dir, target_dir, ignore=shutil.ignore_patterns('.*')) if travis:
data = re.sub( re.compile('doxygenfunction.. (bin|oct|hexu|hex)$', re.MULTILINE), r'doxygenfunction:: \1(int)', data) data = data.replace('std::FILE*', 'std::FILE *') data = data.replace('unsigned int', 'unsigned') with open(reference, 'w') as f: f.write(data) # Build the docs. html_dir = os.path.join(build_dir, 'html') if os.path.exists(html_dir): shutil.rmtree(html_dir) include_dir = fmt_repo.dir if LooseVersion(version) >= LooseVersion('3.0.0'): include_dir = os.path.join(include_dir, 'fmt') build.build_docs(version, doc_dir=target_doc_dir, include_dir=include_dir, work_dir=build_dir) shutil.rmtree(os.path.join(html_dir, '.doctrees')) # Create symlinks for older versions. for link, target in {'index': 'contents', 'api': 'reference'}.items(): link = os.path.join(html_dir, link) + '.html' target += '.html' if os.path.exists(os.path.join(html_dir, target)) and \ not os.path.exists(link): os.symlink(target, link) # Copy docs to the website. version_doc_dir = os.path.join(doc_repo.dir, version) shutil.rmtree(version_doc_dir) shutil.move(html_dir, version_doc_dir)
with open(reference) as f: data = f.read() data = data.replace('std::ostream &', 'std::ostream&') data = re.sub(re.compile('doxygenfunction.. (bin|oct|hexu|hex)$', re.MULTILINE), r'doxygenfunction:: \1(int)', data) data = data.replace('std::FILE*', 'std::FILE *') data = data.replace('unsigned int', 'unsigned') with open(reference, 'w') as f: f.write(data) # Build the docs. html_dir = os.path.join(build_dir, 'html') if os.path.exists(html_dir): shutil.rmtree(html_dir) include_dir = fmt_repo.dir if LooseVersion(version) >= LooseVersion('3.0.0'): include_dir = os.path.join(include_dir, 'fmt') build.build_docs(version, doc_dir=target_doc_dir, include_dir=include_dir, work_dir=build_dir) shutil.rmtree(os.path.join(html_dir, '.doctrees')) # Create symlinks for older versions. for link, target in {'index': 'contents', 'api': 'reference'}.items(): link = os.path.join(html_dir, link) + '.html' target += '.html' if os.path.exists(os.path.join(html_dir, target)) and \ not os.path.exists(link): os.symlink(target, link) # Copy docs to the website. version_doc_dir = os.path.join(doc_repo.dir, version) shutil.rmtree(version_doc_dir) shutil.move(html_dir, version_doc_dir)
def handle(self, *test_labels, **options): build.generate_api_docs() build.build_docs()
fmt_repo.checkout(version) target_doc_dir = os.path.join(fmt_repo.dir, 'doc') # Remove the old theme. for entry in os.listdir(target_doc_dir): path = os.path.join(target_doc_dir, entry) if os.path.isdir(path): shutil.rmtree(path) # Copy the new theme. for entry in ['_static', '_templates', 'basic-bootstrap', 'bootstrap', 'conf.py', 'fmt.less']: src = os.path.join(fmt_dir, 'doc', entry) dst = os.path.join(target_doc_dir, entry) copy = shutil.copytree if os.path.isdir(src) else shutil.copyfile copy(src, dst) # Rename index to contents. contents = os.path.join(target_doc_dir, 'contents.rst') if not os.path.exists(contents): os.rename(os.path.join(target_doc_dir, 'index.rst'), contents) # Build the docs. build.build_docs(version, doc_dir=target_doc_dir, include_dir=fmt_repo.dir) # Create symlinks for older versions. for link, target in {'index': 'contents', 'api': 'reference'}.items(): os.symlink(target + '.html', os.path.join('html', link) + '.html') # Copy docs to the website. version_doc_dir = os.path.join(doc_repo.dir, version) shutil.rmtree(version_doc_dir) shutil.copytree('html', version_doc_dir, symlinks=True) # TODO: fix links # TODO: remove doc repo except: shutil.rmtree(fmt_repo.dir)
if os.path.isdir(path): shutil.rmtree(path) # Copy the new theme. for entry in [ '_static', '_templates', 'basic-bootstrap', 'bootstrap', 'conf.py', 'fmt.less' ]: src = os.path.join(fmt_dir, 'doc', entry) dst = os.path.join(target_doc_dir, entry) copy = shutil.copytree if os.path.isdir(src) else shutil.copyfile copy(src, dst) # Rename index to contents. contents = os.path.join(target_doc_dir, 'contents.rst') if not os.path.exists(contents): os.rename(os.path.join(target_doc_dir, 'index.rst'), contents) # Build the docs. build.build_docs(version, doc_dir=target_doc_dir, include_dir=fmt_repo.dir) # Create symlinks for older versions. for link, target in {'index': 'contents', 'api': 'reference'}.items(): os.symlink(target + '.html', os.path.join('html', link) + '.html') # Copy docs to the website. version_doc_dir = os.path.join(doc_repo.dir, version) shutil.rmtree(version_doc_dir) shutil.copytree('html', version_doc_dir, symlinks=True) # TODO: fix links # TODO: remove doc repo except: shutil.rmtree(fmt_repo.dir)
'conf.py', 'fmt.less']: src = os.path.join(fmt_dir, 'doc', entry) dst = os.path.join(target_doc_dir, entry) copy = shutil.copytree if os.path.isdir(src) else shutil.copyfile copy(src, dst) # TODO: update links in navbar # Rename index to contents. contents = os.path.join(target_doc_dir, 'contents.rst') if not os.path.exists(contents): os.rename(os.path.join(target_doc_dir, 'index.rst'), contents) # Fix issues in reference.rst. reference = os.path.join(target_doc_dir, 'reference.rst') if os.path.exists(reference): with open(reference) as f: data = f.read() data = data.replace('std::ostream &', 'std::ostream&') data = re.sub(r'doxygenfunction.. (bin|oct|hexu|hex)', r'doxygenfunction:: \1(int)', data) with open(reference, 'w') as f: f.write(data) # Build the docs. html_dir = build.build_docs(version, doc_dir=target_doc_dir, include_dir=fmt_repo.dir, work_dir=work_dir) # Create symlinks for older versions. for link, target in {'index': 'contents', 'api': 'reference'}.items(): os.symlink(target + '.html', os.path.join(html_dir, link) + '.html') # Copy docs to the website. version_doc_dir = os.path.join(doc_repo.dir, version) shutil.rmtree(version_doc_dir) shutil.move(html_dir, version_doc_dir)