# Better RDoc Inline Markup

**URL:** <https://rubytalk.org/t/better-rdoc-inline-markup/55224>\
**Category:** ruby-talk\
**Created:** [3 September 2009 15:16 UTC](https://rubytalk.org/t/better-rdoc-inline-markup/55224 "2009-09-03T15:16:31Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![7rans](https://avatars.discourse-cdn.com/v4/letter/7/a8b319/32.png) [@7rans](https://rubytalk.org/u/7rans)\
**Post date:** [3 September 2009 15:16 UTC](https://rubytalk.org/t/better-rdoc-inline-markup/55224/1 "2009-09-03T15:16:31Z")

</div>

RDoc's SimpleMarkup doesn't catch all the cases of inline markup  
that is really useful for a Ruby documentation. I think it's checking  
for \w+ only, but adding some other punctuation marks would be  
helpful. Namely, none of the following work b/c of punctuation marks:

&nbsp;&nbsp;+ActiveRecord::Base+

&nbsp;&nbsp;+merge!+

&nbsp;&nbsp;+is\_a?+

&nbsp;&nbsp;+name=+

&nbsp;&nbsp;+object.call+

It would great if the Regexp could be expanded to catch these cases.

Thanks.

---

<div class="post-metadata">

**Author:** ![Xavier\_Noria](https://yyz1.discourse-cdn.com/flex029/user_avatar/rubytalk.org/xavier_noria/32/1867_2.png) [@Xavier\_Noria](https://rubytalk.org/u/Xavier_Noria)\
**Post date:** [3 September 2009 15:27 UTC](https://rubytalk.org/t/better-rdoc-inline-markup/55224/2 "2009-09-03T15:27:03Z")

</div>

Another gotcha are symbols:

&nbsp;&nbsp;&nbsp;&nbsp;+:select+

> **···**
>
> On Thu, Sep 3, 2009 at 5:16 PM, Intransition\<transfire@gmail.com\> wrote:
> 
> > RDoc's SimpleMarkup doesn't catch all the cases of inline markup  
> > that is really useful for a Ruby documentation. I think it's checking  
> > for \w+ only, but adding some other punctuation marks would be  
> > helpful. Namely, none of the following work b/c of punctuation marks:
> > 
> > +ActiveRecord::Base+
> > 
> > +merge!+
> > 
> > +is\_a?+
> > 
> > +name=+
> > 
> > +object.call+

---

<div class="post-metadata">

**Author:** ![Eric\_Hodel1](https://avatars.discourse-cdn.com/v4/letter/e/a9adbd/32.png) [@Eric\_Hodel1](https://rubytalk.org/u/Eric_Hodel1)\
**Post date:** [3 September 2009 22:17 UTC](https://rubytalk.org/t/better-rdoc-inline-markup/55224/3 "2009-09-03T22:17:18Z")

</div>

+ is for variables and variables don't have punctuation.

If you \*really\* want those in \<tt\> format, use \<tt\>.

RDoc makes classes and (most) methods stand out by turning them into links. If it doesn't link, adding a # in front should fix it. (Single-word method calls don't get links by default since that grabs too many common words.)

> **···**
>
> On Sep 3, 2009, at 08:16, Intransition wrote:
> 
> > RDoc's SimpleMarkup doesn't catch all the cases of inline markup  
> > that is really useful for a Ruby documentation. I think it's checking  
> > for \w+ only, but adding some other punctuation marks would be  
> > helpful. Namely, none of the following work b/c of punctuation marks:
> > 
> > +ActiveRecord::Base+
> > 
> > +merge!+
> > 
> > +is\_a?+
> > 
> > +name=+
> > 
> > +object.call+
> > 
> > It would great if the Regexp could be expanded to catch these cases.

---

<div class="post-metadata">

**Author:** ![Eric\_Hodel1](https://avatars.discourse-cdn.com/v4/letter/e/a9adbd/32.png) [@Eric\_Hodel1](https://rubytalk.org/u/Eric_Hodel1)\
**Post date:** [4 September 2009 19:05 UTC](https://rubytalk.org/t/better-rdoc-inline-markup/55224/4 "2009-09-04T19:05:56Z")

</div>

Wait, did you even try it?

$ echo '+ActiveRecord::Base+ +merge!+ +is\_a?+ +name=+ +object.call+ +:symbol+' | rdoc --pipe  
\<p\>  
+ActiveRecord::Base+ \<tt\>merge!\</tt\> \<tt\>is\_a?\</tt\> \<tt\>name=\</tt\>  
\<tt\>object.call\</tt\> \<tt\>:symbol\</tt\>  
\</p\>

They all work in RDoc 2.4.3 except A::B. I even threw in :symbol.

> **···**
>
> On Sep 3, 2009, at 08:16, Intransition wrote:
> 
> > RDoc's SimpleMarkup doesn't catch all the cases of inline markup  
> > that is really useful for a Ruby documentation. I think it's checking  
> > for \w+ only, but adding some other punctuation marks would be  
> > helpful. Namely, none of the following work b/c of punctuation marks:
> > 
> > +ActiveRecord::Base+
> > 
> > +merge!+
> > 
> > +is\_a?+
> > 
> > +name=+
> > 
> > +object.call+
> > 
> > It would great if the Regexp could be expanded to catch these cases.

---

<div class="post-metadata">

**Author:** ![7rans](https://avatars.discourse-cdn.com/v4/letter/7/a8b319/32.png) [@7rans](https://rubytalk.org/u/7rans)\
**Post date:** [3 September 2009 22:33 UTC](https://rubytalk.org/t/better-rdoc-inline-markup/55224/5 "2009-09-03T22:33:38Z")

</div>

SM is used for more than just generating RDocs. For instance, READMEs.

> **···**
>
> On Sep 3, 6:17 pm, Eric Hodel \<drbr...@segment7.net\> wrote:
> 
> > + is for variables and variables don't have punctuation.
> > 
> > If you \*really\* want those in \<tt\> format, use \<tt\>.
> > 
> > RDoc makes classes and (most) methods stand out by turning them into  
> > links. If it doesn't link, adding a # in front should fix it.  
> > (Single-word method calls don't get links by default since that grabs  
> > too many common words.)

---

<div class="post-metadata">

**Author:** ![Xavier\_Noria](https://yyz1.discourse-cdn.com/flex029/user_avatar/rubytalk.org/xavier_noria/32/1867_2.png) [@Xavier\_Noria](https://rubytalk.org/u/Xavier_Noria)\
**Post date:** [4 September 2009 20:25 UTC](https://rubytalk.org/t/better-rdoc-inline-markup/55224/6 "2009-09-04T20:25:14Z")

</div>

Great! Didn't know it worked in recent rdoc, it is certainly not  
documented in doc\_root/rdoc-2.4.3/rdoc/RDoc.html that I can tell.

That's good we are currently migrating Rails docs to 2.4 indeed.

> **···**
>
> On Fri, Sep 4, 2009 at 9:05 PM, Eric Hodel\<drbrain@segment7.net\> wrote:
> 
> > Wait, did you even try it?
> > 
> > $ echo '+ActiveRecord::Base+ +merge!+ +is\_a?+ +name=+ +object.call+  
> > +:symbol+' | rdoc --pipe  
> > \<p\>  
> > +ActiveRecord::Base+ \<tt\>merge!\</tt\> \<tt\>is\_a?\</tt\> \<tt\>name=\</tt\>  
> > \<tt\>object.call\</tt\> \<tt\>:symbol\</tt\>  
> > \</p\>
> > 
> > They all work in RDoc 2.4.3 except A::B. I even threw in :symbol.

---

<div class="post-metadata">

**Author:** ![7rans](https://avatars.discourse-cdn.com/v4/letter/7/a8b319/32.png) [@7rans](https://rubytalk.org/u/7rans)\
**Post date:** [5 September 2009 00:59 UTC](https://rubytalk.org/t/better-rdoc-inline-markup/55224/7 "2009-09-05T00:59:53Z")

</div>

Hmmm...

&nbsp;&nbsp;require 'rdoc/markup/simple\_markup'  
&nbsp;&nbsp;require 'rdoc/markup/simple\_markup/to\_html'  
&nbsp;&nbsp;p = SM::SimpleMarkup.new  
&nbsp;&nbsp;h = SM::ToHtml.new  
&nbsp;&nbsp;puts p.convert('+ActiveRecord::Base+ +merge!+ +is\_a?+ +name=+  
+object.call+ +:symbol+',h)

produces:

&nbsp;&nbsp;\<p\>  
&nbsp;&nbsp;+ActiveRecord::Base+ +merge!+ +is\_a?+ +name=+ +object.call+ +:symbol

> **···**
>
> On Sep 4, 3:05 pm, Eric Hodel \<drbr...@segment7.net\> wrote:
> 
> > On Sep 3, 2009, at 08:16, Intransition wrote:
> > 
> > \> RDoc's SimpleMarkup doesn't catch all the cases of inline markup  
> > \> that is really useful for a Ruby documentation. I think it's checking  
> > \> for \w+ only, but adding some other punctuation marks would be  
> > \> helpful. Namely, none of the following work b/c of punctuation marks:
> > 
> > \> +ActiveRecord::Base+
> > 
> > \> +merge!+
> > 
> > \> +is\_a?+
> > 
> > \> +name=+
> > 
> > \> +object.call+
> > 
> > \> It would great if the Regexp could be expanded to catch these cases.
> > 
> > Wait, did you even try it?
> > 
> > $ echo '+ActiveRecord::Base+ +merge!+ +is\_a?+ +name=+ +object.call+  
> > +:symbol+' | rdoc --pipe  
> > \<p\>  
> > +ActiveRecord::Base+ \<tt\>merge!\</tt\> \<tt\>is\_a?\</tt\> \<tt\>name=\</tt\>  
> > \<tt\>object.call\</tt\> \<tt\>:symbol\</tt\>  
> > \</p\>
> 
> +  
> &nbsp;&nbsp;\</p\>
> 
> &nbsp;&nbsp;require 'rdoc'  
> &nbsp;&nbsp;RDoc::VERSION #=\> "2.4.3"
> 
> So now I'm thinking RDoc no longer has SM ? And when I require it I am  
> actually picking up the RDoc built into Ruby 1.8.7, but when I require  
> 'rdoc' I'm getting the latest Gem I installed.

---

<div class="post-metadata">

**Author:** ![John\_Barnette1](https://avatars.discourse-cdn.com/v4/letter/j/e99b99/32.png) [@John\_Barnette1](https://rubytalk.org/u/John_Barnette1)\
**Post date:** [3 September 2009 22:53 UTC](https://rubytalk.org/t/better-rdoc-inline-markup/55224/8 "2009-09-03T22:53:27Z")

</div>

I've been pretty happy using \<tt\>\</tt\> for inline code examples, no matter how small, that aren't identifiers. Does this not work for you?

~ j.

> **···**
>
> On Sep 3, 2009, at 3:33 PM, trans wrote:
> 
> > SM is used for more than just generating RDocs. For instance, READMEs.

---

<div class="post-metadata">

**Author:** ![Eric\_Hodel1](https://avatars.discourse-cdn.com/v4/letter/e/a9adbd/32.png) [@Eric\_Hodel1](https://rubytalk.org/u/Eric_Hodel1)\
**Post date:** [5 September 2009 07:10 UTC](https://rubytalk.org/t/better-rdoc-inline-markup/55224/9 "2009-09-05T07:10:43Z")

</div>

There's no more SM, rdoc 2.x is properly namespaced.

See:

[http://rdoc.rubyforge.org/RDoc/Markup.html](http://rdoc.rubyforge.org/RDoc/Markup.html)

> **···**
>
> On Sep 4, 2009, at 17:59, trans wrote:
> 
> > On Sep 4, 3:05 pm, Eric Hodel \<drbr...@segment7.net\> wrote:
> > 
> > > Wait, did you even try it?
> > > 
> > > $ echo '+ActiveRecord::Base+ +merge!+ +is\_a?+ +name=+ +object.call+  
> > > +:symbol+' | rdoc --pipe  
> > > \<p\>  
> > > +ActiveRecord::Base+ \<tt\>merge!\</tt\> \<tt\>is\_a?\</tt\> \<tt\>name=\</tt\>  
> > > \<tt\>object.call\</tt\> \<tt\>:symbol\</tt\>  
> > > \</p\>
> > 
> > Hmmm...
> > 
> > require 'rdoc/markup/simple\_markup'  
> > require 'rdoc/markup/simple\_markup/to\_html'  
> > p = SM::SimpleMarkup.new  
> > h = SM::ToHtml.new  
> > puts p.convert('+ActiveRecord::Base+ +merge!+ +is\_a?+ +name=+  
> > +object.call+ +:symbol+',h)
> > 
> > produces:
> > 
> > [...]
> > 
> > So now I'm thinking RDoc no longer has SM ? And when I require it I am  
> > actually picking up the RDoc built into Ruby 1.8.7, but when I require  
> > 'rdoc' I'm getting the latest Gem I installed.

---

<div class="post-metadata">

**Author:** ![7rans](https://avatars.discourse-cdn.com/v4/letter/7/a8b319/32.png) [@7rans](https://rubytalk.org/u/7rans)\
**Post date:** [3 September 2009 23:44 UTC](https://rubytalk.org/t/better-rdoc-inline-markup/55224/10 "2009-09-03T23:44:34Z")

</div>

Not so much. It isn't very good for all uses. Certain documents are  
intended for being read both as the converted HTML and the original  
text. And lots of \<tags\>\</tags\> hampers that. I really like RDoc.  
Markdown's handling of indented content is lacking in my opinion.  
Moreover I'd rather use a single markup syntax everywhere in my  
project, code, README, HISTORY, etc. I don't mind have to specify a  
"turn on extra processing" flag or something when I need it, but it  
would be really nice if RDoc could handle a broader range of  
documentation markup needs.

> **···**
>
> On Sep 3, 6:53 pm, John Barnette \<jbarne...@gmail.com\> wrote:
> 
> > On Sep 3, 2009, at 3:33 PM, trans wrote:
> > 
> > \> SM is used for more than just generating RDocs. For instance,  
> > \> READMEs.
> > 
> > I've been pretty happy using \<tt\>\</tt\> for inline code examples, no  
> > matter how small, that aren't identifiers. Does this not work for you?

---

<div class="post-metadata">

**Author:** ![Xavier\_Noria](https://yyz1.discourse-cdn.com/flex029/user_avatar/rubytalk.org/xavier_noria/32/1867_2.png) [@Xavier\_Noria](https://rubytalk.org/u/Xavier_Noria)\
**Post date:** [4 September 2009 12:23 UTC](https://rubytalk.org/t/better-rdoc-inline-markup/55224/11 "2009-09-04T12:23:14Z")

</div>

Yeah it works, but ++ would be much simpler and clean.

In fact when docrails started I personally went a cleaned +:symbol+s  
and friends, and there's this gotcha mentioned in the rails docs  
guidelines because of it. That's people's fault because it is clearly  
documented of course, but I think suggests some people indeed expect  
that + covers a bit more than \A\w+\z.

I'd certainly vote for supporting the examples that have been  
mentioned in the thread.

> **···**
>
> On Fri, Sep 4, 2009 at 12:53 AM, John Barnette\<jbarnette@gmail.com\> wrote:
> 
> > On Sep 3, 2009, at 3:33 PM, trans wrote:
> > 
> > > SM is used for more than just generating RDocs. For instance, READMEs.
> > 
> > I've been pretty happy using \<tt\>\</tt\> for inline code examples, no matter  
> > how small, that aren't identifiers. Does this not work for you?

---

<div class="post-metadata">

**Author:** ![7rans](https://avatars.discourse-cdn.com/v4/letter/7/a8b319/32.png) [@7rans](https://rubytalk.org/u/7rans)\
**Post date:** [5 September 2009 10:00 UTC](https://rubytalk.org/t/better-rdoc-inline-markup/55224/12 "2009-09-05T10:00:06Z")

</div>

Thank you!

BTW, there's old docs out there, in particular:

&nbsp;&nbsp;[http://rdoc.sourceforge.net/](http://rdoc.sourceforge.net/)

And tend to be at the top of Google searches.

> **···**
>
> On Sep 5, 3:10 am, Eric Hodel \<drbr...@segment7.net\> wrote:
> 
> > There's no more SM, rdoc 2.x is properly namespaced.  
> > See:
> > 
> > [http://rdoc.rubyforge.org/RDoc/Markup.html](http://rdoc.rubyforge.org/RDoc/Markup.html)
