Class: PuppetLanguageServerSidecar::PuppetStringsHelper::Helper
- Inherits:
-
Object
- Object
- PuppetLanguageServerSidecar::PuppetStringsHelper::Helper
- Defined in:
- lib/puppet-languageserver-sidecar/puppet_strings_helper.rb
Instance Method Summary collapse
-
#file_documentation(path, puppet_path, cache = nil) ⇒ FileDocumentation?
Returns a FileDocumentation object for a given path.
Instance Method Details
#file_documentation(path, puppet_path, cache = nil) ⇒ FileDocumentation?
Returns a FileDocumentation object for a given path
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/puppet-languageserver-sidecar/puppet_strings_helper.rb', line 43 def file_documentation(path, puppet_path, cache = nil) return nil unless PuppetLanguageServerSidecar::PuppetStringsHelper.require_puppet_strings @helper_cache = FileDocumentationCache.new if @helper_cache.nil? return @helper_cache.document(path) if @helper_cache.path_exists?(path) # Load from the permanent cache @helper_cache.populate_from_sidecar_cache!(path, cache) unless cache.nil? || !cache.active? return @helper_cache.document(path) if @helper_cache.path_exists?(path) PuppetLanguageServerSidecar.(:debug, "[PuppetStringsHelper::file_documentation] Fetching documentation for #{path}") PuppetLanguageServerSidecar::PuppetStringsHelper.setup_yard! # For now, assume a single file path search_patterns = [path] # Format the arguments to YARD args = ['doc'] args << '--no-output' args << '--quiet' args << '--no-stats' args << '--no-progress' args << '--no-save' args << '--api public' args << '--api private' args << '--no-api' args += search_patterns # Run YARD ::YARD::CLI::Yardoc.run(*args) # Populate the documentation cache from the YARD information @helper_cache.populate_from_yard_registry!(puppet_path) # Save to the permanent cache @helper_cache.save_to_sidecar_cache(path, cache) unless cache.nil? || !cache.active? # Return the documentation details @helper_cache.document(path) end |