Techioz Blog

rdoc コメントが 2 つのハッシュ/ポンド記号で始まっているように見えるのはなぜですか?

概要

rdoc の readme (https://github.com/ruby/rdoc) で提供されている例では、独自の行で 2 つのハッシュ/ポンド記号を使用してコメント ブロックを開始しています。これは要件ですか、それとも単なる慣例ですか?例 (Readme を引用):

##
# This class represents an arbitrary shape by a series of points.

class Shape

  ##
  # Creates a new shape described by a +polyline+.
  #
  # If the +polyline+ does not end at the same point it started at the
  # first pointed is copied and placed at the end of the line.
  #
  # An ArgumentError is raised if the line crosses itself, but shapes may
  # be concave.

  def initialize polyline
    # ...
  end

end

解決策

簡単な実験では、二重ハッシュを単一ハッシュに減らしたり、二重ハッシュ行を完全に削除したりしても、rdoc のドキュメント生成機能に影響を及ぼさないことがわかります。それは必須ではなく、個人的な美学に基づいて作者が選択したものです。