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

  • SEARCH
  • Home
  • 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 8107629
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T00:50:16+00:00 2026-06-06T00:50:16+00:00

I’m really new to this, and I’ve been going through the YARD docs ,

  • 0

I’m really new to this, and I’ve been going through the YARD docs, and haven’t really been able to figure out a solution to my problem.

Here is the code I’m starting with: https://github.com/spape/yard-rest-plugin which works great, but I’m trying to add some functionality to it.

Basically, I’m trying to add a filter such that I can include some Model documentation such that people looking through the Controller API docs can see what attributes of the Model they can use.

The plugin, yard-rest filters out any methods that don’t have the @resource tag. So, I figured, I’d add a @resource_object tag, for my Models, that I want to show certain information about in the API docs.

In the plugin’s code. I found in /lib/yard-rest.rb

YARD::Templates::Template.extra_includes << RestFilters

and in that file, I’ve modified the reject_without_resource(list) method

  def reject_without_resource(list)
    if list
      list.delete_if { |object| 
        if !object.is_a?(YARD::CodeObjects::ClassObject)
          true
        else
            !object.meths.detect{ |x| x.has_tag?(:resource) }# and 
          #  !object.detect{ |x| x.has_tag?(:resource_object) }
        end
      }
    end
  end

object is a YARD::CodeObjects::ClassObject in the cases that we care about. object.meths is an array of methods (Method Objects). and the Method Objects have a detect method, which allows to test if a method has whatever tag we want to test for via the .has_tag? call. But, I’ve been unable to find something similar for the class level. Right now, because I don’t want to document any methods in the models for the API Docs, I don’t want to put the @resource tag on any of the model methods.

My current .yardopts file, to show that I am indeed searching over models and controllers:

--title "My API Documentation"
--plugin rest
--readme API_README
app/models/*.rb
app/controllers/*.rb

So, how do I change the filter, such that I can include the models? Or at least class-level tags?

  • 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-06T00:50:18+00:00Added an answer on June 6, 2026 at 12:50 am

    Turns out, you can call .has_tag on object.

    If you just rearrange what you have to look like this:

    def reject_without_resource(list)
        if list
          list.delete_if { |object|
            if object.has_tag?(:resource_object)
              false
            elsif object.meths.detect{ |x| x.has_tag? (:resource) }
              false
            else
              true
            end
          }
        end
      end
    

    it will work

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I want use html5's new tag to play a wav file (currently only supported
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString

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.