How to use the manubot.process.ci.get_continuous_integration_parameters function in manubot

To help you get started, we’ve selected a few manubot 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 manubot / manubot / manubot / process / metadata.py View on Github external
the return dictionary will be like:
    ```python
    {
        "html_url": "https://git.dhimmel.com/bitcoin-whitepaper/",
        "pdf_url": "https://git.dhimmel.com/bitcoin-whitepaper/manuscript.pdf",
        "html_url_versioned": "https://git.dhimmel.com/bitcoin-whitepaper/v/cb1f2c12eec8b56db9ef5f641ec805e2d449d319/",
        "pdf_url_versioned": "https://git.dhimmel.com/bitcoin-whitepaper/v/cb1f2c12eec8b56db9ef5f641ec805e2d449d319/manuscript.pdf",
    }
    ```
    Note the trailing `/` in `html_url`, which is required for proper functioning.
    """
    import requests
    from .ci import get_continuous_integration_parameters

    urls = dict()
    ci_params = get_continuous_integration_parameters()
    if html_url is None:
        if not ci_params:
            return urls
        html_url = "https://{repo_owner}.github.io/{repo_name}/".format(**ci_params)
    urls["html_url"] = html_url
    urls["pdf_url"] = urljoin(html_url, "manuscript.pdf")
    if not ci_params:
        return urls
    urls["html_url_versioned"] = urljoin(html_url, "v/{commit}/".format(**ci_params))
    urls["pdf_url_versioned"] = urljoin(urls["html_url_versioned"], "manuscript.pdf")
    response = requests.head(html_url, allow_redirects=True)
    if not response.ok:
        logging.warning(
            "html_url is not web accessible. "
            f"{html_url} returned status code {response.status_code}. "
            "Ignore this warning if the manuscript has not yet been deployed for the first time. "
github manubot / manubot / manubot / process / util.py View on Github external
if "author_info" in metadata:
        authors = metadata.pop("author_info", [])
        warnings.warn(
            "metadata.yaml: 'author_info' is deprecated. Use 'authors' instead.",
            category=DeprecationWarning,
        )
    else:
        authors = metadata.pop("authors", [])
    if authors is None:
        authors = []
    variables["pandoc"]["author-meta"] = [author["name"] for author in authors]
    variables["manubot"]["authors"] = authors
    add_author_affiliations(variables["manubot"])

    # Set repository version metadata for CI builds
    ci_params = get_continuous_integration_parameters()
    if ci_params:
        variables["manubot"]["ci_source"] = ci_params

    # Add manuscript URLs
    variables["manubot"].update(get_manuscript_urls(metadata.pop("html_url", None)))

    # Add software versions
    variables["manubot"].update(get_software_versions())

    # Add thumbnail URL if present
    thumbnail_url = get_thumbnail_url(metadata.pop("thumbnail", None))
    if thumbnail_url:
        variables["manubot"]["thumbnail_url"] = thumbnail_url

    # Update variables with metadata.yaml pandoc/manubot dicts
    for key in "pandoc", "manubot":
github manubot / manubot / manubot / process / metadata.py View on Github external
def _thumbnail_path_to_url(path):
    """
    Convert a local thumbnail path (string) to an absolute URL using the GitHub
    repository location detected using `get_continuous_integration_parameters`.
    """
    if not path:
        return None
    from .ci import get_continuous_integration_parameters

    info = get_continuous_integration_parameters()
    try:
        url = f"https://github.com/{info['repo_slug']}/raw/{info['triggering_commit']}/{path}"
    except (TypeError, KeyError):
        return None
    return url
github manubot / manubot / manubot / webpage / webpage_command.py View on Github external
# Set webpage directory
    args_dict["webpage_directory"] = pathlib.Path("webpage")
    args.webpage_directory.mkdir(exist_ok=True)

    # Create webpage/v directory (if it doesn't already exist)
    args_dict["versions_directory"] = args.webpage_directory.joinpath("v")
    args.versions_directory.mkdir(exist_ok=True)

    # Checkout existing version directories
    checkout_existing_versions(args)

    # Apply --version argument defaults
    if args.version is None:
        from manubot.process.ci import get_continuous_integration_parameters

        ci_params = get_continuous_integration_parameters()
        if ci_params:
            args_dict["version"] = ci_params.get("commit", "local")
        else:
            args_dict["version"] = "local"

    # Create empty webpage/v/version directory
    version_directory = args.versions_directory.joinpath(args.version)
    if version_directory.is_dir():
        logging.warning(
            f"{version_directory} exists: replacing it with an empty directory"
        )
        shutil.rmtree(version_directory)
    version_directory.mkdir()
    args_dict["version_directory"] = version_directory

    # Symlink webpage/v/latest to point to webpage/v/commit