Hi Justin,
On 5/7/2012 6:04 PM, justin.gaylor wrote:
> What is the easiest way to disable generation of "View source" code
> sections for class/module methods? I guess some sort of tag could be
> used (or created) to achieve this (such as @no_source), but I would
> prefer not to rely on the developers to incude that tag (sometimes
> humans forget). Is there an option or something to disable this? Or a
> custom template must be created?
You have to create a custom template. You could do so as an opt-in
method with said custom tag, or just use the logic you defined above
directly, your choice. Add the file
'my_templates/default/fulldoc/method_details/setup.rb' with the
following contents:
def source
return if object.scope == :class # class method
return if object.has_tag?(:no_source) # @no_source tag
super
end
Call yard with `-p my_templates`.
Note:
You shouldn't do this, though. You either choose to display source to
your users or you don't. Picking and choosing is messy. Eventually your
users will want to see source for things you are hiding for no good
reason. If your project is open source, you shouldn't be fussy about
where source is shown. If it's closed source, well, you probably don't
want to show source anywhere. We're actually going to be adding source
displays to attributes in a future version because of this reason.
Loren