Yard doc cleanup

This commit is contained in:
Thomas Reynolds 2012-05-02 11:13:06 -07:00
parent 1855745d8e
commit 2965e3709d
10 changed files with 40 additions and 27 deletions

View file

@ -7,7 +7,7 @@ group :development do
gem "rake", "~> 0.9.2" gem "rake", "~> 0.9.2"
gem "rspec", "~> 2.7" gem "rspec", "~> 2.7"
gem "rdoc", "~> 3.9" gem "rdoc", "~> 3.9"
# gem "yard" gem "yard", "~> 0.8.0"
end end
group :test do group :test do

View file

@ -1,7 +1,6 @@
require 'rubygems' unless defined?(Gem) require 'rubygems' unless defined?(Gem)
# require 'fileutils' unless defined?(FileUtils) # require 'fileutils' unless defined?(FileUtils)
require 'rake' require 'rake'
# require 'yard'
require File.expand_path("../middleman-core/lib/middleman-core/version.rb", __FILE__) require File.expand_path("../middleman-core/lib/middleman-core/version.rb", __FILE__)
@ -74,6 +73,13 @@ task :publish => :push do
Rake::Task["clean"].invoke Rake::Task["clean"].invoke
end end
desc "Generate documentation for all middleman gems"
task :doc do
GEM_PATHS.each do |g|
sh "cd #{File.join(ROOT, g)} && #{Gem.ruby} -S rake yard"
end
end
desc "Run tests for all middleman gems" desc "Run tests for all middleman gems"
task :test do task :test do
GEM_PATHS.each do |g| GEM_PATHS.each do |g|
@ -82,9 +88,4 @@ task :test do
end end
desc "Run tests for all middleman gems" desc "Run tests for all middleman gems"
task :default => :test task :default => :test
# desc "Generate documentation"
# task :doc do
# YARD::CLI::Yardoc.new.run
# end

View file

@ -1,7 +1,7 @@
require 'rubygems' unless defined?(Gem) require 'rubygems' unless defined?(Gem)
require 'rake' require 'rake'
require 'cucumber/rake/task' require 'cucumber/rake/task'
# require 'yard' require 'yard'
require 'bundler' require 'bundler'
Bundler::GemHelper.install_tasks :name => GEM_NAME Bundler::GemHelper.install_tasks :name => GEM_NAME
@ -20,6 +20,6 @@ Cucumber::Rake::Task.new(:test, 'Run features that should pass') do |t|
t.cucumber_opts = "--color --tags ~@wip --strict --format #{ENV['CUCUMBER_FORMAT'] || 'Fivemat'}" t.cucumber_opts = "--color --tags ~@wip --strict --format #{ENV['CUCUMBER_FORMAT'] || 'Fivemat'}"
end end
# YARD::Rake::YardocTask.new YARD::Rake::YardocTask.new
task :default => :test task :default => :test

View file

@ -62,15 +62,16 @@ module Middleman::CoreExtensions::Extensions
# Alias `extensions` to access registered extensions # Alias `extensions` to access registered extensions
# #
# @return [Array<Module] # @return [Array<Module>]
def extensions def extensions
@extensions ||= [] @extensions ||= []
end end
# Register a new extension # Register a new extension
# #
# @param [Array<Module>] new_extensions Extension modules to register # @param [Module] extension Extension modules to register
# @return [Array<Module] # @param [Hash] options Per-extension options hash
# @return [void]
def register(extension, options={}, &block) def register(extension, options={}, &block)
@extensions ||= [] @extensions ||= []
@extensions += [extension] @extensions += [extension]

View file

@ -102,11 +102,11 @@ module Middleman::CoreExtensions::FrontMatter
@_frontmatter_extension ||= FrontMatter.new(self) @_frontmatter_extension ||= FrontMatter.new(self)
end end
# Get the frontmatter for the given params # Get the frontmatter for a given path
# @param [String] path # @param [String] path
# @return [Hash, nil] # @return [Hash]
def frontmatter(*args) def frontmatter(path)
frontmatter_extension.data(*args) frontmatter_extension.data(path)
end end
end end

View file

@ -171,8 +171,8 @@ module Middleman
# to discover extensions and Sprockets-supporting gems. # to discover extensions and Sprockets-supporting gems.
# #
# @private # @private
# @param [Gem::Specification] # @param [Gem::Specification] spec
# @param [String] Path to look for # @param [String] path Path to look for
# @return [Boolean] Whether the file exists # @return [Boolean] Whether the file exists
def spec_has_file?(spec, path) def spec_has_file?(spec, path)
full_path = File.join(spec.full_gem_path, path) full_path = File.join(spec.full_gem_path, path)

View file

@ -16,7 +16,11 @@ module Middleman::Sitemap::Extensions
alias :included :registered alias :included :registered
end end
# Helpers methods for Resources
module ResourceInstanceMethods module ResourceInstanceMethods
# Whether the Resource is ignored
# @return [Boolean]
def ignored? def ignored?
@app.ignore_manager.ignored?(path) || @app.ignore_manager.ignored?(path) ||
(!proxy? && (!proxy? &&
@ -25,25 +29,31 @@ module Middleman::Sitemap::Extensions
end end
end end
# Ignore-related instance methods
module InstanceMethods module InstanceMethods
def ignore_manager def ignore_manager
@_ignore_manager ||= IgnoreManager.new(self) @_ignore_manager ||= IgnoreManager.new(self)
end end
def ignore(*args, &block) # Ignore a path or add an ignore callback
ignore_manager.ignore(*args, &block) # @param [String, Regexp] path Path glob expression, or path regex
# @return [void]
def ignore(path=nil, &block)
ignore_manager.ignore(path, &block)
end end
end end
# Class to handle managing ignores
class IgnoreManager class IgnoreManager
def initialize(app) def initialize(app)
@app = app @app = app
# Array of callbacks which can ass ignored
@ignored_callbacks = [] @ignored_callbacks = []
end end
# Ignore a path or add an ignore callback # Ignore a path or add an ignore callback
# @param [String, Regexp] path, path glob expression, or path regex # @param [String, Regexp] path Path glob expression, or path regex
# @return [void] # @return [void]
def ignore(path=nil, &block) def ignore(path=nil, &block)
original_callback_size = @ignored_callbacks.size original_callback_size = @ignored_callbacks.size

View file

@ -32,8 +32,9 @@ module Middleman::Sitemap
end end
# Register a klass which can manipulate the main site map list # Register a klass which can manipulate the main site map list
# @param [Class] klass # @param [Symbol] name Name of the manipulator for debugging
# @param [Boolean] immediately_rebuild # @param [Class, Module] inst Abstract namespace which can update the resource list
# @param [Boolean] immediately_rebuild Whether the resource list should be immediately recalculated
# @return [void] # @return [void]
def register_resource_list_manipulator(name, inst, immediately_rebuild=true) def register_resource_list_manipulator(name, inst, immediately_rebuild=true)
@resource_list_manipulators << [name, inst] @resource_list_manipulators << [name, inst]

View file

@ -15,9 +15,9 @@ module Middleman::Templates
# @param [Symbol] name The name of the template # @param [Symbol] name The name of the template
# @param [Class] klass The class to be executed for this template # @param [Class] klass The class to be executed for this template
# @return [Hash] List of registered templates # @return [Hash] List of registered templates
def register(*args) def register(name=nil, klass=nil)
@_template_mappings ||= {} @_template_mappings ||= {}
@_template_mappings[args[0]] = args[1] if args.length == 2 @_template_mappings[name] = klass if name && klass
@_template_mappings @_template_mappings
end end

View file

@ -107,4 +107,4 @@ module Middleman
end end
end end
end end
end end