def role_doc_entry(role_name, local_roles):
    """Generates Documentation entry

    If the included role isn't hosted on tripleo-validations, we point to the
    validations-common role documentation. Otherwise, it generates a classical
    local toctree.
    """
    local_role_doc = (".. toctree::\n\n"
                      "   roles/role-{}".format(role_name))
    doc_base_url = "https://docs.openstack.org/validations-common/latest/roles"
    external_role = \
        ("- `{role} <{baseurl}/role-{role}.html>`_ "
         "from `openstack/validations-common "
         "<https://opendev.org/openstack/validations-common>`_"
         "".format(role=role_name,
                   baseurl=doc_base_url))

    if role_name not in local_roles:
        return external_role
    return local_role_doc