query
stringlengths
7
9.5k
document
stringlengths
10
1.07M
negatives
listlengths
19
19
metadata
dict
Get an included module that may be surrounded by parens
def get_included_module_with_optional_parens skip_tkspace_without_nl get_tkread tk = get_tk end_token = get_end_token tk return '' unless end_token nest = 0 continue = false only_constant = true while tk != nil do is_element_of_constant = false case tk[:kind] when...
[ "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 return E[pos, :include, n]\n end", "def included(a_module)\n end", "def included(mod); end", "def module\n return @module if @module\n\n # search ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Marks containers between +container+ and +ancestor+ as ignored
def suppress_parents container, ancestor # :nodoc: while container and container != ancestor do container.suppress unless container.documented? container = container.parent end end
[ "def ignore_parent_exclusion; end", "def ignored_ancestor_tags\n if context[:ignored_ancestor_tags]\n DEFAULT_IGNORED_ANCESTOR_TAGS | context[:ignored_ancestor_tags]\n else\n DEFAULT_IGNORED_ANCESTOR_TAGS\n end\n end", "def ignored_ancestor_tags\n i...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Look for directives in a normal comment block: :stopdoc: Don't display comment from this point forward This routine modifies its +comment+ parameter.
def look_for_directives_in container, comment @preprocess.handle comment, container do |directive, param| case directive when 'method', 'singleton-method', 'attr', 'attr_accessor', 'attr_reader', 'attr_writer' then false # handled elsewhere when 'section' then break unle...
[ "def look_for_directives_in(context, comment)\n preprocess = create_rdoc_preprocess\n\n preprocess.handle(comment) do |directive, param|\n case directive\n when \"stopdoc\"\n context.stop_doc\n \"\"\n when \"startdoc\"\n context.start_doc\n context.force_documentatio...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Creates an RDoc::Attr for the name following +tk+, setting the comment to +comment+.
def parse_attr(context, single, tk, comment) line_no = tk[:line_no] args = parse_symbol_arg 1 if args.size > 0 then name = args[0] rw = "R" skip_tkspace_without_nl tk = get_tk if :on_comma == tk[:kind] then rw = "RW" if get_bool else unget_tk tk en...
[ "def parse_comment_attr container, type, name, comment # :nodoc:\n return if name.empty?\n\n rw = case type\n when 'attr_reader' then 'R'\n when 'attr_writer' then 'W'\n else 'RW'\n end\n\n create_attr container, NORMAL, name, rw, comment\n end", "def find_attr_comment va...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Creates an RDoc::Attr for each attribute listed after +tk+, setting the comment for each to +comment+.
def parse_attr_accessor(context, single, tk, comment) line_no = tk[:line_no] args = parse_symbol_arg rw = "?" tmp = RDoc::CodeObject.new read_documentation_modifiers tmp, RDoc::ATTR_MODIFIERS # TODO In most other places we let the context keep track of document_self # and add found items a...
[ "def parse_attr(context, single, tk, comment)\n line_no = tk[:line_no]\n\n args = parse_symbol_arg 1\n if args.size > 0 then\n name = args[0]\n rw = \"R\"\n skip_tkspace_without_nl\n tk = get_tk\n\n if :on_comma == tk[:kind] then\n rw = \"RW\" if get_bool\n else\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Parses an +alias+ in +context+ with +comment+
def parse_alias(context, single, tk, comment) line_no = tk[:line_no] skip_tkspace if :on_lparen === peek_tk[:kind] then get_tk skip_tkspace end new_name = get_symbol_or_name skip_tkspace if :on_comma === peek_tk[:kind] then get_tk skip_tkspace end begin ...
[ "def visit_alias(node); end", "def find_alias_comment class_name, new_name, old_name\n content =~ %r%((?>/\\*.*?\\*/\\s+))\n rb_define_alias\\(\\s*#{Regexp.escape class_name}\\s*,\n \\s*\"#{Regexp.escape new_name}\"\\s*,\n \\s...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Parses a singleton class in +container+ with the given +name+ and +comment+.
def parse_class_singleton container, name, comment # :nodoc: other = @store.find_class_named name unless other then if name =~ /^::/ then name = $' container = @top_level end other = container.add_module RDoc::NormalModule, name record_location other # class << $...
[ "def parse_method_name_singleton container, name_t # :nodoc:\n skip_tkspace\n name_t2 = get_tk\n\n if (:on_kw == name_t[:kind] && 'self' == name_t[:text]) || (:on_op == name_t[:kind] && '%' == name_t[:text]) then\n # NOTE: work around '[' being consumed early\n if :on_lbracket == name_t2[:kind]\n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Parses a constant in +context+ with +comment+. If +ignore_constants+ is true, no found constants will be added to RDoc.
def parse_constant container, tk, comment, ignore_constants = false line_no = tk[:line_no] name = tk[:text] skip_tkspace_without_nl return unless name =~ /^\w+$/ new_modules = [] if :on_op == peek_tk[:kind] && '::' == peek_tk[:text] then unget_tk tk container, name_t, _, new_modu...
[ "def do_constants\n # %constant <type>[*] <name> = <c-constant>;\n\n @content.scan(/(\\/\\*.*?\\*\\/)?\\s*%constant\\s+(\\w+)([\\s\\*]+)(\\w+)\\s*=\\s*(\\w+);/) do |comment, type, pointer, const_name, definition|\n# puts \"\\nConst #{const_name} : #{comment.inspect}\"\n handle_constants comment, con...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Parse a comment that is describing an attribute in +container+ with the given +name+ and +comment+.
def parse_comment_attr container, type, name, comment # :nodoc: return if name.empty? rw = case type when 'attr_reader' then 'R' when 'attr_writer' then 'W' else 'RW' end create_attr container, NORMAL, name, rw, comment end
[ "def find_attr_comment var_name, attr_name, read = nil, write = nil\n attr_name = Regexp.escape attr_name\n\n rw = if read and write then\n /\\s*#{read}\\s*,\\s*#{write}\\s*/xm\n else\n /.*?/m\n end\n\n if @content =~ %r%((?>/\\*.*?\\*/\\s+))\n rb_de...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Creates an RDoc::Method on +container+ from +comment+ if there is a Signature section in the comment
def parse_comment_tomdoc container, tk, comment return unless signature = RDoc::TomDoc.signature(comment) column = tk[:char_no] line_no = tk[:line_no] name, = signature.split %r%[ \(]%, 2 meth = RDoc::GhostMethod.new get_tkread, name record_location meth meth.line = line_no meth...
[ "def parse_method(container, single, tk, comment)\n singleton = nil\n added_container = false\n name = nil\n column = tk[:char_no]\n line_no = tk[:line_no]\n\n start_collecting_tokens\n add_token tk\n\n token_listener self do\n prev_container = container\n name, container, singlet...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Parses an +include+ or +extend+, indicated by the +klass+ and adds it to +container+ with +comment+
def parse_extend_or_include klass, container, comment # :nodoc: loop do skip_tkspace_comment name = get_included_module_with_optional_parens unless name.empty? then obj = container.add klass, name, comment record_location obj end return if peek_tk.nil? || :on_comma !...
[ "def add klass, name, comment\n if RDoc::Extend == klass then\n ext = RDoc::Extend.new name, comment\n add_extend ext\n elsif RDoc::Include == klass then\n incl = RDoc::Include.new name, comment\n add_include incl\n else\n raise NotImplementedError, \"adding a #{klass} is not imple...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Parses identifiers that can create new methods or change visibility. Returns true if the comment was not consumed.
def parse_identifier container, single, tk, comment # :nodoc: case tk[:text] when 'private', 'protected', 'public', 'private_class_method', 'public_class_method', 'module_function' then parse_visibility container, single, tk return true when 'private_constant', 'public_constant' p...
[ "def line_has_identifier?(line, id)\n while (index = line.index(String_regex)) != nil\n line.insert(index, line.slice!(String_regex)[0..0])\n line.slice!(/^\"/)\n end\n line.slice!(Comment)\n return line.include?(id)\n end", "def allow_comments?\n case @comments\n when :guess\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Parses a metaprogrammed attribute and creates an RDoc::Attr. To create foo and bar attributes on class C with comment "My attributes": class C :attr: My attributes my_attr :foo, :bar end To create a foo attribute on class C with comment "My attribute": class C :attr: foo My attribute my_attr :foo, :bar end
def parse_meta_attr(context, single, tk, comment) args = parse_symbol_arg rw = "?" # If nodoc is given, don't document any of them tmp = RDoc::CodeObject.new read_documentation_modifiers tmp, RDoc::ATTR_MODIFIERS regexp = /^# +:?(attr(_reader|_writer|_accessor)?): *(\S*).*?\n/i if regexp ...
[ "def parse_attr(context, single, tk, comment)\n line_no = tk[:line_no]\n\n args = parse_symbol_arg 1\n if args.size > 0 then\n name = args[0]\n rw = \"R\"\n skip_tkspace_without_nl\n tk = get_tk\n\n if :on_comma == tk[:kind] then\n rw = \"RW\" if get_bool\n else\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Parses the name of a metaprogrammed method. +comment+ is used to determine the name while +tk+ is used in an error message if the name cannot be determined.
def parse_meta_method_name comment, tk # :nodoc: if comment.text.sub!(/^# +:?method: *(\S*).*?\n/i, '') then return $1 unless $1.empty? end name_t = get_tk if :on_symbol == name_t[:kind] then name_t[:text][1..-1] elsif :on_tstring == name_t[:kind] then name_t[:text][1..-2] el...
[ "def parse_method_name_regular container, name_t # :nodoc:\n if :on_op == name_t[:kind] && (%w{* & [] []= <<}.include?(name_t[:text])) then\n name_t[:text]\n else\n unless [:on_kw, :on_const, :on_ident].include?(name_t[:kind]) then\n warn \"expected method name token, . or ::, got #{name_t.in...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Parses the parameters and block for a metaprogrammed method.
def parse_meta_method_params container, single, meth, tk, comment # :nodoc: token_listener meth do meth.params = '' look_for_directives_in meth, comment comment.normalize comment.extract_call_seq meth container.add_method meth last_tk = tk while tk = get_tk do i...
[ "def parse_method_params_and_body container, single, meth, added_container\n token_listener meth do\n parse_method_parameters meth\n\n if meth.document_self or not @track_visibility then\n container.add_method meth\n elsif added_container then\n container.document_self = false\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Parses a normal method defined by +def+
def parse_method(container, single, tk, comment) singleton = nil added_container = false name = nil column = tk[:char_no] line_no = tk[:line_no] start_collecting_tokens add_token tk token_listener self do prev_container = container name, container, singleton = parse_method...
[ "def method_definition(class_def)\n \t_IDENTIFIER7 = nil\n\n\n\n\n \t method = MethodDefinition.new\n\n\n # 123:5: modifier[method] ( type[method] )? IDENTIFIER parameters[method] ( method_body[method] | ';' )\n modifier(method)\n\n # 123:22: ( type[method] )?\n alt16 = 2\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Parses the parameters and body of +meth+
def parse_method_params_and_body container, single, meth, added_container token_listener meth do parse_method_parameters meth if meth.document_self or not @track_visibility then container.add_method meth elsif added_container then container.document_self = false end #...
[ "def parse_meta_method_params container, single, meth, tk, comment # :nodoc:\n token_listener meth do\n meth.params = ''\n\n look_for_directives_in meth, comment\n comment.normalize\n comment.extract_call_seq meth\n\n container.add_method meth\n\n last_tk = tk\n\n while tk = ge...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Parses the name of a method in +container+. Returns the method name, the container it is in (for def Foo.name) and if it is a singleton or regular method.
def parse_method_name container # :nodoc: skip_tkspace name_t = get_tk back_tk = skip_tkspace_without_nl singleton = false dot = get_tk if dot[:kind] == :on_period || (dot[:kind] == :on_op && dot[:text] == '::') then singleton = true name, container = parse_method_name_singleton co...
[ "def parse_method_name_singleton container, name_t # :nodoc:\n skip_tkspace\n name_t2 = get_tk\n\n if (:on_kw == name_t[:kind] && 'self' == name_t[:text]) || (:on_op == name_t[:kind] && '%' == name_t[:text]) then\n # NOTE: work around '[' being consumed early\n if :on_lbracket == name_t2[:kind]\n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
For the given +container+ and initial name token +name_t+ the method name is parsed from the token stream for a regular method.
def parse_method_name_regular container, name_t # :nodoc: if :on_op == name_t[:kind] && (%w{* & [] []= <<}.include?(name_t[:text])) then name_t[:text] else unless [:on_kw, :on_const, :on_ident].include?(name_t[:kind]) then warn "expected method name token, . or ::, got #{name_t.inspect}" ...
[ "def parse_method_name_singleton container, name_t # :nodoc:\n skip_tkspace\n name_t2 = get_tk\n\n if (:on_kw == name_t[:kind] && 'self' == name_t[:text]) || (:on_op == name_t[:kind] && '%' == name_t[:text]) then\n # NOTE: work around '[' being consumed early\n if :on_lbracket == name_t2[:kind]\n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
For the given +container+ and initial name token +name_t+ the method name and the new +container+ (if necessary) are parsed from the token stream for a singleton method.
def parse_method_name_singleton container, name_t # :nodoc: skip_tkspace name_t2 = get_tk if (:on_kw == name_t[:kind] && 'self' == name_t[:text]) || (:on_op == name_t[:kind] && '%' == name_t[:text]) then # NOTE: work around '[' being consumed early if :on_lbracket == name_t2[:kind] get_...
[ "def parse_method_name container # :nodoc:\n skip_tkspace\n name_t = get_tk\n back_tk = skip_tkspace_without_nl\n singleton = false\n\n dot = get_tk\n if dot[:kind] == :on_period || (dot[:kind] == :on_op && dot[:text] == '::') then\n singleton = true\n\n name, container = parse_method_na...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Parses an RDoc::NormalModule in +container+ with +comment+
def parse_module container, single, tk, comment container, name_t, = get_class_or_module container name = name_t[:text] mod = container.add_module RDoc::NormalModule, name mod.ignore unless container.document_children record_location mod read_documentation_modifiers mod, RDoc::CLASS_MODIFIERS...
[ "def parse_comment_tomdoc container, tk, comment\n return unless signature = RDoc::TomDoc.signature(comment)\n column = tk[:char_no]\n line_no = tk[:line_no]\n\n name, = signature.split %r%[ \\(]%, 2\n\n meth = RDoc::GhostMethod.new get_tkread, name\n record_location meth\n meth.line = li...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Parses an RDoc::Require in +context+ containing +comment+
def parse_require(context, comment) skip_tkspace_comment tk = get_tk if :on_lparen == tk[:kind] then skip_tkspace_comment tk = get_tk end name = tk[:text][1..-2] if :on_tstring == tk[:kind] if name then @top_level.add_require RDoc::Require.new(name, comment) else u...
[ "def look_for_directives_in(context, comment)\n preprocess = create_rdoc_preprocess\n\n preprocess.handle(comment) do |directive, param|\n case directive\n when \"stopdoc\"\n context.stop_doc\n \"\"\n when \"startdoc\"\n context.start_doc\n context.force_documentatio...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Retrieve comment body without =begin/=end
def retrieve_comment_body(tk) if :on_embdoc == tk[:kind] tk[:text].gsub(/\A=begin.*\n/, '').gsub(/=end\n?\z/, '') else tk[:text] end end
[ "def extract_comment comment\n if comment.text =~ /^#[ \\t]*:section:.*\\n/ then\n start = $`\n rest = $'\n\n comment.text = if start.empty? then\n rest\n else\n rest.sub(/#{start.chomp}\\Z/, '')\n end\n end\n\n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Parse up to +no+ symbol arguments
def parse_symbol_arg(no = nil) skip_tkspace_comment tk = get_tk if tk[:kind] == :on_lparen parse_symbol_arg_paren no else parse_symbol_arg_space no, tk end end
[ "def parse_symbol_arg_space no, tk # :nodoc:\n args = []\n\n unget_tk tk\n if tk = parse_symbol_in_arg\n args.push tk\n return args if no and args.size >= no\n end\n\n loop do\n skip_tkspace_without_nl\n\n tk1 = get_tk\n if tk1.nil? || :on_comma != tk1[:kind] then\n un...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Parses up to +no+ symbol arguments surrounded by () and places them in +args+.
def parse_symbol_arg_paren no # :nodoc: args = [] loop do skip_tkspace_comment if tk1 = parse_symbol_in_arg args.push tk1 break if no and args.size >= no end skip_tkspace_comment case (tk2 = get_tk)[:kind] when :on_rparen break when :on_comma ...
[ "def parse_symbol_arg(no = nil)\n skip_tkspace_comment\n\n tk = get_tk\n if tk[:kind] == :on_lparen\n parse_symbol_arg_paren no\n else\n parse_symbol_arg_space no, tk\n end\n end", "def parse_symbol_arg_space no, tk # :nodoc:\n args = []\n\n unget_tk tk\n if tk = parse_symbol_in...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Parses up to +no+ symbol arguments separated by spaces and places them in +args+.
def parse_symbol_arg_space no, tk # :nodoc: args = [] unget_tk tk if tk = parse_symbol_in_arg args.push tk return args if no and args.size >= no end loop do skip_tkspace_without_nl tk1 = get_tk if tk1.nil? || :on_comma != tk1[:kind] then unget_tk tk1 ...
[ "def parse_symbol_arg(no = nil)\n skip_tkspace_comment\n\n tk = get_tk\n if tk[:kind] == :on_lparen\n parse_symbol_arg_paren no\n else\n parse_symbol_arg_space no, tk\n end\n end", "def parse_symbol_arg_paren no # :nodoc:\n args = []\n\n loop do\n skip_tkspace_comment\n i...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Parses statements in the toplevel +container+
def parse_top_level_statements container comment = collect_first_comment look_for_directives_in container, comment throw :eof if container.done_documenting @markup = comment.format # HACK move if to RDoc::Context#comment= container.comment = comment if container.document_self unless comment....
[ "def visit_statements(node); end", "def visit_statements(node)\n children =\n node.body.reject do |child|\n child.is_a?(Comment) || child.is_a?(EmbDoc) ||\n child.is_a?(EndContent) || child.is_a?(VoidStmt)\n end\n\n case children.length\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Determines the visibility in +container+ from +tk+
def parse_visibility(container, single, tk) vis_type, vis, singleton = get_visibility_information tk, single skip_tkspace_comment false ptk = peek_tk # Ryan Davis suggested the extension to ignore modifiers, because he # often writes # # protected unless $TESTING # if [:on_nl, :o...
[ "def visibility(name)\n Tk.execute_only(:tkwait, :visibility, name)\n end", "def get_visibility_information tk, single # :nodoc:\n vis_type = tk[:text]\n singleton = single == SINGLE\n\n vis =\n case vis_type\n when 'private' then :private\n when 'protected' then :protected\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Directives are modifier comments that can appear after class, module, or method names. For example: def fred :yields: a, b or: class MyClass :nodoc: We return the directive name and any parameters as a two element array if the name is in +allowed+. A directive can be found anywhere up to the end of the current line.
def read_directive allowed tokens = [] while tk = get_tk do tokens << tk if :on_nl == tk[:kind] or (:on_kw == tk[:kind] && 'def' == tk[:text]) then return elsif :on_comment == tk[:kind] or :on_embdoc == tk[:kind] then return unless tk[:text] =~ /\s*:?([\w-]+):\s*(.*)/ ...
[ "def process_directives\n end", "def get_directives ctx\n directives = []\n this_starting_tok = ctx.getSourceInterval.a\n\n i = this_starting_tok - 1\n curr_tok = i > 0 ? @tokens.get(i) : nil\n while curr_tok && curr_tok.channel != 0\n if curr_tok.channel == 2\n directive...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Records the location of this +container+ in the file for this parser and adds it to the list of classes and modules in the file.
def record_location container # :nodoc: case container when RDoc::ClassModule then @top_level.add_to_classes_or_modules container end container.record_location @top_level end
[ "def file\n add FileCursor.new\n end", "def add_location_to_context(iLocation)\n # * *iLocation* (_String_): Directory\n $LOAD_PATH << iLocation\n end", "def register_file_info(object, file = parser.file, line = statement.line, comments = statement.comments)\n object.add_file(f...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
skip the var [in] part of a 'for' statement
def skip_for_variable skip_tkspace_without_nl get_tk skip_tkspace_without_nl tk = get_tk unget_tk(tk) unless :on_kw == tk[:kind] and 'in' == tk[:text] end
[ "def command_skip\r\n @index += 1 while @list[@index + 1].indent > @indent\r\n end", "def skip_token(nocov_token = T.unsafe(nil)); end", "def for_loop(var, set, body)\n raise NotImplementedError.new('for_loop')\n end", "def leave_optimize_for(node, env)\n if node.is_a?(Twig::Node::For)\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Skips the next method in +container+
def skip_method container meth = RDoc::AnyMethod.new "", "anon" parse_method_parameters meth parse_statements container, false, meth end
[ "def skip_leader\n raise NotImplementedError\n end", "def skip!\n @skip ||= true\n end", "def skip?\n raise NotImplementedError\n end", "def skipped?; end", "def skip\n self + 2\n end", "def skip!\n self.body.skip!\n end", "def skip\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Updates visibility in +container+ from +vis_type+ and +vis+.
def update_visibility container, vis_type, vis, singleton # :nodoc: new_methods = [] case vis_type when 'module_function' then args = parse_symbol_arg container.set_visibility_for args, :private, false container.methods_matching args do |m| s_m = m.dup record_location s_m...
[ "def set_visibility(container, subname, visibility_default, visibility_info)\n return unless container || subname || visibility_default || visibility_info\n not_found = true\n visibility_info.collect!{ |info|\n if info[\"name\"] == subname ||\n @options.ignore_case && info[\"name\"].upcase ==...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Serves the asset at the path in +req+ for +generator_name+ via +res+.
def asset generator_name, req, res asset_dir = @asset_dirs[generator_name] asset_path = File.join asset_dir, req.path if_modified_since req, res, asset_path res.body = File.read asset_path res.content_type = case req.path when /\.css\z/ then 'text/css' ...
[ "def serve_asset(asset_name)\n asset_path = local_asset_path(asset_name)\n\n # Rudimentary mime type detection\n mime = 'application/octet-stream'\n map = {\n 'ico' => 'image/vnd.microsoft.icon',\n 'png' => 'image/png',\n 'css' => 'text/css'\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET request entry point. Fills in +res+ for the path, etc. in +req+.
def do_GET req, res req.path.sub!(/\A#{Regexp.escape @mount_path}/, '') if @mount_path case req.path when '/' then root req, res when '/js/darkfish.js', '/js/jquery.js', '/js/search.js', %r%^/css/%, %r%^/images/%, %r%^/fonts/% then asset :darkfish, req, res when '/js/navigation...
[ "def do_GET(req, res)\n domain, resource, id, format = parse_request_path(req.path_info)\n if domain && resource && id && format == 'xml' # element or query\n unless id == 'query'\n attributes = sdb_get_item(domain, \"#{resource}_#{id}\")\n raise WEBrick::HTTPStatus::NotFound unle...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Fills in +res+ with the class, module or page for +req+ from +store+. +path+ is relative to the mount_path and is used to determine the class, module or page name (/RDoc/Servlet.html becomes RDoc::Servlet). +generator+ is used to create the page.
def documentation_page store, generator, path, req, res text_name = path.chomp '.html' name = text_name.gsub '/', '::' if klass = store.find_class_or_module(name) then res.body = generator.generate_class klass elsif page = store.find_text_page(name.sub(/_([^_]*)\z/, '.\1')) then res.body = ...
[ "def generator_for store\n generator = RDoc::Generator::Darkfish.new store, @options\n generator.file_output = false\n generator.asset_rel_path = '..'\n\n rdoc = RDoc::RDoc.new\n rdoc.store = store\n rdoc.generator = generator\n rdoc.options = @options\n\n @options.main_page = store.ma...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Creates the JSON search index on +res+ for the given +store+. +generator+ must respond to \json_index to build. +req+ is ignored.
def documentation_search store, generator, req, res json_index = @cache[store].fetch :json_index do @cache[store][:json_index] = JSON.dump generator.json_index.build_index end res.content_type = 'application/javascript' res.body = "var search_data = #{json_index}" end
[ "def generate_search_index\n debug_msg \"Generating search index\"\n \n index = {\n :searchIndex => [],\n :longSearchIndex => [],\n :info => []\n }\n \n add_class_search_index(index)\n add_method_search_index(index)\n add_file_search_index(index)\n \n debug_msg \" writi...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns the RDoc::Store and path relative to +mount_path+ for documentation at +path+.
def documentation_source path _, source_name, path = path.split '/', 3 store = @stores[source_name] return store, path if store store = store_for source_name store.load_all @stores[source_name] = store return store, path end
[ "def store_for source_name\n case source_name\n when 'home' then\n RDoc::Store.new RDoc::RI::Paths.home_dir, :home\n when 'ruby' then\n RDoc::Store.new RDoc::RI::Paths.system_dir, :system\n when 'site' then\n RDoc::Store.new RDoc::RI::Paths.site_dir, :site\n when /\\Aextra-(\\d+)\\z/ t...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Generates an error page for the +exception+ while handling +req+ on +res+.
def error exception, req, res backtrace = exception.backtrace.join "\n" res.content_type = 'text/html' res.status = 500 res.body = <<-BODY <!DOCTYPE html> <html> <head> <meta content="text/html; charset=UTF-8" http-equiv="Content-Type"> <title>Error - #{ERB::Util.html_escape exception.class}</title> ...
[ "def render_exception(ex, log_tag=nil)\n Rails.logger.error \"Reference ID: #{@request_id} - #{ex.message}\\n #{ex.backtrace.join(\"\\n \")}\"\n error_code = ex.respond_to?('code') ? ex.code : 1\n message = ex.message\n if ex.kind_of? OpenShift::UserException\n status = :unprocessable_entity\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Instantiates a Darkfish generator for +store+
def generator_for store generator = RDoc::Generator::Darkfish.new store, @options generator.file_output = false generator.asset_rel_path = '..' rdoc = RDoc::RDoc.new rdoc.store = store rdoc.generator = generator rdoc.options = @options @options.main_page = store.main @options...
[ "def initialize(config)\n @crypt = Crypt::Blowfish.new( config.salt )\n @config = config\n end", "def build_wfid_generator\n\n #init_service(:s_wfid_generator, DefaultWfidGenerator)\n #init_service(:s_wfid_generator, UuidWfidGenerator)\n init_service(:s_wfid_generator, KotobaWfidGenerator)\n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Handles the IfModifiedSince HTTP header on +req+ for +path+. If the file has not been modified a Not Modified response is returned. If the file has been modified a LastModified header is added to +res+.
def if_modified_since req, res, path = nil last_modified = File.stat(path).mtime if path res['last-modified'] = last_modified.httpdate return unless ims = req['if-modified-since'] ims = Time.parse ims unless ims < last_modified then res.body = '' raise WEBrick::HTTPStatus::NotModifie...
[ "def http_if_modified_since?(path)\n if since = request.env['HTTP_IF_MODIFIED_SINCE']\n begin\n require 'time'\n since = Time.httpdate(since) rescue Time.parse(since)\n return since < File.mtime(path)\n rescue Exception\n end\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns an Array of installed documentation. Each entry contains the documentation name (gem name, 'Ruby Documentation', etc.), the path relative to the mount point, whether the documentation exists, the type of documentation (See RDoc::RI::Pathseach) and the filesystem to the RDoc::Store for the documentation.
def installed_docs extra_counter = 0 ri_paths.map do |path, type| store = RDoc::Store.new path, type exists = File.exist? store.cache_path case type when :gem then gem_path = path[%r%/([^/]*)/ri$%, 1] [gem_path, "#{gem_path}/", exists, type, path] when :system then...
[ "def docs\n unless @docs\n @docs = []\n content().each_line do |l|\n next unless l =~ %r{/usr/share/doc/packages}\n @docs << l\n end\n end\n @docs\n end", "def install_docs(installed_gem_spec)\n doc_manager = ::Gem::DocManager.new(installed_gem_spec)\n doc_...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns a 404 page built by +generator+ for +req+ on +res+.
def not_found generator, req, res, message = nil message ||= "The page <kbd>#{ERB::Util.h req.path}</kbd> was not found" res.body = generator.generate_servlet_not_found message res.status = 404 end
[ "def not_found!\n res.status = 404\n render \"public/shared/404\"\n halt res.finish\n end", "def res_404\n create_response('Not Found', 404, {'Content-Type' => 'text/plain'})\n end", "def not_found!\n if accept?(\"text/html\")\n render_file(\"public/404.html\", 404, false)\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Enumerates the ri paths. See RDoc::RI::Pathseach
def ri_paths &block RDoc::RI::Paths.each true, true, true, :all, *@extra_doc_dirs, &block #TODO: pass extra_dirs end
[ "def all_paths\n list(\".\").map { |path| expand_path(path) }\n end", "def each_object_path (path=@basepath, &block)\n\n Find.find(path) do |p|\n\n next unless File.exist?(p)\n next if File.stat(p).directory?\n #next unless OpenWFE::ends_with(p, '.yaml')\n ne...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Generates the root page on +res+. +req+ is ignored.
def root req, res generator = RDoc::Generator::Darkfish.new nil, @options res.body = generator.generate_servlet_root installed_docs res.content_type = 'text/html' end
[ "def root\n get '/'\n end", "def do_GET req, res\n req.path.sub!(/\\A#{Regexp.escape @mount_path}/, '') if @mount_path\n\n case req.path\n when '/' then\n root req, res\n when '/js/darkfish.js', '/js/jquery.js', '/js/search.js',\n %r%^/css/%, %r%^/images/%, %r%^/fonts/% then\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Generates a search index for the root page on +res+. +req+ is ignored.
def root_search req, res search_index = [] info = [] installed_docs.map do |name, href, exists, type, path| next unless exists search_index << name case type when :gem gemspec = path.gsub(%r%/doc/([^/]*?)/ri$%, '/specifications/\1.gemspe...
[ "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 do_GET req, res\n req.path.sub!(/\\A#{Regexp.escape @mount_path}/, '') if @mount_path\n\n case req.path\n wh...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Displays documentation for +req+ on +res+, whether that be HTML or some asset.
def show_documentation req, res store, path = documentation_source req.path if_modified_since req, res, store.cache_path generator = generator_for store case path when nil, '', 'index.html' then res.body = generator.generate_index when 'table_of_contents.html' then res.body = gene...
[ "def get(req)\n return not_found unless ::File.exists?(file_path(req))\n @title = header(req).options[:raw_text] unless header(req).nil?\n @subsection = Lynr::Model::Slug.new(type(req))\n @legal_html = document(req).to_html\n render 'legal.erb'\n end", "def documentation\n dataset =...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns an RDoc::Store for the given +source_name+ ('ruby' or a gem name).
def store_for source_name case source_name when 'home' then RDoc::Store.new RDoc::RI::Paths.home_dir, :home when 'ruby' then RDoc::Store.new RDoc::RI::Paths.system_dir, :system when 'site' then RDoc::Store.new RDoc::RI::Paths.site_dir, :site when /\Aextra-(\d+)\z/ then index ...
[ "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 find_store name\n @stores.each...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Creates a new Stats that will have +num_files+. +verbosity+ defaults to 1 which will create an RDoc::Stats::Normal outputter.
def initialize store, num_files, verbosity = 1 @num_files = num_files @store = store @coverage_level = 0 @doc_items = nil @files_so_far = 0 @fully_documented = false @num_params = 0 @percent_doc = nil @start = Time.now @undoc_params = 0...
[ "def store_stats\n return if @stats_filename.nil?\n File.open(@stats_filename, \"w\") do |file|\n file.puts \"Total Reads: #{total_read_cnt}\"\n file.puts \"Post-Filter Reads: #{pass_read_cnt}\"\n end\n end", "def create_custom_stats_files\n new_stats_dir_path = @flowcell.paths.custom_sta...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Records the parsing of an alias +as+.
def add_alias as @display.print_alias as end
[ "def as!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 1 )\n\n\n\n type = AS\n channel = ANTLR3::DEFAULT_CHANNEL\n # - - - - label initialization - - - -\n\n\n # - - - - main rule block - - - -\n # at line 31:5: 'as'\n match( \"as\" )\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Calculates documentation totals and percentages for classes, modules, constants, attributes and methods.
def calculate return if @doc_items ucm = @store.unique_classes_and_modules classes = @store.unique_classes.reject { |cm| cm.full_name == 'Object' } constants = [] ucm.each { |cm| constants.concat cm.constants } methods = [] ucm.each { |cm| methods.concat cm.method_list } attributes ...
[ "def doc_method_percent(klass)\n total = klass.meths.size.to_f\n undocd = klass.meths.select { |m| m.docstring.empty? }.size.to_f\n\n undocd.zero? ? 0.0 : (undocd / total)\n end", "def percent_doc\n return @percent_doc if @percent_doc\n\n @fully_documented = (@num_items - @doc_ite...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Sets coverage report level. Accepted values are: false or nil:: No report 0:: Classes, modules, constants, attributes, methods 1:: Level 0 + method parameters
def coverage_level= level level = -1 unless level @coverage_level = level end
[ "def set_level(level)\n @level = level\n end", "def level=(value)\n @level = value\n end", "def level=(level, update_config = true)\n super(level)\n @config[:'log-level'] = level if update_config\n end", "def report!\n simplecov\n Coveralls.push!\n\n nil...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Calculates the percentage of items documented.
def percent_doc return @percent_doc if @percent_doc @fully_documented = (@num_items - @doc_items) == 0 @percent_doc = @doc_items.to_f / @num_items * 100 if @num_items.nonzero? @percent_doc ||= 0 @percent_doc end
[ "def percentage\n items_done.to_f / items_size * 100\n end", "def doc_method_percent(klass)\n total = klass.meths.size.to_f\n undocd = klass.meths.select { |m| m.docstring.empty? }.size.to_f\n\n undocd.zero? ? 0.0 : (undocd / total)\n end", "def percentage\n ( earned_marks / se...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns a report on which items are not documented
def report if @coverage_level > 0 then extend RDoc::Text end if @coverage_level.zero? then calculate return great_job if @num_items == @doc_items end ucm = @store.unique_classes_and_modules report = RDoc::Markup::Document.new report << RDoc::Markup::Paragraph.new('The f...
[ "def report_missing_documentation(arg0)\n end", "def print_undocumented_objects; end", "def missing_documentation\n analytics_methods.flat_map do |method_object|\n error_prefix = \"#{method_object.file}:#{method_object.line} #{method_object.name}\"\n errors = []\n\n param_names = method_objec...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns a report on undocumented attributes in ClassModule +cm+
def report_attributes cm return if cm.attributes.empty? report = [] cm.each_attribute do |attr| next if attr.documented? line = attr.line ? ":#{attr.line}" : nil report << " #{attr.definition} :#{attr.name} # in file #{attr.file.full_name}#{line}\n" report << "\n" end rep...
[ "def dump_classmod_desc( cm )\n { \"name\" => cm.full_name,\n \"constants\" => cm.constants.collect{ |c| dump_ri(c) },\n \"includes\" => cm.includes.collect{ |i| dump_ri(i) },\n \"details\" => dump_markup( cm.comment ),\n \"imethods\" => cm.instance_methods.collect{ |meth|\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns a report on undocumented items in ClassModule +cm+
def report_class_module cm return if cm.fully_documented? and @coverage_level.zero? return unless cm.display? report = RDoc::Markup::Document.new if cm.in_files.empty? then report << RDoc::Markup::Paragraph.new("#{cm.definition} is referenced but empty.") report << RDoc::Markup::Paragraph....
[ "def report_attributes cm\n return if cm.attributes.empty?\n\n report = []\n\n cm.each_attribute do |attr|\n next if attr.documented?\n line = attr.line ? \":#{attr.line}\" : nil\n report << \" #{attr.definition} :#{attr.name} # in file #{attr.file.full_name}#{line}\\n\"\n report << \"...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns a report on undocumented constants in ClassModule +cm+
def report_constants cm return if cm.constants.empty? report = [] cm.each_constant do |constant| # TODO constant aliases are listed in the summary but not reported # figure out what to do here next if constant.documented? || constant.is_alias_for line = constant.line ? ":#{constan...
[ "def all_constants\n Registry.all(:constant).map do |m|\n # This is an example of a constant:\n # Vlogger::Severity::SEVERITY_TO_COLOR\n # The name of the constant is as above. The name of the file\n # is the Vlogger/Severity.html\n t = [m.to_s, \"Constant\", \"#{DOC_DIR}/\" + transpo...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns a report on undocumented methods in ClassModule +cm+
def report_methods cm return if cm.method_list.empty? report = [] cm.each_method do |method| next if method.documented? and @coverage_level.zero? if @coverage_level > 0 then params, undoc = undoc_params method @num_params += params unless undoc.empty? then ...
[ "def report_class_module cm\n return if cm.fully_documented? and @coverage_level.zero?\n return unless cm.display?\n\n report = RDoc::Markup::Document.new\n\n if cm.in_files.empty? then\n report << RDoc::Markup::Paragraph.new(\"#{cm.definition} is referenced but empty.\")\n report << RDoc::Mar...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Determines which parameters in +method+ were not documented. Returns a total parameter count and an Array of undocumented methods.
def undoc_params method @formatter ||= RDoc::Markup::ToTtOnly.new params = method.param_list params = params.map { |param| param.gsub(/^\*\*?/, '') } return 0, [] if params.empty? document = parse method.comment tts = document.accept @formatter undoc = params - tts [params.length,...
[ "def missing_documentation\n analytics_methods.flat_map do |method_object|\n error_prefix = \"#{method_object.file}:#{method_object.line} #{method_object.name}\"\n errors = []\n\n param_names = method_object.parameters.map { |p| p.first }\n _splat_params, other_params = param_names.partition ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Prints a file with a progress bar
def print_file files_so_far, filename progress_bar = sprintf("%3d%% [%2d/%2d] ", 100 * files_so_far / @num_files, files_so_far, @num_files) if $stdout.tty? # Print a progress bar, but make sure it fits on a single line. Fil...
[ "def print_file(files_so_far, filename)\n progress_bar = sprintf(\"%3d%% [%2d/%2d] \",\n 100 * (files_so_far + 1) / @total_files,\n files_so_far + 1,\n @total_files)\n\n if $stdout.tty?\n # Print a progress bar, bu...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Prints when an alias is added
def print_alias(*) end
[ "def add_alias as\n @display.print_alias as\n end", "def add\n append_alias\n write_aliases\n show_aliases\n end", "def add_alias(event)\n assert_permissions(event) # Only the botmaster can execute this\n\n msg = event.content\n aka = parse_term(msg)\n raise OutteError.new \"Yo...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Prints when an attribute is added
def print_attribute(*) end
[ "def add_attribute(name, &block); end", "def on_attribute(value)\n add_token(:T_ATTR, value)\n end", "def attr_printer(santa) \n\tputs \"HO HO HO! Here comes a(n) #{santa.ethnicity} santa who identifies as #{santa.gender}.\\nThis santa is #{santa.age} years young!\"\nend", "def attribute; end", ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Prints when a constant is added
def print_constant(*) end
[ "def const(name, value)\n @data << \"#{name}\\tequ #{value}\"\n end", "def on_const(value); end", "def on_top_const_field(constant); end", "def constants() end", "def dump_constants(io)\n @constants.each do |name, constant|\n name = [@prefix, name].join '.' if @prefix\n io.pu...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Prints when a method is added
def print_method(*) end
[ "def display_method_info\n end", "def print\n\t\tputs name + className + \" says \" + call\n\tend", "def print\r\n\t\tputs name + className + \" says \" + call\r\n\tend", "def display_method_list\n end", "def print_methods\n m = \"----- #{self} (methods) -----\\n\"\n m << methods.sort.join(\"\\n\")\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Prints when a module is added
def print_module(*) end
[ "def auto_add\n send Rainbow('Adding modules...').yellow\n module_classes = ObjectSpace.each_object(Class).select do |c|\n c.included_modules.include? CPGUI::AppModule\n end\n add_classes(module_classes)\n send Rainbow('Successfully added modules!').green\n end", "def show_modul...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Instructs +compiler+ how to write to +io_variable+
def set_eoutvar compiler, io_variable compiler.put_cmd = "#{io_variable}.write" compiler.insert_cmd = "#{io_variable}.write" compiler.pre_cmd = [] compiler.post_cmd = [] end
[ "def _do_write(io)\n raise \"can't write whilst reading\" if @in_read\n io.writebytes(val_to_str(_value))\n end", "def setio(input, output)\n @@input = input\n @@output = output\n end", "def io=(io) # :nodoc:\n io.extend Io unless io.kind_of?(Io)\n @io = io\n end", "def output...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Initializes state for visibility of this CodeObject and its children.
def initialize_visibility # :nodoc: @document_children = true @document_self = true @done_documenting = false @force_documentation = false @received_nodoc = false @ignored = false @suppressed = false @track_visibility = true end
[ "def visibility_will_change_with_lifecycle_hooks!\n @visibility_lifecycle_previous_state = visibility\n visibility_will_change_without_lifecycle_hooks!\n end", "def initialize_visibility\n default_accessor = @options.fetch(:accessor)\n @reader_visibility = @options.fetch(:reader, defa...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Should this CodeObject be displayed in output? A code object should be displayed if: The item didn't have a nodoc or wasn't in a container that had nodoc The item wasn't ignored The item has documentation and was not suppressed
def display? @document_self and not @ignored and (documented? or not @suppressed) end
[ "def render_doc_markup_for(code_object); end", "def print_undocumented_objects; end", "def nodoc\n @hide_commands_without_desc and description.nil?\n end", "def code_description_support; end", "def content_for(code_object)\n Code.new(render_doc_markup_for(code_object),\n start_lin...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Does this object have a comment with content or is received_nodoc true?
def documented? @received_nodoc or !@comment.empty? end
[ "def documented?\n return true if @received_nodoc\n return false if @comment_location.empty?\n @comment_location.any? { |comment, _| not comment.empty? }\n end", "def nodoc_comment?(node, ast_with_comments, require_all = false)\n return false unless node\n nodoc_node = node.children.fi...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Yields each parent of this CodeObject. See also RDoc::ClassModuleeach_ancestor
def each_parent code_object = self while code_object = code_object.parent do yield code_object end self end
[ "def each_ancestor # :nodoc:\n end", "def each_ancestor\n ancestor = parent_blueprint\n while ancestor\n yield ancestor\n ancestor = ancestor.parent_blueprint\n end\n end", "def parentwalk(block)\r\n raise \"Must be passed a block\" unless block.kind_of?(Proc)\r\n all_pare...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Force the documentation of this object unless documentation has been turned off by :enddoc: HACK untested, was assigning to an ivar
def force_documentation=(value) @force_documentation = value unless @done_documenting end
[ "def no_doc!\n @controller.doc = false\n end", "def documented?\n @options[:doc] != false\n end", "def original_docstring\n implicit_docstring? ? \"\" : super\n end", "def doc_string; end", "def documentation=(value); @_sequence.documentation(value) end", "d...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Sets the full_name overriding any computed full name. Set to +nil+ to clear RDoc's cached value
def full_name= full_name @full_name = full_name end
[ "def set_full_name\n unless self.first_name.nil? or self.last_name.nil?\n self.full_name = \"#{self.first_name.capitalize} #{self.last_name.capitalize}\"\n else\n self.full_name = \"#{self.first_name} #{self.last_name}\"\n end\n end", "def full_name\n display_optional name.ful...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Use this to ignore a CodeObject and all its children until found again (record_location is called). An ignored item will not be displayed in documentation. See github issue 55 The ignored status is temporary in order to allow implementation details to be hidden. At the end of processing a file RDoc allows all classes a...
def ignore return unless @track_visibility @ignored = true stop_doc end
[ "def unignore\n @ignored = false\n end", "def ignore\n Parslet::Atoms::Ignored.new(self)\n end", "def ignore(node)\n puts \"ignoring #{node.name} - custom ignore\"\n node.ignore\nend", "def ignore!\n @should_ignore = true\n end", "def ignore *node\n end", "def ignored?(object)\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Has this class been ignored? See also ignore
def ignored? @ignored end
[ "def ignore?\n @should_ignore\n end", "def ignored?\n\t\treturn self.status == 'I'\n\tend", "def ignoring?(object)\n interest_in(object) == :ignoring\n end", "def has_ignored?(object)\n ignores.exists?(:ignoreable_id => object.id, :ignoreable_type => object.class.to_s)\n end", "def i...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
File name of our parent
def parent_file_name @parent ? @parent.base_name : '(unknown)' end
[ "def parent_file_name\n @parent ? @parent.file_base_name : '(unknown)'\n end", "def parent_name\n parent_info && parent_info.name\n end", "def file_name\n @file_name ||= File.basename tree\n end", "def relative_file_name; end", "def parent\n parent = Pathname.new(to_s).paren...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Records the RDoc::TopLevel (file) where this code object was defined
def record_location top_level @ignored = false @suppressed = false @file = top_level end
[ "def record_location container # :nodoc:\n case container\n when RDoc::ClassModule then\n @top_level.add_to_classes_or_modules container\n end\n\n container.record_location @top_level\n end", "def get_toplevels\n RDoc::TopLevel\n end", "def files_toplevel\n @files_toplevel ||= @fi...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Use this to suppress a CodeObject and all its children until the next file it is seen in or documentation is discovered. A suppressed item with documentation will be displayed while an ignored item with documentation may not be displayed.
def suppress return unless @track_visibility @suppressed = true stop_doc end
[ "def suppressFor _obj, _args\n \"_obj suppressFor _args;\" \n end", "def suppress_parents container, ancestor # :nodoc:\n while container and container != ancestor do\n container.suppress unless container.documented?\n container = container.parent\n end\n end", "def ignore\n return u...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Has this class been suppressed? See also suppress
def suppressed? @suppressed end
[ "def suppressed?\n status == 'suppressed'\n end", "def suppressed?\n holding_data.dig('holding_suppress_from_publishing') == 'true'\n end", "def have_quiet_prototype?\n ! @have_quiet_prototype.nil?\n end", "def safe_class?\n true\n end", "def save!(*args) # :nodoc:\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Adds +module+ as an enclosure (namespace) for the given +variable+ for C files.
def add_c_enclosure variable, namespace @c_enclosure_classes[variable] = namespace end
[ "def find_c_enclosure variable\n @c_enclosure_classes.fetch variable do\n break unless name = @c_enclosure_names[variable]\n\n mod = find_class_or_module name\n\n unless mod then\n loaded_mod = load_class_data name\n\n file = loaded_mod.in_files.first\n\n return unless file # ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Adds C variables from an RDoc::Parser::C
def add_c_variables c_parser filename = c_parser.top_level.relative_name @c_class_variables[filename] = make_variable_map c_parser.classes @c_singleton_class_variables[filename] = c_parser.singleton_classes end
[ "def var_cte\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 27 )\n\n\n __C_INT38__ = nil\n __C_FLOAT39__ = nil\n __C_CHAR40__ = nil\n __C_BOOL41__ = nil\n\n\n begin\n # at line 258:5: ( var_access | C_INT | C_FLOAT | C_CHAR | C_BOOL )...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Adds the file with +name+ as an RDoc::TopLevel to the store. Returns the created RDoc::TopLevel.
def add_file absolute_name, relative_name: absolute_name, parser: nil unless top_level = @files_hash[relative_name] then top_level = RDoc::TopLevel.new absolute_name, relative_name top_level.parser = parser if parser top_level.store = self @files_hash[relative_name] = top_level @text_f...
[ "def add_prince name\n if File.exist?(name)\n filename = File.basename(name)\n filepath = File.expand_path(name)\n element = @doc.root.elements[\"PrinceText\"]\n if element.has_attributes?\n element.attributes[\"name\"] = filename\n element.attributes[\"path\"] = filepath\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Attributes cache accessor. Maps a class to an Array of its attributes.
def attributes @cache[:attributes] end
[ "def get_attributes(klass)\n return @attribute_store[klass] if @attribute_store.key?(klass)\n\n attributes = []\n klass.ancestors.map do |k|\n hash = k.instance_variable_get(:@class_kit_attributes)\n if hash != nil\n hash.values.each do |a|\n attributes.push(a)\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Path to the cache file
def cache_path File.join @path, 'cache.ri' end
[ "def cache_file_path\n raise IOError.new 'Write permission is required for cache directory' unless File.writable?(@args[:cache_directory])\n \"#{@args[:cache_directory]}/#{Digest::SHA1.hexdigest((@args[:cache_ref] || @path).to_s + size.to_s + last_modified.to_s)}.cache\"\n end", "def cache_path\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Path to the ri data for +klass_name+
def class_file klass_name name = klass_name.split('::').last File.join class_path(klass_name), "cdesc-#{name}.ri" end
[ "def data_path\n self.class.data_path\n end", "def class_path klass_name\n File.join @path, *klass_name.split('::')\n end", "def data_filename; base_name + \".data\"; end", "def data_path(filetype)\n \"#{@datapath}.#{filetype}.txt\"\n end", "def type_path\n type_directory + \"#{@nam...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Class methods cache accessor. Maps a class to an Array of its class methods (not full name).
def class_methods @cache[:class_methods] end
[ "def instance_methods\n @cache[:instance_methods]\n end", "def select_methods(pattern)\n methods = []\n class_cache.keys.sort.each do |klass|\n class_cache[klass][\"instance_methods\"].map{|h|h[\"name\"]}.grep(pattern) do |name|\n method = load_cache_for(klass)[klass+'#'+name]\n metho...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Path where data for +klass_name+ will be stored (methods or class data)
def class_path klass_name File.join @path, *klass_name.split('::') end
[ "def data_path\n self.class.data_path\n end", "def data_path(filetype)\n \"#{@datapath}.#{filetype}.txt\"\n end", "def data_path name\n File.join File.dirname(__FILE__), 'data', \"#{ name }.yml\"\nend", "def data_dir\n path_to('data')\n end", "def class_cache_file_path\n File.joi...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Removes empty items and ensures item in each collection are unique and sorted
def clean_cache_collection collection # :nodoc: collection.each do |name, item| if item.empty? then collection.delete name else # HACK mongrel-1.1.5 documents its files twice item.uniq! item.sort! end end end
[ "def test_emptyItem\n c = ItemComparer.new()\n new_list = [].sort{|x,y| c.compare(x,y)}\n return new_list.size == 0\n end", "def add_unique(*items)\n return unless items.count > 0\n notify_will_change!\n @collection = collection | items.flatten\n @collection\n end", "def without...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Prepares the RDoc code object tree for use by a generator. It finds unique classes/modules defined, and replaces classes/modules that are aliases for another one by a copy with RDoc::ClassModuleis_alias_for set. It updates the RDoc::ClassModuleconstant_aliases attribute of "real" classes or modules. It also completely ...
def complete min_visibility fix_basic_object_inheritance # cache included modules before they are removed from the documentation all_classes_and_modules.each { |cm| cm.ancestors } unless min_visibility == :nodoc then remove_nodoc @classes_hash remove_nodoc @modules_hash end @uniqu...
[ "def update_aliases\n constants.each do |const|\n next unless cm = const.is_alias_for\n cm_alias = cm.dup\n cm_alias.name = const.name\n\n # Don't move top-level aliases under Object, they look ugly there\n unless RDoc::TopLevel === cm_alias.parent then\n cm_alias.parent = self\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Finds the enclosure (namespace) for the given C +variable+.
def find_c_enclosure variable @c_enclosure_classes.fetch variable do break unless name = @c_enclosure_names[variable] mod = find_class_or_module name unless mod then loaded_mod = load_class_data name file = loaded_mod.in_files.first return unless file # legacy data sour...
[ "def add_c_enclosure variable, namespace\n @c_enclosure_classes[variable] = namespace\n end", "def find_variable(variable)\n for scope in $current_scope_list.sort{|a, b| b <=> a}\n if $var_list[scope][variable] != nil\n return $var_list[scope][variable]\n end\n end\n return nil\nend", "def mak...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Finds the class with +name+ starting in namespace +from+
def find_class_named_from name, from from = find_class_named from unless RDoc::Context === from until RDoc::TopLevel === from do return nil unless from klass = from.find_class_named name return klass if klass from = from.parent end find_class_named name end
[ "def findClassesThatMatch(name)\n fname = name.tr(':', '_')\n return ClassIndex.findClasses(fname)\n end", "def find_class_named(name)\n return self if full_name == name\n @classes.each_value {|c| return c if c.find_class_named(name) }\n nil\n end", "def class_for_name qualified_name\n raise...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Finds the module with +name+ in all discovered modules
def find_module_named name @modules_hash[name] end
[ "def find_module_named(name)\n find_class_or_module(name)\n end", "def find_module_named(name)\n find_class_or_module_named(name) || find_enclosing_module_named(name)\n end", "def find_module_named(name)\n find_class_or_module_named(name) || find_enclosing_module_named(name)\n end", "def find_...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Fixes the erroneous BasicObject in 1.9. Because we assumed all classes without a stated superclass inherit from Object, we have the above wrong inheritance. We fix BasicObject right away if we are running in a Ruby version >= 1.9.
def fix_basic_object_inheritance basic = classes_hash['BasicObject'] return unless basic basic.superclass = nil end
[ "def orig_object; end", "def inherited(_sub)\n raise Error, \"cannot subclass #{self}\" unless self == Object\n end", "def fix_dispatch_object_header!\n $stdout.print 'Creating patched copy of dispatch/object.h... '\n $stdout.flush\n status = 'failed'\n if (srcfile = find_header_file('dispatch/o...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Instance methods cache accessor. Maps a class to an Array of its instance methods (not full name).
def instance_methods @cache[:instance_methods] end
[ "def class_methods\n @cache[:class_methods]\n end", "def cached_methods\n raise NotImplementedError\n end", "def instance_methods\n select { |e| e.is_a?(InstanceMethod) }\n end", "def inspect_instance_methods\n return [] unless constant.respond_to?(:instance_methods)\n\n methods ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Loads ri data for +klass_name+ and hooks it up to this store.
def load_class klass_name obj = load_class_data klass_name obj.store = self case obj when RDoc::NormalClass then @classes_hash[klass_name] = obj when RDoc::SingleClass then @classes_hash[klass_name] = obj when RDoc::NormalModule then @modules_hash[klass_name] = obj end ...
[ "def define_loader(klass)\n klass.define_reader(@load_name)\n\n self\n end", "def load!\n class_names.each { |name| self[name] }\n end", "def load_class_data klass_name\n file = class_file klass_name\n\n File.open file, 'rb' do |io|\n Marshal.load io.read\n end\n re...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Loads ri data for +klass_name+
def load_class_data klass_name file = class_file klass_name File.open file, 'rb' do |io| Marshal.load io.read end rescue Errno::ENOENT => e error = MissingFileError.new(self, file, klass_name) error.set_backtrace e.backtrace raise error end
[ "def load_class klass_name\n obj = load_class_data klass_name\n\n obj.store = self\n\n case obj\n when RDoc::NormalClass then\n @classes_hash[klass_name] = obj\n when RDoc::SingleClass then\n @classes_hash[klass_name] = obj\n when RDoc::NormalModule then\n @modules_hash[klass_name] ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Loads ri data for +method_name+ in +klass_name+
def load_method klass_name, method_name file = method_file klass_name, method_name File.open file, 'rb' do |io| obj = Marshal.load io.read obj.store = self obj.parent = find_class_or_module(klass_name) || load_class(klass_name) unless obj.parent obj end rescue Er...
[ "def load_data\n raise NotImplementedError, 'Should be defined in subclass'\n end", "def method_missing(meth, *args, &block)\n (ARRAY.respond_to?(meth) ? @instance.send(:load_associated_objects, @reflection, @reload) : @instance.send(@reflection.dataset_method)).\n send(meth, *args, &b...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Converts the variable => ClassModule map +variables+ from a C parser into a variable => class name map.
def make_variable_map variables map = {} variables.each { |variable, class_module| map[variable] = class_module.full_name } map end
[ "def add_c_variables c_parser\n filename = c_parser.top_level.relative_name\n\n @c_class_variables[filename] = make_variable_map c_parser.classes\n\n @c_singleton_class_variables[filename] = c_parser.singleton_classes\n end", "def load_variable_map map_name\n return {} unless files = @store.cache[map...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Path to the ri data for +method_name+ in +klass_name+
def method_file klass_name, method_name method_name = method_name.split('::').last method_name =~ /#(.*)/ method_type = $1 ? 'i' : 'c' method_name = $1 if $1 method_name = method_name.gsub(/\W/) { "%%%02x" % $&[0].ord } File.join class_path(klass_name), "#{method_name}-#{method_type}.ri" end
[ "def data_path\n self.class.data_path\n end", "def compiled_template_path(klass, method_name)\n File.join(const_to_path(klass, @context.gen_root), method_name.to_s << '.tpl.rb')\n end", "def method_name\n name\n end", "def compiled_template_path(klass, method_name)\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Modules cache accessor. An Array of all the module (and class) names in the store.
def module_names @cache[:modules] end
[ "def modules\n @modules.values\n end", "def get_module\n\t\tmodules = []\n\t\tDB[:_mods].each do | row |\n\t\t\tmodules << row[:name]\n\t\tend\n\t\tmodules\n\tend", "def loaded_modules\n @loaded_modules ||= []\n end", "def classes\n return @classes if @classes\n @classes = {}\n @stores.ea...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Path to the ri data for +page_name+
def page_file page_name file_name = File.basename(page_name).gsub('.', '_') File.join @path, File.dirname(page_name), "page-#{file_name}.ri" end
[ "def pages_path\n return File.expand_path(\"data/imdb_pages\") if File.exist?(\"data/imdb_pages\")\n File.join(File.dirname(File.expand_path(\"../../\", __FILE__)), 'data/imdb_pages')\n end", "def data_item_path\n \"/data#{path}/#{data_item_uid}\"\n end", "def filename\n @basen...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }