query stringlengths 7 9.5k | document stringlengths 10 1.07M | negatives listlengths 19 19 | metadata dict |
|---|---|---|---|
Finds a method, constant, attribute, external alias, module or file named +symbol+ in this context. | def find_local_symbol(symbol)
find_method_named(symbol) or
find_constant_named(symbol) or
find_attribute_named(symbol) or
find_external_alias_named(symbol) or
find_module_named(symbol) or
find_file_named(symbol)
end | [
"def find_local_symbol(symbol)\n find_method_named(symbol) or\n find_constant_named(symbol) or\n find_attribute_named(symbol) or\n find_module_named(symbol) or\n find_file_named(symbol)\n end",
"def find_symbol(symbol, method = nil)\n result = nil\n\n case symbol\n when /^::(.*)/ then\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Finds a method named +name+ with singleton value +singleton+. | def find_method(name, singleton)
@method_list.find { |m|
if m.singleton
m.name == name && m.singleton == singleton
else
m.name == name && !m.singleton && !singleton
end
}
end | [
"def find_class_method_named(name)\n @method_list.find { |meth| meth.singleton && meth.name == name }\n end",
"def find_instance_method_named(name)\n @method_list.find {|meth| meth.name == name && !meth.singleton}\n end",
"def find_instance_method_named(name)\n @method_list.find { |meth| meth.nam... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Find a module with +name+ using ruby's scoping rules | def find_module_named(name)
res = @modules[name] || @classes[name]
return res if res
return self if self.name == name
find_enclosing_module_named name
end | [
"def find_module_named(name)\n find_class_or_module_named(name) || find_enclosing_module_named(name)\n end",
"def find_module_named(name)\n find_class_or_module_named(name) || find_enclosing_module_named(name)\n end",
"def find_module_named(name)\n find_class_or_module(name)\n end",
"def find_... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Look up a module named +symbol+. | def find_symbol_module(symbol)
result = nil
# look for a class or module 'symbol'
case symbol
when /^::/ then
result = @store.find_class_or_module symbol
when /^(\w+):+(.+)$/
suffix = $2
top = $1
searched = self
while searched do
mod = searched.find_module_name... | [
"def locate( symbol )\n binder = @lookup_table[ symbol.object_id ]\n return binder.entry if binder\n\n #puts \"Failed to locate symbol <#{symbol}:#{symbol.class}>:\"\n #puts to_s\n return nil\n end",
"def find_symbol(symbol, method = nil)\n result = nil\n\n case symbol\n when /^::(.*)/ th... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Breaks method_list into a nested hash by type ('class' or 'instance') and visibility (+:public+, +:protected+, +:private+). If +section+ is provided only methods in that RDoc::Context::Section will be returned. | def methods_by_type section = nil
methods = {}
TYPES.each do |type|
visibilities = {}
RDoc::VISIBILITIES.each do |vis|
visibilities[vis] = []
end
methods[type] = visibilities
end
each_method do |method|
next if section and not method.section == section
meth... | [
"def build_method_detail_list(section)\n outer = []\n\n methods = @methods.sort.select do |m|\n m.document_self and m.section == section\n end\n\n for singleton in [true, false]\n for vis in [ :public, :protected, :private ]\n res = []\n methods.each do |m|\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Yields AnyMethod and Attr entries matching the list of names in +methods+. | def methods_matching(methods, singleton = false, &block)
(@method_list + @attributes).each do |m|
yield m if methods.include?(m.name) and m.singleton == singleton
end
each_ancestor do |parent|
parent.methods_matching(methods, singleton, &block)
end
end | [
"def methods_matching(methods, singleton = false)\n count = 0\n\n @method_list.each do |m|\n if methods.include? m.name and m.singleton == singleton then\n yield m\n count += 1\n end\n end\n\n return if count == methods.size || singleton\n\n @attributes.each do |a|\n yiel... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Hash of modules keyed by module name | def modules_hash
@modules
end | [
"def modules_hash\n @modules\n end",
"def module_names\n @cache[:modules]\n end",
"def list_installed_modules\n installed_modules = {}\n exec_semodule_cmd.each_line do |line|\n line.chomp\n if (match = line.match(/^(\\w+.*?)\\s+((\\d+\\.)?(\\d+\\.)?(\\*|\\d+))/))\n m... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Name to use to generate the url. full_name by default. | def name_for_path
full_name
end | [
"def name\n url_id + \"_\" + params_slug\n end",
"def full_name\n name = self.ref.respond_to?(:full_name) ? self.ref.full_name : :\"\"\n return :\"#{name}::#{self.name}\"\n end",
"def full_name\n \"#{prename} #{name}\"\n end",
"def full_name\n display_optional nam... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Should we remove this context from the documentation? The answer is yes if: received_nodoc is +true+ any_content is +false+ (not counting includes) All includes are modules (not a string), and their module has remove_from_documentation? == true All classes and modules have remove_from_documentation? == true | def remove_from_documentation?
@remove_from_documentation ||=
@received_nodoc &&
!any_content(false) &&
@includes.all? { |i| !i.module.is_a?(String) && i.module.remove_from_documentation? } &&
classes_and_modules.all? { |cm| cm.remove_from_documentation? }
end | [
"def remove_nodoc all_hash\n all_hash.keys.each do |name|\n context = all_hash[name]\n all_hash.delete(name) if context.remove_from_documentation?\n end\n end",
"def documented?\n @received_nodoc or !@comment.empty?\n end",
"def documented?\n return true if @received_nodoc\n return fa... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Removes methods and attributes with a visibility less than +min_visibility+. TODO mark the visibility of attributes in the template (if not public?) | def remove_invisible min_visibility
return if [:private, :nodoc].include? min_visibility
remove_invisible_in @method_list, min_visibility
remove_invisible_in @attributes, min_visibility
remove_invisible_in @constants, min_visibility
end | [
"def complete min_visibility\n fix_basic_object_inheritance\n\n # cache included modules before they are removed from the documentation\n all_classes_and_modules.each { |cm| cm.ancestors }\n\n unless min_visibility == :nodoc then\n remove_nodoc @classes_hash\n remove_nodoc @modules_hash\n e... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Tries to resolve unmatched aliases when a method or attribute has just been added. | def resolve_aliases added
# resolve any pending unmatched aliases
key = added.pretty_name
unmatched_alias_list = @unmatched_alias_lists[key]
return unless unmatched_alias_list
unmatched_alias_list.each do |unmatched_alias|
added.add_alias unmatched_alias, self
@external_aliases.delete un... | [
"def add_alias(an_alias)\n meth = find_instance_method_named(an_alias.old_name)\n\n if meth then\n add_alias_impl an_alias, meth\n else\n add_to @aliases, an_alias\n unmatched_alias_list = @unmatched_alias_lists[an_alias.old_name] ||= []\n unmatched_alias_list.push an_alias\n end\n\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets the current section to a section with +title+. See also add_section | def set_current_section title, comment
@current_section = add_section title, comment
end | [
"def add_section title, comment = nil\n if section = @sections[title] then\n section.add_comment comment if comment\n else\n section = Section.new self, title, comment\n @sections[title] = section\n end\n\n section\n end",
"def section(title, options = {}, &block)\n add_outline_it... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Given an array +methods+ of method names, set the visibility of each to +visibility+ | def set_visibility_for(methods, visibility, singleton = false)
methods_matching methods, singleton do |m|
m.visibility = visibility
end
end | [
"def set_visibility_for(methods, vis, singleton = false)\n methods_matching methods, singleton do |m|\n m.visibility = vis\n end\n end",
"def expose(*meths)\n @exposed ||= []\n meths.each do |meth|\n @exposed << meth unless @exposed.include?(meth)\n end\n @... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Given an array +names+ of constants, set the visibility of each constant to +visibility+ | def set_constant_visibility_for(names, visibility)
names.each do |name|
constant = @constants_hash[name] or next
constant.visibility = visibility
end
end | [
"def names=(names)\n @names = Array(names)\n end",
"def set_visibility( groups, entries = sir_entries )\n if groups.nil?\n entries.each{ |se| se.visibility = 0 }\n elsif groups.empty?\n entries.each{ |se| se.visibility = 1 }\n else\n se_stack = Array.new\n entries.each do |se|... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sorts sections alphabetically (default) or in TomDoc fashion (none, Public, Internal, Deprecated) | def sort_sections
titles = @sections.map { |title, _| title }
if titles.length > 1 and
TOMDOC_TITLES_SORT ==
(titles | TOMDOC_TITLES).sort_by { |title| title.to_s } then
@sections.values_at(*TOMDOC_TITLES).compact
else
@sections.sort_by { |title, _|
title.to_s
}.ma... | [
"def sections_sorted(&block)\n return to_enum(:sections_sorted) if ! block_given?\n @sections.values.sort { |a,b| \n # Tricky sort: ident is often an index but can be an abritrary string\n # depending on what the :parse_file plugin decided.\n # If a.to_i == b... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Upgrades NormalModule +mod+ in +enclosing+ to a +class_type+ | def upgrade_to_class mod, class_type, enclosing
enclosing.modules_hash.delete mod.name
klass = RDoc::ClassModule.from_module class_type, mod
klass.store = @store
# if it was there, then we keep it even if done_documenting
@store.classes_hash[mod.full_name] = klass
enclosing.classes_hash[mod.na... | [
"def handle_class_module(var_name, type, class_name, parent, in_module)\n parent_name = @known_classes[parent] || parent\n\n if in_module then\n enclosure = @classes[in_module] || @store.find_c_enclosure(in_module)\n\n if enclosure.nil? and enclosure = @known_classes[in_module] then\n enc_typ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Internal: Builds a verbatim from the token stream. A verbatim in the Examples section will be marked as in Ruby format. margin The indentation from the margin for lines that belong to this verbatim section. Returns an RDoc::Markup::Verbatim | def build_verbatim margin
verbatim = super
verbatim.format = :ruby if @section == 'Examples'
verbatim
end | [
"def build_verbatim margin\n p :verbatim_begin => margin if @debug\n verbatim = RDoc::Markup::Verbatim.new\n\n until @tokens.empty? do\n type, data, column, = get\n\n case type\n when :INDENT then\n if margin >= data then\n unget\n break\n end\n\n inden... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Detects a section change to "Returns" and adds a heading | def parse_text parent, indent # :nodoc:
paragraph = build_paragraph indent
if false == @seen_returns and 'Returns' == @section then
@seen_returns = true
parent << RDoc::Markup::Heading.new(3, 'Returns')
parent << RDoc::Markup::BlankLine.new
end
parent << paragraph
end | [
"def parse_returns(section)\n returns, raises, current = [], [], []\n\n lines = section.split(\"\\n\") \n lines.each do |line|\n case line\n when /^Returns/\n returns << line\n current = returns\n when /^Raises/\n raises << line\n current = ra... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Creates a new Mixin for +name+ with +comment+ | def initialize(name, comment)
super()
@name = name
self.comment = comment
@module = nil # cache for module if found
end | [
"def add klass, name, comment\n if RDoc::Extend == klass then\n ext = RDoc::Extend.new name, comment\n add_extend ext\n elsif RDoc::Include == klass then\n incl = RDoc::Include.new name, comment\n add_include incl\n else\n raise NotImplementedError, \"adding a #{klass} is not imple... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Attempts to locate the included module object. Returns the name if not known. The scoping rules of Ruby to resolve the name of an included module are: first look into the children of the current context; if not found, look into the children of included modules, in reverse inclusion order; if still not found, go up the ... | def module
return @module if @module
# search the current context
return @name unless parent
full_name = parent.child_name(@name)
@module = @store.modules_hash[full_name]
return @module if @module
return @name if @name =~ /^::/
# search the includes before this one, in reverse order
... | [
"def module\n return @module if @module\n\n # search the current context\n return @name unless parent\n full_name = parent.child_name(@name)\n @module = @store.modules_hash[full_name]\n return @module if @module\n return @name if @name =~ /^::/\n\n # search the includes before this one, in r... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Adds +comment+ to this ClassModule's list of comments at +location+. This method is preferred over comment= since it allows ri data to be updated across multiple runs. | def add_comment comment, location
return unless document_self
original = comment
comment = case comment
when RDoc::Comment then
comment.normalize
else
normalize_comment comment
end
if location.parser == RDoc::Parser::C
@c... | [
"def add_comment(body, location = nil)\n return comments << body if location.nil?\n\n add_comment_on_file(body, *parse_location(location))\n end",
"def update_comments(comment)\r\n self.comments << comment\r\n end",
"def add_comment(comment)\n @comment += comment + \"\\n\"\n e... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Ancestors list for this ClassModule: the list of included modules (classes will add their superclass if any). Returns the included classes or modules, not the includes themselves. The returned values are either String or RDoc::NormalModule instances (see RDoc::Includemodule). The values are returned in reverse order of... | def ancestors
includes.map { |i| i.module }.reverse
end | [
"def ancestors\n [doc_parent].concat(doc_parent.ancestors)\n end",
"def ancestors\n ancestor_array = []\n PyCall::List.(@py_token.ancestors).each do |ancestor|\n ancestor_array << Token.new(ancestor)\n end\n ancestor_array\n end",
"def ancestors\n each_ancestor.to_a\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Clears the comment. Used by the Ruby parser. | def clear_comment
@comment = ''
end | [
"def del_comment\n @comment = ''\n end",
"def clear_comments; end",
"def delete_comment\n Jhead.call(\"-dc\", @match, @pattern)\n end",
"def remove_comment(ruby_value)\n self.comment_property.delete(RiCal::PropertyValue::Text.convert(self, ruby_value))\n end",
"def remove_comment com... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Does this ClassModule or any of its methods have document_self set? | def document_self_or_methods
document_self || method_list.any?{ |m| m.document_self }
end | [
"def self\n @define_self = true",
"def process_require_self_directive; end",
"def initialize\n @comment = nil\n @document_children = true\n @document_self = true\n @done_documenting = false\n @force_documentation = false\n @parent = nil\n end",
"def singleton_method_via_class_self_no... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Does this class or module have a comment with content or is received_nodoc true? | def documented?
return true if @received_nodoc
return false if @comment_location.empty?
@comment_location.any? { |comment, _| not comment.empty? }
end | [
"def documented?\n @received_nodoc or !@comment.empty?\n end",
"def nodoc_comment?(node, ast_with_comments, require_all = false)\n return false unless node\n nodoc_node = node.children.first\n return false unless nodoc_node\n comment = ast_with_comments[nodoc_node].first\n\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Looks for a symbol in the ancestors. See Contextfind_local_symbol. | def find_ancestor_local_symbol symbol
each_ancestor do |m|
res = m.find_local_symbol(symbol)
return res if res
end
nil
end | [
"def find_local_symbol(symbol)\n find_method_named(symbol) or\n find_constant_named(symbol) or\n find_attribute_named(symbol) or\n find_external_alias_named(symbol) or\n find_module_named(symbol) or\n find_file_named(symbol)\n end",
"def find_local_symbol(symbol)\n find_method_named(symbol) ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Merges +class_module+ into this ClassModule. The data in +class_module+ is preferred over the receiver. | def merge class_module
@parent = class_module.parent
@parent_name = class_module.parent_name
other_document = parse class_module.comment_location
if other_document then
document = parse @comment_location
document = document.merge other_document
@comment = @comment_location = d... | [
"def _class_module=(n)\n @_class_module = n\n end",
"def extend_class(class_, module_)\n class_.class_eval do\n include module_\n extend module_.const_get(:ClassMethods) if module_.const_defined?(:ClassMethods, false)\n prepend module_.const_get(:PrependMethods) if module_.const_defi... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Merges collection +mine+ with +other+ preferring other. +other_files+ is used to help determine which items should be deleted. Yields whether the item should be added or removed (true or false) and the item to be added or removed. merge_collections things, other.things, other.in_files do |add, thing| if add then add th... | def merge_collections mine, other, other_files, &block # :nodoc:
my_things = mine. group_by { |thing| thing.file }
other_things = other.group_by { |thing| thing.file }
remove_things my_things, other_files, &block
add_things my_things, other_things, &block
end | [
"def merge other\n if empty? then\n @parts = other.parts\n return self\n end\n\n other.parts.each do |other_part|\n self.parts.delete_if do |self_part|\n self_part.file and self_part.file == other_part.file\n end\n\n self.parts << other_part\n end\n\n self\n end",
"... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Merges the comments in this ClassModule with the comments in the other ClassModule +cm+. | def merge_sections cm # :nodoc:
my_sections = sections.group_by { |section| section.title }
other_sections = cm.sections.group_by { |section| section.title }
other_files = cm.in_files
remove_things my_sections, other_files do |_, section|
@sections.delete section.title
end
other_s... | [
"def merge class_module\n @parent = class_module.parent\n @parent_name = class_module.parent_name\n\n other_document = parse class_module.comment_location\n\n if other_document then\n document = parse @comment_location\n\n document = document.merge other_document\n\n @comment = @comm... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Parses +comment_location+ into an RDoc::Markup::Document composed of multiple RDoc::Markup::Documents with their file set. | def parse comment_location
case comment_location
when String then
super
when Array then
docs = comment_location.map do |comment, location|
doc = super comment
doc.file = location
doc
end
RDoc::Markup::Document.new(*docs)
when RDoc::Comment then
doc ... | [
"def parse\n case @comments\n when String then\n super\n when Array then\n docs = @comments.map do |comment, location|\n doc = super comment\n doc.file = location if location\n doc\n end\n\n RDoc::Markup::Document.new(*docs)\n when RDoc::Comment then\n doc =... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Path to this class or module for use with HTML generator output. | def path
http_url @store.rdoc.generator.class_dir
end | [
"def html_path(m)\n base_name = transpose(m)\n \"#{DOC_DIR}/\" + base_name + \".html\"\n end",
"def class_path klass_name\n File.join @path, *klass_name.split('::')\n end",
"def get_file_name class_name\n class_name.underscore\n end",
"def compiled_template_path(klass, method_name)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the classes and modules that are not constants aliasing another class or module. For use by formatters only (caches its result). | def non_aliases
@non_aliases ||= classes_and_modules.reject { |cm| cm.is_alias_for }
end | [
"def included_in_modules\n modules = []\n ObjectSpace.each_object(Module) { |k| modules << k if k.included_modules.include?(self) }\n\n modules.reverse.inject([]) do |unique_modules, klass|\n unique_modules << klass unless unique_modules.collect { |k| k.to_s }.include?(klass.to_s)\n unique_module... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Updates the child modules or classes of class/module +parent+ by deleting the ones that have been removed from the documentation. +parent_hash+ is either parent.modules_hash or parent.classes_hash and +all_hash+ is ::all_modules_hash or ::all_classes_hash. | def remove_nodoc_children
prefix = self.full_name + '::'
modules_hash.each_key do |name|
full_name = prefix + name
modules_hash.delete name unless @store.modules_hash[full_name]
end
classes_hash.each_key do |name|
full_name = prefix + name
classes_hash.delete name unless @store... | [
"def update_for_parent_delete( parent_hash, key, object )\n\n unless @replaced_parents[ key ]\n \n if @without_child_hooks\n child_pre_delete_hook_result = true\n else\n child_pre_delete_hook_result = child_pre_delete_hook( key, parent_hash )\n end\n \n if @witho... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets the store for this class or module and its contained code objects. | def store= store
super
@attributes .each do |attr| attr.store = store end
@constants .each do |const| const.store = store end
@includes .each do |incl| incl.store = store end
@extends .each do |ext| ext.store = store end
@method_list.each do |meth| meth.store = store end
end | [
"def store=(store)\n @store = store\n end",
"def store=(store)\n @store = begin\n if store.class < APICache::AbstractStore\n store\n elsif store.class.to_s =~ /Moneta/\n MonetaStore.new(store)\n elsif store.nil?\n nil\n else\n raise Argument... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Get the superclass of this class. Attempts to retrieve the superclass object, returns the name if it is not known. | def superclass
@store.find_class_named(@superclass) || @superclass
end | [
"def super_class\n return nil unless super_class_name\n Parfait.object_space.get_class_by_name(super_class_name)\n end",
"def super_class!\n raise \"No super_class for class #{name}\" unless super_class_name\n s = super_class\n raise \"superclass not found for class #{name} (#{super_cl... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Updates the child modules & classes by replacing the ones that are aliases through a constant. The aliased module/class is replaced in the children and in RDoc::Storemodules_hash or RDoc::Storeclasses_hash by a copy that has RDoc::ClassModuleis_alias_for set to the aliased module/class, and this copy is added to aliase... | def update_aliases
constants.each do |const|
next unless cm = const.is_alias_for
cm_alias = cm.dup
cm_alias.name = const.name
# Don't move top-level aliases under Object, they look ugly there
unless RDoc::TopLevel === cm_alias.parent then
cm_alias.parent = self
cm_alia... | [
"def do_aliases\n @content.scan(/rb_define_alias\\s*\\(\n \\s*(\\w+),\n \\s*\"(.+?)\",\n \\s*\"(.+?)\"\n \\s*\\)/xm) do |var_name, new_name, old_name|\n class_name = @known_classes[var_name]\n\n unless class_name then\n @opt... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Deletes from includes those whose module has been removed from the documentation. FIXME: includes are not reliably removed, see _possible_bug test case | def update_includes
includes.reject! do |include|
mod = include.module
!(String === mod) && @store.modules_hash[mod.full_name].nil?
end
includes.uniq!
end | [
"def remove_from_documentation?\n @remove_from_documentation ||=\n @received_nodoc &&\n !any_content(false) &&\n @includes.all? { |i| !i.module.is_a?(String) && i.module.remove_from_documentation? } &&\n classes_and_modules.all? { |cm| cm.remove_from_documentation? }\n end",
"def clean_inc... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Deletes from extends those whose module has been removed from the documentation. FIXME: like update_includes, extends are not reliably removed | def update_extends
extends.reject! do |ext|
mod = ext.module
!(String === mod) && @store.modules_hash[mod.full_name].nil?
end
extends.uniq!
end | [
"def remove_nodoc all_hash\n all_hash.keys.each do |name|\n context = all_hash[name]\n all_hash.delete(name) if context.remove_from_documentation?\n end\n end",
"def remove_from_documentation?\n @remove_from_documentation ||=\n @received_nodoc &&\n !any_content(false) &&\n @incl... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Turns RDoc from stdin into HTML | def handle_pipe
@html = RDoc::Markup::ToHtml.new @options
parser = RDoc::Text::MARKUP_FORMAT[@options.markup]
document = parser.parse $stdin.read
out = @html.convert document
$stdout.write out
end | [
"def html_markup_asciidoc(text); end",
"def html_markup_rdoc(text); end",
"def rdoc(text)\n require 'rdoc/markup/simple_markup'\n require 'rdoc/markup/simple_markup/to_html'\n sm_p, sm_h = SM::SimpleMarkup.new, SM::ToHtml.new\n sm_p.convert(text, sm_h)\nend",
"def rdoc(content)\n markup = RDoc::Marku... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Installs a siginfo handler that prints the current filename. | def install_siginfo_handler
return unless Signal.list.include? 'INFO'
@old_siginfo = trap 'INFO' do
puts @current if @current
end
end | [
"def install_siginfo_handler\n return unless Signal.list.key? 'INFO'\n\n @old_siginfo = trap 'INFO' do\n puts @current if @current\n end\n end",
"def install_siginfo_trap\n Signal.trap \"INFO\" do\n message = \"==> info: process #$$ dumping stack\\n\"\n message << caller.join(\"\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets the current documentation tree to +store+ and sets the store's rdoc driver to this instance. | def store= store
@store = store
@store.rdoc = self
end | [
"def store=(store)\n @store = store\n end",
"def store\n @current_store_selector.store\n end",
"def store= store\n super\n\n @attributes .each do |attr| attr.store = store end\n @constants .each do |const| const.store = store end\n @includes .each do |incl| incl.store = store ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return a list of the files to be processed in a directory. We know that this directory doesn't have a .document file, so we're looking for real files. However we may well contain subdirectories which must be tested for .document files. | def list_files_in_directory dir
files = Dir.glob File.join(dir, "*")
normalized_file_list files, false, @options.exclude
end | [
"def get_files(directory)\n Dir.entries(directory).select { |entry| not is_dir?(\"#{directory}/#{entry}\") }\n end",
"def find_files_in_directory(directory, allowed_extensions)\n files = []\n\n ::Find.find(directory) do |path|\n files << path if lintable_file?(path, allowed_extensio... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Parses +filename+ and returns an RDoc::TopLevel | def parse_file filename
encoding = @options.encoding
filename = filename.encode encoding
@stats.add_file filename
return if RDoc::Parser.binary? filename
content = RDoc::Encoding.read_file filename, encoding
return unless content
filename_path = Pathname(filename).expand_path
begin
... | [
"def parse(filename)\n file = File.open(filename, \"r\").readlines\n\n $root = Node.new('root')\n $context = $root\n\n file.each_with_index do |line, index|\n process_line(line, index) if line.match(/\\S/)\n end\n\n return $root\n\nend",
"def load_file_at_toplevel(file); end",
"def get_ruby_parser(file... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Removes file extensions known to be unparseable from +files+ and TAGS files for emacs and vim. | def remove_unparseable files
files.reject do |file, *|
file =~ /\.(?:class|eps|erb|scpt\.txt|svg|ttf|yml)$/i or
(file =~ /tags$/i and
File.open(file, 'rb') { |io|
io.read(100) =~ /\A(\f\n[^,]+,\d+$|!_TAG_)/
})
end
end | [
"def clean_arb_dot_files(src)\n clean_list = $config[\"clean\"][\"remove_extentions\"].split(/,/)\n\n Find.find(src) do |path|\n next if File.basename(path) =~ /^\\._/\n clean_list.each do |ext|\n next if path !~ /\\.#{ext}/\n FileUtils.rm(path,$options) if File.exists? path\n end\n\n end\nend... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Generates documentation or a coverage report depending upon the settings in +options+. +options+ can be either an RDoc::Options instance or an array of strings equivalent to the strings that would be passed on the command line like %w[q o doc t My\ Doc\ Title]. document will automatically call RDoc::Optionsfinish if an... | def document options
self.store = RDoc::Store.new
if RDoc::Options === options then
@options = options
else
@options = RDoc::Options.load_options
@options.parse options
end
@options.finish
if @options.pipe then
handle_pipe
exit
end
unless @options.coverag... | [
"def document generator, options, destination\n generator_name = generator\n\n options = options.dup\n options.exclude ||= [] # TODO maybe move to RDoc::Options#finish\n options.setup_generator generator\n options.op_dir = destination\n Dir.chdir @spec.full_gem_path do\n options.finish\n e... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Removes a siginfo handler and replaces the previous | def remove_siginfo_handler
return unless Signal.list.key? 'INFO'
handler = @old_siginfo || 'DEFAULT'
trap 'INFO', handler
end | [
"def remove_unhandled_handler\n @unhandled_handler = nil\n end",
"def remove_handler\n @handler = nil\n @running = false\n change_info\n send_message_all \"Service terminating...\"\n end",
"def untrap_info\n return unless Signal.list['INFO']\n\n trap 'INFO', 'DEFAULT'\n end... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets the locale object for +locale_name+. Normally, this method is not used. This method is useful for testing. | def []=(locale_name, locale)
@@locales[locale_name] = locale
end | [
"def set_locale(name, value)\n talk('SET-LOCALE ' + name + '=' +value)\n end",
"def locale=(value)\n @locale = value\n end",
"def set_locale_by_default(name='lang')\n set_default_locale\n end",
"def setLocale(locale)\n @fields['locale'] = locale\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Translates the +message+ into locale. If there is no translation messages for +message+ in locale, +message+ itself is returned. | def translate(message)
@messages[message] || message
end | [
"def i18n_message(locale = nil)\n if defined?(I18n.translate)\n case locale\n when Hash\n I18n.translate(i18n_key, @i18n_params.merge(locale))\n when nil\n @i18n_message ||= I18n.translate(i18n_key, @i18n_params).freeze\n else\n I18n.translate(i18n_key, @i... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Extracts translation target messages and yields each message. Each yielded message is a Hash. It consists of the followings: :type :: :paragraph :paragraph :: String (The translation target message itself.) :line_no :: Integer (The line number of the :paragraph is started.) The above content may be added in the future. | def extract_messages
parse do |part|
case part[:type]
when :empty_line
# ignore
when :paragraph
yield(part)
end
end
end | [
"def translation_entries\r\n entries = {}\r\n self.translate_calls.each do |c|\r\n e = c.to_translation_entry(@relative_filename)\r\n if e.is_a?(Array)\r\n e.each do |te|\r\n if entries[te.source]\r\n entries[te.source].references += te.references\r\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Translates raw text into +locale+. | def translate(locale)
translated_text = ''
parse do |part|
case part[:type]
when :paragraph
translated_text += locale.translate(part[:paragraph])
when :empty_line
translated_text += part[:line]
else
raise "should not reach here: unexpected type: #{type}"
end... | [
"def localize_text(locale, text)\n text_tag = Regexp.escape(localize_text_tag).to_s\n expression = Regexp.new(text_tag + \"(.*?)\" + text_tag)\n tagged_text = text[expression, 1]\n while tagged_text do\n text = text.sub(expression, translate(locale, tagged_text))\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Creates a new Alias with a token stream of +text+ that aliases +old_name+ to +new_name+, has +comment+ and is a +singleton+ context. | def initialize(text, old_name, new_name, comment, singleton = false)
super()
@text = text
@singleton = singleton
@old_name = old_name
@new_name = new_name
self.comment = comment
end | [
"def initialize(text, old_name, new_name, comment)\n super()\n @text = text\n @old_name = old_name\n @new_name = new_name\n self.comment = comment\n end",
"def parse_alias(context, single, tk, comment)\n line_no = tk[:line_no]\n\n skip_tkspace\n\n if :on_lparen === peek_tk[:kind] then\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
HTML fragment reference for this alias | def aref
type = singleton ? 'c' : 'i'
"#alias-#{type}-#{html_name}"
end | [
"def name\n '#document-fragment'\n end",
"def fragment\n return @fragment\n end",
"def fragment_name; end",
"def anchor; end",
"def alias anchor\n raise \"Unexpected alias #{anchor}\"\n end",
"def uri_fragment\n @uri.fragment || self.class.default_template_re... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
HTML idfriendly version of +new_name+. | def html_name
CGI.escape(@new_name.gsub('-', '-2D')).gsub('%','-').sub(/^-/, '')
end | [
"def pretty_new_name\n \"#{singleton ? '::' : '#'}#{@new_name}\"\n end",
"def id2name() end",
"def html_id!\n gsub!(/[^0-9a-zA-Z\\-_]/, '_')\n prepend('a') if self[0] !~ /[a-zA-Z]/\n self\n end",
"def append_name_with_id\n tname = get_testcase_name\n #Remove data drivern label from tc ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
'::' for the alias of a singleton method/attribute, '' for instancelevel. | def name_prefix
singleton ? '::' : '#'
end | [
"def ns_alias; end",
"def full_name\n \"#{namespace.name || namespace.inspect}::#{namespace.instances[ self ]}\"\n end",
"def this_member(member)\n \"this->equivalent#{pointer_wrapper? ? '->' : '.'}#{member}\"\n end",
"def attribute_alias(name); end",
"def prefix\n \"#{name}::\"\n en... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Old name with prefix '::' or ''. | def pretty_old_name
"#{singleton ? '::' : '#'}#{@old_name}"
end | [
"def fix_name(name)\n if name[0,1] == '^'\n return \"#{ARTML.prefix}#{name[1..-1].strip}\"\n else\n return name.strip\n end\n end",
"def modulize(name)\n name = name.gsub(/\\./, '::')\n name = name.gsub(/(^(?:::)?[a-z]|::[a-z])/, &:upcase)\n name\n end",
... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
New name with prefix '::' or ''. | def pretty_new_name
"#{singleton ? '::' : '#'}#{@new_name}"
end | [
"def prefix\n \"#{name}::\"\n end",
"def name_prefix\n singleton ? '::' : '#'\n end",
"def pretty_old_name\n \"#{singleton ? '::' : '#'}#{@old_name}\"\n end",
"def prepend_name(name)\n name.prepend(\"xX_\")\nend",
"def apply_prefix(name)\n name\n end",
"def add_prefix(name, pr... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Constants are equal when their parent and name is the same | def == other
self.class == other.class and
@parent == other.parent and
@name == other.name
end | [
"def test_Module_InstanceMethods_CaseEquality\n\t\tassert_equal(false, Parent_6 === Parent_6)\n\t\t# Need, add other test cases.\n\t\t# assert_equal(true, Fred === Fred)\n\tend",
"def == other\n self.class === other and @relative_name == other.relative_name\n end",
"def == other\n self.class == other.c... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Abstract method. Contexts in their building phase call this to register a new alias for this known method/attribute. creates a new AnyMethod/Attribute named an_alias.new_name; adds +self+ as an alias for the new method or attribute adds the method or attribute to aliases adds the method or attribute to +context+. | def add_alias(an_alias, context)
raise NotImplementedError
end | [
"def add_alias an_alias, context = nil\n method = self.class.new an_alias.text, an_alias.new_name\n\n method.record_location an_alias.file\n method.singleton = self.singleton\n method.params = self.params\n method.visibility = self.visibility\n method.comment = an_alias.comment\n method.is_alia... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Prefix for +aref+, defined by subclasses. | def aref_prefix
raise NotImplementedError
end | [
"def aref_prefix\n 'method'\n end",
"def aref_prefix\n 'attribute'\n end",
"def aref\n type = singleton ? 'c' : 'i'\n \"#alias-#{type}-#{html_name}\"\n end",
"def visit_aref(node); end",
"def reference_a(ref, version = nil, label = nil)\n ref = expand_reference(ref)\n \n unless label... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Name for output to HTML. For class methods the full name with a "." is used like +SomeClass.method_name+. For instance methods the class name is used if +context+ does not match the parent. This is to help prevent people from using :: to call class methods. | def output_name context
return "#{name_prefix}#{@name}" if context == parent
"#{parent_name}#{@singleton ? '.' : '#'}#{@name}"
end | [
"def context_name(mod)\n name = mod.name\n name = name.split(\"::\").last\n name.gsub!(/(Context|Builder)$/, '')\n name.scan(/.[^A-Z]+/).map { |part| part.downcase }.join(\"_\")\n end",
"def template_name name = nil\n name ||= @current_method\n name = name.to_s\n if name.include? \... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Look for a 'callseq' in the comment to override the normal parameter handling. The :callseq: is indented from the baseline. All lines of the same indentation level and prefix are consumed. For example, all of the following will be used as the :callseq: :callseq: ARGF.readlines(sep=$/) > array ARGF.readlines(limit) > ar... | def extract_call_seq method
# we must handle situations like the above followed by an unindented first
# comment. The difficulty is to make sure not to match lines starting
# with ARGF at the same indent, but that are after the first description
# paragraph.
if @text =~ /^\s*:?call-seq:(.*?(?:\S).*... | [
"def extract_call_seq(comment, meth) # :nodoc:\n if comment.sub!(/:?call-seq:(.*?)(\\Z|\\n\\s*#?\\s*\\n)/m, '\\2') then\n seq = $1\n seq.gsub!(/^\\s*\\#\\s*/, '')\n meth.call_seq = seq\n end\n\n meth\n end",
"def extract_call_seq(comment, meth)\n if comment.sub!(/:?call-seq:(.*?)^\\s*\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets the format of this comment and resets any parsed document | def format= format
@format = format
@document = nil
end | [
"def force(new_format)\r\n @format = new_format\r\n self\r\n end",
"def reset_format!\n self.format = @default_format\n end",
"def format= new_format\n @gapi.configuration.load.update! source_format: Convert.source_format(new_format)\n end",
"def format\n @for... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Normalizes the text. See RDoc::Textnormalize_comment for details | def normalize
return self unless @text
return self if @normalized # TODO eliminate duplicate normalization
@text = normalize_comment @text
@normalized = true
self
end | [
"def pre_normalize(text); end",
"def pre_normalize(text)\n text = text.to_s.downcase\n preprocess = Chronic.translate([:pre_normalize, :preprocess])\n if preprocess.is_a? Proc\n text = preprocess.call(text)\n else\n preprocess.each do |proc|\n text = proc.call(text)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Removes private sections from this comment. Private sections are flush to the comment marker and start with and end with ++. For Cstyle comments, a private marker may not start at the opening of the comment. / private ++ public | def remove_private
# Workaround for gsub encoding for Ruby 1.9.2 and earlier
empty = ''
empty = RDoc::Encoding.change_encoding empty, @text.encoding
@text = @text.gsub(%r%^\s*([#*]?)--.*?^\s*(\1)\+\+\n?%m, empty)
@text = @text.sub(%r%^\s*[#*]?--.*%m, '')
end | [
"def remove_private_comment comment\n # Workaround for gsub encoding for Ruby 1.9.2 and earlier\n empty = ''\n empty = RDoc::Encoding.change_encoding empty, comment.encoding\n\n comment = comment.gsub(%r%^--\\n.*?^\\+\\+\\n?%m, empty)\n comment.sub(%r%^--\\n.*%m, empty)\n end",
"def remove_private... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Replaces this comment's text with +text+ and resets the parsed document. An error is raised if the comment contains a document but no text. | def text= text
raise RDoc::Error, 'replacing document-only comment is not allowed' if
@text.nil? and @document
@document = nil
@text = text.nil? ? nil : text.dup
end | [
"def parse text\n return text if RDoc::Markup::Document === text\n\n text = normalize_comment text\n\n return RDoc::Markup::Document.new if text =~ /\\A\\n*\\z/\n\n RDoc::Markup::Parser.parse text\n rescue RDoc::Markup::Parser::Error => e\n $stderr.puts <<-EOF\nWhile parsing markup, RDoc encountered... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns true if this comment is in TomDoc format. | def tomdoc?
@format == 'tomdoc'
end | [
"def is_document_style?\n true\n end",
"def documented?\n @received_nodoc or !@comment.empty?\n end",
"def documented?\n return true if @received_nodoc\n return false if @comment_location.empty?\n @comment_location.any? { |comment, _| not comment.empty? }\n end",
"def is_document_st... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
The definition of this class, class MyClassName | def definition
"class #{full_name}"
end | [
"def class() end",
"def class_definition()\n \t_IDENTIFIER1 = nil\n\n\n\n\n \t class_def = ClassDefinition.new\n\n\n # 19:7: modifier[class_def] CLASS ( IDENTIFIER ) ( class_name_parameters[class_def] )? ( inheritance[class_def] )? ( interface[class_def] )? class_body[class_def]\n modifier(... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Adds +tokens+ to the collected tokens | def add_tokens(tokens)
@token_stream.concat(tokens)
end | [
"def add_tokens(*tokens)\n tokens.flatten.each { |token| @token_stream << token }\n end",
"def add_tokens(tokens)\n tokens -= self.class.stop_words\n\n tokens.each do |w|\n @tokens[w] = @tokens.fetch(w, 0).to_i + 1\n end\n end",
"def append(tokens)\n @result.push(*tokens)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Adds one +token+ to the collected tokens | def add_token(token)
@token_stream.push(token)
end | [
"def add_token(token)\n process_unknown\n @tokens << token\n @position += token.length\n end",
"def <<(new_token)\n @tokens << new_token\n end",
"def add_token(token)\n @records[token] = {} unless @records[token]\n end",
"def add_token(aToken)\n append_symbol_to(start, aToke... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Remove the last token from the collected tokens | def pop_token
@token_stream.pop
end | [
"def unget # :nodoc:\n @tokens.unshift @current_token\n end",
"def remove_last_word\n @last_word_index = @words.keys.sort.last\n @words.delete(@last_word_index)\n end",
"def next_token\n @tokens.shift\n end",
"def erase_insignificant_tokens!\n\t\ti = 0;\n\t\twhile i < @tokens.size do\n\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns a string representation of the token stream | def tokens_to_s
token_stream.compact.map { |token| token[:text] }.join ''
end | [
"def tokens_to_s\n token_stream.compact.map { |token| token.text }.join ''\n end",
"def to_s\n @token\n end",
"def to_s\n token\n end",
"def to_s\n self.token.to_s\n end",
"def token_stream\n @tokenizer.tokens\n end",
"def token_string\n @token\n end",
"def to_s\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns a reference to +name+. If the reference is found and +name+ is not documented +text+ will be returned. If +name+ is escaped +name+ is returned. If +name+ is not found +text+ is returned. | def resolve name, text
return @seen[name] if @seen.include? name
ref = case name
when /^\\(#{CLASS_REGEXP_STR})$/o then
@context.find_symbol $1
else
@context.find_symbol name
end
ref = resolve_method name unless ref
# Try a page name
ref = @st... | [
"def get_ref(name)\n# if not name.properties[:link_to_ref_from_row].nil?\n# return @name_collection.ref_collection.object_from_row(name.properties[:link_to_ref_from_row])\n# end\n# nil\n name.original_description_reference ? name.original_description_reference : nil\n end",
"def manual_r... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Creates a new Parser storing +top_level+, +file_name+, +content+, | def initialize top_level, file_name, content, options, stats
@top_level = top_level
@top_level.parser = self.class
@store = @top_level.store
@file_name = file_name
@content = content
@options = options
@stats = stats
@preprocess = RDoc::Markup::PreProcess.new @file_name, @options.rdoc_... | [
"def new(*args)\n Parser.new(*args)\n end",
"def create_parser\n @parser = Parser.new.tap do |p|\n p.stream_open {|node| @nodes.push(node) }\n p.stream_close { close_connection }\n p.stanza {|node| @nodes.push(node) }\n end\n end",
"def open_parser(this_file)\n\t\t@file... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
The definition of this module, module MyModuleName | def definition
"module #{full_name}"
end | [
"def name\n @module.name\n end",
"def ModuleDeclaration(constant, bodystmt); end",
"def name\n\t\tmodule_info['Name']\n\tend",
"def generate_module_definition\n get_module_definition_file_name\n file = get_module_definition_file\n file.write(get_renderer(ProfileTemplates.module_definition_tem... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
This is a module, returns true | def module?
true
end | [
"def modules?\n name == Modules\n end",
"def module?(uri)\n uri.include?('/modules/')\n end",
"def _extended?(_module)\n _extended.include?(_module)\n end",
"def module_loaded?\n /^#{new_resource.modname}/.match?(::File.read(\"/proc/modules\"))\n end",
"def includes_modules?\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Creates a new TopLevel for the file at +absolute_name+. If documentation is being generated outside the source dir +relative_name+ is relative to the source directory. | def initialize absolute_name, relative_name = absolute_name
super()
@name = nil
@absolute_name = absolute_name
@relative_name = relative_name
@file_stat = File.stat(absolute_name) rescue nil # HACK for testing
@diagram = nil
@parser = nil
@classes_or_modules = []
end | [
"def add_file absolute_name, relative_name: absolute_name, parser: nil\n unless top_level = @files_hash[relative_name] then\n top_level = RDoc::TopLevel.new absolute_name, relative_name\n top_level.parser = parser if parser\n top_level.store = self\n @files_hash[relative_name] = top_level\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
An RDoc::TopLevel is equal to another with the same relative_name | def == other
self.class === other and @relative_name == other.relative_name
end | [
"def within_original_tree?\n nest_path&.start_with? \"#{@document.nest_path}/\"\n end",
"def root_namespace_for?(other)\n [@name.name, @name.namespace].flatten == other.definition.name.namespace\n end",
"def non_conflicting_parent_and_project\n if parent && parent.project != project\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Adds +an_alias+ to +Object+ instead of +self+. | def add_alias(an_alias)
object_class.record_location self
return an_alias unless @document_self
object_class.add_alias an_alias
end | [
"def add_alias(an_alias)\n meth = find_instance_method_named(an_alias.old_name)\n\n if meth then\n add_alias_impl an_alias, meth\n else\n add_to @aliases, an_alias\n unmatched_alias_list = @unmatched_alias_lists[an_alias.old_name] ||= []\n unmatched_alias_list.push an_alias\n end\n\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Adds +constant+ to +Object+ instead of +self+. | def add_constant constant
object_class.record_location self
return constant unless @document_self
object_class.add_constant constant
end | [
"def add_constant(const)\n raise \"Must be Parfait #{const}\" unless const.is_a?(Parfait::Object)\n @constants << const\n end",
"def add_constant(name, value)\n self[name] ||= { }\n self[name].merge!({:value => value, :type => :const})\n end",
"def add(constant)\n return if @nesting... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Adds +include+ to +Object+ instead of +self+. | def add_include(include)
object_class.record_location self
return include unless @document_self
object_class.add_include include
end | [
"def add_include include\n add_to @includes, include\n\n include\n end",
"def include( *args )\n includeSubobject( *args )\n end",
"def include_in_object(obj, include_ancestry = false)\n (include_ancestry ? @rmixins : @mixins).each { |m| obj.extend(m) }\n self\n end",
"... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Adds +method+ to +Object+ instead of +self+. | def add_method(method)
object_class.record_location self
return method unless @document_self
object_class.add_method method
end | [
"def add_method(method)\n object = self.class.find_class_named 'Object'\n object = add_class RDoc::NormalClass, 'Object' unless object\n\n object.add_method method\n end",
"def add_method method\n return method unless @document_self\n\n # HACK: avoid duplicate 'new' in io.c & struct.c (1.8.7 sourc... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Adds class or module +mod+. Used in the building phase by the Ruby parser. | def add_to_classes_or_modules mod
@classes_or_modules << mod
end | [
"def add_module_by_normal_module(mod)\n add_class_or_module mod, @modules, @store.modules_hash\n end",
"def add(mod)\n @modules ||= []\n @modules << mod\n end",
"def add_module(mod_)\n @modules << mod_\n end",
"def add_module(class_type, name)\n return @classes[name... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Finds a module or class with +name+ | def find_module_named(name)
find_class_or_module(name)
end | [
"def find_module_named(name)\n find_class_or_module_named(name) || find_enclosing_module_named(name)\n end",
"def find_module_named(name)\n find_class_or_module_named(name) || find_enclosing_module_named(name)\n end",
"def find_module_named(name)\n res = @modules[name] || @classes[name]\n retu... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the NormalClass "Object", creating it if not found. Records +self+ as a location in "Object". | def object_class
@object_class ||= begin
oc = @store.find_class_named('Object') || add_class(RDoc::NormalClass, 'Object')
oc.record_location self
oc
end
end | [
"def new_object; @@new_object; end",
"def get_object(name, parent_id = nil)\n if @objects.key? name then\n @objects[name]\n elsif parent_id.nil? then\n raise Error, \"object #{name} does not exist\"\n else\n add_object name, parent_id\n end\n end",
"def create_object object\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Search record used by RDoc::Generator::JsonIndex | def search_record
return unless @parser < RDoc::Parser::Text
[
page_name,
'',
page_name,
'',
path,
'',
snippet(@comment),
]
end | [
"def find( search = {} )\n load_index\n _index = @index\n if _index.empty?\n e = default_entry( @default_author )\n @updated[e.id] = e.updated\n _index = {e.id => @weblog.index_class.new(e)}\n end\n # if search[:search]\n # sr = @search_... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
The files comments in this section come from | def in_files
return [] if @comments.empty?
case @comments
when Array then
@comments.map do |comment|
comment.file
end
when RDoc::Markup::Document then
@comment.parts.map do |document|
document.file
end
else
raise RDoc::Error, "BUG: unknown comment class... | [
"def file_comments; end",
"def extract_comments(file)\n\nend",
"def source_file_comments(file)\n file_parts = { dir: File.dirname(file), name: File.basename(file) }\n content = File.read(file)\n matches = content.scan(HEADER_LICENSE_REGEX)\n matches.map { |match| [source_comm... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Parses +comment_location+ into an RDoc::Markup::Document composed of multiple RDoc::Markup::Documents with their file set. | def parse
case @comments
when String then
super
when Array then
docs = @comments.map do |comment, location|
doc = super comment
doc.file = location if location
doc
end
RDoc::Markup::Document.new(*docs)
when RDoc::Comment then
doc = super @comments.t... | [
"def parse comment_location\n case comment_location\n when String then\n super\n when Array then\n docs = comment_location.map do |comment, location|\n doc = super comment\n doc.file = location\n doc\n end\n\n RDoc::Markup::Document.new(*docs)\n when RDoc::Commen... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Removes a comment from this section if it is from the same file as +comment+ | def remove_comment comment
return if @comments.empty?
case @comments
when Array then
@comments.delete_if do |my_comment|
my_comment.file == comment.file
end
when RDoc::Markup::Document then
@comments.parts.delete_if do |document|
document.file == comment.file.name
... | [
"def del_comment\n @comment = ''\n end",
"def set_comment(comment)\n return unless comment\n\n if comment =~ /^#[ \\t]*:section:.*\\n/ then\n start = $`\n rest = $'\n\n if start.empty?\n @comment = rest\n else\n @comment = rest.sub(/#{start.chomp}\\Z... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Parses +arg+ and returns rest of +arg+ and matched portion to the argument pattern. Yields when the pattern doesn't match substring. | def parse_arg(arg) # :nodoc:
pattern or return nil, [arg]
unless m = pattern.match(arg)
yield(InvalidArgument, arg)
return arg, []
end
if String === m
m = [s = m]
else
m = m.to_a
s = m[0]
return nil, m unless String === s
end
rais... | [
"def regex_match_func(*args)\n regex_match(args[0], args[1])\n end",
"def scan_args(str)\n scanner = convert_to_scanner(str)\n str = scanner.string\n \n # skip whitespace and leading LPAREN\n scanner.skip(/\\s*\\(?\\s*/) \n \n args = []\n brakets = braces = ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Produces the summary text. Each line of the summary is yielded to the block (without newline). +sdone+:: Already summarized short style options keyed hash. +ldone+:: Already summarized long style options keyed hash. +width+:: Width of left side (option part). In other words, the right side (description part) starts aft... | def summarize(sdone = {}, ldone = {}, width = 1, max = width - 1, indent = "")
sopts, lopts = [], [], nil
@short.each {|s| sdone.fetch(s) {sopts << s}; sdone[s] = true} if @short
@long.each {|s| ldone.fetch(s) {lopts << s}; ldone[s] = true} if @long
return if sopts.empty? and lopts.empty? # comp... | [
"def render_summary\n summary = nil\n max_chars = (self.display_configuration.try {|h| h[\"summary_max_chars\"]}) || 280\n\n\n\n if self.snippets.length > 0 && !(self.display_configuration.try {|h| h[\"prefer_abstract_as_summary\"]} && self.abstract)\n summary = self.snippets.first\n se... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Main name of the switch. | def switch_name
(long.first || short.first).sub(/\A-+(?:\[no-\])?/, '')
end | [
"def name(id)\n $data_system.switches[id]\n end",
"def name\n \"#{@@config[:deployment]}_#{circuit}\"\n end",
"def default_name_func(klass)\n if (klass.respond_to? :command_name)\n klass.method(:command_name).call\n else\n klass.to_s.split(\"::\").last.gsub(/([a-z0-9])([A-Z])/, '\\1_\\2'... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Adds +sw+ according to +sopts+, +lopts+ and +nlopts+. +sw+:: OptionParser::Switch instance to be added. +sopts+:: Short style option list. +lopts+:: Long style option list. +nlopts+:: Negated long style options list. | def update(sw, sopts, lopts, nsw = nil, nlopts = nil) # :nodoc:
sopts.each {|o| @short[o] = sw} if sopts
lopts.each {|o| @long[o] = sw} if lopts
nlopts.each {|o| @long[o] = nsw} if nsw and nlopts
used = @short.invert.update(@long.invert)
@list.delete_if {|o| Switch === o and !used[o]}
... | [
"def update(sw, sopts, lopts, nsw = nil, nlopts = nil)\n o = nil\n sopts.each {|o| @short[o] = sw} if sopts\n lopts.each {|o| @long[o] = sw} if lopts\n nlopts.each {|o| @long[o] = nsw} if nsw and nlopts\n used = @short.invert.update(@long.invert)\n @list.delete_if {|o| Switch === o and... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Searches +key+ in +id+ list. The result is returned or yielded if a block is given. If it isn't found, nil is returned. | def search(id, key)
if list = __send__(id)
val = list.fetch(key) {return nil}
block_given? ? yield(val) : val
end
end | [
"def lookup(id, block)\n if @inv.respond_to?(\"each\")\n @inv.each do |invItem|\n block.call(invItem) if invItem.are_you(id)\n end\n end\n return nil\n end",
"def find(key, key_hash)\n return self if match? key, key_hash\n return unless nxt = ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Searches list +id+ for +opt+ and the optional patterns for completion +pat+. If +icase+ is true, the search is case insensitive. The result is returned or yielded if a block is given. If it isn't found, nil is returned. | def complete(id, opt, icase = false, *pat, &block)
__send__(id).complete(opt, icase, *pat, &block)
end | [
"def complete(typ, opt, icase = false, *pat) # :nodoc:\n if pat.empty?\n search(typ, opt) {|sw| return [sw, opt]} # exact match or...\n end\n ambiguous = catch(:ambiguous) {\n visit(:complete, typ, opt, icase, *pat) {|o, *sw| return sw}\n }\n exc = ambiguous ? AmbiguousOption : InvalidOptio... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Iterates over each option, passing the option to the +block+. | def each_option(&block)
list.each(&block)
end | [
"def each_option\n @options.each {|opt_sym, opt| yield opt_sym, opt }\n end",
"def each\n loop do\n option_name, option_argument = get_option\n break if option_name == nil\n yield option_name, option_argument\n end\n end",
"def each\n opt_list.each do |o|\n yield o\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Creates the summary table, passing each line to the +block+ (without newline). The arguments +args+ are passed along to the summarize method which is called on every option. | def summarize(*args, &block)
sum = []
list.reverse_each do |opt|
if opt.respond_to?(:summarize) # perhaps OptionParser::Switch
s = []
opt.summarize(*args) {|l| s << l}
sum.concat(s.reverse)
elsif !opt or opt.empty?
sum << ""
elsif opt.respond_t... | [
"def Summary(*args)\n Stupidedi::Schema::TableDef.summary(*args)\n end",
"def summary(name, options = {}, &block)\n create_attribute(name, summary_attributes, options, &block)\n end",
"def summary_table\n update_now_date_time\n calc_difference\n labels = [DueText.period, ' ', DueText.... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Initializes the instance and yields itself if called with a block. +banner+:: Banner message. +width+:: Summary width. +indent+:: Summary indent. | def initialize(banner = nil, width = 32, indent = ' ' * 4)
@stack = [DefaultList, List.new, List.new]
@program_name = nil
@banner = banner
@summary_width = width
@summary_indent = indent
@default_argv = ARGV
@require_exact = false
add_officious
yield self if block_given?
end | [
"def banner(msg = nil, &block)\n super_info(\"-----> #{msg}\", &block)\n end",
"def initialize(&block)\n @html_begin = '<col'\n @html_body = ''\n @html_end = ''\n instance_eval(&block) if block_given?\n end",
"def initialize(&block)\n @background_image = nil\n @backgr... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns version string from program_name, version and release. | def ver
if v = version
str = +"#{program_name} #{[v].join('.')}"
str << " (#{v})" if v = release
str
end
end | [
"def release_name\n return [dashed_name, @version].join('-')\n end",
"def get_nameprog_swversion\n nomeprog = APP_CUPERATIVA_NAME\n ver_prog = sw_version_to_int\n return nomeprog, ver_prog\n end",
"def get_nameprog_swversion\r\n nomeprog = APP_CUPERATIVA_NAME\r\n ver_prog = CuperativaGui... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Puts option summary into +to+ and returns +to+. Yields each line if a block is given. +to+:: Output destination, which must have method <<. Defaults to []. | def summarize(to = [], width = @summary_width, max = width - 1, indent = @summary_indent, &blk)
nl = "\n"
blk ||= proc {|l| to << (l.index(nl, -1) ? l : l + nl)}
visit(:summarize, {}, {}, width, max, indent, &blk)
to
end | [
"def summarize(*args, &block)\n sum = []\n list.reverse_each do |opt|\n if opt.respond_to?(:summarize) # perhaps OptionParser::Switch\n s = []\n opt.summarize(*args) {|l| s << l}\n sum.concat(s.reverse)\n elsif !opt or opt.empty?\n sum << \"\"\n els... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
:nodoc: :callseq: make_switch(params, block = nil) :include: ../doc/optparse/creates_option.rdoc | def make_switch(opts, block = nil)
short, long, nolong, style, pattern, conv, not_pattern, not_conv, not_style = [], [], []
ldesc, sdesc, desc, arg = [], [], []
default_style = Switch::NoArgument
default_pattern = nil
klass = nil
q, a = nil
has_arg = false
opts.each do |o|
# argum... | [
"def make_switch(opts, block = nil)\n \n # Test if a switch is required\n required = opts.delete(:required)\n\n return_values = pickled_make_switch(opts, block)\n\n # Make sure required switches are given\n if required \n short = return_values[1][0].nil? ? nil : \"-#{return_values[1][0]}\"\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.