Is syntax highlighting Ruby code in an RDoc file?

I am documenting the Ruby library that I am writing. In my README.rdoc file, I include a usage example with some Ruby demo code.

However, the resulting HTML documentation does not display syntax highlighted Ruby code, just like a block of code.

When I look at a source, for example, http://rdoc.rubyforge.org/README_rdoc.html , all that I see is part of the Ruby code, like me included in my README.rdoc. Is there a special option to go to the rdoc command?

+4
source share
2 answers

You should use an RDoc template that includes syntax highlighting. There are many floaters on the Internet.

(I agree with Phrogz, you should use YARD, as well as Markdown syntax.)

+2
source

RDoc, somewhat naively, uses the method below to determine if it can use a syntax shortcut.

def parseable? text text =~ /\b(def|class|module|require) |=>|\{\s?\||do \|/ and text !~ /<%|%>/ end 

Thus, your code will be highlighted only if it contains one of the following lines:

  • Protection
  • class
  • Module
  • required
  • =>
  • {|
  • do |
+4
source

Source: https://habr.com/ru/post/1393096/


All Articles