From 2f4033539015a2ef05a1571c3d1ed47391c78023 Mon Sep 17 00:00:00 2001 From: Ivan Blinkov Date: Mon, 30 Mar 2020 22:33:33 +0300 Subject: [PATCH] Extra logging at build.py + rearrange ifs --- docs/tools/build.py | 52 +++++++++++++++++++++++---------------------- 1 file changed, 27 insertions(+), 25 deletions(-) diff --git a/docs/tools/build.py b/docs/tools/build.py index 741e9343923..2e764f1c5b0 100755 --- a/docs/tools/build.py +++ b/docs/tools/build.py @@ -218,39 +218,39 @@ def build_single_page_version(lang, args, cfg): os.path.join(site_temp, 'single'), single_page_output_path ) + + logging.info(f'Re-building single page for {lang} pdf/test') + with util.temp_dir() as test_dir: + single_page_pdf = os.path.abspath( + os.path.join(single_page_output_path, f'clickhouse_{lang}.pdf') + ) + extra['single_page'] = False + cfg.load_dict({ + 'docs_dir': docs_temp_lang, + 'site_dir': test_dir, + 'extra': extra, + 'nav': [ + {cfg.data.get('site_name'): 'single.md'} + ] + }) + mkdocs_build.build(cfg) - if not args.skip_pdf: - with util.temp_dir() as test_dir: - single_page_pdf = os.path.abspath( - os.path.join(single_page_output_path, f'clickhouse_{lang}.pdf') - ) - extra['single_page'] = False - cfg.load_dict({ - 'docs_dir': docs_temp_lang, - 'site_dir': test_dir, - 'extra': extra, - 'nav': [ - {cfg.data.get('site_name'): 'single.md'} - ] - }) - mkdocs_build.build(cfg) - - css_in = ' '.join(website.get_css_in(args)) - js_in = ' '.join(website.get_js_in(args)) - subprocess.check_call(f'cat {css_in} > {test_dir}/css/base.css', shell=True) - subprocess.check_call(f'cat {js_in} > {test_dir}/js/base.js', shell=True) + css_in = ' '.join(website.get_css_in(args)) + js_in = ' '.join(website.get_js_in(args)) + subprocess.check_call(f'cat {css_in} > {test_dir}/css/base.css', shell=True) + subprocess.check_call(f'cat {js_in} > {test_dir}/js/base.js', shell=True) + if not args.skip_pdf: port_for_pdf = util.get_free_port() with socketserver.TCPServer( ('', port_for_pdf), http.server.SimpleHTTPRequestHandler ) as httpd: - logging.info(f"serving for pdf at port {port_for_pdf}") + logging.info(f"Serving for {lang} pdf at port {port_for_pdf}") thread = threading.Thread(target=httpd.serve_forever) with util.cd(test_dir): thread.start() create_pdf_command = [ 'wkhtmltopdf', '--print-media-type', - '--no-stop-slow-scripts', '--log-level', 'warn', f'http://localhost:{port_for_pdf}/single/', single_page_pdf ] @@ -262,10 +262,12 @@ def build_single_page_version(lang, args, cfg): finally: httpd.shutdown() thread.join(timeout=5.0) + logging.info(f"Stop serving for {lang} pdf at port {port_for_pdf}") - if not args.version_prefix: # maybe enable in future - test.test_single_page( - os.path.join(test_dir, 'single', 'index.html'), lang) + if not args.version_prefix: # maybe enable in future + logging.info(f'Running tests for {lang}') + test.test_single_page( + os.path.join(test_dir, 'single', 'index.html'), lang) logging.info(f'Finished building single page version for {lang}')