Skip to content
This repository was archived by the owner on Mar 18, 2022. It is now read-only.

Check for readthedocs file with yaml extension #48

Closed
wants to merge 11 commits into from
Closed

Check for readthedocs file with yaml extension #48

wants to merge 11 commits into from

Conversation

StefanoChiodino
Copy link

@StefanoChiodino StefanoChiodino commented May 22, 2018

Fixes readthedocs/readthedocs.org#4102.
Ref. readthedocs/readthedocs.org#4129 that documents this change.

@@ -14,7 +14,7 @@
'load', 'BuildConfig', 'ConfigError', 'InvalidConfig', 'ProjectConfig')


CONFIG_FILENAMES = ('readthedocs.yml', '.readthedocs.yml')
CONFIG_FILENAMES = ('readthedocs.yml', '.readthedocs.yml', 'readthedocs.yaml')
Copy link
Member

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?

Copy link
Author

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.

Copy link
Author

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.

@StefanoChiodino
Copy link
Author

StefanoChiodino commented May 23, 2018

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.

@StefanoChiodino
Copy link
Author

Weirdly enough 18 tests fails for me on master, that's weird.

@stsewd
Copy link
Member

stsewd commented May 23, 2018

I think I'll have to change that list to a set anyway

Yeah, that should be a set.

@StefanoChiodino
Copy link
Author

@stsewd Is this good, or should I change the description to read something like
readthedocs.yml (with optional '.' prefix or 'yaml' file extension)
??

@StefanoChiodino
Copy link
Author

Any luck with this?

@stsewd
Copy link
Member

stsewd commented Jun 5, 2018

@StefanoChiodino I'll try to review this in the morning

Copy link
Member

@stsewd stsewd left a 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')))
Copy link
Member

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

Copy link
Author

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')))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

Copy link
Author

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
Copy link
Member

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?

Copy link
Author

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.

Copy link
Member

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.

Copy link
Member

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

Copy link
Author

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

Copy link
Member

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.

Copy link
Author

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 :)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@stsewd tests passes :)

Copy link
Member

@stsewd stsewd left a 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'
Copy link
Member

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)

Copy link
Author

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?

Copy link
Member

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

@StefanoChiodino
Copy link
Author

@stsewd happy with this?

Copy link
Member

@stsewd stsewd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

Copy link
Contributor

@agjohnson agjohnson left a 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.

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),
Copy link
Contributor

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."

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@agjohnson agjohnson added the Status: blocked Issue is blocked on another issue label Jun 19, 2018
@agjohnson
Copy link
Contributor

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.

@StefanoChiodino
Copy link
Author

Done, hopefully (tests aren't playing nice on my machine) readthedocs/readthedocs.org#4512

@stsewd
Copy link
Member

stsewd commented Sep 5, 2018

Ported on readthedocs/readthedocs.org#4512

@stsewd stsewd closed this Sep 5, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants