Skip to content

Commit

Permalink
Fix templated default/example values in config ref docs (#16442)
Browse files Browse the repository at this point in the history
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 cc3c13c)
  • Loading branch information
jedcunningham authored and ashb committed Jun 22, 2021
1 parent e58a6a9 commit acc824f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion airflow/configuration.py
Expand Up @@ -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
Expand Down
14 changes: 13 additions & 1 deletion docs/conf.py
Expand Up @@ -339,8 +339,20 @@ def _get_rst_filepath_from_path(filepath: str):
) 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
Expand Down

0 comments on commit acc824f

Please sign in to comment.