Prism parser no longer accepts legacy ghost method directives without a leading colon
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 76/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- ruby
調査の方向性
Prism パーサーのコメント処理から始め、コメントが共通ディレクティブパーサーにどのように到達するかを追跡してください。legacy と canonical のメソッド、singleton-method、属性の各ディレクティブを対象とするテストを追加し、両方の形式が期待されるメンバーを生成し、canonical ディレクティブを保持することを確認してください。
索引モデルが issue の本文から書いたものです。
説明
Description
The previous Ruby parser accepted ghost/meta directives both with and without
an initial colon:
# method: foo
# :method: foo
RDoc 8.0.0 only recognizes the canonical second form.
Although the form without the initial colon is not the currently documented
syntax, the previous parser explicitly supported it. Existing documentation
relies on this behavior.
Minimal reproduction
class Example
##
# method: legacy_method
# A legacy ghost method directive.
##
# :method: canonical_method
# A canonical ghost method directive.
end
With RDoc 6.17.0:
Example.method_list.map(&:name)
# => ["legacy_method", "canonical_method"]
With RDoc 8.0.0:
Example.method_list.map(&:name)
# => ["canonical_method"]
The previous parser deliberately made the initial colon optional:
/^# +:?method:/
It did the same for singleton-method and attribute directives.
Real-world example
net-imap documents members created dynamically by Struct using this
syntax:
##
# method: media_type
# :call-seq: media_type -> string
Source:
https://github.com/ruby/net-imap/blob/v0.6.4.1/lib/net/imap/response_data.rb#L903
RDoc 8 does not create the ghost method, so references such as:
rdoc-ref:BodyTypeBasic#media_type
cannot be resolved.
Expected behavior
For backward compatibility, the Prism parser should recognize both:
# method: foo
# :method: foo
The same compatibility should apply to:
method
singleton-method
attr
attr_reader
attr_writer
attr_accessor
Suggested fix
Before passing Ruby comments to the common directive parser, normalize legacy
meta directives to their canonical form.
For example:
LEGACY_META_DIRECTIVE =
/^([ \t]*\#[ \t]+)(singleton-method|method|attr(?:_reader|_writer|_accessor)?):/i
A match can be rewritten from:
# method: foo
to:
# :method: foo
Canonical directives must remain unchanged.
Tests should cover both forms for methods, singleton methods, and attributes.
Environment
Ruby 4.0.5 +PRISM
RDoc 8.0.0
Prism 1.9.0
- 主要言語
- Ruby
- スター
- 930
- フォーク
- 465
- 平均マージ
- 3日 10時間
- マージ済み PR(30日)
- 27
環境構築
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
ruby/rdoc のほかの issue
-
RDoc 8.0.0 gem omits `doc/rdoc/example.rb`, which is referenced by the packaged markup documentationオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
メンテナーはふだん 1 日以内に返信
-
enhancement
難易度 4/5 3〜5日 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信
-
難易度 3/5 1〜2日 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信
-
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
メンテナーはふだん 1 日以内に返信
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
-
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
TheOdinProject/curriculum#31423 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
oxidize-rb/rb-sys#807 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信