You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
module_function without arguments is not applied to subsequent method definitions #1823
but RDoc 8 does not appear to document JSON.parse.
Likely cause
RDoc already seems to handle the explicit form:
module_function:foo
by converting an existing method to a module function.
The no-argument form has different semantics: it changes the state of the module so that methods defined subsequently become module functions.
RDoc therefore needs to remember that module_function was called without arguments and apply that state to later def nodes, until the relevant scope ends or the state is otherwise changed.
Conceptually:
module_functiondeffooend
should result in RDoc recording both:
# private instance methodM#foo# public singleton/module methodM.foo
Notes
This does not appear to be a Prism parsing issue itself: the syntax is parsed normally. The missing part seems to be in RDoc's tracking of the semantic state introduced by a no-argument module_function.
I encountered this while generating documentation for json 3.0.2 with RDoc 8.
Currently, only module_function with argument is supported.
module_function:name1,:name2
module_function without argument is not supported nor implemented yet.
I think it wasn't implemented in the old ripper-based parser too.
Here's a sample code that may be related (found by Claude)
moduleMprivate# private instance method, not documenteddefhelper;end# Old ripper based parser wrongly treat this as `public`module_function# Documented as public "instance" method in old RDoc, not documented in current RDoc# Actually: private instance method and public singleton methoddeffoo;endend
Currently, only module_function with argument is supported.
module_function:name1,:name2
module_function without argument is not supported nor implemented yet. I think it wasn't implemented in the old ripper-based parser too.
Here's a sample code that may be related (found by Claude)
moduleMprivate# private instance method, not documenteddefhelper;end# Old ripper based parser wrongly treat this as `public`module_function# Documented as public "instance" method in old RDoc, not documented in current RDoc# Actually: private instance method and public singleton methoddeffoo;endend
I have patched RDoc to support module_function without argument : do you want me to fork & create a pull request ?
@thyresias
Yes, please! I'd be happy to review it.
To make the review smooth, here is what I'd expect
moduleM# visibility changed to special :module_functionmodule_function# attr will be private instance methodattr_reader:module_function_attr# other instance method def will make it private and copies to public singleton_methoddefmodule_function_method;end# visibility reset to :privateprivatedefprivate_instance_method1;end# visibility reset to :publicpublicdefpublic_instance_method1;endend
module_function can be reset with other visibility method, so treating as it creates a special visibility state @visibility = :module_function which is different from :private | :public | :protected seems a good idea.
Activity
skatkov commentedon Sep 16, 2026
By default, rdoc documents only
publicandprotectedmethods. Did you try changing visibility?rdoc --visibility=private?thyresias commentedon Sep 16, 2026
The module method is public. And it is not documented.
tompng commentedon Sep 16, 2026
Currently, only
module_functionwith argument is supported.module_functionwithout argument is not supported nor implemented yet.I think it wasn't implemented in the old ripper-based parser too.
Here's a sample code that may be related (found by Claude)
thyresias commentedon Sep 16, 2026
I have patched RDoc to support module_function without argument : do you want me to fork & create a pull request ?
tompng commentedon Sep 16, 2026
@thyresias
Yes, please! I'd be happy to review it.
To make the review smooth, here is what I'd expect
module_functioncan be reset with other visibility method, so treating as it creates a special visibility state@visibility = :module_functionwhich is different from:private | :public | :protectedseems a good idea.