Skip to content

Embedded Racc runtime is exposed as part of RDoc's generated API documentation #1762

Description

@thyresias

Description

RDoc's generated RD parsers contain a complete embedded copy of the Racc
runtime:

lib/rdoc/rd/block_parser.rb
lib/rdoc/rd/inline_parser.rb

In both files, the embedded section is delimited by:

###### racc/parser.rb begin

and:

###### racc/parser.rb end

RDoc parses this embedded implementation as if it were part of RDoc's public
API. As a result, generating RDoc's own documentation creates a Racc module
page.

The embedded comments also contain this reference:

rdoc-ref:lib/racc/rdoc/grammar.en.rdoc

It produces two unresolved-reference warnings, one from each generated
parser:

classes/Racc.html: `rdoc-ref:lib/racc/rdoc/grammar.en.rdoc` can't be resolved
classes/Racc.html: `rdoc-ref:lib/racc/rdoc/grammar.en.rdoc` can't be resolved

Relevant generated files:

https://github.com/ruby/rdoc/blob/v8.0.0/lib/rdoc/rd/block_parser.rb

https://github.com/ruby/rdoc/blob/v8.0.0/lib/rdoc/rd/inline_parser.rb

Expected behavior

The embedded Racc runtime is an implementation detail of the RD parsers. It
should not create Racc, Racc::Parser, or related pages in RDoc's API
documentation.

The actual RDoc classes defined after the embedded section, such as
RDoc::RD, must remain documentable.

Suggested fix

Wrap the embedded runtime in RDoc exclusion directives:

# :stopdoc:
###### racc/parser.rb begin

# Embedded Racc runtime

###### racc/parser.rb end
# :startdoc:

This must be integrated into parser generation or its post-processing, since
the generated .rb files are committed and regenerated from the .ry
sources.

I tested these directive positions:

  • Racc is no longer added to the documentation store;
  • RDoc::RD remains documented;
  • the two unresolved references disappear.

A regression test could parse both generated files and assert:

refute store.find_class_or_module("Racc")
assert store.find_class_or_module("RDoc::RD")

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