Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Making custom YARD markdown

Tags:

ruby

yard

I have the following method that I would like to document using YARDoc.

# Here is my method
# @arg woop [Woop] *dangerous* this parameter is output to the screen
def shoop(woop)
  puts woop
end

This generates HTML where dangerous is in bold. Because I have to parse this output, I would like to have a custom HTML tag. In other words, I would like to make it so that when the following code comment is parsed by YARDoc, the word dangerous is surrounded by <div class="custom"></div> tags, instead of <b><\b> tags, make it much easier to parse with Nokogiri. Not to say that it is currently impossible to parse with Nokogiri, it's just a bit more awkward and vulnerable to changes in the YARD code.

# Here is my method
# @arg woop [Woop] **dangerous** this parameter is output to the screen
def shoop(woop)
  puts woop
end

Is there any functionality in YARD that allows me to accomplish this? I looked at creating custom templates, but that seems to be more in regards to parsing code. I then inspected creating a custom markdown template, but I didn't see how this could or should be accomplished. I'm starting to get the impression that I'm barking up the wrong tree and would appreciate a Google keyword thrown my way.

Why I'm trying to parse the HTML in the first place:
As I've described in previous questions, I'm trying to define an interface without having to duplicate code. In this example, I want a server to "call" a method that is dangerous differently than a method that is not dangerous.

like image 349
Seanny123 Avatar asked Oct 11 '13 02:10

Seanny123


1 Answers

Markdown allows you to include inline html. So maybe try:

# Here is my method
# @arg woop [Woop] <div class="custom">dangerous</div> this ....
def shoop...
...

If this works, you could then override the default css in the doc/css/common.css file.

like image 121
pandita Avatar answered Oct 03 '22 07:10

pandita