Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow "x-" options in readthedocs.yml configuration #7288

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions readthedocs/config/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -1085,10 +1085,13 @@ def _get_extra_key(self, value):
}

Will return `['key', 'name']`.

Ignores keys that start with ``x-``.
"""
if isinstance(value, dict) and value:
key_name = next(iter(value))
return [key_name] + self._get_extra_key(value[key_name])
if isinstance(value, dict):
key_name = next((k for k in value if not k.startswith('x-')), None)
if key_name is not None:
return [key_name] + self._get_extra_key(value[key_name])
return []

@property
Expand Down
1 change: 1 addition & 0 deletions readthedocs/config/tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -1966,6 +1966,7 @@ def test_strict_validation_pops_all_keys(self):
({'one': {'two': 3}}, ['one', 'two']),
(OrderedDict([('one', 1), ('two', 2)]), ['one']),
(OrderedDict([('one', {'two': 2}), ('three', 3)]), ['one', 'two']),
({'one': 1, 'x-two': 2}, ['one']),
],
)
def test_get_extra_key(self, value, expected):
Expand Down