Skip to content

Commit

Permalink
Added the @LLVMECB YARD tag and used it to add aditional documentatio…
Browse files Browse the repository at this point in the history
…n to methods that require the extended C bindings in the Support module and the Value and Module classes.
  • Loading branch information
chriswailes committed Jun 12, 2012
1 parent f29e628 commit ee95770
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
2 changes: 2 additions & 0 deletions lib/rltk/cg/module.rb
Expand Up @@ -97,6 +97,8 @@ def dump
# file may be specified via a file name (which will be created or
# truncated) or an object that responds to #fileno.
#
# @LLVMECB
#
# @param [String, #fileno] io File name or object with a file descriptor to print to.
#
# @return [void]
Expand Down
2 changes: 2 additions & 0 deletions lib/rltk/cg/support.rb
Expand Up @@ -21,6 +21,8 @@ module Support
# Load a shared library into memory and make its exported symbols
# available to execution engines.
#
# @LLVMECB
#
# @param [String] lib Path to the shared library to load.
def self.load_library(lib)
Bindings.load_library_permanently(lib).to_bool
Expand Down
2 changes: 2 additions & 0 deletions lib/rltk/cg/value.rb
Expand Up @@ -99,6 +99,8 @@ def null?
# may be specified via a file name (which will be created or
# truncated) or an object that responds to #fileno.
#
# @LLVMECB
#
# @param [String, #fileno] io File name or object with a file descriptor to print to.
#
# @return [void]
Expand Down
14 changes: 10 additions & 4 deletions yardlib/rltk.rb
Expand Up @@ -8,14 +8,19 @@
class RLTKTagFactory < YARD::Tags::DefaultFactory
def parse_tag(name, text)
case name
when :LLVMECB then ecb_tag()
when :LLVMInst then inst_tag(text)
when :LLVMPass then pass_tag(text)
else super
end
end

private


def ecb_tag
YARD::Tags::Tag.new('note', 'This method requires the [LLVM Extended C Bindings](https://github.com/chriswailes/llvm-ecb).')
end

def inst_tag(text)
url = "http://llvm.org/docs/LangRef.html#i_#{text}"
markup = "<a href=\"#{url}\">LLVM Instruction: #{text}</a>"
Expand All @@ -31,6 +36,7 @@ def pass_tag(text)
end
end

YARD::Tags::Library.define_tag 'Instruction', :LLVMInst
YARD::Tags::Library.define_tag 'Pass', :LLVMPass
YARD::Tags::Library.define_tag 'ExtendedBindings', :LLVMECB
YARD::Tags::Library.define_tag 'Instruction', :LLVMInst
YARD::Tags::Library.define_tag 'Pass', :LLVMPass
YARD::Tags::Library.default_factory = RLTKTagFactory

0 comments on commit ee95770

Please sign in to comment.