예제 #1
0
def build(
    all: bool,
    verbose: bool,
    draft: bool,
    continuous: bool,
    path: Optional[Path] = None,
    input: Optional[Path] = None,
    output: Optional[Path] = None,
    template: Optional[Path] = None,
    reformat: bool = False,
    log: bool = False,
    urls: bool = False,
):
    report = Report()
    core = Core(report=report, collect_urls=urls)
    print(logo_2(__version__))
    print_pandoc_info()

    path_setup = setup_paths(path, input, output, template, report)
    format = "html"

    builder = HTMLBuilder(
        path_setup.input,
        path_setup.output,
        path_setup.template,
        report,
        rebuild_all_pages=all,
        abort_draft=not draft,
        verbose=verbose,
        reformat=reformat,
    )
    builder.set_core(core)
    builder.build()

    if urls:
        core.url_checker.check()

    if log:
        report.print_to_file(base_path / "supermark.log")
    else:
        report.print(verbose=verbose)
    if report.has_error():
        # beep(3)  # sad error
        ex = ClickException("Something is wrong.")
        ex.exit_code = 1
        raise ex
예제 #2
0
def build(
    all: bool,
    verbose: bool,
    draft: bool,
    continuous: bool,
    path: Optional[Path] = None,
    input: Optional[Path] = None,
    output: Optional[Path] = None,
    template: Optional[Path] = None,
    reformat: bool = False,
    log: bool = False,
):
    report = Report()
    core = Core(report=report)
    print(logo_2(__version__))
    print_pandoc_info()

    path = ensure_path(path)
    input = ensure_path(input)
    output = ensure_path(output)
    template = ensure_path(template)

    base_path = path or Path.cwd()
    input_path = None
    output_path = None
    template_path = None

    # read configuration file
    config_file = Path("config.toml")
    if config_file.exists():
        report.info("Found configuration file.", path=config_file)
        config = toml.load(config_file)
        if "input" in config and input is None:
            input_path = base_path / config["input"]
        if "output" in config and output is None:
            output_path = base_path / config["output"]
        if "template" in config and template is None:
            template_path = base_path / config["template"]

    if input_path is None:
        input_path = base_path / "pages"
    if output_path is None:
        output_path = output or Path.cwd()
    if template_path is None:
        template_path = template or (base_path / "templates/page.html")

    format = "html"

    builder = HTMLBuilder(
        input_path,
        output_path,
        template_path,
        report,
        rebuild_all_pages=all,
        abort_draft=not draft,
        verbose=verbose,
        reformat=reformat,
    )
    builder.set_core(core)
    builder.build()
    if log:
        report.print_to_file(base_path / "supermark.log")
    else:
        report.print(verbose=verbose)
    if report.has_error():
        # beep(3)  # sad error
        ex = ClickException("Something is wrong.")
        ex.exit_code = 1
        raise ex