-
Notifications
You must be signed in to change notification settings - Fork 25
Check for readthedocs file with yaml extension #48
Conversation
Fix some typos and document the new file extension.
readthedocs_build/config/config.py
Outdated
@@ -14,7 +14,7 @@ | |||
'load', 'BuildConfig', 'ConfigError', 'InvalidConfig', 'ProjectConfig') | |||
|
|||
|
|||
CONFIG_FILENAMES = ('readthedocs.yml', '.readthedocs.yml') | |||
CONFIG_FILENAMES = ('readthedocs.yml', '.readthedocs.yml', 'readthedocs.yaml') |
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 need a .readthedocs.yaml
too. Maybe we can refactor this to be a regex?
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.
Good point, I was considering even an helper method as this is not the only yaml file in use.
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.
Done, notice that now also .readthedocs.yaml
is allowed. If you are happy with this implementation I'll document it but I'm not sure that listing 4 exact filenames with a slight difference is very human friendly, so I was thinking something along the lines of
... readthedocs.yml
(optionally with .
prefix, or yaml
extension)
Most importantly: functionally it's now not possible to specify which file to prefer. There was a test that checked that files were found in the correct order (e.g. the order specified in the list), I had to reduce it to just testing whether it could find the files.
There's a test that is failing on travis but not on my pc. I think I'll have to change that list to a set anyway. I'll check it later. |
Weirdly enough 18 tests fails for me on master, that's weird. |
Yeah, that should be a set. |
@stsewd Is this good, or should I change the description to read something like |
Any luck with this? |
@StefanoChiodino I'll try to review this in the morning |
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 left some minor recommendations
@@ -39,11 +39,11 @@ def test_find_nested(tmpdir): | |||
apply_fs(tmpdir, {'first/readthedocs.yml': ''}) | |||
|
|||
base = str(tmpdir) | |||
paths = list(find_all(base, ('readthedocs.yml',))) | |||
assert set(paths) == set([ | |||
paths = set(list(find_all(base, r'readthedocs\.yml'))) |
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 can omit the list
conversion here and directly do a set
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.
yep
paths = list(find_all(base, ('readthedocs.yml', | ||
'.readthedocs.yml'))) | ||
assert paths == [ | ||
paths = set(list(find_all(base, r'\.?readthedocs\.yml'))) |
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.
Same 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.
yep
@@ -0,0 +1,2 @@ | |||
name: docs |
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.
Looks like we aren't using this file, do we?
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.
If you look at https://github.com/rtfd/readthedocs-build/pull/48/files#diff-c5258b81d7a5c3182be62b7f82e02aedR105 there is a new test that uses it. Not sure if this is redundant considering the "find" functionality tests.
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.
The apply_fs
function takes the dict and creates a filesystem with dirs and files on a temporal location.
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.
So, the files inside integration_tests/
are used in other tests
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.
@stsewd maybe I'm confused: I'm thinking that the apply_fs
function makes a temporary directory to test, and because I'd like to test whether the .yaml
file is found I've added readthedocs.yaml
to this folder and created the test to take this file and see if it's found. Am I missing something? Thanks
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've added readthedocs.yaml to this folder
If you mean by this line
https://github.com/rtfd/readthedocs-build/pull/48/files#diff-c5258b81d7a5c3182be62b7f82e02aedR52
Then, the file that you created isn't necessary, the apply_fs will create that file for you in a temporary directory with the content name: docs\ntype: sphinx
. The file in minimal_project
isn't necessary for this test.
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.
Thanks for explaining! I'll give it a quick try pre-work :)
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.
@stsewd tests passes :)
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 just a thought, otherwise LGTM
@@ -14,7 +14,7 @@ | |||
'load', 'BuildConfig', 'ConfigError', 'InvalidConfig', 'ProjectConfig') | |||
|
|||
|
|||
CONFIG_FILENAMES = ('readthedocs.yml', '.readthedocs.yml') | |||
CONFIG_FILENAME_REGEX = r'\.?readthedocs.ya?ml' |
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 wonder if isn't better to test this regex (because right now we are hardcoding a regex in the tests)
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.
Sure, can do that too, is a very easy test, I'm just wondering what will I actually be testing? I can see 4 permutations that the regex need to test, but should I test that it doesn't match something else as well?
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 testing matching is enough
@stsewd happy with this? |
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.
Thanks
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.
Thanks for the contribution! I think the additional filenames make sense. We could also explore adding json
to this list, as Python YAML will load json files fine. That's later though.
I think the changes here look good, but we're currently in the middle of moving this code to rtd core. I'll set this as blocking for now, but once the porting is finished, we should redo this PR as a pr against rtd core.
readthedocs_build/config/config.py
Outdated
files += ' or ' | ||
files += '{!r}'.format(CONFIG_FILENAMES[-1]) | ||
raise ConfigError('No files {} found'.format(files), | ||
raise ConfigError('No files with regex \'{}\' found'.format(CONFIG_FILENAME_REGEX), |
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 mention regex here as this is a user facing error. The error message should probably just be "No configuration file found."
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.
Done
Okay, this is now unblocked. As noted, we are moving this logic to rtfd/readthedocs.org repository. The next step is going to be replicating these changes in that repo. Sorry this is probably an annoying request, I don't know the best way to port this over easily. A diff might get most of the way there if you are able to put the change in soon. Once the code there deviates, this PR is going to need a manual rewrite, likely. |
Done, hopefully (tests aren't playing nice on my machine) readthedocs/readthedocs.org#4512 |
Ported on readthedocs/readthedocs.org#4512 |
Fixes readthedocs/readthedocs.org#4102.
Ref. readthedocs/readthedocs.org#4129 that documents this change.