Mailinglist Archive: yast-devel (251 mails)

< Previous Next >
Re: [yast-devel] Yast UI in Ruby: Formatting, Usage...
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).

--
David Majda
SUSE Studio developer
http://susestudio.com/
--
To unsubscribe, e-mail: yast-devel+unsubscribe@xxxxxxxxxxxx
To contact the owner, e-mail: yast-devel+owner@xxxxxxxxxxxx

< Previous Next >
Follow Ups