This is an automated email from the ASF dual-hosted git repository. ash pushed a commit to branch v2-1-test in repository https://gitbox.apache.org/repos/asf/airflow.git
commit acc824f60786069e596fd0e97fa99fcef9f00fa6 Author: Jed Cunningham <[email protected]> AuthorDate: Tue Jun 15 10:34:44 2021 -0600 Fix templated default/example values in config ref docs (#16442) We should show the actual default/example value in the configuration reference docs, not the templated values. e.g. `{dag_id}` like you get in a generated airflow.cfg, not `{{dag_id}} like is stored in the airflow.cfg template. (cherry picked from commit cc3c13c1f52a0051aea79d90bf8258e7d156d6b7) --- airflow/configuration.py | 2 +- docs/conf.py | 14 +++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/airflow/configuration.py b/airflow/configuration.py index 53e76a6..c3595d7 100644 --- a/airflow/configuration.py +++ b/airflow/configuration.py @@ -91,7 +91,7 @@ def _default_config_file_path(file_name: str): return os.path.join(templates_dir, file_name) -def default_config_yaml() -> dict: +def default_config_yaml() -> List[dict]: """ Read Airflow configs from YAML file diff --git a/docs/conf.py b/docs/conf.py index 39426d6..e403ffe 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -339,8 +339,20 @@ if PACKAGE_NAME == 'apache-airflow': ) in AirflowConfigParser.deprecated_options.items(): deprecated_options[deprecated_section][deprecated_key] = section, key, since_version + configs = default_config_yaml() + + # We want the default/example we show in the docs to reflect the value _after_ + # the config has been templated, not before + # e.g. {{dag_id}} in default_config.cfg -> {dag_id} in airflow.cfg, and what we want in docs + keys_to_format = ["default", "example"] + for conf_section in configs: + for option in conf_section["options"]: + for key in keys_to_format: + if option[key] and "{{" in option[key]: + option[key] = option[key].replace("{{", "{").replace("}}", "}") + jinja_contexts = { - 'config_ctx': {"configs": default_config_yaml(), "deprecated_options": deprecated_options}, + 'config_ctx': {"configs": configs, "deprecated_options": deprecated_options}, 'quick_start_ctx': { 'doc_root_url': f'https://airflow.apache.org/docs/apache-airflow/{PACKAGE_VERSION}/' if FOR_PRODUCTION
