Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7876159
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T03:07:31+00:00 2026-06-03T03:07:31+00:00

FIRST, I would like to customize RDoc such that it automatically recognizes each key

  • 0

FIRST, I would like to customize RDoc such that it automatically recognizes each key of the attrs hash foo and bar of the following code:

class SomeClass
  def initialize( args = { }) 
    attrs = { 'foo'  => nil,
              'bar'    => 'us'}
    attrs.each_key{ |key| (class << self; self; end).send( :attr_accessor, key.to_sym)}

    attrs.each_key do |key|
      attrs[ key] = args[ key] if( args.has_key?( key))
      raise "No #{key} defined" if( attrs[key] === nil))
    end

    attrs.each {|key, value| instance_variable_set( "@#{key}", value)}
  end
end

As if I had initialized them as follows:

class SomeClass
  attr_accessor :foo, :bar
  def initialize( foo = nil, bar = 'us') 
      raise "No foo defined" if( foo === nil))
      @foo = foo
      @bar = bar
  end
end

I am able to do the following and have the accessors show up properly as Attributes:

class SomeClass
  ##
  # :attr_accessor: foo

  ##
  # :attr_accessor: bar

  ##
  # this is a comment for a the initialize method

  def initialize( args = { }) 
    attrs = { 'foo'  => nil,
              'bar'    => 'us'}
    attrs.each_key{ |key| (class << self; self; end).send( :attr_accessor, key.to_sym)}

    attrs.each_key do |key|
      attrs[ key] = args[ key] if( args.has_key?( key))
      raise "No #{key} defined" if( attrs[key] === nil))
    end

    attrs.each {|key, value| instance_variable_set( "@#{key}", value)}
  end
end

But I would like to be able to have RDoc recognize these automatically!

SECOND, I would like to be able to make comment relevant to their definitions in a manor similar to the following and have the comments show up in the documentation:

class SomeClass
  def initialize( args = { }) 
    attrs = { 
              ##
              #This stores your Foo
              'foo'  => nil,
              ##
              #This stores your Bar
              'bar'    => 'us'}
    attrs.each_key{ |key| (class << self; self; end).send( :attr_accessor, key.to_sym)}

    attrs.each_key do |key|
      attrs[ key] = args[ key] if( args.has_key?( key))
      raise "No #{key} defined" if( attrs[key] === nil))
    end

    attrs.each {|key, value| instance_variable_set( "@#{key}", value)}
  end
end

LAST, I would like their default values automatically listed as well (i.e. within the documentation it would list with the attributes that by default foo = nil and bar = 'us').

I have been examining the RDoc documentation for the Ruby code parser RDoc::Parser::Ruby and I would like to build a plugin as described in the RDoc Developer Introduction but I am unsure of how to even begin.

1) Is there something out there which already accomplishes what I have described?
2) If nothing exists, could someone please point me to an example plugin accomplishing similar functionality?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T03:07:32+00:00Added an answer on June 3, 2026 at 3:07 am

    Define a Domain Specific Language (DSL) and use Yard Macro Expansion Variables.

    Also see my other related questions:

    • Iterating over the registers of a Yardoc @macro
    • How to make Yard @macros apply to multiple files
    • Dynamic documentation, using the return of method in the description of another YARD?
    • Ruby DSLs and Dynamic Documentation?
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

First I would like to say that I am new to this site, never
First off I would like to say that this is my first post and
Please take a look at this screenshot first: I would like to move the
Right first of I would like to thank everyone for helping me out on
I would like to get the first item from a list matching a condition.
I would like to replace the first character ' x ' with the number
I would like to make a First Access Database Setup Process in my spring
I would like to subset out the first 5 minutes of time series data
I would like to find the first occurrence of a string, after a certain
I would like to change the background color of the first row in a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.