On 07/03/2013 11:38 AM, David Majda wrote:
Dne 3.7.2013 11:03, Lukas Ocilka napsal(a):
So, it seems that UI definition is something similar to
Array
https://github.com/SUSE/style-guides/blob/master/Ruby.md#arrays
or
Hash
https://github.com/SUSE/style-guides/blob/master/Ruby.md#hashes
As Josef pointed out, these are just method calls. This means that if we
treat them as "non-DSL" in the style guide terminology, they should be
written on one-line, and if that's not possible, like this (with a break
before column 80):
UI.ChangeWidget(Id(IDs::SERVICES_TABLE), Cell(service, 2),
(running ? _('Active') : _('Inactive')))
I personally find this style of writing calls pretty much unreadable
(this part of the style guide was a compromise), and I sometimes use a
style like this (for calls in general, not only UI calls):
UI.ChangeWidget(
Id(IDs::SERVICES_TABLE),
Cell(service, 2),
(running ? _('Active') : _('Inactive'))
)
That is, I put each parameter on a separate line.
I think such occasional violations of the style guide are warranted by
increased readability (note the style guide explicitly allows violations
when that makes sense).
This style of multiline calls is also what Y2R uses in all code it emits
(because it was readable & simple to implement). This means we'll have a
lot of code styled like this soon.
-----
I propose to adopt a convention like this:
* If it fits one line, write the call one line.
* If it doesn't fit one line, write it in the "one line per
parameter" style shown above.
If you agree, there is a question of scope -- should this style be used
for all calls in general, or just for UI calls? If we agree the scope
should be all calls, we may also want to modify the style guide to
explicitly allow that style (i.e. make it a SUSE-wide rule, not just
YaST-wide).
Sounds good.
Anyway, if we adjust the style guide, we should also cover multi-line
prameters, e.g. Report::Error(_("Long multi-line text")), possibly in
combination with function call nesting, e.g.
Report::Error(sformat(_("Foo%1"),bar)).
Both of these constructs are pretty common in YaST code.
Jiri
--
Regards,
Jiri Srain
Project Manager
---------------------------------------------------------------------
SUSE LINUX, s.r.o. e-mail: [email protected]
Lihovarska 1060/12 tel: +420 284 084 659
190 00 Praha 9 fax: +420 284 084 001
Czech Republic http://www.suse.com
--
To unsubscribe, e-mail: [email protected]
To contact the owner, e-mail: [email protected]