Skip to content

doc: Database#busy_timeout= renders without its description (shadowed by alias_method in database.rb) #772

Open

Description

@mrhoribu

Summary

The generated docs show Database#busy_timeout= with no description. Its rdoc comment in ext/sqlite3/database.c ("Indicates that if a request for a resource terminates because that resource is busy, …") is never rendered, on main too, so anything added to that comment is invisible in the published docs. #771 adds text there about holding the GVL and deferring interrupts, which is how this came up.

Cause

lib/sqlite3/database.rb:387:

alias_method :busy_timeout, :busy_timeout=

When RDoc (8.1.0 here) parses this, it creates an undocumented busy_timeout= entry for SQLite3::Database, and that entry takes the place of the C method's documentation.

Checked by running rdoc on subsets of the files:

Files given to rdoc busy_timeout= description rendered
ext/sqlite3/database.c alone yes
ext/sqlite3/database.c + lib/sqlite3/pragmas.rb yes
ext/sqlite3/database.c + lib/sqlite3/database.rb no
the whole repo (bundle exec rdoc, as rdoc.yml runs it) no
ext/sqlite3/database.c + lib/sqlite3/database.rb without the alias_method line yes

Suggested fix

Define the alias in C, next to the method, and drop the Ruby alias_method:

    rb_define_method(cSqlite3Database, "busy_timeout=", set_busy_timeout, 1);
    rb_define_alias(cSqlite3Database, "busy_timeout", "busy_timeout=");

With that change, the busy_timeout= description renders, and busy_timeout still appears as "Alias for: busy_timeout=". Runtime behaviour is unchanged, since both define the same alias on SQLite3::Database.

I haven't included this in #771 to keep that PR focused. Happy to open a separate PR if you'd like.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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