-
-
Notifications
You must be signed in to change notification settings - Fork 14
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
Trim trailing whitespace #38
Comments
Hmmm good point. Can have a look. |
This could be a simple template plugin, like copy. When it needs to be added to a templated file, a pipeline could be used. i.e. the mobanfile can have an extra target for intermediate file, like how gmake works. e.g. .jj2 -> .dirty.txt -> .txt and the intermediate file could be removed by a delete rule (#167) Or we might allow the same target to be listed twice, and then use two template engines consecutively (jinja, then whitespace-cleaner). |
We can introduce filter plugin but my worry is that current implementation does not respect(or guarantee) appearance order. So all is collected and aggregated to a dictionary: template type: its template targets. And then this dictionary is iterated through its corresponding template engine. |
I think that problem needs to be solved, and solved using a 'gmake' like algorithm. We should be able to find an existing 'solver' algorithm, maybe by looking in other tools like https://github.com/brushtechnology/fabricate , or https://github.com/mesonbuild/meson (but the solver might be in https://github.com/ninja-build/ninja ) SAT solvers are another approach, but not so well supported in Python and probably overkill . https://research.swtch.com/version-sat |
We could have a very basic solution by adding a 'plugin order' config value to the yaml, so the user can specify moban_plugin_order:
- jinja
- trim-whitespace
- etc |
I think ordereddict should be able to help us. |
one more missing functionality: moban expects all templates to have existed before execution. In this case, one output of template engine become the input of another, this will cause exception for current moban. |
And to truly respect the template file based sequence order( rather than template type based sequence order), two alternatives can be considered: a. ignore moban engine optimization where if found that a data config or a template file is used across many templating actions, the file will be re-used across these actions. b. provide higher level of abstraction os that render_to_files does not get invoked immediately but only generate an execution sequence, and such a sequence is given to a batch runner which does the action no matter which templating engine is involved. Then, we can consider include a in the batch runner so that render_to_files will drop the optimization and batch runner will try to re-implement the optimization. |
Third alternative is to implement trailing spaces cleaner as post templating action.
|
Similar to #36 , and the trailing blank line fixup, ..
When importing content from other providers, their trailing blank lines shouldnt be propagated into moban managed repositories.
e.g. github/gitignore#2728 and moremoban/pypi-mobans#22 (comment)
If trailing whitespace needs to be preserved, we can use jinja
{% raw %}
to keep it.The text was updated successfully, but these errors were encountered: