Class: Tidewave::Tools::GetDocs
- Inherits:
-
Tidewave::Tool
- Object
- Tidewave::Tool
- Tidewave::Tools::GetDocs
- Defined in:
- lib/tidewave/tools/get_docs.rb
Constant Summary collapse
- DESCRIPTION =
<<~DESCRIPTION.freeze Returns the documentation for the given reference. The reference may be a constant, most commonly classes and modules such as `String`, an instance method, such as `String#gsub`, or class method, such as `File.executable?` This works for methods in the current project, as well as dependencies. This tool only works if you know the specific constant/method being targeted. If that is the case, prefer this tool over grepping the file system. DESCRIPTION
Instance Method Summary collapse
Methods inherited from Tidewave::Tool
descendants, inherited, #initialize, #validate_and_call
Constructor Details
This class inherits a constructor from Tidewave::Tool
Instance Method Details
#call(arguments) ⇒ Object
35 36 37 38 39 40 41 42 43 44 |
# File 'lib/tidewave/tools/get_docs.rb', line 35 def call(arguments) reference = arguments.fetch("reference") file_path, line_number = Tidewave::Tools::GetSourceLocation.get_source_location(reference) if file_path extract_documentation(file_path, line_number) else raise NameError, "could not find docs for #{reference}" end end |
#definition ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/tidewave/tools/get_docs.rb', line 17 def definition { "name" => "get_docs", "description" => DESCRIPTION, "inputSchema" => { "type" => "object", "properties" => { "reference" => { "type" => "string", "minLength" => 1, "description" => "The constant/method to lookup, such String, String#gsub or File.executable?" } }, "required" => [ "reference" ] } } end |