How to handle tool-specific magic comments

Open
#1,614 1 comment 3 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
ruby
Domain
documentation

Research direction

The issue names no implementation file or test. Reproduce the example with RDoc, then trace the handling of shebangs and Ruby magic comments and compare it with tool-specific comments such as # typed: true and # rbs_inline: enabled. Done means those comments no longer appear as top-level documentation without breaking RDoc's existing magic-comment behavior.

Written by the indexing model from the issue text.

Description

rdoc currently removes shebangs and ruby magic comments from rendered documetantion.

But other tools like sorbet and rbs-inline provide their own comments like # typed: true or rbs_inline: enabled which aren't excluded. If I have a file like this:

# frozen_string_literal: true
# rbs_inline: enabled
# :markup: markdown

module Prism
  module Foo
    # ...
  end
end

Then for each file, you get one rbs_inline comment on the top-level namespace. I feel like either rdoc should

  • ignore any magic-style comment, regardless of if it is "official" or not
  • Not attach comments where there is whitespace before the top-level. I guess this is not feasable for backwards compat since rdoc itself makes heavy use of that style.

This can be worked around by inserting #-- before the magic comments but I don't think I should need to care about this at all.

Dominant language
Ruby
Stars
930
Forks
472
Avg merge
2d 8h
Merged PRs (30d)
12

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from ruby/rdoc

All issues in ruby/rdoc

Similar issues

More Ruby issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.