-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
V2 of the configuration file #4355
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
Conversation
Ok, I have ~147 tests to pass |
This ones have a replace in v2
I have re-reviewed this, about the duplicate logic:
So, I'm not sure if reusing some methods are going to save a lot of code. We have different cases to manage in each version. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the last commits I change the code to respect the defaults from the schema rather than the db, remove some unused keys from v1 that have a replacement in v2, and added a feature flag to deactivate the v2 on production.
}, | ||
'readthedocs/build:stable': { | ||
'python': {'supported_versions': [2, 2.7, 3, 3.3, 3.4, 3.5, 3.6]}, | ||
}, | ||
'readthedocs/build:latest': { | ||
'python': {'supported_versions': [2, 2.7, 3, 3.3, 3.4, 3.5, 3.6]}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BTW, latest is the same for v1 and v2, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For now, yeah.
@@ -26,16 +27,26 @@ def load_yaml_config(version): | |||
|
|||
img_name = project.container_image or DOCKER_IMAGE | |||
python_version = 3 if project.python_interpreter == 'python3' else 2 | |||
allow_v2 = project.has_feature(Feature.ALLOW_V2_CONFIG_FILE) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if this is the best way of using the feature flag here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let me know if this is okay, to generate the migration.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we support v2 no matter when the project was created, so "ALLOW_V2_CONFIG_FILE" isn't the best name for this. Rather, when projects have this feature flag, we'll assume the user will definitely be using v2 config to configure their project. This allows us to disable the UI elements in the admin for options that can be controlled in config.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wanted to add this to don't allow users to use the v2 in production yet. Maybe a django setting is the best here? or what name do you suggest for this feature flag?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking close. I think there are some changes needed still on the feature flag concept, and I think we probably want a type
field, even if it is determined from the use of sphinx
vs mkdocs
keys.
}, | ||
'readthedocs/build:stable': { | ||
'python': {'supported_versions': [2, 2.7, 3, 3.3, 3.4, 3.5, 3.6]}, | ||
}, | ||
'readthedocs/build:latest': { | ||
'python': {'supported_versions': [2, 2.7, 3, 3.3, 3.4, 3.5, 3.6]}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For now, yeah.
readthedocs/config/config.py
Outdated
'You can not have the ``sphinx`` and ``mkdocs`` ' | ||
'keys at the same time', | ||
code=INVALID_KEYS_COMBINATION | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I get what this particular function is doing, but what i was pointing out is that we aren't using the config file to determine the build type.
Currently, I believe build type is handled here:
https://github.com/rtfd/readthedocs.org/blob/ca7afe6577672e129ccfe63abe33561dc32a6651/readthedocs/doc_builder/python_environments.py#L275
So, currently, it's possible for a sphinx
key to exist in the config file, but the user can set mkdocs
build type, and we'll use that as the build backend type. I think what we actually want is for the config file to dictate build type. If there is a mkdocs
key, we can assume this is a mkdocs build.
@@ -26,16 +27,26 @@ def load_yaml_config(version): | |||
|
|||
img_name = project.container_image or DOCKER_IMAGE | |||
python_version = 3 if project.python_interpreter == 'python3' else 2 | |||
allow_v2 = project.has_feature(Feature.ALLOW_V2_CONFIG_FILE) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we support v2 no matter when the project was created, so "ALLOW_V2_CONFIG_FILE" isn't the best name for this. Rather, when projects have this feature flag, we'll assume the user will definitely be using v2 config to configure their project. This allows us to disable the UI elements in the admin for options that can be controlled in config.
@@ -1022,6 +1022,7 @@ def add_features(sender, **kwargs): | |||
SKIP_SUBMODULES = 'skip_submodules' | |||
BUILD_JSON_ARTIFACTS_WITH_HTML = 'build_json_artifacts_with_html' | |||
DONT_OVERWRITE_SPHINX_CONTEXT = 'dont_overwrite_sphinx_context' | |||
ALLOW_V2_CONFIG_FILE = 'allow_v2_config_file' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Noted above, i think this feature flag name should change
@@ -1033,6 +1034,8 @@ def add_features(sender, **kwargs): | |||
'Build the json artifacts with the html build step')), | |||
(DONT_OVERWRITE_SPHINX_CONTEXT, _( | |||
'Do not overwrite context vars in conf.py with Read the Docs context',)), | |||
(ALLOW_V2_CONFIG_FILE, _( | |||
'Allow to use the v2 of the configuration file')), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also needs update here
I think this PR is ready for a final review, next step is matching the properties between v1 and v2 (where it makes sense of course). And modify the build process to make use of the new properties, and I think we can implement the new features like submodules here too. I'll be building some projects to make sure this doesn't break the v1, but it shouldn't, I didn't touch the v1 logic here. |
readthedocs/config/config.py
Outdated
valid_sphinx_builders = { | ||
'sphinx': 'sphinx', | ||
'htmldir': 'sphinx_htmldir', | ||
'singlehtml': 'sphinx_singlehtml', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I leave this values as plain htmldir
rather than sphinx_htmldir
to avoid redundancy in the sphinx
key, but we always return the full name from the config object.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should the first builder should be html
then, instead of sphinx
? I know our mapping has sphinx
for the default html builder, but this is not clear, and should probably not be this way anyways. I think {'html': 'sphinx_html'}
make more sense for this. Also, from the user perspective, I'd expect to fill in sphinx.builder: html
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah that makes more sense, I wasn't sure what to put there p: Changing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, it looks like you followed our existing pattern, it's just that our existing pattern is sort of wrong also. Do we also need to update the logic for deciding on the builder?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need to update the logic here, but yeah when implementing the actual changes in the logic we need to modify that.
About the pattern, I'm not sure if I follow you hehe, do you mean changing the names from sphinx
-> html
there too? We can create an issue to track that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 that works
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think for consistency the html sphinx keys/value needs to change, but this looks good otherwise. I'm not sure we need to update the design doc, as i think we'll use the schema as a source for generating documentation on the schema, but we could update that if you think it's important. I'm not certain it is though.
readthedocs/config/config.py
Outdated
valid_sphinx_builders = { | ||
'sphinx': 'sphinx', | ||
'htmldir': 'sphinx_htmldir', | ||
'singlehtml': 'sphinx_singlehtml', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should the first builder should be html
then, instead of sphinx
? I know our mapping has sphinx
for the default html builder, but this is not clear, and should probably not be this way anyways. I think {'html': 'sphinx_html'}
make more sense for this. Also, from the user perspective, I'd expect to fill in sphinx.builder: html
.
Yeah, I think the same, the design doc was to put an initial path in the project. Having the schema is enough I think. What I was wondering is that we'll need to repeat the schema in the docs, but there aren't many keys anyway. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think these changes look good to merge! 👍
This PR will just add the parser/validation for the v2 schema.