KLab / PlaygroundOSS

490 stars 94 forks source link

Define standard code formats and apply them to current code #32

Open muojp opened 11 years ago

muojp commented 11 years ago

draft:

Java

Apply AOSP rule XML (with some changes; lineSplit=120, format_comments=false)

C++

We welcome for comments.

pointed out by.. many people (incl. @repeatedly )

muojp commented 11 years ago

English/日本語 would be ok on this thread.

futoase commented 11 years ago

Awesome :smile:

futoase commented 10 years ago

Define standard code formats and apply them to current code

Luaの場合はどうしましょう?

What's this code format of Lua?

see https://github.com/KLab/PlaygroundOSS/tree/master/Tutorial

Try this product use of https://github.com/LuaDist/luapretty or http://lua-users.org/wiki/SourceCodeFormatter ?

muojp commented 10 years ago

In my opinion, we could skip lua code in formatting, because they have lots of "spaces for explanation" such as:

    pSimpleItem = UI_SimpleItem(    nil,                            -- arg[1]:      親となるUIタスクポインタ
                                    7000,                           -- arg[2]:      表示プライオリティ
                                    x, y,                           -- arg[3,4]:    表示位置
                                    "asset://itemimage.png.imag"    -- arg[5]:      表示assetのパス
                                )

I bet applying code formatter on these code result in ugly styling :(

muojp commented 10 years ago

http://lua-users.org/wiki/LuaStyleGuide

Indentation - Indenting often uses two spaces. This is followed in Programming in Lua, the Lua Reference Manual, Beginning Lua Programming, and the Lua users wiki. (Why this is the case, I don't know, but perhaps it is because Lua statements can tend to be deeply nested, even in a LISP or functional manner, or perhaps it is affected by the fact that the code in these examples is small and pedagogical.) You'll see other common conventions (e.g. 3-4 spaces or tabs).

2 sp is preferred, also 3 sp / 4 sp are applied, and hard tab is also applied. aggghagghghg

muojp commented 10 years ago

"Simply applying 2 sp and modifying comments on line endings to make explanations look better" seems a practical option to me.

futoase commented 10 years ago

I bet applying code formatter on these code result in ugly styling :(

I understand.

2 sp is preferred, also 3 sp / 4 sp are applied, and hard tab is also applied.

2 space there better?

futoase commented 10 years ago

"Simply applying 2 sp and modifying comments on line endings to make explanations look better" seems a practical option to me.

:+1: