Sha256: 367f6e133c9b89674f78959a4cf9cb34e982d9ade7e443e7d984edb243a891b0

Contents?: true

Size: 747 Bytes

Versions: 3

Compression:

Stored size: 747 Bytes

Contents

#!/usr/bin/env ruby

require 'rainbow'
require 'ffi/clang'

index = FFI::Clang::Index.new

# clang -Xclang -ast-dump -fsyntax-only ./examples/docs.cpp

def title(declaration)
	puts ["Symbol:", Rainbow(declaration.spelling).blue.bright, "Type:", Rainbow(declaration.type.spelling).green, declaration.kind.to_s].join(' ')
end

ARGV.each do |path|
	translation_unit = index.parse_translation_unit(path)
	
	declarations = translation_unit.cursor.select(&:declaration?)
	
	declarations.each do |declaration|
		title declaration
		
		if location = declaration.location
			puts "Defined at #{location.file}:#{location.line}"
		end
		
		if comment = declaration.comment
			# puts Rainbow(comment.inspect).gray
			puts Rainbow(comment.text)
		end
	end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ffi-clang-0.7.0 examples/docs.rb
ffi-clang-0.6.0 examples/docs.rb
ffi-clang-0.5.0 examples/docs.rb