Giter Site home page Giter Site logo

yard-chef's Introduction

YARD-Chef

Description

yard-chef is a YARD plugin for Chef that adds support for documenting Chef recipes, lightweight resources and providers, libraries and definitions.

Requirements

  • Ruby 1.8.7 or higher
  • YARD
  • Ripper if you are using Ruby 1.8.x

Installation

It is available from RubyGems:

gem install yard-chef

If you are using Ruby 1.8.x, you need to install Ripper as well:

gem install ripper

Documenting Your Cookbooks

Cookbook README

The cookbook README file included in your cookbooks will be the landing page for each cookbook. Under this verbatim inclusion of your README will be a Cookbook Documentation section that contains the auto-generated information

Cookbook Metadata

This plugin grabs most of it's information from the cookbook metadata.rb file. This includes the cookbook version and description, recipe descriptions, attribute names, and attribute descriptions.

The rest of the stuff is parsed from cookbook code itself.

YARD-Chef Tags

We also need a way to link your providers to their resources. To do so add a @resource <resource_name> tag in each of your provider code. This tag should be in a comment separated from other comments, for example:

# This is my super_cool provider
# and it does something cool.

# @resouce super_cool

# Here is the first action
...

Standard YARD Tags and Comments

Your definitions, libraries, resources and providers can benefit from adding YARD tags and comments for each class and method. You can learn more about the tags from yardoc.org and the list of available tags

Here is an example of adding standard YARD comments to a definition:

# Does a database backup.
#
# @param [String] backup_type If 'primary' will do a primary backup using volumes. If 'secondary' will do a backup S3.
#
# @raise [RuntimeError] If database is not 'initialized'
define :db_do_backup, :backup_type => "primary" do
  ...
end

Here is an example of adding YARD comments to a light-weight resource:

# Install packages required for application server setup
#
actions :install

  # Set of packages to be installed in addition to the base application
  # packages
  #
  attribute :packages, :kind_of => Array

The first comment will add a description for a resource action. The second comment adds a description for a resource attribute. You can also use comments to document your light-weight provider actions.

Generating Cookbook Docs

Rake Task

For generating documentation it is recommended to create a rake task:

require "rubygems"
require "chef"
require "yard"

YARD::Config.load_plugin 'chef'
YARD::Rake::YardocTask.new do |t|
  t.files = ['<path_to_cookbooks_repo>/**/*.rb']
  #t.options = ['--debug']
end

Then just run

rake yard

Command-line

From the root of your cookbook repository, run the yardoc command to generate documentation using the following command

yardoc '**/*.rb' --plugin chef

Viewing Cookbook Docs

YARD output will be present in a folder named "doc" which will be located in the same folder from where the command was run.

It is recommended to view these pages from a running YARD server. To start a local YARD server you should be in the same directory that contains your generated ./doc directory. Once there run:

yard server --reload -B localhost -p 8000 --plugin yard-chef

Add a -d option flag to run the server in daemon mode. For more information about YARD server see http://yardoc.org/

License

Copyright (c) 2012 RightScale, Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Maintained by the RightScale White Team

yard-chef's People

Contributors

douglaswth avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.