Open idgserpro opened 5 years ago
zpretty does always write one attribute per line which is in contrast with the zcml style. Probably having generally all the attributes on one line if they fit some reasonable length is a good idea, but for the moment I have no spare time to provide a patch for that.
Probably having generally all the attributes on one line if they fit some reasonable length is a good idea,
I think the length could follow zcml style itself:
If all the attributes fit on one line with the tag name, do that:
The ZCML style guide has been developed with the following qualities in mind:
Lines under 80 characters wherever possible
Given to have easy diffing support, I would keep them on single lines.
Given to have easy diffing support, I would keep them on single lines.
i was of similar opinions, unless i saw that it quickly becomes very difficult to read in an example like below. also, the opinionated black-formatter (aimed at easy diffing) for python does the same; till long-line if possible, else one per line
<div class="collapse navbar-collapse" id="navbar">
{% if session["user_id"] %}
<ul class="navbar-nav me-auto mt-2">
<li class="nav-item">
<a class="nav-link" href="/quote">Quote</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/buy">Buy</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/sell">Sell</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/history">History</a>
</li>
</ul>
<ul class="navbar-nav ms-auto mt-2">
<li class="nav-item">
<a class="nav-link" href="/logout">Log Out</a>
</li>
</ul>
{% else %}
<ul class="navbar-nav ms-auto mt-2">
<li class="nav-item">
<a class="nav-link" href="/register">Register</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/login">Log In</a>
</li>
</ul>
{% endif %}
</div>
Black allows some control here, the magic trailing comma: https://black.readthedocs.io/en/stable/the_black_code_style/current_style.html#the-magic-trailing-comma
From https://zopetoolkit.readthedocs.io/en/latest/codingstyle/zcml-style.html#attributes:
But as shown in https://github.com/plone/plone.api/issues/219#issuecomment-507805012:
was changed to:
Since "If all the attributes fit on one line with the tag name, do that" is already met, why the line was changed? I'm not sure if this is really a bug...