How to use the mkdocs.commands.build function in mkdocs

To help you get started, we’ve selected a few mkdocs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mkdocs / mkdocs / mkdocs / __main__.py View on Github external
def build_command(clean, **kwargs):
    """Build the MkDocs documentation"""

    try:
        build.build(config.load_config(**kwargs), dirty=not clean)
    except exceptions.ConfigurationError as e:  # pragma: no cover
        # Avoid ugly, unhelpful traceback
        raise SystemExit('\n' + str(e))
github mkdocs / mkdocs / mkdocs / __main__.py View on Github external
def gh_deploy_command(clean, message, remote_branch, remote_name, force, ignore_version, **kwargs):
    """Deploy your documentation to GitHub Pages"""
    try:
        cfg = config.load_config(
            remote_branch=remote_branch,
            remote_name=remote_name,
            **kwargs
        )
        build.build(cfg, dirty=not clean)
        gh_deploy.gh_deploy(cfg, message=message, force=force, ignore_version=ignore_version)
    except exceptions.ConfigurationError as e:  # pragma: no cover
        # Avoid ugly, unhelpful traceback
        raise SystemExit('\n' + str(e))
github SAP / vulnerability-assessment-tool / docs / docs.py View on Github external
def handle_mkdocs_build(to_build, kind):
    print('Building website using MKdocs, will be saved in ./site')
    if to_build:
        build.build(config.load_config(
            config_file=select_config(kind),
        ))
github ClickHouse / ClickHouse / docs / tools / build.py View on Github external
create_pdf_command = ['wkhtmltopdf', '--print-media-type', single_page_index_html, single_page_pdf]
                    logging.debug(' '.join(create_pdf_command))
                    subprocess.check_call(' '.join(create_pdf_command), shell=True)

                with util.temp_dir() as test_dir:
                    cfg.load_dict({
                        'docs_dir': docs_temp_lang,
                        'site_dir': test_dir,
                        'extra': {
                            'single_page': False
                        },
                        'nav': [
                            {cfg.data.get('site_name'): 'single.md'}
                        ]
                    })
                    mkdocs_build.build(cfg)
                    if not args.version_prefix:  # maybe enable in future
                        test.test_single_page(os.path.join(test_dir, 'single', 'index.html'), lang)
                    if args.save_raw_single_page:
                        shutil.copytree(test_dir, args.save_raw_single_page)
github SAP / vulnerability-assessment-tool / docs / docs.py View on Github external
def handle_mkdocs_ghdeploy(to_ghdeploy, kind, remote):
    if to_ghdeploy:
        delete_branch('gh-pages')
        cfg = config.load_config(
            config_file=os.path.join(CWD, select_config(kind)),
            remote_name=remote
        )
        build.build(cfg)
        print('Deploying {} Github Pages to {}#gh-pages'.format(kind, remote))
        gh_deploy.gh_deploy(cfg, force=True)
github ClickHouse / ClickHouse / docs / tools / build.py View on Github external
for filename in filenames:
                        if filename != 'single.md' and filename.endswith('.md'):
                            os.unlink(os.path.join(root, filename))

                cfg.load_dict({
                    'docs_dir': docs_temp_lang,
                    'site_dir': site_temp,
                    'extra': {
                        'single_page': True
                    },
                    'nav': [
                        {cfg.data.get('site_name'): 'single.md'}
                    ]
                })

                mkdocs_build.build(cfg)

                if args.version_prefix:
                    single_page_output_path = os.path.join(args.docs_dir, args.docs_output_dir, args.version_prefix, lang, 'single')
                else:
                    single_page_output_path = os.path.join(args.docs_dir, args.docs_output_dir, lang, 'single')

                if os.path.exists(single_page_output_path):
                    shutil.rmtree(single_page_output_path)

                shutil.copytree(
                    os.path.join(site_temp, 'single'),
                    single_page_output_path
                )

                if not args.skip_pdf:
                    single_page_index_html = os.path.abspath(os.path.join(single_page_output_path, 'index.html'))
github restaction / mkdocs-autodoc / mkdocs_autodoc / __init__.py View on Github external
@patch(build.build)
def patched_build(f, config, *args, **kwargs):
    print("HACK".center(60, "-"))
    real_config = load_config(config_file=None)
    for k in ["theme", "theme_dir"]:
        config[k] = real_config[k]
    return f(config, *args, **kwargs)
github restaction / mkdocs-autodoc / mkdocs_autodoc / __init__.py View on Github external
@patch(build._build_page)
def build_page(f, page, *args, **kwargs):
    """
    A patch of mkdocs.commands.build._build_page
    """
    if page.input_path.endswith(AUTODOC_MARK):
        return build_autodoc(page, *args, **kwargs)
    return f(page, *args, **kwargs)