def _get_current_scope(env):
    """Get the refid that is being currently documented. Also, create the scope
    stack it it does not exist."""
    scope_stack = env.ref_context.setdefault('doxy:refid', [])
    try:
        scope = scope_stack[-1]
    except IndexError:
        scope = 0
    return scope
