Class: YARD::Handlers::Chef::RecipeHandler
- Defined in:
- lib/yard-chef/handlers/recipe.rb
Overview
Handles “recipes” in a cookbook.
Instance Method Summary collapse
-
#docstring ⇒ YARD::Docsting
Gets the docstring for the recipe.
-
#name ⇒ String
Gets the recipe name from the metadata.rb.
- #process ⇒ Object
Methods inherited from Base
Instance Method Details
#docstring ⇒ YARD::Docsting
Gets the docstring for the recipe. The docstring is obtained from the description field in the recipe.
53 54 55 56 57 58 59 60 61 |
# File 'lib/yard-chef/handlers/recipe.rb', line 53 def docstring description = "" # YARD builds an abstract syntax tree (AST) which we need to traverse # to obtain the complete docstring statement.parameters[1].traverse do |child| description << child.jump(:string_content).source if child.type == :string_content end YARD::DocstringParser.new.parse(description).to_docstring end |
#name ⇒ String
Gets the recipe name from the metadata.rb.
41 42 43 44 45 46 |
# File 'lib/yard-chef/handlers/recipe.rb', line 41 def name recipe = statement.parameters.first.jump(:string_content, :ident).source recipe = recipe.split("::")[1] if recipe =~ /::/ recipe = 'default' if recipe == cookbook.name.to_s recipe end |
#process ⇒ Object
30 31 32 33 34 35 |
# File 'lib/yard-chef/handlers/recipe.rb', line 30 def process return unless statement.file.to_s =~ /metadata.rb/ recipe_obj = ChefObject.register(cookbook, name, :recipe) recipe_obj.docstring = docstring end |