トップ «前の日記(2007-11-01) 最新 次の日記(2007-11-03)» 編輯

Pyon's Diary

[はてなブックマーク登録数] [Google に登録] [RSS フィード] Gourmet Hardware Programming Society Software

2007-11-02 舊 平成拾玖年丁亥長月廿參日庚子 (金・曇) [昔の今日]

[節] Perltidy (及び PythonTidy) を入れてみた。

Perl Hacks - プロが教へるテクニック & ツール 101 選 先日購入した Perl Hacks - プロが教へるテクニック & ツール 101 選を讀んでゐて Perltidy と云ふソース・コードを整形するツールが在る事を知つたので入れてみた。

Gentoo なので、

# emerge -Dav dev-perl/perltidy

で終はり。

それで試しに使つて見た處、初期設定の儘だと整形規則が氣に入ら無かつたので、${HOME}/.perltidyrc を編輯して以下の樣にした。

# I/O Control
#--standard-output           # 整形結果は標準出力に出力する。
--standard-error-output      # エラーは標準エラー出力に出力する。
--warning-output             # 深刻でない警告も表示する。
# Basic Options
--maximum-line-length=78     # 一行は最大 78 カラム。
--indent-columns=4           # インデントは 4 カラム。
--check-syntax               # 文法を檢査する。
# Code Indentation Control
--continuation-indentation=4 # 繼續行のインデントは 4 カラム。
# Whitespace Control
--paren-tightness=2          # 丸括弧の内側は詰める。
--square-bracket-tightness=2 # 角括弧の内側は詰める。
--brace-tightness=2          # 中括弧(ブレース)の内側は詰める。
--block-brace-tightness=2    # ブロックの中括弧の内側は詰める。
--nospace-for-semicolon      # for 文のセミコロンの前を詰める。
# Comment Controls
--indent-block-comments      # ブロック・コメントをインデントする。
# Line Break Control
--cuddled-else               # else, elsif では改行しない。

取敢へず暫く此で樣子を見る。

追記: Perl ベストプラクティスでは。

Perl ベストプラクティス 色々檢索してみると Perl ベストプラクティスでは以下の設定を推奬してゐるらしい。

-l=78 # Max line witdh is 78 cols
-i=4 # Indent level is 4 cols
-ci=4 # Continuation indent is 4 cols
-st # Output to STDOUT
-se # Errors to STDERR
-vt=2 # Maximal vertical tightness
-cti=0 # No extra indentation for closing brackets
-pt=1 # Medium parenthesis tightness
-bt=1 # Medium brace tightness
-sbt=1 # Medium square bracket tightness
-bbt=1 # Medium block brace tightness
-nsfs # No space before semicolons
-nolq # Don't outdent long quoted strings
-wbb="% + - * / x != == >= <= =~ !~ < > | & >= < = **= += *= &= <<= &&= -= /= |= >>= ||= .= %= ^= x="
# Break before all operators

括弧の内側に空白が入るのは好きでは無いのだが、此方に慣れる樣にした方が良いのかな。

追記: Python には。

Python には PythonTidy と云ふものが在る模樣。

此を使ふと PEP 8 (日本語譯)に準據出來る模樣。

追記: Perl ベストプラクティスオプション。(2008-08-21)

Perl ベストプラクティスに準據するには、上に書いた樣に $HOME/.perltidyrc に一つ一つ書かなくても、

-pbp

亦は

--perl-best-practices

と書いて置けば濟むと「man 1 perltidy」*1には記して在つた。

と云ふ譯で、自分の $HOME/.perltidyrc も其乃樣にした。

體裁なんて凝り出したらキリが無いし。

Tags: Software | del.icio.usに追加 | はてなブックマークに追加 | livedoor クリップに追加 | Yahoo! ブックマークに追加 | Google ブックマークに追加 | Permalink

*1 但し 20070508 版。

[節] 晩御飯。

  • チョコレート。
  • 握り飯。
  • 拉麺。
Tags: None | del.icio.usに追加 | はてなブックマークに追加 | livedoor クリップに追加 | Yahoo! ブックマークに追加 | Google ブックマークに追加 | Permalink
[]

正當なXHTML1.1です! 正當なCSSです! BlogScouter Pyon's Diary Chat. Pyon's Land (MyMiniCity)
© pyon