Purge expired values from the environment.

    When certain configuration values change, related values in the
    environment must be cleared. While Sphinx can rebuild documents on
    configuration changes, it does not notify extensions when this
    happens. Instead, cache relevant values in the environment in order
    to detect when they change.

    Args:
        app: The Sphinx application.

def validate_env(app):
    """Purge expired values from the environment.

    When certain configuration values change, related values in the
    environment must be cleared. While Sphinx can rebuild documents on
    configuration changes, it does not notify extensions when this
    happens. Instead, cache relevant values in the environment in order
    to detect when they change.

    Args:
        app: The Sphinx application.
    """

    if not hasattr(app.env, 'javalink_config_cache'):
        app.env.javalink_config_cache = {}

    for conf_attr, (_, _, env_attr) in ref.CONFIG_VALUES.iteritems():
        if not env_attr:
            continue

        value = getattr(app.config, conf_attr)
        cached = app.env.javalink_config_cache.get(conf_attr, value)

        app.env.javalink_config_cache[conf_attr] = value
        if value != cached:
            app.verbose('[javalink] config.%s has changed, clearing related env', conf_attr)
            delattr(app.env, env_attr)