query
stringlengths
7
9.5k
document
stringlengths
10
1.07M
negatives
listlengths
19
19
metadata
dict
Removes from +all_hash+ the contexts that are nodoc or have no content. See RDoc::Contextremove_from_documentation?
def remove_nodoc all_hash all_hash.keys.each do |name| context = all_hash[name] all_hash.delete(name) if context.remove_from_documentation? end end
[ "def remove_all_contexts\n previous_size = @contexts.size\n @contexts = []\n previous_size\n end", "def clear_diagnostic_contexts(all = false)\n if all\n MUTEX_FOR_DIAG_CLEAR.synchronize {\n Thread.list.each { |thread|\n thread[MappedDiagnosticContext::NAME].clear...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Writes the ri data for +method+ on +klass+
def save_method klass, method full_name = klass.full_name FileUtils.mkdir_p class_path(full_name) unless @dry_run cache = if method.singleton then @cache[:class_methods] else @cache[:instance_methods] end cache[full_name] ||= [] cache[full_name] ...
[ "def method_file klass_name, method_name\n method_name = method_name.split('::').last\n method_name =~ /#(.*)/\n method_type = $1 ? 'i' : 'c'\n method_name = $1 if $1\n method_name = method_name.gsub(/\\W/) { \"%%%02x\" % $&[0].ord }\n\n File.join class_path(klass_name), \"#{method_name}-#{method_...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Source of the contents of this store. For a store from a gem the source is the gem name. For a store from the home directory the source is "home". For system ri store (the standard library documentation) the source is"ruby". For a store from the site ri directory the store is "site". For other stores the source is the ...
def source case type when :gem then File.basename File.expand_path '..', @path when :home then 'home' when :site then 'site' when :system then 'ruby' else @path end end
[ "def documentation_source path\n _, source_name, path = path.split '/', 3\n\n store = @stores[source_name]\n return store, path if store\n\n store = store_for source_name\n\n store.load_all\n\n @stores[source_name] = store\n\n return store, path\n end", "def store_for source_name\n case s...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns the unique modules discovered by RDoc. ::complete must have been called prior to using this method.
def unique_modules @unique_modules end
[ "def referenced_modules\n # TODO: check content type before scanning\n content.scan(/\\s*(include|extend)\\s+([A-Za-z0-9_\\.]*)/).map { |_, m| m }.uniq\n end", "def used_modules\n @used_modules ||= []\n end", "def complete min_visibility\n fix_basic_object_inheritance\n\n # cache included m...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Fixes the page_dir to be relative to the root_dir and adds the page_dir to the files list.
def finish_page_dir return unless @page_dir @files << @page_dir page_dir = Pathname(@page_dir) begin page_dir = page_dir.expand_path.relative_path_from @root rescue ArgumentError # On Windows, sometimes crosses different drive letters. page_dir = page_dir.expand_path end ...
[ "def page_dir\n if root?\n site.public_dir\n else\n pieces = path.sub(/^\\//, '').split('/')\n File.join(site.site_files_dir, *pieces[0..-2])\n end\n end", "def populate_temp_dir\n Dir.chdir(temp_dir) do\n (@pages + static_files).each do |page|\n i...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns a properlyspace list of generators and their descriptions.
def generator_descriptions lengths = [] generators = RDoc::RDoc::GENERATORS.map do |name, generator| lengths << name.length description = generator::DESCRIPTION if generator.const_defined? :DESCRIPTION [name, description] end longest = lengths.max generators.sort.map d...
[ "def generators\n generators = []\n section_found = false\n `cmake --help`.each_line do |line|\n section_found = true if line =~ /^Generators/\n next unless section_found\n generators << $1 if line =~ /^ (\\S.*?)(?: \\[arch\\])?\\s*(=|$)/\n end\n return generators\nend", "def generators\n @g...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Set quietness to +bool+
def quiet= bool @verbosity = bool ? 0 : 1 end
[ "def quiet?\n @quiet\n end", "def silent=(boolean)\n $SILENT = !!boolean\n end", "def quiet?\n config.quiet\n end", "def be_quiet\n logging = \"quiet\"\n end", "def quiet_mode?\n @@quiet_mode\n end", "def quiet_mode\n orig = @@quiet_mode\n @@qu...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Set up an output generator for the named +generator_name+. If the found generator responds to :setup_options it will be called with the options instance. This allows generators to add custom options or set default options.
def setup_generator generator_name = @generator_name @generator = @generators[generator_name] unless @generator then raise OptionParser::InvalidArgument, "Invalid output formatter #{generator_name}" end return if @generator_options.include? @generator @generator_name = generator...
[ "def add_generator(name, options)\n if options.is_a?(Proc)\n @generators[name.to_sym] = options\n else\n @generators[name.to_sym] = build_default_generator(options)\n end\n\n return nil\n end", "def generates(name, options)\n @factory.add_generator(name.to_sym, options)...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Finds the template dir for +template+
def template_dir_for template template_path = File.join 'rdoc', 'generator', 'template', template $LOAD_PATH.map do |path| File.join File.expand_path(path), template_path end.find do |dir| File.directory? dir end end
[ "def template_directory_for(template)\n template_directory = \"pages\"\n \n %w(stylesheets layouts).each do |directory|\n template_directory = \"\" if template.match(/^(\\/)?#{directory}/)\n end\n \n template_directory\n end", "def find_template_root\n File.join(STREAMLINED_ROOT, \"te...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Sets the minimum visibility of a documented method. Accepts +:public+, +:protected+, +:private+, +:nodoc+, or +:all+. When +:all+ is passed, visibility is set to +:private+, similarly to RDOCOPT="all", see visibility for more information.
def visibility= visibility case visibility when :all @visibility = :private else @visibility = visibility end end
[ "def default_visibility(new_visibility = nil)\n if new_visibility\n if [ :public, :private ].include?(new_visibility)\n @default_visibility = new_visibility\n else\n raise ArgumentError, \"Invalid default visibility: #{new_visibility.inspect}; must be :public or :priva...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Writes the YAML file .rdoc_options to the current directory containing the parsed options.
def write_options RDoc.load_yaml File.open '.rdoc_options', 'w' do |io| io.set_encoding Encoding::UTF_8 io.print to_yaml end end
[ "def setup_rdoc\n self.extra_rdoc_files = [ \"README.rdoc\", \"LICENSE\", \"ChangeLog\" ]\n self.rdoc_options << \"--title\" << \"#{title} #{version}\" \\\n << \"--main\" << \"README.rdoc\" \\\n << \"--line-numbers\" \\\n << \"--all\" \\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Adds +an_alias+ as an alias for this method in +context+.
def add_alias an_alias, context = nil method = self.class.new an_alias.text, an_alias.new_name method.record_location an_alias.file method.singleton = self.singleton method.params = self.params method.visibility = self.visibility method.comment = an_alias.comment method.is_alias_for = self ...
[ "def add_alias(an_alias, context)\n raise NotImplementedError\n end", "def add_alias(an_alias, context)\n new_attr = self.class.new(self.text, an_alias.new_name, self.rw,\n self.comment, self.singleton)\n\n new_attr.record_location an_alias.file\n new_attr.visibility = se...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Prefix for +aref+ is 'method'.
def aref_prefix 'method' end
[ "def method_prefix; end", "def aref_prefix\n raise NotImplementedError\n end", "def route_prefix_to_method_name(method)\n \"#{route_prefix + \"_\" if route_prefix}#{method}\"\n end", "def prefix = signature", "def method_reference=(_arg0); end", "def aref_prefix\n 'attribute'\n end", ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
The call_seq or the param_seq with method name, if there is no call_seq. Use this for displaying a method's argument lists.
def arglists if @call_seq then @call_seq elsif @params then "#{name}#{param_seq}" end end
[ "def describe_arguments\n return '' unless respond_to?(:allow_kwargs?) && allow_kwargs?\n method = if options.key?(:coerce_class)\n if options[:coerce_class].is_a?(Proc)\n target = Class.new\n target.class_eval(&options[:coerce_class]...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Sets the different ways you can call this method. If an empty +call_seq+ is given nil is assumed. See also param_seq
def call_seq= call_seq return if call_seq.empty? @call_seq = call_seq end
[ "def place_calls\n @calls.each do |call|\n target, specific_options = @call_targets[call]\n local_options = @options.dup.deep_merge specific_options if specific_options\n call.dial target, (local_options || @options)\n end\n end", "def call_options=(value)...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
A list of this method's method and yield parameters. +callseq+ params are preferred over parsed method and block params.
def param_list if @call_seq then params = @call_seq.split("\n").last params = params.sub(/.*?\((.*)\)/, '\1') params = params.sub(/(\{|do)\s*\|([^|]*)\|.*/, ',\2') elsif @params then params = @params.sub(/\((.*)\)/, '\1') params << ",#{@block_params}" if @block_params elsif @b...
[ "def arglists\n if @call_seq then\n @call_seq\n elsif @params then\n \"#{name}#{param_seq}\"\n end\n end", "def each\n params = [@value, @optional, @rest, @more, @block].select do |p|\n !p.nil?\n end\n\n params.flatten.each { |param| yield param }\n end", "...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
For methods that +super+, find the superclass method that would be called.
def superclass_method return unless @calls_super return @superclass_method if @superclass_method parent.each_ancestor do |ancestor| if method = ancestor.method_list.find { |m| m.name == @name } then @superclass_method = method break end end @superclass_method end
[ "def lookup_super(obj, super_level); end", "def super_method; end", "def process_super(exp)\n args = process exp.shift\n # TODO try to look up the method in our superclass?\n return t(:super, args, CType.unknown)\n end", "def lookup_super(obj, super_level)\n return nil if !obj\n\n sup = ob...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
call_seq with alias examples information removed, if this method is an alias method.
def deduplicate_call_seq(call_seq) return call_seq unless is_alias_for || !aliases.empty? method_name = self.name method_name = method_name[0, 1] if method_name =~ /\A\[/ entries = call_seq.split "\n" ignore = aliases.map(&:name) if is_alias_for ignore << is_alias_for.name ignore....
[ "def remove_all_aliases\n super\n end", "def remove\n remove_alias\n write_aliases\n show_aliases\n end", "def forget_aliases\n aliases.clear\n end", "def remove_example(example); end", "def remove_invocation(*names); end", "def aliases=(aliases)\n super((alias...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Task description for the clobber rdoc task or its renamed equivalent
def clobber_task_description "Remove RDoc HTML files" end
[ "def rdoc_task_description\n 'Build RDoc HTML files'\n end", "def doc_task; end", "def generate_tasks_reference(rdoc_tasks_reference)\n methods = Bee::Task::Default.instance_methods(false)\n rdoc = \"Here is the reference for bee tasks:\\n\\n\"\n for method in methods.sort\n comment = Bee::Task::Defau...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
All source is inline now. This method is deprecated
def inline_source # :nodoc: warn "RDoc::Task#inline_source is deprecated" true end
[ "def source() end", "def use_inline_editor\n @use_inline_editor = true;\n end", "def processed_source; end", "def source_lines; end", "def inline(source)\n ast = parse(source)\n inlined = inline_template(ast)\n Unparser.unparse(inlined)\n end", "def all_inline_replacements(_alternate...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
List of options that will be supplied to RDoc
def option_list result = @options.dup result << "-o" << @rdoc_dir result << "--main" << main if main result << "--markup" << markup if markup result << "--title" << title if title result << "-T" << template if template result << '-f' << generator if generato...
[ "def rdoc_options\n @rdoc_options ||= []\n end", "def rdoc_options=(options)\n @rdoc_options = Array options\n end", "def options(*) end", "def docopt_options(width)\n @options['Options'] = {} unless @options['Options']\n @options['Options']['-h --help'] = 'Show this screen'\n @options[...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Task description for the rdoc task or its renamed equivalent
def rdoc_task_description 'Build RDoc HTML files' end
[ "def description\n\t\t\"This just does a generic (untracked) task!\"\n\tend", "def doc_task; end", "def task_name\n \"#{key}: #{summary}\"\n end", "def task_help(shell, task_name)\n meth = normalize_task_name(task_name)\n task = all_tasks[meth]\n handle_no_task_error(meth) unless task\n\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Adds paths for undocumented classes +also_in+ to +out+
def add_also_in out, also_in return if also_in.empty? out << RDoc::Markup::Rule.new(1) out << RDoc::Markup::Paragraph.new("Also found in:") paths = RDoc::Markup::Verbatim.new also_in.each do |store| paths.parts.push store.friendly_path, "\n" end out << paths end
[ "def add_also_in out, also_in\n return if also_in.empty?\n out << RDoc::Markup::Rule.new(1)\n out << RDoc::Markup::Paragraph.new(\"Also found in:\")\n paths = RDoc::Markup::Verbatim.new\n also_in.each do |store|\n paths.parts.push store.friendly_path, \"\\n\"\n end\n out << paths\n end", ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Adds a class header to +out+ for class +name+ which is described in +classes+.
def add_class out, name, classes heading = if classes.all? { |klass| klass.module? } then name else superclass = classes.map do |klass| klass.superclass unless klass.module? end.compact.shift || 'Object' superclass = su...
[ "def add_class out, name, classes\n heading = if classes.all? { |klass| klass.module? } then\n name\n else\n superclass = classes.map do |klass|\n klass.superclass unless klass.module?\n end.compact.shift || 'Object'\n \"#{...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Adds +extends+ to +out+
def add_extends out, extends add_extension_modules out, 'Extended by', extends end
[ "def do_extend(extends)\n node = dup\n node.resolved_rules = resolved_rules.do_extend(extends)\n node\n end", "def add_extend ext\n add_to @extends, ext\n\n ext\n end", "def extend_plugins(extends)\n extensions_matching(extends).each do |plugin|\n extend plugin\n end\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Adds a list of +extensions+ to this module of the given +type+ to +out+. add_includes and add_extends call this, so you should use those directly.
def add_extension_modules out, type, extensions return if extensions.empty? out << RDoc::Markup::Rule.new(1) out << RDoc::Markup::Heading.new(1, "#{type}:") extensions.each do |modules, store| if modules.length == 1 then add_extension_modules_single out, store, modules.first else ...
[ "def add_extends out, extends\n add_extension_modules out, 'Extended by', extends\n end", "def include_extensions(component, type, name)\n component_metaclass = metaclass(component)\n extensions = Component.get_extensions(type, name)\n extensions.each do |extension|\n runtime.logger.trac...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Renders multiple included +modules+ from +store+ to +out+.
def add_extension_modules_multiple out, store, modules # :nodoc: out << RDoc::Markup::Paragraph.new("(from #{store.friendly_path})") wout, with = modules.partition { |incl| incl.comment.empty? } out << RDoc::Markup::BlankLine.new unless with.empty? with.each do |incl| out << RDoc::Markup::Parag...
[ "def add_extension_modules_single out, store, include # :nodoc:\n name = include.name\n path = store.friendly_path\n out << RDoc::Markup::Paragraph.new(\"#{name} (from #{path})\")\n\n if include.comment then\n out << RDoc::Markup::BlankLine.new\n out << include.comment\n end\n end", "def...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Adds a single extension module +include+ from +store+ to +out+
def add_extension_modules_single out, store, include # :nodoc: name = include.name path = store.friendly_path out << RDoc::Markup::Paragraph.new("#{name} (from #{path})") if include.comment then out << RDoc::Markup::BlankLine.new out << include.comment end end
[ "def add_include include\n add_to @includes, include\n\n include\n end", "def add_include(path)\n @includes << path\n end", "def include?(arg)\n arg.is_a?(Module) ? !!included_modules.detect{ |m| m === arg } : store.include?(arg)\n end", "def update_includes\n includes.reject! do |in...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Looks up the method +name+ and adds it to +out+
def add_method out, name filtered = lookup_method name method_out = method_document name, filtered out.concat method_out.parts end
[ "def register_outputter(name, klass, method_name)\n outputters[name] = [klass, method_name]\n end", "def stow_existing_definition(method_name)\n @methods_proxied << method_name\n new_alias = create_alias_for_existing_method(method_name)\n if new_alias\n my_object = @obj\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Adds documentation for all methods in +klass+ to +out+
def add_method_documentation out, klass klass.method_list.each do |method| begin add_method out, method.full_name rescue NotFoundError next end end end
[ "def generate\n @structure.each do |klass_name, tokens|\n klass = tokens[0]\n methods = tokens[1]\n results = @class_erb.result(binding)\n \n File.open(\"#{Dir.getwd}/doc/#{klass.name}.html\", 'w') do |f|\n f.write(results)\n end\n end\n end", "def r...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Adds a list of +methods+ to +out+ with a heading of +name+
def add_method_list out, methods, name return if methods.empty? out << RDoc::Markup::Heading.new(1, "#{name}:") out << RDoc::Markup::BlankLine.new if @use_stdout and !@interactive then out.concat methods.map { |method| RDoc::Markup::Verbatim.new method } else out << RDoc:...
[ "def add_method_list out, methods, name\n return unless methods && !methods.empty?\n out << RDoc::Markup::Heading.new(1, \"#{name}:\")\n out << RDoc::Markup::BlankLine.new\n out << RDoc::Markup::IndentedParagraph.new(2, methods.join(', '))\n out << RDoc::Markup::BlankLine.new\n end", "def add_meth...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns ancestor classes of +klass+
def ancestors_of klass ancestors = [] unexamined = [klass] seen = [] loop do break if unexamined.empty? current = unexamined.shift seen << current stores = classes[current] next unless stores and not stores.empty? klasses = stores.flat_map do |store| stor...
[ "def ancestors_for(klass)\n klass.lookup_ancestors\n end", "def ancestors_of klass\n ancestors = []\n unexamined = [klass]\n seen = []\n loop do\n break if unexamined.empty?\n current = unexamined.shift\n seen << current\n stores = classes[current]\n break unless s...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Builds a RDoc::Markup::Document from +found+, +klasess+ and +includes+
def class_document name, found, klasses, includes, extends also_in = [] out = RDoc::Markup::Document.new add_class out, name, klasses add_includes out, includes add_extends out, extends found.each do |store, klass| render_class out, store, klass, also_in end add_also_in out, ...
[ "def build_rdoc(files)\n return unless $haverdoc\n begin\n r = RDoc::RDoc.new\n r.document([\"--main\", \"MCollective\", \"--line-numbers\"] + files)\n rescue RDoc::RDocError => e\n $stderr.puts e.message\n rescue Exception => e\n $stderr.puts \"Couldn't build RDoc documentation\\n#{e.message}\"\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Adds the class +comment+ to +out+.
def class_document_comment out, comment # :nodoc: unless comment.empty? then out << RDoc::Markup::Rule.new(1) if comment.merged? then parts = comment.parts parts = parts.zip [RDoc::Markup::BlankLine.new] * parts.length parts.flatten! parts.pop out.concat parts ...
[ "def add_class(class_desc)\n dir = path_to_dir(class_desc)\n FileUtils.mkdir_p(dir)\n class_file_name = NbWriter.class_desc_path(dir, class_desc)\n# puts \"Writing class \" + class_file_name\n# class_file_name = NbWriter.class_desc_path(@base_dir, class_desc)\n File.open(class_file_nam...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Adds the constants from +klass+ to the Document +out+.
def class_document_constants out, klass # :nodoc: return if klass.constants.empty? out << RDoc::Markup::Heading.new(1, "Constants:") out << RDoc::Markup::BlankLine.new list = RDoc::Markup::List.new :NOTE constants = klass.constants.sort_by { |constant| constant.name } list.items.concat consta...
[ "def render_class out, store, klass, also_in # :nodoc:\n comment = klass.comment\n # TODO the store's cache should always return an empty Array\n class_methods = store.class_methods[klass.full_name] || []\n instance_methods = store.instance_methods[klass.full_name] || []\n attributes = st...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Hash mapping a known class or module to the stores it can be loaded from
def classes return @classes if @classes @classes = {} @stores.each do |store| store.cache[:modules].each do |mod| # using default block causes searched-for modules to be added @classes[mod] ||= [] @classes[mod] << store end end @classes end
[ "def classes\n return @classes if @classes\n @classes = {}\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] << store\n end\n end\n @classes\n end", "...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns the stores wherein +name+ is found along with the classes, extends and includes that match it
def classes_and_includes_and_extends_for name klasses = [] extends = [] includes = [] found = @stores.map do |store| begin klass = store.load_class name klasses << klass extends << [klass.extends, store] if klass.extends includes << [klass.includes, store] if kl...
[ "def find_all_storenames\n\n WiStore.find(:all).collect do |store|\n store.name\n end\n end", "def find_store name\n @stores.each do |store|\n source = store.source\n\n return source if source == name\n\n return source if\n store.type == :gem and source =~ /^#{Regexp.e...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Converts +document+ to text and writes it to the pager
def display document page do |io| f = formatter(io) f.width = @width if @width and f.respond_to?(:width) text = document.accept f io.write text end end
[ "def display document\n page do |io|\n text = document.accept formatter(io)\n io.write text\n end\n end", "def postprocess(document)\n document.gsub(\"\\n\", ' ').strip\n end", "def render_document\n execute_inline_ruby!\n\n output = document.content\n Bridgetown.logg...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Outputs formatted RI data for class +name+. Groups undocumented classes
def display_class name return if name =~ /#|\./ found, klasses, includes, extends = classes_and_includes_and_extends_for name return if found.empty? out = class_document name, found, klasses, includes, extends display out end
[ "def display_class name\n return if name =~ /#|\\./\n\n found, klasses, includes, extends =\n classes_and_includes_and_extends_for name\n\n context = klasses.reverse.inject do |merged, k|\n merged.merge k\n end\n\n return if found.empty?\n\n out = class_document name, found, klasses, inc...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Outputs formatted RI data for method +name+
def display_method name out = RDoc::Markup::Document.new add_method out, name display out end
[ "def display_method name\n found = load_methods_matching name\n raise NotFoundError, name if found.empty?\n filtered = filter_methods found, name\n out = RDoc::Markup::Document.new\n out << RDoc::Markup::Heading.new(1, name)\n out << RDoc::Markup::BlankLine.new\n filtered.each do |store, method...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Outputs formatted RI data for the class or method +name+. Returns true if +name+ was found, false if it was not an alternative could be guessed, raises an error if +name+ couldn't be guessed.
def display_name name if name =~ /\w:(\w|$)/ then display_page name return true end return true if display_class name display_method name if name =~ /::|#|\./ true rescue NotFoundError matches = list_methods_matching name if name =~ /::|#|\./ matches = classes.keys.grep(/^#{...
[ "def display_name name\n return if display_class name\n\n display_method name if name =~ /::|#|\\./\n\n true\n rescue NotFoundError\n @message.error \"#{name} not found\"\n end", "def name?(name)\n name == @name\n end", "def findAndDescribe(name)\n methods = MethodIndex.findMethods(name)\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Displays each name in +name+
def display_names names names.each do |name| name = expand_name name display_name name end end
[ "def print_name\n\t\tname = 'Myname'\n\t\ti = 0\n\t\t#zolang i kleiner is dan 10:\n\t\twhile i < 10\n\t\t\t#print naam en verhoog i met 1\n\t\t\tputs name\n\t\t\ti= i + 1\n\t\tend\n\tend", "def display_each_trail_name\n puts 'Here is our list of Colorado hiking trails:'\n trail_names.each do |trail_...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Outputs a formatted RI page list for the pages in +store+.
def display_page_list store, pages = store.cache[:pages], search = nil out = RDoc::Markup::Document.new title = if search then "#{search} pages" else 'Pages' end out << RDoc::Markup::Heading.new(1, "#{title} in #{store.friendly_path}") out << RDoc::M...
[ "def render_pages\n pages.each do |page|\n page.save(output)\n end\n end", "def index\n @r_pages_to_entries = RPagesToEntry.all\n end", "def all\n puts header\n puts output_for @items\n end", "def display_shelf\n\t\tputs @books\n\tend", "def print_index_page_summary(pages)\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Filters the methods in +found+ trying to find a match for +name+.
def filter_methods found, name regexp = name_regexp name filtered = found.find_all do |store, methods| methods.any? { |method| method.full_name =~ regexp } end return filtered unless filtered.empty? found end
[ "def filter_methods found, name\n regexp = name_regexp name\n filtered = found.find_all do |store, methods|\n methods.any? { |method| method.full_name =~ regexp }\n end\n return filtered unless filtered.empty?\n found\n end", "def list_methods_matching name\n found = []\n\n find_methods...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Yields items matching +name+ including the store they were found in, the class being searched for, the class they were found in (an ancestor) the types of methods to look up (from method_type), and the method name being searched for
def find_methods name klass, selector, method = parse_name name types = method_type selector klasses = nil ambiguous = klass.empty? if ambiguous then klasses = classes.keys else klasses = ancestors_of klass klasses.unshift klass end methods = [] klasses.each do...
[ "def find_methods name\n klass, selector, method = parse_name name\n types = method_type selector\n klasses = nil\n ambiguous = klass.empty?\n if ambiguous then\n klasses = classes.keys\n else\n klasses = ancestors_of klass\n klasses.unshift klass\n end\n methods = []\n kla...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Finds the given +pager+ for jruby. Returns an IO if +pager+ was found. Returns false if +pager+ does not exist. Returns nil if the jruby JVM doesn't support ProcessBuilder redirection (1.6 and older).
def find_pager_jruby pager require 'java' require 'shellwords' return nil unless java.lang.ProcessBuilder.constants.include? :Redirect pager = Shellwords.split pager pb = java.lang.ProcessBuilder.new(*pager) pb = pb.redirect_output java.lang.ProcessBuilder::Redirect::INHERIT @jruby_pager...
[ "def setup_pager\n return if @use_stdout\n\n jruby = RUBY_ENGINE == 'jruby'\n\n pagers = [ENV['RI_PAGER'], ENV['PAGER'], 'pager', 'less', 'more']\n\n pagers.compact.uniq.each do |pager|\n next unless pager\n\n pager_cmd = pager.split(' ').first\n\n next unless in_path? pager_cmd\n\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Finds a store that matches +name+ which can be the name of a gem, "ruby", "home" or "site". See also RDoc::Storesource
def find_store name @stores.each do |store| source = store.source return source if source == name return source if store.type == :gem and source =~ /^#{Regexp.escape name}-\d/ end raise RDoc::RI::Driver::NotFoundError, name end
[ "def lookup_store (store_name)\n each_store do |regex, name, store|\n return store if regex.match store_name\n end\n nil\n end", "def get_store (store_name)\n each_store do |regex, s_name, store|\n return store if s_name == store_name\n end\n nil\n end", "def fi...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Creates a new RDoc::Markup::Formatter. If a formatter is given with f, use it. If we're outputting to a pager, use bs, otherwise ansi.
def formatter(io) if @formatter_klass then @formatter_klass.new elsif paging? or !io.tty? then RDoc::Markup::ToBs.new else RDoc::Markup::ToAnsi.new end end
[ "def f; @formatter end", "def default_formatter\n Proc.new do |text|\n text.to_s.gsub(\"\\r\\n\", \"\\n\").gsub(\"\\n\", '<br>')\n end\n end", "def default_formatter\n Proc.new do |text|\n text.gsub(\"\\r\\n\", \"\\n\").gsub(\"\\n\", \"<br />\")\n end\n en...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Lists classes known to ri starting with +names+. If +names+ is empty all known classes are shown.
def list_known_classes names = [] classes = [] stores.each do |store| classes << store.module_names end classes = classes.flatten.uniq.sort unless names.empty? then filter = Regexp.union names.map { |name| /^#{name}/ } classes = classes.grep filter end page do |io| ...
[ "def list_known_classes names = []\n classes = []\n stores.each do |store|\n classes << store.modules\n end\n classes = classes.flatten.uniq.sort\n unless names.empty? then\n filter = Regexp.union names.map { |name| /^#{name}/ }\n classes = classes.grep filter\n end\n puts classe...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns an Array of methods matching +name+
def list_methods_matching name found = [] find_methods name do |store, klass, ancestor, types, method| if types == :instance or types == :both then methods = store.instance_methods[ancestor] if methods then matches = methods.grep(/^#{Regexp.escape method.to_s}/) matc...
[ "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 filter_methods found, name\n regexp = name_regexp name\n\n filtered = found.find_all do |store, methods|\n methods...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Loads RI data for method +name+ on +klass+ from +store+. +type+ and +cache+ indicate if it is a class or instance method.
def load_method store, cache, klass, type, name methods = store.public_send(cache)[klass] return unless methods method = methods.find do |method_name| method_name == name end return unless method store.load_method klass, "#{type}#{method}" rescue RDoc::Store::MissingFileError => e ...
[ "def load_method store, cache, klass, type, name\n methods = store.send(cache)[klass]\n return unless methods\n method = methods.find do |method_name|\n method_name == name\n end\n return unless method\n store.load_method klass, \"#{type}#{method}\"\n end", "def load_method klass_name, met...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns the type of method (:both, :instance, :class) for +selector+
def method_type selector case selector when '.', nil then :both when '#' then :instance else :class end end
[ "def type_registered?(klass_or_type, selector=:both)\n end", "def get_selector_methods(selector)\n data = {}\n\n # We only keep the methods that start with `record_`\n selector.methods.each do |method|\n method_name = method.to_s\n next unless method_name =~ /^record_/\n object_key = me...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Are we using a pager?
def paging? @paging end
[ "def has_pager?\n @options[:pager] = RawJS.new(\"#{convert_dom_id(@table_id)} + '_pager'\") if @options[:pager] == true\n @options.has_key?(:pager)\n end", "def paginable?\n gt_screen_height? && output.tty?\n end", "def pagination_enabled?(site); end", "def has_next?\n 1 < self...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Renders the +klass+ from +store+ to +out+. If the klass has no documentable items the class is added to +also_in+ instead.
def render_class out, store, klass, also_in # :nodoc: comment = klass.comment # TODO the store's cache should always return an empty Array class_methods = store.class_methods[klass.full_name] || [] instance_methods = store.instance_methods[klass.full_name] || [] attributes = store.attrib...
[ "def class_document name, found, klasses, includes, extends\n also_in = []\n\n out = RDoc::Markup::Document.new\n\n add_class out, name, klasses\n\n add_includes out, includes\n add_extends out, extends\n\n found.each do |store, klass|\n render_class out, store, klass, also_in\n end\n\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Sets up a pager program to pass output through. Tries the RI_PAGER and PAGER environment variables followed by pager, less then more.
def setup_pager return if @use_stdout jruby = RUBY_ENGINE == 'jruby' pagers = [ENV['RI_PAGER'], ENV['PAGER'], 'pager', 'less', 'more'] pagers.compact.uniq.each do |pager| next unless pager pager_cmd = pager.split(' ').first next unless in_path? pager_cmd if jruby then ...
[ "def setup_pager\n unless @use_stdout then\n for pager in [ ENV['PAGER'], \"less\", \"more\", 'pager' ].compact.uniq\n return IO.popen(pager, \"w\") rescue nil\n end\n @use_stdout = true\n nil\n end\n end", "def enable_paging\n return unless $stdout.tty?\n return unless...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Creates a PO entry for +msgid+. Other valus can be specified by +options+.
def initialize msgid, options = {} @msgid = msgid @msgstr = options[:msgstr] || "" @translator_comment = options[:translator_comment] @extracted_comment = options[:extracted_comment] @references = options[:references] || [] @flags = options[:flags] || [] end
[ "def add entry\n existing_entry = @entries[entry.msgid]\n if existing_entry\n entry = existing_entry.merge(entry)\n end\n @entries[entry.msgid] = entry\n end", "def international_create(label_options)\n create_label File.join(LABEL_URL, 'international', label_options)\n end", "def nsge...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Merges the PO entry with +other_entry+.
def merge other_entry options = { :extracted_comment => merge_string(@extracted_comment, other_entry.extracted_comment), :translator_comment => merge_string(@translator_comment, other_entry.translator_comment), :r...
[ "def merge(other_file)\n unless other_file.is_a?(POFile)\n raise ArgumentError, 'argument must be a PutText::POFile'\n end\n\n @entries += other_file.entries\n end", "def merge(other_entry)\n @references += other_entry.references\n self\n end", "def merge_entries! other_fee...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Adds a PO entry to the PO.
def add entry existing_entry = @entries[entry.msgid] if existing_entry entry = existing_entry.merge(entry) end @entries[entry.msgid] = entry end
[ "def add_entry(entry)\n @entries << entry\n end", "def add(entry)\n @entries[entry.tag] = entry\n end", "def add(o); addObject o end", "def manual_add_entry\n address_book.add_entry(enter_name, enter_phone, enter_email)\n end", "def add(entry)\n heap.add(entry.run_at, entry)\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Copies static files from the static_path into the output directory
def copy_static return if @options.static_path.empty? fu_options = { :verbose => $DEBUG_RDOC, :noop => @dry_run } @options.static_path.each do |path| unless File.directory? path then FileUtils.install path, @outputdir, **fu_options.merge(:mode => 0644) next end Dir.chdir...
[ "def copy_static\n FileUtils.cp_r 'static/.', 'output/', :preserve => true\nend", "def copy_static\n FileUtils.cp_r 'static/.', 'output/'\nend", "def copy_static\n FileUtils.cp_r 'static/.', 'output/' \nend", "def copy_static_files\n @static_files.each{|full,partial|\n File.makedirs(File.dirnam...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Generate a documentation file for each file
def generate_file_files setup page_file = @template_dir + 'page.rhtml' fileinfo_file = @template_dir + 'fileinfo.rhtml' # for legacy templates filepage_file = @template_dir + 'filepage.rhtml' unless page_file.exist? or fileinfo_file.exist? return unless page_file.exist? or fil...
[ "def generate_file_files\n template_file = @template_dir + 'file-page.html.erb'\n debug_msg \"Generating file documentation\"\n @all_files.each do |file|\n debug_msg \" file #{file.path}\"\n outfile = @output_dir + file.path\n @file = file\n self.render_template(template_file, binding(...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Generate a page file for +file+
def generate_page file setup template_file = @template_dir + 'page.rhtml' out_file = @outputdir + file.path debug_msg " working on %s (%s)" % [file.full_name, out_file] rel_prefix = @outputdir.relative_path_from out_file.dirname search_index_rel_prefix = rel_prefix search_index_rel_prefix...
[ "def page_file page_name\n file_name = File.basename(page_name).gsub('.', '_')\n\n File.join @path, File.dirname(page_name), \"page-#{file_name}.ri\"\n end", "def generate_file_files\n\t\tlayout = self.load_layout_template\n\t\ttemplate = self.load_template( 'file.tmpl' )\n\n\t\tself.log.debug \"Generating...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Generates the 404 page for the RDoc servlet
def generate_servlet_not_found message setup template_file = @template_dir + 'servlet_not_found.rhtml' return unless template_file.exist? debug_msg "Rendering the servlet 404 Not Found page..." rel_prefix = rel_prefix = '' search_index_rel_prefix = rel_prefix search_index_rel_prefix += @a...
[ "def not_found generator, req, res, message = nil\n message ||= \"The page <kbd>#{ERB::Util.h req.path}</kbd> was not found\"\n res.body = generator.generate_servlet_not_found message\n res.status = 404\n end", "def res_404\n create_response('Not Found', 404, {'Content-Type' => 'text/plain'})\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Generates the servlet root page for the RDoc servlet
def generate_servlet_root installed setup template_file = @template_dir + 'servlet_root.rhtml' return unless template_file.exist? debug_msg 'Rendering the servlet root page...' rel_prefix = '.' asset_rel_prefix = rel_prefix search_index_rel_prefix = asset_rel_prefix search_index_rel_p...
[ "def root req, res\n generator = RDoc::Generator::Darkfish.new nil, @options\n\n res.body = generator.generate_servlet_root installed_docs\n\n res.content_type = 'text/html'\n end", "def gen_main_index\n template = TemplatePage.new(RDoc::Page::INDEX)\n File.open(\"index.html\", \"w...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Try to extract Subversion information out of the first constant whose value looks like a subversion Id tag. If no matching constant is found, and empty hash is returned.
def get_svninfo klass constants = klass.constants or return {} constants.find { |c| c.value =~ SVNID_PATTERN } or return {} filename, rev, date, time, committer = $~.captures commitdate = Time.parse "#{date} #{time}" return { :filename => filename, :rev => Integer(rev), ...
[ "def extract_vsys_id(id)\n /^(\\w+-\\w+)\\b.*/ =~ id\n $1\n end", "def extract_sha_for_binary(asset_filename, sha_file_content)\n lines_of_interest = sha_file_content\n .to_s\n .split(\"\\n\")\n .map(&:squish)\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Creates a template from its components and the +body_file+. For backwards compatibility, if +body_file+ contains "<html" the body is used directly.
def assemble_template body_file body = body_file.read return body if body =~ /<html/ head_file = @template_dir + '_head.rhtml' footer_file = @template_dir + '_footer.rhtml' <<-TEMPLATE <!DOCTYPE html> <html> <head> #{head_file.read} #{body} #{footer_file.read} TEMPLATE end
[ "def body_template(parser = template_parser)\n @bt ||= parser.parse(body)\n end", "def mailto_body_template\n Liquid::Template.parse(File.read(File.join(@options[:templates], \"mailto_body.liquid\")))\n end", "def render\n template_body = Tilt.new(@template).render(self)\n if @layout\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Renders the ERb contained in +file_name+ relative to the template directory and returns the result based on the current context.
def render file_name template_file = @template_dir + file_name template = template_for template_file, false, RDoc::ERBPartial template.filename = template_file.to_s template.result @context end
[ "def render_file(file)\n data = in_template_directory { File.read(file) }\n ERB.new(data).result(builder.get_binding)\n end", "def render_file(file)\n ERB.new(read_file(file)).result(builder.get_binding)\n end", "def render_file(path, options = {})\n pn = absolute_path_from_current_template(path...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Load and render the erb template in the given +template_file+ and write it out to +out_file+. Both +template_file+ and +out_file+ should be Pathnamelike objects. An io will be yielded which must be captured by binding in the caller.
def render_template template_file, out_file = nil # :yield: io io_output = out_file && !@dry_run && @file_output erb_klass = io_output ? RDoc::ERBIO : ERB template = template_for template_file, true, erb_klass if io_output then debug_msg "Outputting to %s" % [out_file.expand_path] out_fil...
[ "def render_template(template_file, binding, outfile)\n\n debug_msg \" rendering #{outfile}\"\n\n @rel_prefix = @output_dir.relative_path_from(outfile.dirname)\n @stylesheet_url = @babel_options[:stylesheet_url] || (@rel_prefix + 'rdoc.css').to_s\n\n template_src = template_file.read\n template = ER...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Creates the result for +template+ with +context+. If an error is raised a Pathname +template_file+ will indicate the file where the error occurred.
def template_result template, context, template_file template.filename = template_file.to_s template.result context rescue NoMethodError => e raise RDoc::Error, "Error while evaluating %s: %s" % [ template_file.expand_path, e.message, ], e.backtrace end
[ "def render_template( templatefile, context, outfile )\n\t\ttemplate_src = templatefile.read\n\t\ttemplate = ERB.new( template_src, nil, '<>' )\n\t\ttemplate.filename = templatefile.to_s\n\n\t\toutput = begin\n\t\t\ttemplate.result( context )\n\t\trescue NoMethodError => err\n\t\t\traise \"Error while evaluating %s...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Generates a relative URL from +from_path+ to this object's path
def as_href(from_path) RDoc::Markup::ToHtml.gen_relative_url from_path, path end
[ "def relative_path_from(from)\n from = self.class.new(from).expand_path.gsub(%r!/$!, \"\")\n self.class.new(expand_path.gsub(%r!^#{\n from.regexp_escape\n }/!, \"\"))\n end", "def generate_url(path)\n if path =~ /^\\//\n path.sub!('/', '')\n end\n path = \"#{@base_url}/#{path}...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Creates an RDoc::Markup::ToHtmlCrossref formatter
def formatter return @formatter if defined? @formatter options = @store.rdoc.options this = RDoc::Context === self ? self : @parent @formatter = RDoc::Markup::ToHtmlCrossref.new options, this.path, this @formatter.code_object = self @formatter end
[ "def xreftext xrefstyle = nil\n reftext\n end", "def get_reference ref\n result = \"\"\n result << \". \" if Styles.is_numeric? @style\n\n begin\n cptext = @citeproc.render :bibliography, id: ref\n rescue Exception => e\n puts \"Failed to render #{ref}: #{e}\"\n end\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Build a webcvs URL starting for the given +url+ with +full_path+ appended as the destination path. If +url+ contains '%s' +full_path+ will be will replace the %s using sprintf on the +url+.
def cvs_url(url, full_path) if /%s/ =~ url then sprintf url, full_path else url + full_path end end
[ "def cvs_url(url, full_path)\n if /%s/ =~ url\n return sprintf( url, full_path )\n else\n return url + full_path\n end\n end", "def cvs_url(url, full_path)\n if /%s/ =~ url\n return sprintf( url, full_path )\n else\n ret...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Turns the method's token stream into HTML. Prepends line numbers if +options.line_numbers+ is true.
def markup_code return '' unless @token_stream src = RDoc::TokenStream.to_html @token_stream # dedent the source indent = src.length lines = src.lines.to_a lines.shift if src =~ /\A.*#\ *File/i # remove '# File' comment lines.each do |line| if line =~ /^ *(?=\S)/ n = $&.lengt...
[ "def render_code_line\n @line = @indent << @line_tokens.map! do |text, css_class|\n if css_class\n \"<span class=\\\"#{css_class}\\\">#{h(text)}</span>\"\n else\n h(text)\n end\n end.join\n end", "def generate(options = {})\n options.default! :error_wrapping => false, :strip...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
:nodoc: Creates a new generator. +parent_generator+ is used to determine the class_dir and file_dir of links in the output index. +options+ are the same options passed to the parent generator.
def initialize parent_generator, options @parent_generator = parent_generator @store = parent_generator.store @options = options @template_dir = File.expand_path '../template/json_index', __FILE__ @base_dir = @parent_generator.base_dir @classes = nil @files = nil ...
[ "def initialize(generator_or_options = {})\n @generator = self.class.prepare_generator generator_or_options\n end", "def create_generator(klass, name, options={})\n raise \"Will not create a new generator, already using one with temp dir #{@app_spec_base_dir}\" unless @app_spec_base_dir.nil?\n\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Compress the search_index.js file using gzip
def generate_gzipped return if @options.dry_run or not defined?(Zlib) debug_msg "Compressing generated JSON index" out_dir = @base_dir + @options.op_dir search_index_file = out_dir + SEARCH_INDEX_FILE outfile = out_dir + "#{search_index_file}.gz" debug_msg "Reading the JSON index fi...
[ "def js_compressor; end", "def generate_search_index\n\t\tout_file = self.output_dir + 'js/searchindex.js'\n\n\t\tself.log.debug \"Generating search index (%s).\" % [ out_file ]\n\t\tindex = []\n\n\t objs = self.get_indexable_objects\n\t\tobjs.each do |codeobj|\n\t\t\tself.log.debug \" #{codeobj.name}...\"\n\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Adds methods to the index
def index_methods debug_msg " generating method search index" list = @classes.uniq.map do |klass| klass.method_list end.flatten.sort_by do |method| [method.name, method.parent.full_name] end list.each do |method| debug_msg " #{method.full_name}" record = method.search_r...
[ "def add_method_search_index(index)\n debug_msg \" generating method search index\"\n \n list = self.data.map { |mod_name, mod| \n mod.funcs\n }.flatten\n \n list.each do |func|\n func.short_names.each do |func_name|\n index[:searchIndex].push( search_string(func.p_module.title +...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Adds pages to the index
def index_pages debug_msg " generating pages search index" pages = @files.select do |file| file.text? end pages.each do |page| debug_msg " #{page.page_name}" record = page.search_record @index[:searchIndex] << search_string(record.shift) @index[:longSearchIndex] <...
[ "def pages_index\n @pages.inject([]) { |h, p|\n h << {\n :title => p.to_s,\n :url => p.url,\n :type => p.data['group'],\n :parent => (urls.index(p.parent.path) if p.parent?) }\n h\n }\n end", "def fill_pages_index(site, urlset)\n # Iterate ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Creates a new Attr with body +text+, +name+, read/write status +rw+ and +comment+. +singleton+ marks this as a class attribute.
def initialize(text, name, rw, comment, singleton = false) super text, name @rw = rw @singleton = singleton self.comment = comment end
[ "def createAttribute(name)\n ret = Attr.new(name)\n ret.ownerDocument = self\n ret\n end", "def attr(name, default_value=:undefined)\n other_attrs[name] = Attr.new(name, default_value, @_current_desc)\n @_current_desc = nil\n _define_attr(name)\n end", ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Attributes are equal when their names, singleton and rw are identical
def == other self.class == other.class and self.name == other.name and self.rw == other.rw and self.singleton == other.singleton end
[ "def attr_equal?(o)\n self == o and\n self.instance_variables_compare(o).empty? and\n self.attributes == o.attributes\n end", "def same_attributes?(attr1,attr2)\n attr1.each do |k,v|\n if attr2.has_key?(k)\n a1v = v.value\n a2v = attr2[k].value\n if a1v != a2v\n return fals...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Add +an_alias+ as an attribute in +context+.
def add_alias(an_alias, context) new_attr = self.class.new(self.text, an_alias.new_name, self.rw, self.comment, self.singleton) new_attr.record_location an_alias.file new_attr.visibility = self.visibility new_attr.is_alias_for = self @aliases << new_attr context.ad...
[ "def add_alias(an_alias, context)\n raise NotImplementedError\n 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 ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
The aref prefix for attributes
def aref_prefix 'attribute' end
[ "def aref_prefix\n raise NotImplementedError\n end", "def attribute_alias(name); end", "def aref_prefix\n 'method'\n end", "def format_prefix\n values = CEF::PREFIX_ATTRIBUTES.keys.map { |k| send(k) }\n escaped = values.map do |value|\n escape_prefix_value(value)\n end\n esc...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Expands tab characters in +text+ to eight spaces
def expand_tabs text expanded = [] text.each_line do |line| nil while line.gsub!(/(?:\G|\r)((?:.{8})*?)([^\t\r\n]{0,7})\t/) do r = "#{$1}#{$2}#{' ' * (8 - $2.size)}" r = RDoc::Encoding.change_encoding r, text.encoding r end expanded << line end expanded.join ...
[ "def expand_tab!\n self.gsub!(/([^\\t]{8})|([^\\t]*)\\t/n) {[$+].pack(\"A8\")} \n nil\n end", "def tab(txt, width = 4)\n return txt if width <= 0\n\n tab = \" \" * width\n\n return tab + txt if txt.is_a? String\n\n txt.map { |l| tab + l }\n end", "def con...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Flush +text+ left based on the shortest line
def flush_left text indent = 9999 text.each_line do |line| line_indent = line =~ /\S/ || 9999 indent = line_indent if indent > line_indent end empty = '' empty = RDoc::Encoding.change_encoding empty, text.encoding text.gsub(/^ {0,#{indent}}/, empty) end
[ "def flush_left text\n indents = []\n\n text.each_line do |line|\n indents << (line =~ /[^\\s]/ || 9999)\n end\n\n indent = indents.min\n\n flush = []\n\n text.each_line do |line|\n line[/^ {0,#{indent}}/] = ''\n flush << line\n end\n\n flush.join\n end", "def line_flush_ri...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Converts the parts of +paragraph+ to a single entry.
def accept_paragraph paragraph parts = paragraph.parts.chunk do |part| String === part end.map do |string, chunk| string ? chunk.join.rstrip : chunk end.flatten paragraph.parts.replace parts end
[ "def parse_paragraph; end", "def paragraph\n paragraphs(1)\n end", "def paragraph parts\n parts = parts.map do |part|\n if \"\\n\" == part then\n RDoc::Markup::HardBreak.new\n else\n part\n end\n end if break_on_newline?\n\n RDoc::Markup::Paragraph.new(*parts)\n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Joins the raw paragraph text and converts inline HardBreaks to the +hard_break+ text.
def text hard_break = '' @parts.map do |part| if RDoc::Markup::HardBreak === part then hard_break else part end end.join end
[ "def text hard_break = nil\n @parts.map do |part|\n if RDoc::Markup::HardBreak === part then\n '%1$s%3$*2$s' % [hard_break, @indent, ' '] if hard_break\n else\n part\n end\n end.join\n end", "def paragraph parts\n parts = parts.map do |part|\n if \"\\n\" == part then\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Creates a new ListItem with an optional +label+ containing +parts+
def initialize label = nil, *parts @label = label @parts = [] @parts.concat parts end
[ "def initialize(label)\n @label = label\n @items = []\n end", "def accept_list_item_start(list_item)\n case current_list_type\n when :LABEL, :NOTE\n labels = Array(list_item.label).join(\", \")\n parts << \".It #{labels}\\n\"\n else\n parts << \".It\\n\"\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Appends +part+ to the ListItem
def << part @parts << part end
[ "def add_part(part); end", "def add_part(part)\n \n @parts.push(part)\n \n end", "def add_part(part)\n @parts ||= Array.new\n @parts << part\n end", "def add_part(part)\n self.parts << part\n part.save unless part.pid\n part.is_part_of = self\n self.sav...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Runs this list item and all its parts through +visitor+
def accept visitor visitor.accept_list_item_start self @parts.each do |part| part.accept visitor end visitor.accept_list_item_end self 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", "def process item\n end", "def process_item(items, index, &block); end", "def accept(visitor)\n visitor.visit(self)\n end", "de...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Length of parts in the ListItem
def length @parts.length end
[ "def length\n parts.length\n end", "def length(list); end", "def size\n\tparts.size\nend", "def item_count\n items.size\n end", "def length\n case @type\n when :data\n return 0 if self.empty?\n 1\n when :list\n @data[:list].length\n end\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Handles rdoc type links for footnotes.
def handle_rdoc_link url case url when /^rdoc-ref:/ then $' when /^rdoc-label:footmark-(\d+)/ then "[^#{$1}]:" when /^rdoc-label:foottext-(\d+)/ then "[^#{$1}]" when /^rdoc-label:label-/ then gen_url url, $' when /^rdoc-image:/ then "![](#{$'})" when /^rdoc-[a-z...
[ "def post_type_link(text, type = nil)\r\n type = text if type.nil?\r\n link_to text, :controller => 'post', :action => 'list_by_type',\r\n :type => type\r\n end", "def post_type_link(text, type = nil)\n type = text if type.nil?\n link_to text, :controller => 'tumble', :action => 'lis...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Calls accept_raw+ on +visitor+
def accept visitor visitor.accept_raw self end
[ "def accept visitor\n visitor.accept_verbatim self\n end", "def accept visitor\n visitor.start_accepting\n\n visitor.accept_document self\n\n visitor.end_accepting\n end", "def accept(_visitor)\n raise NotImplementedError\n end", "def accept_visitor(visitor)\n visit_me...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Calls accept_heading on +visitor+
def accept visitor visitor.accept_heading self end
[ "def accept_visitor(visitor)\n visit_method_name = \"visit#{basename(self.class.name.to_s.gsub(/::/, '/'))}\".to_sym\n visitor.send(visit_method_name, self) if visitor.respond_to?(visit_method_name)\n end", "def accept visitor\n visitor.start_acc...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Creates a fullyqualified label which will include the label from +context+. This helps keep ids unique in HTML.
def label context = nil label = aref label = [context.aref, label].compact.join '-' if context and context.respond_to? :aref label end
[ "def label_with_id\n text_and_id( :label )\n end", "def label_html\n \"<label for='#{id}'>#{title}:</label>\"\n end", "def label(attrs)\n attrs ||= {}\n for_attr = attrs[:id] ? {:for => attrs[:id]} : {}\n if label_text = attrs.delete(:label)\n tag(:label, label_text, for_attr)\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Calls accept_hard_break on +visitor+
def accept visitor visitor.accept_hard_break self end
[ "def accept visitor\r\n visitor.accept_hard_break self\r\n end", "def visit_break(node); end", "def visit_break(node)\n node.copy(arguments: visit(node.arguments))\n end", "def accept visitor\n visitor.accept_raw self\n end", "def accept(_visitor)\n raise NotImplementedError\n end", ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Runs this list and all its items through +visitor+
def accept visitor visitor.accept_list_start self @items.each do |item| item.accept visitor end visitor.accept_list_end self end
[ "def accept visitor\n visitor.accept_list_item_start self\n\n @parts.each do |part|\n part.accept visitor\n end\n\n visitor.accept_list_item_end self\n end", "def accept(visitor)\n visitor.visit(self)\n end", "def visit\n @visit\n end", "def visit_collection(printer, coll...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Creates a new crossref resolver that generates links relative to +context+ which lives at +from_path+ in the generated files. '' characters on references are removed unless +show_hash+ is true. Only method names preceded by '' or '::' are linked, unless +hyperlink_all+ is true.
def initialize(options, from_path, context, markup = nil) raise ArgumentError, 'from_path cannot be nil' if from_path.nil? super options, markup @context = context @from_path = from_path @hyperlink_all = @options.hyperlink_all @show_hash = @options.show_hash @cross_reference...
[ "def initialize(from_path, context, show_hash)\n raise ArgumentError, 'from_path cannot be nil' if from_path.nil?\n super()\n\n @markup.add_special(CROSSREF_REGEXP, :CROSSREF)\n\n @from_path = from_path\n @context = context\n @show_hash = show_hash\n\n @seen = {}\n end", "def as_href(from_pa...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
We're invoked when any text matches the CROSSREF pattern. If we find the corresponding reference, generate a link. If the name we're looking for contains no punctuation, we look for it up the module/class chain. For example, ToHtml is found, even without the RDoc::Markup:: prefix, because we look for it in module Marku...
def handle_regexp_CROSSREF(target) name = target.text return name if name =~ /@[\w-]+\.[\w-]/ # labels that look like emails unless @hyperlink_all then # This ensures that words entirely consisting of lowercase letters will # not have cross-references generated (to suppress lots of erroneous ...
[ "def handle_special_CROSSREF(special)\n name = special.text\n\n # This ensures that words entirely consisting of lowercase letters will\n # not have cross-references generated (to suppress lots of erroneous\n # cross-references to \"new\" in text, for instance)\n return name if name =~ /\\A[a-z]*\\z/...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Handles rdocref: scheme links and allows RDoc::Markup::ToHtml to handle other schemes.
def handle_regexp_HYPERLINK target return cross_reference $' if target.text =~ /\Ardoc-ref:/ super 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 \"![](#{$'}...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Creates a new IndentedParagraph containing +parts+ indented with +indent+ spaces
def initialize indent, *parts @indent = indent super(*parts) end
[ "def paragraph parts\n parts = parts.map do |part|\n if \"\\n\" == part then\n RDoc::Markup::HardBreak.new\n else\n part\n end\n end if break_on_newline?\n\n RDoc::Markup::Paragraph.new(*parts)\n end", "def format_paragraph(text, len = 72, indent = 2)\n sentences = [[]]...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Calls accept_indented_paragraph on +visitor+
def accept visitor visitor.accept_indented_paragraph self end
[ "def visit_indented(node)\n if NOINDENT.include?(node.type)\n visit_plain(node)\n else\n indented { visit_plain(node) }\n end\n end", "def parse_paragraph; end", "def wrap_with_paragraphs(env, nodes); end", "def format_paragraph(text, len = T.unsafe(nil), indent = T.unsafe(nil)...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Joins the raw paragraph text and converts inline HardBreaks to the +hard_break+ text followed by the indent.
def text hard_break = nil @parts.map do |part| if RDoc::Markup::HardBreak === part then '%1$s%3$*2$s' % [hard_break, @indent, ' '] if hard_break else part end end.join end
[ "def text hard_break = ''\n @parts.map do |part|\n if RDoc::Markup::HardBreak === part then\n hard_break\n else\n part\n end\n end.join\n end", "def paragraph parts\n parts = parts.map do |part|\n if \"\\n\" == part then\n RDoc::Markup::HardBreak.new\n else\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }