Skip to content

Commit 45be27e

Browse files
znzclaude
andcommitted
@undef 段落の後方互換を過渡期用に残す
bitclust の CI(rurema ジョブ)は doctree master を checkout してビルドする ため、@undef のパースを即時削除すると doctree 側の {: undef} への移行が マージされるまで CI が通らない(UNKNOWN_META_INFO を check_format が検出)。 旧 @undef 段落のパース(kind = :undefined)と描画(専用メッセージ)を deprecated として残す。doctree の移行完了後にフォローアップ PR で削除する。 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent a650a70 commit 45be27e

5 files changed

Lines changed: 41 additions & 0 deletions

File tree

lib/bitclust/mdcompiler.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,10 @@ def entry_chunk
140140
when /\A@todo\b/
141141
# findings#3: rd 側と同じく行頭アンカー付きで
142142
todo
143+
when /\A@undef\b/
144+
# 旧 @undef 段落の後方互換(rd 側と同期。移行完了後に削除する)
145+
@f.gets
146+
undef_message
143147
when RAW_META_RE
144148
entry_info
145149
when /\A\s*\|/

lib/bitclust/rdcompiler.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,11 @@ def entry_chunk
162162
see
163163
when /\A@todo\b/
164164
todo
165+
when /\A@undef\b/
166+
# 旧 @undef 段落の後方互換(UNKNOWN_META_INFO にすると doctree の
167+
# check_format が落ちる)。{: undef} への移行完了後に削除する
168+
@f.gets
169+
undef_message
165170
when /\A@[a-z]/
166171
entry_info
167172
else

lib/bitclust/rrdparser.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,10 @@ def define_method(chunk)
486486
:undefined
487487
elsif attrs.include?('nomethod')
488488
:nomethod
489+
elsif chunk.source.match?(/^@undef$/)
490+
# 旧 @undef 段落の後方互換。
491+
# doctree の {: undef} への移行完了後に削除する
492+
:undefined
489493
else
490494
@kind
491495
end

test/test_mdcompiler.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,17 @@ def test_entry_paragraph_with_midline_see_not_swallowed
255255
assert_match(/本文中で @see を説明する行。/, html)
256256
end
257257

258+
def test_legacy_undef_paragraph_renders_dedicated_message
259+
# 旧 @undef 段落の後方互換(doctree master 移行完了後に削除)。
260+
# UNKNOWN_META_INFO にしない(doctree の check_format が落ちるため)
261+
rd_src = "--- <(other) -> bool\n\n@undef\n"
262+
md_src = BitClust::RRDToMarkdown.convert(rd_src)
263+
rd_html = compile_method(@rd, rd_src)
264+
assert_not_match(/UNKNOWN_META_INFO/, rd_html)
265+
assert_match(/このメソッドは定義されていません/, rd_html)
266+
assert_equal rd_html, compile_method(@md, md_src), "md source:\n#{md_src}"
267+
end
268+
258269
def test_undef_renders_dedicated_message
259270
# {: undef} 属性行は専用の説明文を描画する(statichtml は undefined を
260271
# skip するため露出は server 等の動的経路のみ)

test/test_rrdparser.rb

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,3 +164,20 @@ def test_detached_attribute_line_is_not_a_method_attribute
164164
assert_equal(:defined, db.get_method(BitClust::MethodSpec.parse('Dummy#test_foo')).kind)
165165
end
166166
end
167+
168+
class TestRRDParserLegacyUndef < Test::Unit::TestCase
169+
# 旧 @undef の後方互換。doctree master が {: undef} へ移行するまでの
170+
# 過渡期用で、移行完了後に削除する
171+
def test_legacy_undef_paragraph_still_sets_kind
172+
result = BitClust::RRDParser.parse(<<HERE, 'dummy')
173+
= module Dummy
174+
== Instance Methods
175+
--- test_undef
176+
177+
@undef
178+
179+
HERE
180+
_library, db = result
181+
assert_equal(:undefined, db.get_method(BitClust::MethodSpec.parse('Dummy#test_undef')).kind)
182+
end
183+
end

0 commit comments

Comments
 (0)