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
Fixing dependencies #2547
Fixing dependencies #2547
Conversation
…get for render_posts plugin.
I’d rather not create empty .dep files. Are there any issues with the current approach? |
Yes: if the |
How about letting the compiler decide whether |
Are compilers the only things that can provide .dep files? If yes, we could do that. |
Well, of course any other plugin could also create A problem is that sometimes compilers also create I'll try that out. |
… be always created and added as a target.
Ah. There's actually a bug in the |
@@ -250,6 +250,7 @@ class PageCompiler(BasePlugin): | |||
friendly_name = '' | |||
demote_headers = False | |||
supports_onefile = True | |||
use_dep_file = False # If set to true, the .dep file is always written and added as a target |
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.
Is there a case when we want this to be False? If not, then let's lose the option and simplify.
Other than that, LGTM.
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, some compilers might use .dep
files for something else. Actually, the WordPress compiler does: it uses the .dep
file to store a JSON-encoded file which not only contains file dependencies, but potentially other dependencies. (I added that feature when .dep
files were completely handled by the compilers themselves.) I don't know if any other plugin not shipped with Nikola directly uses .dep
like this 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.
Or perhaps we could make it so .dep
always means file dependencies separated by newlines, and the WordPress compiler creates its custom .wpdep
format?
And I think the default should be True
.
Hmm, there seem to be a LOT of failing stuff in the tests which are not caused by this PR. Like all the flake8 warnings. I was only able to get these warnings after upgrading flake8. Also, it seems like the baseline is (again) out-of-date, as the generated thumbnails differ. |
@@ -250,6 +250,7 @@ class PageCompiler(BasePlugin): | |||
friendly_name = '' | |||
demote_headers = False | |||
supports_onefile = True | |||
use_dep_file = False # If set to true, the .dep file is always written and added as a target |
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.
Or perhaps we could make it so .dep
always means file dependencies separated by newlines, and the WordPress compiler creates its custom .wpdep
format?
And I think the default should be True
.
@@ -273,7 +278,18 @@ def _read_extra_deps(self, post): | |||
|
|||
def register_extra_dependencies(self, post): | |||
"""Add dependency to post object to check .dep file.""" | |||
post.add_dependency(lambda: self._read_extra_deps(post), 'fragment') | |||
def create_lambda(lang): |
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.
Add a comment for future readers to explain this:
# We create a lambda like this so we can pass `lang` to it, because if we didn’t add that function, `lang` would always be the last language in TRANSLATIONS.
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.
Fixed 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.
@.dep file name: Yes, we could do that, too. I'll change it.
Signed-off-by: Chris Warrick <kwpolska@gmail.com>
I'll wait until the checks are done, and then I'll merge. |
Fixing .dep filename, and adjusting to getnikola/nikola#2547.
Implementation of #2536.
The first part ensures that the
.dep
file is always written and specified as a second target of therender_post
task, so that the.dep
file will be created if it isn't there yet. (Otherwise changing dependencies of the post might be ignored when the.dep
file is gone.)