Skip to content

Documentation silently dropped when certain constructs parsed #1553

@zenspider

Description

@zenspider

The released version of minitest v6 fail to generate the top level documentation for the Minitest namespace.

bad: minitest/minitest@d5c8842

(I'm about to commit a change to fix rdoc generation)

After a lot of bisecting, both with git and manually, I tracked it down to the following diff:

diff --git a/lib/minitest/sprint_plugin.rb b/lib/minitest/sprint_plugin.rb
index afd2f08..1d82218 100644
--- a/lib/minitest/sprint_plugin.rb
+++ b/lib/minitest/sprint_plugin.rb
@@ -2,7 +2,9 @@ require_relative "../minitest"
 
 # :stopdoc:
 class OptionParser # unofficial embedded gem "makeoptparseworkwell"
-  def hidden(...)         = define(...).tap { |sw| def sw.summarize(*) = nil }
+  def hidden(...)
+    define(...).tap { |sw| def sw.summarize(*) = nil }
+  end
   def deprecate(from, to) = hidden(from) { abort "#{from} is deprecated. Use #{to}." }
   def topdict(name)       = name.length > 1 ? top.long : top.short
   def alias(from, to)     = (dict = topdict(from) and dict[to] = dict[from])

It isn't endless methods because the rest of them work...
nor does it seem to be using a block on an endless, because the rest of the work...
nor does it seem to be the ... arg/call...

After much mangling, it appears to be the singleton method on sw but ONLY if that's done as an endless on an endless?

this works:

  def hidden(...) = define(...).tap { |sw| sw.define_singleton_method(:summarize) { |*_| nil } }

this works:

  def hidden(...)
    define(...).tap { |sw| def sw.summarize(*) = nil }
  end

this does not:

  def hidden(...) = define(...).tap { |sw| def sw.summarize(*) = nil }

my testing script:

rm -rf doc
rdoc -q --fmt ri lib
ri -Td doc -f rdoc --no-system --no-home --no-gems Minitest | rg '^= \w+ methods:'

(rg is just a fancier / faster grep... grep will work w/ tweaks)

Generating ri info and then running:

ri -Td doc -f rdoc --no-system --no-home --no-gems Minitest

should show output that lists class and instance methods and mentions "The top-level namespace for Minitest".


I think the worst part of this is that it is entirely silent about it. -D outputs literally nothing extra. And -V outputs way too much and shows

 91% [22/24]  lib/minitest/sprint_plugin.rb
  class OptionParser (undocumented)
    #alias (undocumented)
    ::plugin_sprint_options
    ::plugin_sprint_init (undocumented)
  module OptionParser::Minitest
    #topdict (undocumented)
    #deprecate
    #hidden

which is totally wrong, but you wouldn't guess that just looking at the run.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions