diff --git a/docs/tools/build.py b/docs/tools/build.py index 4733333d467..581658a0162 100755 --- a/docs/tools/build.py +++ b/docs/tools/build.py @@ -196,19 +196,9 @@ def build_single_page_version(lang, args, cfg): shutil.copytree(test_dir, args.save_raw_single_page) -def build_redirect_html(args, from_path, to_path): - for lang in args.lang.split(','): - out_path = os.path.join(args.docs_output_dir, lang, from_path.replace('.md', '/index.html')) - out_dir = os.path.dirname(out_path) - try: - os.makedirs(out_dir) - except OSError: - pass - version_prefix = args.version_prefix + '/' if args.version_prefix else '/' - to_url = '/docs%s%s/%s' % (version_prefix, lang, to_path.replace('.md', '/')) - to_url = to_url.strip() - with open(out_path, 'w') as f: - f.write(''' +def write_redirect_html(out_path, to_url): + with open(out_path, 'w') as f: + f.write('''
@@ -224,6 +214,20 @@ def build_redirect_html(args, from_path, to_path): ''' % (to_url, to_url, to_url)) +def build_redirect_html(args, from_path, to_path): + for lang in args.lang.split(','): + out_path = os.path.join(args.docs_output_dir, lang, from_path.replace('.md', '/index.html')) + out_dir = os.path.dirname(out_path) + try: + os.makedirs(out_dir) + except OSError: + pass + version_prefix = args.version_prefix + '/' if args.version_prefix else '/' + to_url = '/docs%s%s/%s' % (version_prefix, lang, to_path.replace('.md', '/')) + to_url = to_url.strip() + write_redirect_html(out_path, to_url) + + def build_redirects(args): lang_re_fragment = args.lang.replace(',', '|') rewrites = [] @@ -263,6 +267,11 @@ def build(args): if not args.skip_website: minify_website(args) + write_redirect_html( + os.path.join(args.output_dir, 'tutorial.html'), + '/docs/en/getting_started/tutorial/' + ) + if __name__ == '__main__': os.chdir(os.path.join(os.path.dirname(__file__), '..'))