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 6779837
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:26:06+00:00 2026-05-26T16:26:06+00:00

I am using macros in the YARD doc tool and on some files they

  • 0

I am using macros in the YARD doc tool and on some files they work and some they don’t.

For example, I define a macro in one of my source files.

# @macro [new] my_macro
# @param [String] my_string it's a string!
#
def method(my_string)
  #do stuff
end

Then in other files/classes I have:

#@macro my_macro
def a_method(my_string)
  #do stuff
end

When I run the doc generator, the macro will work for many of the files but not all. My guess is that the doc generator isn’t seeing the macro before generating the docs that failed. Once it reaches the macro, it works for every file after that. But that is a guess.

Is there a way to ensure that the macro works for every file? I suspect there is a disconnect between how I think macros work in YARD and how they actually do work.

P.S. For those that don’t know what YARD is, you should check it out. It essentially does what rDoc does, but much much better. http://yardoc.org/

  • 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-05-26T16:26:07+00:00Added an answer on May 26, 2026 at 4:26 pm

    It indeed depends on the order in which YARD is processing your source files, and the currently only solution is to manually set that order by passing a list of files to yardoc, like following:

    yardoc "lib/foo_that_defines_buncha_macros.rb" "lib/**/*.rb"
    

    This will first process the file that defines macros, then all other files. Please note the quotation marks, YARD does its own globbing, so that e.g. ** will be possible to use (recursive glob)

    And yes, this won’t work if you have a circular “dependency”, i.e. two files using each others’ macros.

    According to the YARD developer, using two passes to first get all macros would have a too heavy imposition on performance, so don’t expect this to change any time soon.

    Edit: An extension of this idea is to have a file dedicated to defining macros, as there is no reason that their definition has to be in the same file as the implementation of your methods.

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

Sidebar

Related Questions

I'm having some problems with users cheating my online game by using macros to
I'm using MSBUILD macros in my .csproj files for AfterBuild events mainly just to
I'm using VIM do alot of work for me using the macros. There's alot
For example printf instead of cout , scanf instead of cin , using #define
I encountered a problem when declare some global variables using macros. Here is the
I've already implemented, using macros, a C++ property system that satisfied the following requirements:
Is it possible to have scoped macros using custom defined macros through boost wave?
I've written lots of Excel macros in the past using the following development process:
I've been using the macro from this blog entry for attaching the Visual Studio
I know of several approaches using a macro (VBA) to show/hide columns and rows

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.