query stringlengths 7 9.5k | document stringlengths 10 1.07M | negatives listlengths 19 19 | metadata dict |
|---|---|---|---|
Return an attribute object with the given turn_on and turn_off bits set | def attribute(turn_on, turn_off)
RDoc::Markup::AttrChanger.new turn_on, turn_off
end | [
"def turn(light, on_or_off)\n target = \"1\" if on_or_off.downcase == \"on\" \n target = \"0\" if on_or_off.downcase == \"off\"\n perform_action(light, \"SetTarget\", \"newTargetValue\", target) \n end",
"def lights(lights)\n if lights == \"on\"\n @lights = true\n elsif lights == \"off\"\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Changes the current attribute from +current+ to +new+ | def change_attribute current, new
diff = current ^ new
attribute(new & diff, current & diff)
end | [
"def current_position=(new_current_position)\n Klass.setCurrentPosition(@handle, @index, new_current_position.to_i)\n\t new_current_position\n end",
"def current=(new)\n Thread.current[:lspace] = new\n end",
"def set_current(node)\n\t\t@current_node = node\n\tend",
"def old=(value); end",
"... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Used by the tests to change attributes by name from +current_set+ to +new_set+ | def changed_attribute_by_name current_set, new_set
current = new = 0
current_set.each do |name|
current |= @attributes.bitmap_for(name)
end
new_set.each do |name|
new |= @attributes.bitmap_for(name)
end
change_attribute(current, new)
end | [
"def rename(new_name, data_set)\n unless new_name == name\n @attributes = PublicEarth::Db::Category.one.rename(self.id, new_name, data_set.id)\n update_cache\n end\n end",
"def change_attribute current, new\n diff = current ^ new\n attribute(new & diff, current & diff)\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Copies +start_pos+ to +end_pos+ from the current string | def copy_string(start_pos, end_pos)
res = @str[start_pos...end_pos]
res.gsub!(/\000/, '')
res
end | [
"def extend_start(str)\n while start_pos >= str.size\n str += \" \"\n end\n str\n end",
"def string_start_end(string, start_point, end_point)\n if end_point > start_point\n final_string = string[start_point..end_point]\n elsif start_point == end_point\n final_string = string[start_point]\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Converts regexp handling sequences to RDoc attributes | def convert_regexp_handlings str, attrs, exclusive = false
@regexp_handlings.each do |regexp, attribute|
next unless exclusive == exclusive?(attribute)
str.scan(regexp) do
capture = $~.size == 1 ? 0 : 1
s, e = $~.offset capture
attrs.set_attrs s, e - s, attribute | @attributes.... | [
"def convert_regexp_handling target\n return target.text if in_tt?\n\n handled = false\n\n @attributes.each_name_of target.type do |name|\n method_name = \"handle_regexp_#{name}\"\n\n if respond_to? method_name then\n target.text = public_send method_name, target\n handled = true\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Adds a regexp handling for +pattern+ with +name+. A simple URL handler would be: | def add_regexp_handling pattern, name, exclusive = false
bitmap = @attributes.bitmap_for(name)
@regexp_handlings << [pattern, bitmap]
@exclusive_bitmap |= bitmap if exclusive
end | [
"def initialize name, pattern\n @name = name\n @pattern = pattern\n end",
"def add_special(pattern, name)\n @am.add_special(pattern, name)\n end",
"def register_pattern(pattern, handler = nil)\n @patterns.push Pattern.new pattern, handler\n end",
"def matchname?(name)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Splits the string into chunks by attribute change | def split_into_flow
res = []
current_attr = 0
str_len = @str.length
# skip leading invisible text
i = 0
i += 1 while i < str_len and @str[i].chr == "\0"
start_pos = i
# then scan the string, chunking it on attribute changes
while i < str_len
new_attr = @attrs[i]
if new... | [
"def split_attributes(attribute_string)\n attributes = {}\n hashes = attribute_string.split(';').map { |assignment|\n match = assignment.match(/([^=]+)=(.+)/) ;\n { match[1].strip => match[2].split(',').map { |value| URI.decode(value.strip) } }\n }\n hashes.map { |hash|\n hash.each_pair {... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Calls convert_string on the result of convert_regexp_handling | def convert_regexp_handling target
convert_string super
end | [
"def convert_regexp_handling target\n return target.text if in_tt?\n\n handled = false\n\n @attributes.each_name_of target.type do |name|\n method_name = \"handle_regexp_#{name}\"\n\n if respond_to? method_name then\n target.text = public_send method_name, target\n handled = true\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Calls accept_blank_line on +visitor+ | def accept visitor
visitor.accept_blank_line self
end | [
"def accept_blank_line blank_line\n @res << \"\\n\"\n end",
"def empty_line\n end",
"def parse_blank_line; end",
"def accept visitor\n visitor.accept_verbatim self\n end",
"def change_verbatim_blank_lines\n frag_block = nil\n blank_count = 0\n @fragments.each_with_index do |frag, i... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Calls accept_verbatim on +visitor+ | def accept visitor
visitor.accept_verbatim self
end | [
"def accept visitor\n visitor.accept_raw self\n end",
"def accept(_visitor)\n raise NotImplementedError\n end",
"def accept_visitor(visitor)\n visit_method_name = \"visit#{basename(self.class.name.to_s.gsub(/::/, '/'))}\".to_sym\n visitor.send(visit_method_n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Creates a new preprocessor for +input_file_name+ that will look for included files in +include_path+ | def initialize(input_file_name, include_path)
@input_file_name = input_file_name
@include_path = include_path
@options = nil
end | [
"def update_header name\n from_filename = \"#{name}.inc.h\"\n filename = \"#{name}.h\"\n\n # Find the current version of the inc file. It may have already been written in the build directory, in which case\n # we should start with that one rather than the true original.\n orig =\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Look for directives in the given +text+. Options that we don't handle are yielded. If the block returns false the directive is restored to the text. If the block returns nil or no block was given the directive is handled according to the registered directives. If a String was returned the directive is replaced with the... | def handle text, code_object = nil, &block
if RDoc::Comment === text then
comment = text
text = text.text
end
# regexp helper (square brackets for optional)
# $1 $2 $3 $4 $5
# [prefix][\]:directive:[spaces][param]newline
text = text.gsub(/^([ \t]*(?:#|\/?\*)?[ \t]*... | [
"def look_for_directives_in context, comment\n @preprocess.handle comment, context do |directive, param|\n case directive\n when 'main' then\n @options.main_page = param\n ''\n when 'title' then\n @options.default_title = param if @options.respond_to? :default_title=\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Performs the actions described by +directive+ and its parameter +param+. +code_object+ is used for directives that operate on a class or module. +prefix+ is used to ensure the replacement for handled directives is correct. +encoding+ is used for the include directive. For a list of directives in RDoc see RDoc::Markup. ... | def handle_directive prefix, directive, param, code_object = nil,
encoding = nil
blankline = "#{prefix.strip}\n"
directive = directive.downcase
case directive
when 'arg', 'args' then
return "#{prefix}:#{directive}: #{param}\n" unless code_object && code_object.kind_of?(RDoc... | [
"def _code_prefix(code, libs = nil, precode = nil, memlimit = nil, identifier = nil)\n memlimit ||= @@memlimit\n libs ||= DEFAULT_LIBS\n precode ||= DEFAULT_PRECODE\n\n identifier += '; ' if identifier\n\n prefix = ''\n\n unless $DEBUG\n # The following makes it use \"sicuro ([identifier... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Handles the :include: _filename_ directive. If the first line of the included file starts with '', and contains an encoding information in the form 'coding:' or 'coding=', it is removed. If all lines in the included file start with a '', this leading '' is removed before inclusion. The included content is indented like... | def include_file name, indent, encoding
full_name = find_include_file name
unless full_name then
warn "Couldn't find file to include '#{name}' from #{@input_file_name}"
return ''
end
content = RDoc::Encoding.read_file full_name, encoding, true
content = RDoc::Encoding.remove_magic_comm... | [
"def include_file(name, indent)\n if full_name = find_include_file(name) then\n content = File.read full_name\n\n # strip leading '#'s, but only if all lines start with them\n if content =~ /^[^#]/ then\n content.gsub(/^/, indent)\n else\n content.gsub(/^#?/, indent)\n end\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Toggles +bits+ from +start+ to +length+ | def set_attrs(start, length, bits)
updated = false
for i in start ... (start+length)
if (@exclusive & @attrs[i]) == 0 || (@exclusive & bits) != 0
@attrs[i] |= bits
updated = true
end
end
updated
end | [
"def set_attrs(start, length, bits)\n for i in start ... (start+length)\n @attrs[i] |= bits\n end\n end",
"def setBit(index)\n byteIndex = index / 8\n shift = (byteIndex + 1) * 8 - index - 1\n @bytes[byteIndex] |= 1 << shift\n end",
"def reverse!(start, length)\n length ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns a string representation of +bitmap+ | def as_string bitmap
return 'none' if bitmap.zero?
res = []
@name_to_bitmap.each do |name, bit|
res << name if (bitmap & bit) != 0
end
res.join ','
end | [
"def to_bmp\n end",
"def to_s\n image.map { |row| \"#{row.join}\\n\" }.join\n end",
"def bitmap\n @bitmap\n end",
"def make_bitmap_data1\n w = @bitmap.width\n h = @bitmap.height\n data = []\n for y in 0...h\n data.push(0)\n for x in 0...w\n color =... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
yields each attribute name in +bitmap+ | def each_name_of bitmap
return enum_for __method__, bitmap unless block_given?
@name_to_bitmap.each do |name, bit|
next if bit == @regexp_handling
yield name.to_s if (bitmap & bit) != 0
end
end | [
"def attributs()\n if block_given?\n rados_getxattrs.each { |key,value| \n yield key,value\n }\n else\n return rados_getxattrs\n end\n \n end",
"def each_attribute(&b)\n @graph.each do |k,v|\n yield(k,v)\n end\n end",
"def each\n getAttributeNa... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Adds +heading+ to the output as a paragraph | def accept_heading heading
@res << "<p>#{to_html heading.text}\n"
add_paragraph
end | [
"def print_heading(heading)\n puts \"-----> #{heading}\"\n end",
"def display_heading(text, level, indent)\n level = 4 if level > 4\n tag(\"h#{level}\") { text }\n @output.puts\n end",
"def accept_heading heading\n level = [6, heading.level].min\n\n label = heading.label @code_object\n\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Removes escaping from the crossreferences in +target+ | def handle_regexp_CROSSREF target
target.text.sub(/\A\\/, '')
end | [
"def handle_regexp_CROSSREF target\n text = target.text\n\n text.sub(/^\\\\/, '')\n end",
"def handle_regexp_CROSSREF(target)\n name = target.text\n\n return name if name =~ /@[\\w-]+\\.[\\w-]/ # labels that look like emails\n\n unless @hyperlink_all then\n # This ensures that words entirely ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Throws +:done+ when paragraph_limit paragraphs have been encountered | def add_paragraph
@paragraphs += 1
throw :done if @paragraphs >= @paragraph_limit
end | [
"def paragraph_end; end",
"def parse_paragraph; end",
"def paragraphs?\n false\n end",
"def each_paragraph\r\n paragraphs.each { |p| yield(p) }\r\n end",
"def paginate!\n @paras.each do |para|\n new_para= @pages.last.push_para(para)\n unless new_para.nil?\n new_paras=... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Truncates +text+ at the end of the first word after the character_limit. | def truncate text
length = text.length
characters = @characters
@characters += length
return text if @characters < @character_limit
remaining = @character_limit - characters
text =~ /\A(.{#{remaining},}?)(\s|$)/m # TODO word-break instead of \s?
$1
end | [
"def truncate_characters(text, limit=250)\n text.first(limit)[/^(.*)\\W.*$/m,1] + \"...\"\n end",
"def trim_text(txt, limit)\n if txt\n txt = (txt.size > limit) ?\n (txt.slice(0, limit ) + \"...\") :\n txt\n else\n txt = \"\"\n end\n end",
"def truncate_words(text, length =... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Adds tts from +block_quote+ to the output | def accept_block_quote block_quote
tt_sections block_quote.text
end | [
"def accept_block_quote block_quote\n @res << \"\\n<blockquote>\"\n\n block_quote.parts.each do |part|\n part.accept self\n end\n\n @res << \"</blockquote>\\n\"\n end",
"def insert_into_transcript\n @transcript_lines << {\n transcript_id: @transcript_id,\n start_time: @line_te... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Pops the list type for +list+ from list_type | def accept_list_end list
@list_type.pop
end | [
"def start_special_list(list_type)\n end",
"def special_list_type\n @in_special_list ? @in_special_list : nil\n end",
"def unregister_type\n types_list.delete self\n end",
"def accept_list_start list\n @list_type << list.type\n end",
"def convert_list_in_string_form_to_list_type(list_... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Pushes the list type for +list+ onto list_type | def accept_list_start list
@list_type << list.type
end | [
"def list_type=(list_type)\n if self.type != :list\n raise NodeError, \"can't set list_type for non-list\"\n end\n res = CMark.node_set_list_type(@pointer, list_type)\n if res == 0 then raise NodeError, \"could not set list_type\" end\n end",
"def add_list(name, type)\n add_da... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Does nothing to +markup_item+ because it doesn't have any userbuilt content | def do_nothing markup_item
end | [
"def never_embed_creatable_item\n return @never_embed_creatable_item unless @never_embed_creatable_item.nil?\n\n aer = option_type_config&.view_options&.dig(:always_embed_creatable_reference)\n @never_embed_creatable_item = (aer == 'never')\n end",
"def unfiltered_content; end",
"def never_emb... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
:nodoc: Extracts tt sections from +text+ | def tt_sections text
flow = @am.flow text.dup
flow.each do |item|
case item
when String then
@res << item if in_tt?
when RDoc::Markup::AttrChanger then
off_tags res, item
on_tags res, item
when RDoc::Markup::RegexpHandling then
@res << convert_regexp_hand... | [
"def scan(text, pattern, &block)\n # convert tabs to spaces\n text.gsub!(/^(\\t+)/) {|tabs| ' ' * (8 * tabs.length)}\n\n text.scan(pattern).each do |matches|\n hash = Hash[pattern.names.zip(matches)]\n yield hash if block\n\n section = hash.delete('section')\n section ||= hash.delete('a... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Adds a regexp handling for links of the form rdoc...: | def add_regexp_handling_RDOCLINK
@markup.add_regexp_handling(/rdoc-[a-z]+:[^\s\]]+/, :RDOCLINK)
end | [
"def handle_rdoc_link url\n case url\n when /^rdoc-ref:/ then\n $'\n when /^rdoc-label:footmark-(\\d+)/ then\n \"[^#{$1}]:\"\n when /^rdoc-label:foottext-(\\d+)/ then\n \"[^#{$1}]\"\n when /^rdoc-label:label-/ then\n gen_url url, $'\n when /^rdoc-image:/ then\n \"
res = []
flow.each do |item|
case item
when String then
res << convert_string(item)
when RDoc::Markup::AttrChanger then
off_tags res, item
on_tags res, item
when RDoc::Markup::RegexpHandling then
res << convert_regexp_handling(item)... | [
"def convert_flow(flow)\n res = []\n\n flow.each do |item|\n case item\n when String then\n res << convert_string(item)\n when RDoc::Markup::AttrChanger then\n off_tags res, item\n on_tags res, item\n when RDoc::Markup::Special then\n res << convert_special(item... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Converts added regexp handlings. See RDoc::Markupadd_regexp_handling | def convert_regexp_handling target
return target.text if in_tt?
handled = false
@attributes.each_name_of target.type do |name|
method_name = "handle_regexp_#{name}"
if respond_to? method_name then
target.text = public_send method_name, target
handled = true
end
end
... | [
"def convert_regexp_handling target\n convert_string super\n end",
"def init_regexp_handlings\n # external links\n @markup.add_regexp_handling(/(?:link:|https?:|mailto:|ftp:|irc:|www\\.)\\S+\\w/,\n :HYPERLINK)\n init_link_notation_regexp_handlings\n end",
"def init_l... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Use ignore in your subclass to ignore the content of a node. We don't support raw nodes in ToNoRaw alias accept_raw ignore | def ignore *node
end | [
"def ignore(node)\n puts \"ignoring #{node.name} - custom ignore\"\n node.ignore\nend",
"def ignore_node(xn)\n @xn_context.process_children = false\n end",
"def ignore\n Parslet::Atoms::Ignored.new(self)\n end",
"def visit_not(node); end",
"def exclude_node?(node); end",
"def visit_not(n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Turns on tags for +item+ on +res+ | def on_tags res, item
attr_mask = item.turn_on
return if attr_mask.zero?
@attr_tags.each do |tag|
if attr_mask & tag.bit != 0 then
res << annotate(tag.on)
@in_tt += 1 if tt? tag
end
end
end | [
"def add_tags_to_item(item, tags_to_add)\n \ttags_to_add.each do |tag_id|\n \t if tag_id.present?\n \t\ttag = Tag.find(tag_id)\n \t\titem.tags << tag\n \t end\n \tend\n end",
"def off_tags res, item\n attr_mask = item.turn_off\n return if attr_mask.zero?\n\n @attr_tags.reverse_each do |tag|\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Turns off tags for +item+ on +res+ | def off_tags res, item
attr_mask = item.turn_off
return if attr_mask.zero?
@attr_tags.reverse_each do |tag|
if attr_mask & tag.bit != 0 then
@in_tt -= 1 if tt? tag
res << annotate(tag.off)
end
end
end | [
"def remove_tags_from_item(item, tags_to_remove)\n \ttags_to_remove.each do |tag_id|\n \t if tag_id.present?\n \t\ttag = Tag.find(tag_id)\n \t\titem.tags.delete(tag)\n \t end\n \tend\n end",
"def untagged\n items = select { |i| i.respond_to?(:tags) ? i.tags.empty? : true }\n items.each { |i... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Extracts and a scheme, url and an anchor id from +url+ and returns them. | def parse_url url
case url
when /^rdoc-label:([^:]*)(?::(.*))?/ then
scheme = 'link'
path = "##{$1}"
id = " id=\"#{$2}\"" if $2
when /([A-Za-z]+):(.*)/ then
scheme = $1.downcase
path = $2
when /^#/ then
else
scheme = 'http'
path = url
url ... | [
"def parse_url(url, options)\n url.gsub!(/\\s/, '')\n url.gsub!(/\\?.*/, '') if options.strip_query?\n url.gsub!(/\\#.*/, '') if options.strip_anchor?\n Addressable::URI.parse(url)\n end",
"def unpack_url(url)\n root_url = []\n path_prefix = ''\n parts = URI.split(url)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Is +tag+ a tt tag? | def tt? tag
tag.bit == @tt_bit
end | [
"def tag?(t)\n return false if t.nil?\n if t =~ /^[a-zA-Z][\\w\\_\\-]+[a-zA-Z]$/\n return true\n end\n false\n end",
"def is_tag?(string)\n !!string.match(/<\\s?[^<>\\/]*\\s?>/)\n end",
"def ruby_tag?(term)\n term == '<*'\n end",
"def tagged?(tag)\n @tags.include... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Adds +document+ to the output, using its heading cutoff if present | def accept_document document
@omit_headings_below = document.omit_headings_below
super
end | [
"def render_document_heading(*args)\n opt = args.last.is_a?(Hash) ? args.pop.dup : {}\n doc = args.first || @document\n tag = opt.delete(:tag) || :h4\n opt.reverse_merge!(class: 'extra-document-title', itemprop: 'name')\n content_tag(tag, presenter(doc).heading, opt)\n end",
"def add_document(docu... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns true if +heading+ is below the display threshold | def suppressed? heading
return false unless @omit_headings_below
heading.level > @omit_headings_below
end | [
"def heading?\n self.is_heading?\n end",
"def below_threshold?\n threshold > largest_mass\n end",
"def health_below_threshold?\n (plugins[Character].current_health.to_f / plugins[Character].total_health.to_f) * 100 < @health_threshold_percentage\n end",
"def valid_heading?\n ele... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
:section: Regexp Handling These methods are used by regexp handling markup added by RDoc::Markupadd_regexp_handling. Adds regexp handlings. | def init_regexp_handlings
# external links
@markup.add_regexp_handling(/(?:link:|https?:|mailto:|ftp:|irc:|www\.)\S+\w/,
:HYPERLINK)
init_link_notation_regexp_handlings
end | [
"def add_regexp_handling pattern, name, exclusive = false\n bitmap = @attributes.bitmap_for(name)\n @regexp_handlings << [pattern, bitmap]\n @exclusive_bitmap |= bitmap if exclusive\n end",
"def on_regexp_add(regexp_content, part); end",
"def convert_regexp_handling target\n return target.text if i... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Adds regexp handlings about link notations. | def init_link_notation_regexp_handlings
add_regexp_handling_RDOCLINK
add_regexp_handling_TIDYLINK
end | [
"def init_regexp_handlings\n # external links\n @markup.add_regexp_handling(/(?:link:|https?:|mailto:|ftp:|irc:|www\\.)\\S+\\w/,\n :HYPERLINK)\n init_link_notation_regexp_handlings\n end",
"def format_autolink_regexp text, attrs = {}\n attrs = attrs.map{ |k,v| \" #{k}=\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Adds +block_quote+ to the output | def accept_block_quote block_quote
@res << "\n<blockquote>"
block_quote.parts.each do |part|
part.accept self
end
@res << "</blockquote>\n"
end | [
"def wrap(with, &block)\n @output_buffer << \"#{with} {\"\n yield\n @output_buffer << '}'\n end",
"def accept_block_quote block_quote\n tt_sections block_quote.text\n end",
"def append_quote(quote)\n @quotes << quote\n end",
"def add_language_support_for_block_quotes(content)\n cont... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Adds +heading+ to the output. The headings greater than 6 are trimmed to level 6. | def accept_heading heading
level = [6, heading.level].min
label = heading.label @code_object
@res << if @options.output_decoration
"\n<h#{level} id=\"#{label}\">"
else
"\n<h#{level}>"
end
@res << to_html(heading.text)
unless @options.pipe then
... | [
"def print_heading(heading)\n puts \"-----> #{heading}\"\n end",
"def build_heading level\n heading = RDoc::Markup::Heading.new level, text\n skip :NEWLINE\n\n heading\n end",
"def add_heading(heading)\n table.heading = heading\n end",
"def display_heading(text, level, indent)\n l... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Adds +raw+ to the output | def accept_raw raw
@res << raw.parts.join("\n")
end | [
"def accept_raw(raw)\n parts << raw.parts.join(\"\\n\")\n end",
"def raw(string)\n @source << string\n self\n end",
"def preserve_raw; end",
"def add_raw(raw)\n @fields << Field.new(raw)\n self\n end",
"def raw_message=(raw)\n @pending_raw_message = raw.force_encodin... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Determines the HTML list element for +list_type+ and +open_tag+ | def html_list_name(list_type, open_tag)
tags = LIST_TYPE_TO_HTML[list_type]
raise RDoc::Error, "Invalid list type: #{list_type.inspect}" unless tags
tags[open_tag ? 0 : 1]
end | [
"def list_tag(ast)\n if ast.list_type == :Bulleted\n return \"ul\"\n elsif ast.list_type == :Numbered\n return \"ol\"\n elsif ast.list_type == :Dictionary\n return \"dl\"\n end\n end",
"def list_type\n case @node.name\n when '... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the HTML tag for +list_type+, possible using a label from +list_item+ | def list_item_start(list_item, list_type)
case list_type
when :BULLET, :LALPHA, :NUMBER, :UALPHA then
"<li>"
when :LABEL, :NOTE then
Array(list_item.label).map do |label|
"<dt>#{to_html label}\n"
end.join << "<dd>"
else
raise RDoc::Error, "Invalid list type: #{list_type.i... | [
"def html_list_name(list_type, open_tag)\n tags = LIST_TYPE_TO_HTML[list_type]\n raise RDoc::Error, \"Invalid list type: #{list_type.inspect}\" unless tags\n tags[open_tag ? 0 : 1]\n end",
"def dump_list_item( markup, type=:BULLET )\n case type\n when :BULLET\n \"* \"+dump_markup_body(m... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the HTML endtag for +list_type+ | def list_end_for(list_type)
case list_type
when :BULLET, :LALPHA, :NUMBER, :UALPHA then
"</li>"
when :LABEL, :NOTE then
"</dd>"
else
raise RDoc::Error, "Invalid list type: #{list_type.inspect}"
end
end | [
"def list_tag(ast)\n if ast.list_type == :Bulleted\n return \"ul\"\n elsif ast.list_type == :Numbered\n return \"ol\"\n elsif ast.list_type == :Dictionary\n return \"dl\"\n end\n end",
"def html_list_name(list_type, open_tag)\n tags = LIST_TYPE_TO... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns true if text is valid ruby syntax | def parseable? text
verbose, $VERBOSE = $VERBOSE, nil
eval("BEGIN {return true}\n#{text}")
rescue SyntaxError
false
ensure
$VERBOSE = verbose
end | [
"def valid_ruby?(code)\n RubyParser.for_current_ruby.parse(code)\n rescue Racc::ParseError, RubyParser::SyntaxError\n false\n end",
"def valid?(text)\n res = @driver.checkSyntax([text])\n return res.first.valid\n end",
"def is_ruby_multiline?(text); end",
"def ruby_code?(str)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Adds +blank_line+ to the output | def accept_blank_line blank_line
@res << "\n"
end | [
"def blank_line\n output \"\"\n end",
"def write_empty\r\n write_line('')\r\n end",
"def empty_line\n end",
"def empty_line\r\n puts \"\\n\"\r\n end",
"def print_blank_line\n\t\t\tuser_output.prompting(false)\n\t\t\tuser_output.print_line\n\t\tend",
"def p_blankline\n p do\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Adds +raw+ to the output | def accept_raw raw
@res << raw.parts.join("\n")
end | [
"def accept_raw(raw)\n parts << raw.parts.join(\"\\n\")\n end",
"def raw(string)\n @source << string\n self\n end",
"def preserve_raw; end",
"def add_raw(raw)\n @fields << Field.new(raw)\n self\n end",
"def raw_message=(raw)\n @pending_raw_message = raw.force_encodin... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Adds the stored prefix to the output and clears it. Lists generate a prefix for later consumption. | def use_prefix
prefix, @prefix = @prefix, nil
@res << prefix if prefix
prefix
end | [
"def delete_prefix! prefix\n return unless start_with? prefix\n return if prefix.empty?\n self[0...prefix.length] = ''\n self\n end",
"def accumulate!(content)\n\t\t\t\t@accumulated_prefix = '' unless defined?(@accumulated_prefix)\n\t\t\t\t@accumulated_prefix << content\n\t\t\tend",
"def ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Runs this document and all its items through +visitor+ | def accept visitor
visitor.start_accepting
visitor.accept_document self
visitor.end_accepting
end | [
"def visit_collection(printer, collection)\n collection.each do |object|\n visit(printer, object)\n end\n end",
"def accept visitor\n visitor.accept_list_start self\n\n @items.each do |item|\n item.accept visitor\n end\n\n visitor.accept_list_end self\n end",
... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Concatenates the given +parts+ onto the document | def concat parts
self.parts.concat parts
end | [
"def add_part(part); end",
"def << part\n @parts << part\n end",
"def <<(content)\n @parts << content\n end",
"def concatenate(uid, part_uids, info = {})\n multipart_upload = create_file(uid, info)\n\n objects = part_uids.map { |part_uid| object(part_uid) }\n parts = copy_pa... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
When this is a collection of documents (file is not set and this document contains only other documents as its direct children) merge replaces documents in this class with documents from +other+ when the file matches and adds documents from +other+ when the files do not. The information in +other+ is preferred over the... | def merge other
if empty? then
@parts = other.parts
return self
end
other.parts.each do |other_part|
self.parts.delete_if do |self_part|
self_part.file and self_part.file == other_part.file
end
self.parts << other_part
end
self
end | [
"def merge_collections mine, other, other_files, &block # :nodoc:\n my_things = mine. group_by { |thing| thing.file }\n other_things = other.group_by { |thing| thing.file }\n\n remove_things my_things, other_files, &block\n add_things my_things, other_things, &block\n end",
"def merge(other_fi... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Builds a Heading of +level+ | def build_heading level
type, text, = get
text = case type
when :TEXT then
skip :NEWLINE
text
else
unget
''
end
RDoc::Markup::Heading.new level, text
end | [
"def build_heading level\n heading = RDoc::Markup::Heading.new level, text\n skip :NEWLINE\n\n heading\n end",
"def heading(level, title)\n @io << @templates[:heading_3].result(binding) if level == 3\n @io << @templates[:heading_4].result(binding) if level == 4\n end",
"def heading_leve... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Builds a List flush to +margin+ | def build_list margin
p :list_start => margin if @debug
list = RDoc::Markup::List.new
label = nil
until @tokens.empty? do
type, data, column, = get
case type
when *LIST_TOKENS then
if column < margin || (list.type && list.type != type) then
unget
break
... | [
"def build_list margin\n p :list_start => margin if @debug\n\n list = RDoc::Markup::List.new\n\n until @tokens.empty? do\n type, data, column, = get\n\n case type\n when :BULLET, :LABEL, :LALPHA, :NOTE, :NUMBER, :UALPHA then\n list_type = type\n\n if column < margin then\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Builds a Paragraph that is flush to +margin+ | def build_paragraph margin
p :paragraph_start => margin if @debug
paragraph = RDoc::Markup::Paragraph.new
until @tokens.empty? do
type, data, column, = get
if type == :TEXT and column == margin then
paragraph << data
break if peek_token.first == :BREAK
data << ' ' if... | [
"def build_paragraph margin\n p :paragraph_start => margin if @debug\n\n paragraph = RDoc::Markup::Paragraph.new\n\n until @tokens.empty? do\n type, data, column, = get\n\n case type\n when :INDENT then\n next if data == margin and peek_token[0] == :TEXT\n\n unget\n brea... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Builds a Verbatim that is indented from +margin+. The verbatim block is shifted left (the least indented lines start in column 0). Each part of the verbatim is one line of text, always terminated by a newline. Blank lines always consist of a single newline character, and there is never a single newline at the end of th... | def build_verbatim margin
p :verbatim_begin => margin if @debug
verbatim = RDoc::Markup::Verbatim.new
min_indent = nil
generate_leading_spaces = true
line = ''.dup
until @tokens.empty? do
type, data, column, = get
if type == :NEWLINE then
line << data
verbatim << l... | [
"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"
]
]
}
} |
Parses the tokens into an array of RDoc::Markup::XXX objects, and appends them to the passed +parent+ RDoc::Markup::YYY object. Exits at the end of the token stream, or when it encounters a token in a column less than +indent+ (unless it is a NEWLINE). Returns +parent+. | def parse parent, indent = 0
p :parse_start => indent if @debug
until @tokens.empty? do
type, data, column, = get
case type
when :BREAK then
parent << RDoc::Markup::BlankLine.new
skip :NEWLINE, false
next
when :NEWLINE then
# trailing newlines are skippe... | [
"def parse_content parent, content, attributes = nil\n reader = Reader === content ? content : (Reader.new content)\n while reader.has_more_lines?\n block = Parser.next_block reader, parent, (attributes ? attributes.dup : {})\n parent << block if block\n end\n parent\n end",
"... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Skips the next token if its type is +token_type+. Optionally raises an error if the next token is not of the expected type. | def skip token_type, error = true
type, = get
return unless type # end of stream
return @current_token if token_type == type
unget
raise ParseError, "expected #{token_type} got #{@current_token.inspect}" if error
end | [
"def skip token_type, error = true\n type, data, = get\n\n return unless type # end of stream\n\n return @current_token if token_type == type\n\n unget\n\n raise ParseError, \"expected #{token_type} got #{@current_token.inspect}\" if\n error\n end",
"def skip_to_token(*kinds, through: false)\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Converts the CROSSREF +target+ to plain text, removing the suppression marker, if any | def handle_regexp_CROSSREF target
text = target.text
text.sub(/^\\/, '')
end | [
"def handle_regexp_CROSSREF target\n target.text.sub(/\\A\\\\/, '')\n end",
"def handle_regexp_CROSSREF(target)\n name = target.text\n\n return name if name =~ /@[\\w-]+\\.[\\w-]/ # labels that look like emails\n\n unless @hyperlink_all then\n # This ensures that words entirely consisting of low... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Converts the TIDYLINK +target+ to just the text part | def handle_regexp_TIDYLINK target
text = target.text
return text unless text =~ /\{(.*?)\}\[(.*?)\]/ or text =~ /(\S+)\[(.*?)\]/
$1
end | [
"def link_target\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 13 )\n value = nil\n target22 = nil\n\n begin\n # at line 107:32: ( WS )? '<' target '>'\n # at line 107:32: ( WS )?\n alt_22 = 2\n look_22_0 = @input.peek(1... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Parses +src+ and returns an RDoc::Markup::Document. | def parse src
@src = src
@src.push false
@footnotes = []
@labels = {}
# @i: index(line no.) of src
@i = 0
# stack for current indentation
@indent_stack = []
# how indented.
@current_indent = @indent_stack.join("")
# RDoc::RD::BlockParser for tmp src
@subparser = nil
# which part is in... | [
"def parse(src)\r\n doc = nil\r\n doc = Document.new(src)\r\n root = doc.root\r\n\r\n return parseRuleXml(root)\r\n\r\n end",
"def doc_src\n @doc_src ||= unless doc_place\n \"no documentation available\" \n else\n file, line = doc_place\n RubyTools::extract_fi... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Yields to the given block if +indent+ matches the current indent, otherwise an indentation token is processed. | def if_current_indent_equal(indent)
indent = indent.sub(/\t/, "\s" * 8)
if @current_indent == indent
@i += 1 # next line
yield
elsif indent.index(@current_indent) == 0
@indent_stack.push(indent[@current_indent.size .. -1])
[:INDENT, ":INDENT"]
else
@indent_stack.pop
[:DEDENT, ":DEDENT"]
... | [
"def indented(&block)\n @indent += 1\n yield\n @indent += 1\n end",
"def with_indent ()\n thread[:indent] += 1\n yield\n ensure\n thread[:indent] -= 1\n end",
"def indent\r\n @indent_level += 1\r\n newline\r\n yield\r\n @indent_l... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Cuts off excess whitespace in +src+ | def cut_off(src)
ret = []
whiteline_buf = []
line = src.shift
/^\s*/ =~ line
indent = Regexp.quote($&)
ret.push($')
while line = src.shift
if /^(\s*)$/ =~ line
whiteline_buf.push(line)
elsif /^#{indent}/ =~ line
unless whiteline_buf.empty?
ret.concat(whiteline_buf)
w... | [
"def remove_trailing_spaces(source)\n for_outstrings_of(source) do |str|\n str.gsub! /\\s+/im, ' '\n str.gsub! /\\s*(\\+|>|\\||~|\\{|\\}|,|\\)|\\(|;|:|\\*)\\s*/im, '\\1'\n str.gsub! /;\\}/, '}'\n str.strip\n end\n end",
"def remove_whitespace(oldsource)\n need_newline = false\n source... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Retrieves the content for +file+ from the include_path | def get_included(file)
included = []
@include_path.each do |dir|
file_name = File.join dir, file
if File.exist? file_name then
included = IO.readlines file_name
break
end
end
included
end | [
"def include(file, options = {})\n content = StringIO.new\n content.puts \"<notextile>\" if options[:skip_textile]\n content.puts IO.read(File.join(::Webby.site.content_dir, file))\n content.puts \"</notextile>\" if options[:skip_textile]\n content.string\nend",
"def get_file_contents\n o_file = File.open... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Formats line numbers +line_numbers+ prettily | def format_line_num(*line_numbers)
width = line_numbers.collect{|i| i.to_s.length }.max
line_numbers.collect{|i| sprintf("%#{width}d", i) }
end | [
"def with_line_numbers(text, offset, color=:blue)\n lines = text.each_line.to_a\n max_width = (offset + lines.count).to_s.length\n lines.each_with_index.map do |line, index|\n adjusted_index = (index + offset).to_s.rjust(max_width)\n \"#{self.send(color, adjusted_index)}: #{li... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Creates a paragraph for +value+ | def paragraph value
content = cut_off(value).join(' ').rstrip
contents = @inline_parser.parse content
RDoc::Markup::Paragraph.new(*contents)
end | [
"def para(text)\n para = Shoes::Para.new(text)\n add_widget para.to_label\n para\n end",
"def text(value)\n if value.is_a? Widget\n widget value\n else\n output.concat(value.html_escape)\n end\n @at_start_of_line = false\n nil\n end",
"def make_paragra... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Adds footnote +content+ to the document | def add_footnote content
index = @footnotes.length / 2 + 1
footmark_link = "{^#{index}}[rdoc-label:footmark-#{index}:foottext-#{index}]"
@footnotes << RDoc::Markup::Paragraph.new(footmark_link, ' ', *content)
@footnotes << RDoc::Markup::BlankLine.new
index
end | [
"def move_footnotes_to_footer content\n container = content[%r{<div class=\"footnotes\">\\s*(.*?)\\s*</div>}m]\n if container\n footnotes = $1\n content[container] = ''\n content['</footer>'] = <<-FOOTER\n <section id=\"footnotes\">\n <h2>Footnotes</h2>\n #{footnotes}\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Adds label +label+ to the document | def add_label label
@labels[label] = true
label
end | [
"def add_label(label)\n @label_by_id[label.id] = label if !@label_by_id.include?(label.id)\n end",
"def add_label(label)\n @api.do_request(\"PUT\", label.get_base_api_path() + \"/messages/\" + get('id'));\n @label_ids_set[label.id] = true\n end",
"def add(label)\n labels[label.name] = la... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Appends +more+ to this inline. +more+ may be a String or another Inline. | def append more
case more
when String then
@reference += more
@rdoc += more
when RDoc::RD::Inline then
@reference += more.reference
@rdoc += more.rdoc
else
raise "unknown thingy #{more}"
end
self
end | [
"def read_more(content, options = {})\n options = {:length => 400}.merge(options)\n more_tag = \"<!--more-->\"\n if cutoff_index = (content.html_safe.index(more_tag))\n content.html_safe[0,cutoff_index]\n else\n truncate_html content.html_safe, :length => options[:length]\n end\n end",
"... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns words before the error | def prev_words_on_error(ev)
pre = @pre
if ev and /#{Regexp.quote(ev)}$/ =~ pre
pre = $`
end
last_line(pre)
end | [
"def error_sentence(errors)\n error_text = errors.to_sentence.strip\n error_text << \".\" unless %w(? ! . :).include?(error_text[-1, 1])\n template.content_tag(:p, error_text, :class => 'inline-errors')\n end",
"def humanized_errors\n _errors.map do |code|\n case code\n when \"UNKNOWN... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the last line of +src+ | def last_line(src)
if n = src.rindex("\n")
src[(n+1) .. -1]
else
src
end
end | [
"def last_line\n line = buffer[end_line]\n line[0, end_pos] \n end",
"def last_line; end",
"def last_line\n IO.readlines(path)[-1]\n end",
"def last_line\n @lines[-1]\n end",
"def last_non_empty_line\n index = source_lines.rindex { |l| !l.empty? }\n (index || 0) + 1\n end",
... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns words following an error | def next_words_on_error
if n = @src.rest.index("\n")
@src.rest[0 .. (n-1)]
else
@src.rest
end
end | [
"def prev_words_on_error(ev)\n pre = @pre\n if ev and /#{Regexp.quote(ev)}$/ =~ pre\n pre = $`\n end\n last_line(pre)\nend",
"def errors\n \" \" + @results.scan(self.errors_regexp).join(\"\\n \")\n end",
"def printLexicographicErrors\n\t\t@wrongTokens.each do |tk|\n\t\t\tputs tk.to_s\n\t\te... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Creates a new RDoc::RD::Inline for the +rdoc+ markup and the raw +reference+ | def inline rdoc, reference = rdoc
RDoc::RD::Inline.new rdoc, reference
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 html_markup_rdoc(text); end",
"def formatter\n return @formatter if defined? @formatter\n\n options = @store.rd... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Generates documentation using the named +generator+ ("darkfish" or "ri") and following the given +options+. Documentation will be generated into +destination+ | def document generator, options, destination
generator_name = generator
options = options.dup
options.exclude ||= [] # TODO maybe move to RDoc::Options#finish
options.setup_generator generator
options.op_dir = destination
Dir.chdir @spec.full_gem_path do
options.finish
end
genera... | [
"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 options.finish\n\n generator = options.generator.new @rdoc... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
new_rdoc creates a new RDoc instance. This method is provided only to make testing easier. | def new_rdoc # :nodoc:
::RDoc::RDoc.new
end | [
"def legacy_rdoc *args\n args << @spec.rdoc_options\n args << '--quiet'\n args << @spec.require_paths.clone\n args << @spec.extra_rdoc_files\n args << '--title' << \"#{@spec.full_name} Documentation\"\n args = args.flatten.map do |arg| arg.to_s end\n\n delete_legacy_args args if\n Gem::Req... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Is ri data installed? | def ri_installed?
File.exist? @ri_dir
end | [
"def clorox_installed?\n File.exists? EXECUTABLE\n end",
"def check_for_rrdtool\n\t\t\t\treturn false if !File.executable? @@rrdtool_bin\n\t\t\t\treturn true;\n\t\t\tend",
"def installed?\n File.exists?(@path)\n end",
"def knotx_installed?\n libs =\n if ::File.directory?(new_re... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Adds an item of type +klass+ with the given +name+ and +comment+ to the context. Currently only RDoc::Extend and RDoc::Include are supported. | def add klass, name, comment
if RDoc::Extend == klass then
ext = RDoc::Extend.new name, comment
add_extend ext
elsif RDoc::Include == klass then
incl = RDoc::Include.new name, comment
add_include incl
else
raise NotImplementedError, "adding a #{klass} is not implemented"
en... | [
"def add_item( klass, name, action )\n fail SyntaxError, \"Undefined class #{klass} found in #{self}\" unless library_defined?(klass)\n library_handler[klass].define(name, action) \n end",
"def add_comment_name(name)\n comment_name = \"/xl/#{name}.xml\"\n\n add_override(comment_name, \"... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Adds +attribute+ if not already there. If it is (as method(s) or attribute), updates the comment if it was empty. The attribute is registered only if it defines a new method. For instance, attr_reader :foo will not be registered if method +foo+ exists, but attr_accessor :foo will be registered if method +foo+ exists, b... | def add_attribute attribute
return attribute unless @document_self
# mainly to check for redefinition of an attribute as a method
# TODO find a policy for 'attr_reader :foo' + 'def foo=()'
register = false
key = nil
if attribute.rw.index 'R' then
key = attribute.pretty_name
known ... | [
"def new_attribute( attribute )\n @attribute += attribute\n attribute.each { |a|\n a.set_owner self\n @name_list.add_item( a )\n if( a.is_omit? )then\n @n_attribute_omit += 1\n elsif( a.is_rw? )then\n @n_attribute_rw += 1\n else\n @n_attribute_ro += 1\n end\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Adds a class named +given_name+ with +superclass+. Both +given_name+ and +superclass+ may contain '::', and are interpreted relative to the +self+ context. This allows handling correctly examples like these: class RDoc::Gauntlet class Container::Item RDoc assumes +Container+ is a module unless it later sees class Conta... | def add_class class_type, given_name, superclass = '::Object'
# superclass +nil+ is passed by the C parser in the following cases:
# - registering Object in 1.8 (correct)
# - registering BasicObject in 1.9 (correct)
# - registering RubyVM in 1.9 in iseq.c (incorrect: < Object in vm.c)
#
# If we ... | [
"def add_superclass(klass)\n self.superclasses << klass\n klass.subclasses << self\n end",
"def add_class(class_type, name, superclass = 'Object')\n klass = add_class_or_module @classes, class_type, name, superclass\n\n # If the parser encounters Container::Item before encountering\n # Conta... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Adds the class or module +mod+ to the modules or classes Hash +self_hash+, and to +all_hash+ (either TopLevel::modules_hash or TopLevel::classes_hash), unless done_documenting is +true+. Sets the parent of +mod+ to +self+, and its section to current_section. Returns +mod+. | def add_class_or_module mod, self_hash, all_hash
mod.section = current_section # TODO declaring context? something is
# wrong here...
mod.parent = self
mod.full_name = nil
mod.store = @store
unless @done_documenting then
self_hash[mod.name] = mod
# this... | [
"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"
]
]
}
} |
Adds +constant+ if not already there. If it is, updates the comment, value and/or is_alias_for of the known constant if they were empty/nil. | def add_constant constant
return constant unless @document_self
# HACK: avoid duplicate 'PI' & 'E' in math.c (1.8.7 source code)
# (this is a #ifdef: should be handled by the C parser)
known = @constants_hash[constant.name]
if known then
known.comment = constant.comment if known.comment.empt... | [
"def add(constant)\n return if @nesting.constants.find_first(constant)\n\n root = @nesting.constants.root_namespace_for(constant)\n (root.nil? ? @nesting.constants : root.constants) << constant\n @last_added = constant\n end",
"def add_constant(name, value)\n self[nam... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Adds included module +include+ which should be an RDoc::Include | def add_include include
add_to @includes, include
include
end | [
"def add_include(include)\n object_class.record_location self\n return include unless @document_self\n object_class.add_include include\n end",
"def parse_include\n pos = position\n keyword(:include) or return\n ws\n n = parse_name or expected(\"name of module to include\")\n ws\n retu... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Adds extension module +ext+ which should be an RDoc::Extend | def add_extend ext
add_to @extends, ext
ext
end | [
"def add_extends out, extends\n add_extension_modules out, 'Extended by', extends\n end",
"def extend(ext_mod)\n unless @ext_mods.include?(ext_mod)\n @ext_mods << ext_mod\n # check for Writer instance extension\n if ext_mod.const_defined?('WriterExtension')\n # ext... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Adds +method+ if not already there. If it is (as method or attribute), updates the comment if it was empty. | def add_method method
return method unless @document_self
# HACK: avoid duplicate 'new' in io.c & struct.c (1.8.7 source code)
key = method.pretty_name
known = @methods_hash[key]
if known then
if @store then # otherwise we are loading
known.comment = method.comment if known.comment.e... | [
"def add_method(method_name, &definition)\n new_patch AddMethodPatch.send(:new, method_name, &definition)\n end",
"def add_method\n <<-CODE\n next_literal;\n t1 = stack_pop();\n t2 = stack_pop();\n cpu_add_method(state, c, t1, _lit, t2);\n stack_push(t2);\n cpu_perform_hook(state, c, ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Adds a module by +RDoc::NormalModule+ instance. See also add_module. | def add_module_by_normal_module(mod)
add_class_or_module mod, @modules, @store.modules_hash
end | [
"def add_module(mod_)\n @modules << mod_\n end",
"def add(module_object)\n @additional_modules << module_object\n end",
"def add_module(module_code)\n @module = Tableau::ModuleParser.new(module_code).parse\n @modules << @module if @module\n end",
"def add(type_, module_)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Adds an alias from +from+ (a class or module) to +name+ which was defined in +file+. | def add_module_alias from, from_name, to, file
return from if @done_documenting
to_full_name = child_name to.name
# if we already know this name, don't register an alias:
# see the metaprogramming in lib/active_support/basic_object.rb,
# where we already know BasicObject is a class when we find
... | [
"def moved_from(from)\n self.deprecated_names << from\n\n if const_defined?(:Aliases)\n const_get(:Aliases).append from\n else\n const_set(:Aliases, [from])\n end\n\n # NOTE: aliases are not set until after initialization, so might as well\n # use the block form of alert ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Adds +require+ to this context's top level | def add_require(require)
return require unless @document_self
if RDoc::TopLevel === self then
add_to @requires, require
else
parent.add_require require
end
end | [
"def add_require(require)\n if RDoc::TopLevel === self then\n add_to @requires, require\n else\n parent.add_require require\n end\n end",
"def parse_require(context, comment)\n skip_tkspace_comment\n tk = get_tk\n\n if :on_lparen == tk[:kind] then\n skip_tkspace_comment\n tk... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns a section with +title+, creating it if it doesn't already exist. +comment+ will be appended to the section's comment. A section with a +title+ of +nil+ will return the default section. See also RDoc::Context::Section | def add_section title, comment = nil
if section = @sections[title] then
section.add_comment comment if comment
else
section = Section.new self, title, comment
@sections[title] = section
end
section
end | [
"def add_section(element, title)\n \n section = Element.new(\"section\")\n section << Reports::XMLReportUtil.text_element(\"title\", title)\n element << section\n return section\n end",
"def create_new_section(title, options={})\n send_request('create_new_section', normalize_options(title, op... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Is there any content? This means any of: comment, aliases, methods, attributes, external aliases, require, constant. Includes and extends are also checked unless includes == false. | def any_content(includes = true)
@any_content ||= !(
@comment.empty? &&
@method_list.empty? &&
@attributes.empty? &&
@aliases.empty? &&
@external_aliases.empty? &&
@requires.empty? &&
@constants.empty?
)
@any_content || (includes && !(@includes + @extends).empty? )
... | [
"def has_content; end",
"def has_content?\n !content.nil?\n end",
"def has_content=(_); end",
"def content?\n !content.nil? && !content.empty?\n end",
"def includes_definition?\n includes_arguments? || runnable? || argument_parsing_disabled? ||\n includes_modules? || includes... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Hash of classes keyed by class name | def classes_hash
@classes
end | [
"def classes_hash\n @classes\n end",
"def classes\n return @classes if @classes\n\n @classes = {}\n\n @stores.each do |store|\n store.cache[:modules].each do |mod|\n # using default block causes searched-for modules to be added\n @classes[mod] ||= []\n @classes[mod] << s... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
The current documentation section that new items will be added to. If temporary_section is available it will be used. | def current_section
if section = @temporary_section then
@temporary_section = nil
else
section = @current_section
end
section
end | [
"def set_current_section title, comment\n @current_section = add_section title, comment\n end",
"def section\n unless @section\n @section = full_section.last if full_section \n end\n \n @section\n end",
"def new\n @section = current_cookbook.sections.create(name: \"My new section\")\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Is part of this thing was defined in +file+? | def defined_in?(file)
@in_files.include?(file)
end | [
"def defined_in?(file)\n @in_files.include?(file)\n end",
"def defined?\n\t\t@definition != nil\n\tend",
"def has_source?\n !!file\n end",
"def include?(file)\n manifest_entry[file] != nil\n end",
"def was_required?(file)\n rex = Regexp.new(\"/#{Regexp.quote(file)}\\.(so|o|s... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Iterator for ancestors for ducktyping. Does nothing. See RDoc::ClassModuleeach_ancestor. This method exists to make it easy to work with Context subclasses that aren't part of RDoc. | def each_ancestor # :nodoc:
end | [
"def ancestors\n [doc_parent].concat(doc_parent.ancestors)\n end",
"def each_ancestor\n ancestors = [self]\n while not ancestors.last.parent.nil?\n ancestors << ancestors.last.parent\n end\n ancestors.reverse_each { |a| yield a }\n end",
"def walk_ancestors(inc_self = true, &blk)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Iterator for classes and modules | def each_classmodule(&block) # :yields: module
classes_and_modules.sort.each(&block)
end | [
"def each_classmodule\n @modules.each_value {|m| yield m}\n @classes.each_value {|c| yield c}\n end",
"def all_classes_and_modules(&block)\n enum = Enumerator.new do |y|\n ObjectSpace.each_object(Module) do |klass|\n y.yield klass\n end\n end\n\n if block_given?\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Iterator for each section's contents sorted by title. The +section+, the section's +constants+ and the sections +attributes+ are yielded. The +constants+ and +attributes+ collections are sorted. To retrieve methods in a section use methods_by_type with the optional +section+ parameter. NOTE: Do not edit collections yie... | def each_section # :yields: section, constants, attributes
return enum_for __method__ unless block_given?
constants = @constants.group_by do |constant| constant.section end
attributes = @attributes.group_by do |attribute| attribute.section end
constants.default = []
attributes.default = []
... | [
"def persection(section)\n section = section.to_sym\n self.each { |name, obj|\n if obj.section == section\n yield obj\n end\n }\n end",
"def sections_sorted(&block)\n return to_enum(:sections_sorted) if ! block_given?\n @sections.values.sort { |a,b| \n # Tricky sort: id... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Finds an attribute +name+ with singleton value +singleton+. | def find_attribute(name, singleton)
name = $1 if name =~ /^(.*)=$/
@attributes.find { |a| a.name == name && a.singleton == singleton }
end | [
"def find_attribute_named(name)\n @attributes.find {|m| m.name == name}\n end",
"def find_attribute_named(name)\n @attributes.find { |m| m.name == name }\n end",
"def cache_as_singleton_attribute(attr_name, value)\n # Cache the value in an instance variable\n instance_variable_set(\"@#{att... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Finds a class method with +name+ in this context | def find_class_method_named(name)
@method_list.find { |meth| meth.singleton && meth.name == name }
end | [
"def find_method_named(name)\n @method_list.find {|meth| meth.name == name}\n end",
"def find_method_named(name)\n @method_list.find { |meth| meth.name == name }\n end",
"def find_instance_method_named(name)\n @method_list.find { |meth| !meth.singleton && meth.name == name }\n end",
"def find_... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Finds a constant with +name+ in this context | def find_constant_named(name)
@constants.find do |m|
m.name == name || m.full_name == name
end
end | [
"def find_constant_named(name)\n @constants.find {|m| m.name == name}\n end",
"def find_constant_named(name)\n @constants.find {|m| m.name == name}\n end",
"def find(name)\n @constants.find { |const| Name.match?(const.key, name) }\n end",
"def constant(name)\n @constants[name]\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Finds an external alias +name+ with singleton value +singleton+. | def find_external_alias(name, singleton)
@external_aliases.find { |m| m.name == name && m.singleton == singleton }
end | [
"def find_external_alias_named(name)\n case name\n when /\\A#/ then\n find_external_alias name[1..-1], false\n when /\\A::/ then\n find_external_alias name[2..-1], true\n else\n @external_aliases.find { |a| a.name == name }\n end\n end",
"def find_method(name, singleton)\n @metho... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Finds an external alias with +name+ in this context | def find_external_alias_named(name)
case name
when /\A#/ then
find_external_alias name[1..-1], false
when /\A::/ then
find_external_alias name[2..-1], true
else
@external_aliases.find { |a| a.name == name }
end
end | [
"def find_external_alias(name, singleton)\n @external_aliases.find { |m| m.name == name && m.singleton == singleton }\n end",
"def find_alias(name, position=0)\n data_source(position).find { |r| r.pointer && r.pointer.upcase == name.upcase }\n end",
"def find_alias(str)\n al = find(str,:obj... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Finds an instance method with +name+ in this context | def find_instance_method_named(name)
@method_list.find { |meth| !meth.singleton && meth.name == name }
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.name == name && !meth.singleton }\n end",
"def find_method_named(name)\n @method_list.find {|meth| meth.name ==... | {
"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.