def generate_block(name, abstract, authors, contributors, types, tags, category,
                   img_url, article_url=None, deployment_url=None):
    """Generate json documentation for a training program block.
    
    If both `article_url` and `deployment_url` are None, the block is assumed
    to be a container for further sub-blocks (i.e. has an "open" button).
    Otherwise, either one of or both `article_url` and `deployment_url` must
    be provided. 
    """
    block = {
        "name": name,
        "abstract": abstract,
        "authors": authors,
        "contributors": contributors,
        "types": types,
        "tags": tags,
        "category": category,
        "imageUrl": img_url
    }

    if article_url is None and deployment_url is None:
        block["parts"] = []
    if deployment_url is not None:
        block["deploymentUrl"] = deployment_url
    if article_url is not None:
        block["articleUrl"] = article_url

    return block