# RDOC: several related modules in several C files

**URL:** <https://www.ruby-forum.com/t/rdoc-several-related-modules-in-several-c-files/87893>\
**Category:** Ruby\
**Created:** [March 6, 2007, 5:41pm UTC](https://www.ruby-forum.com/t/rdoc-several-related-modules-in-several-c-files/87893 "2007-03-06T17:41:49Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Victor\_SZverokSS\_Sh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/f04885/32.png) [@Victor\_SZverokSS\_Sh](https://www.ruby-forum.com/u/Victor_SZverokSS_Sh)\
**Post date:** [March 6, 2007, 5:41pm UTC](https://www.ruby-forum.com/t/rdoc-several-related-modules-in-several-c-files/87893/1 "2007-03-06T17:41:49Z")

</div>

Hi all!

I have a pretty large extension I want to document with RDoc.

The problem is, I have several files:

htmr\_main.cpp:  
…  
rb\_mHtmr = rb\_define\_module(“Htmr”);  
…

# htmr\_constants.cpp:

…  
rb\_mHtmrConstants = rb\_define\_module\_under(rb\_mHtmr, “Constants”);  
…

The problem with such organization: RDoc says “Enclosing class/module  
‘rb\_mHtmr’ for module Constants not known”.

I can:

1. move the line “rb\_mHtmr = …” to htmr\_constants.cpp, but rb\_mHtmr is  
used not only from this file.
2. move the line “rb\_mHtmrConstants = …” to htmr\_main.cpp, but in this  
case all othre contents of htmr\_constants.cpp is ignored by Rdoc.
3. join all files of the extension into one huge file, but it will be  
ugly  
☹

Was I miss something?

Thanks.

V.

---

<div class="post-metadata">

**Author:** ![Victor\_SZverokSS\_Sh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/f04885/32.png) [@Victor\_SZverokSS\_Sh](https://www.ruby-forum.com/u/Victor_SZverokSS_Sh)\
**Post date:** [March 16, 2007, 8:10am UTC](https://www.ruby-forum.com/t/rdoc-several-related-modules-in-several-c-files/87893/2 "2007-03-16T08:10:03Z")

</div>

> The problem with such organization: RDoc says “Enclosing class/module  
> ‘rb\_mHtmr’ for module Constants not known”.

I’ve done the following with my extensions:  
while creating documentation, I’ve concatenated all data in one file and  
rdoc is parsing one file.

---

<div class="post-metadata">

**Author:** ![Victor\_SZverokSS\_Sh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/f04885/32.png) [@Victor\_SZverokSS\_Sh](https://www.ruby-forum.com/u/Victor_SZverokSS_Sh)\
**Post date:** [March 16, 2007, 4:52pm UTC](https://www.ruby-forum.com/t/rdoc-several-related-modules-in-several-c-files/87893/3 "2007-03-16T16:52:49Z")

</div>

From: removed\_email\_address@domain.invalid [[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)] On Behalf  
Of  
Max L.  
Sent: Friday, March 16, 2007 9:10 AM

> > The problem with such organization: RDoc says “Enclosing class/module  
> > ‘rb\_mHtmr’ for module Constants not known”.
> 
> I’ve done the following with my extensions:  
> while creating documentation, I’ve concatenated all data in one file and  
> rdoc is parsing one file.

I’ve eventually found another solution: have added to each file some  
additional definitions to make RDoc happy, and make them “invsible” to  
compiler with #ifdef SOME\_STRANGE\_SYMBOL/#endif

It works.

(BTW, the solution to join all files to one can’t work for me in any  
case,  
as in my sources there are many other problems for RDoc, like shortcut  
macro  
for defining ruby methods, additional namespaces and so on).

V.

---

<div class="post-metadata">

**Author:** ![Victor\_SZverokSS\_Sh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/f04885/32.png) [@Victor\_SZverokSS\_Sh](https://www.ruby-forum.com/u/Victor_SZverokSS_Sh)\
**Post date:** [March 16, 2007, 4:59pm UTC](https://www.ruby-forum.com/t/rdoc-several-related-modules-in-several-c-files/87893/4 "2007-03-16T16:59:33Z")

</div>

> as in my sources there are many other problems for RDoc, like shortcut  
> macro

These shortcuts seems to be one of the greatest problem. The only way to  
bypass them is to use some sort of C-\>xml compilers in RDoc (to make it  
very complicated), or to create some sort of explicit binding C  
functions to ruby methods

---

<div class="post-metadata">

**Author:** ![Victor\_SZverokSS\_Sh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/f04885/32.png) [@Victor\_SZverokSS\_Sh](https://www.ruby-forum.com/u/Victor_SZverokSS_Sh)\
**Post date:** [March 16, 2007, 5:15pm UTC](https://www.ruby-forum.com/t/rdoc-several-related-modules-in-several-c-files/87893/5 "2007-03-16T17:15:48Z")

</div>

> BTW, I’ve found even \t (Tab) symbol in sources confuses RDoc

Yes, RDoc seems to be a rather confusable thing =)  
I think, that there is no use in trying to make a perfect RDoc for C  
extensions, so You hack is OK. You can also make the following:  
preprecess sources before RDoc-ing them. Thus, all You macroses will be  
expanded to rb\_define\_method

---

<div class="post-metadata">

**Author:** ![Victor\_SZverokSS\_Sh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/f04885/32.png) [@Victor\_SZverokSS\_Sh](https://www.ruby-forum.com/u/Victor_SZverokSS_Sh)\
**Post date:** [March 16, 2007, 5:11pm UTC](https://www.ruby-forum.com/t/rdoc-several-related-modules-in-several-c-files/87893/6 "2007-03-16T17:11:52Z")

</div>

From: removed\_email\_address@domain.invalid [[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)] On Behalf  
Of  
Max L.  
Sent: Friday, March 16, 2007 6:00 PM

> > as in my sources there are many other problems for RDoc, like shortcut  
> > macro
> 
> These shortcuts seems to be one of the greatest problem. The only way to  
> bypass them is to use some sort of C-\>xml compilers in RDoc (to make it  
> very complicated), or to create some sort of explicit binding C  
> functions to ruby methods

Aha. I’ve ended with having something like

//real definition  
DEF\_METHOD(method, c\_method, 1);

#ifdef MAKIN\_RDOC\_HAPPY // MAKIN\_RDOC\_HAPPY isn’t defined 🙂

//fake definition  
rb\_define\_method(rb\_cMyClass, “method”, c\_method, 1);

#endif

My DEF\_METHOD definitons (even if they are many) looks much more DRY (I  
have  
to write only differing parts of each definition).

BTW, I’ve found even \t (Tab) symbol in sources confuses RDoc

V.
