Skip to content

Commit

Permalink
enable the module documentation cop
Browse files Browse the repository at this point in the history
  • Loading branch information
whoward committed Feb 6, 2016
1 parent 8b10814 commit 71575dd
Show file tree
Hide file tree
Showing 18 changed files with 31 additions and 22 deletions.
6 changes: 1 addition & 5 deletions .rubocop_todo.yml
Expand Up @@ -31,8 +31,4 @@ Metrics/MethodLength:

# Offense count: 5
Metrics/PerceivedComplexity:
Max: 15

# Offense count: 24
Style/Documentation:
Enabled: false
Max: 15
1 change: 1 addition & 0 deletions lib/cadenza.rb
Expand Up @@ -31,6 +31,7 @@
# require all nodes
Dir[File.join File.dirname(__FILE__), 'cadenza', 'nodes', '*.rb'].each { |f| require f }

# The Cadenza module is the top level namespace for the cadenza gem
module Cadenza
# this utility method sets up the standard Cadenza lexer/parser/renderer
# stack and renders the given template text with the given variable scope
Expand Down
2 changes: 2 additions & 0 deletions lib/cadenza/base_context.rb
@@ -1,5 +1,7 @@

module Cadenza
# BaseContext is the recommended context class for beginners - it includes the full standard library of Cadenza
# filters, blocks and functions.
class BaseContext < Context
include Cadenza::StandardLibrary
end
Expand Down
2 changes: 2 additions & 0 deletions lib/cadenza/base_renderer.rb
@@ -1,4 +1,6 @@
module Cadenza
# This exception is raised when something exceptional occurs while rendering a
# template and the exception handler is set to :raise
class RenderError < Cadenza::Error
attr_reader :inner_error
def initialize(err)
Expand Down
1 change: 1 addition & 0 deletions lib/cadenza/cli.rb
Expand Up @@ -3,6 +3,7 @@
require 'multi_json'

module Cadenza
# The code for the command line interface is defined here
module Cli
module_function

Expand Down
1 change: 1 addition & 0 deletions lib/cadenza/cli/options.rb
@@ -1,5 +1,6 @@
module Cadenza
module Cli
# The parser for the command line options is defined here
class Options < OptionParser
attr_reader :options

Expand Down
2 changes: 2 additions & 0 deletions lib/cadenza/context/loaders.rb
@@ -1,8 +1,10 @@

module Cadenza
# This exception is raised when a requested template cannot be loaded
TemplateNotFoundError = Class.new(Cadenza::Error)

class Context
# This module contains all methods related to the loaders
module Loaders
# @!attribute [rw] whiny_template_loading
# @return [Boolean] true if a {TemplateNotFoundError} should still be
Expand Down
1 change: 1 addition & 0 deletions lib/cadenza/context/stack.rb
@@ -1,6 +1,7 @@

module Cadenza
class Context
# This module contains all methods related to the variable stack
module Stack
# @!attribute [r] stack
# @return [Array] the variable stack
Expand Down
1 change: 1 addition & 0 deletions lib/cadenza/library.rb
Expand Up @@ -4,6 +4,7 @@
require 'cadenza/library/expectation'

module Cadenza
# Libraries provide a way to define a set of filters, blocks and functions which can be easily included into a context
module Library
# Instantiates a new library module and calls the passed block in the
# context of the new module. This makes the block build the library in the
Expand Down
2 changes: 2 additions & 0 deletions lib/cadenza/library/blocks.rb
@@ -1,8 +1,10 @@

module Cadenza
# This exception is raised when a block is referred to but is not defined
BlockNotDefinedError = Class.new(Cadenza::Error)

module Library
# The logic for storing and calling blocks is found in this module
module Blocks
# @!attribute [r] blocks
# @return [Hash] the block names mapped to their implementing procs
Expand Down
2 changes: 2 additions & 0 deletions lib/cadenza/library/expectation.rb
@@ -1,11 +1,13 @@

module Cadenza
# This exception is raised when a function is called with an unexpected number of arguments
class InvalidArgumentCountError < Cadenza::Error
def initialize(expected_count, actual_count)
super "wrong number of arguments (#{actual_count} for #{expected_count})"
end
end

# This exception is raised when an unexpected argument is passed to a function
class InvalidArgumentTypeError < Cadenza::Error
def initialize(expected, actual)
super "expected #{expected} but got #{actual}"
Expand Down
2 changes: 2 additions & 0 deletions lib/cadenza/library/filters.rb
@@ -1,8 +1,10 @@

module Cadenza
# This exception is raised when a filter is referred to but is not defined
FilterNotDefinedError = Class.new(Cadenza::Error)

module Library
# The logic for storing and calling filters is found in this module
module Filters
# @!attribute [r] filters
# @return [Hash] the filter names mapped to their implementing procs
Expand Down
12 changes: 2 additions & 10 deletions lib/cadenza/library/functions.rb
@@ -1,18 +1,10 @@

module Cadenza
# This exception is raised when a function is referred to but is not defined
FunctionNotDefinedError = Class.new(Cadenza::Error)

# Returns {FunctionNotDefinedError} when the deprecated {FunctionalVariableNotDefinedError} is requested
# @private
# @todo remove in v0.9.x
def self.const_missing(const_name)
super unless const_name == :FunctionalVariableNotDefinedError
warn '`Cadenza::FunctionalVariableNotDefinedError` has been deprecated. ' \
'Use `Cadenza::FunctionNotDefinedError` instead.'
FunctionNotDefinedError
end

module Library
# The logic for storing and calling functions is found in this module
module Functions
# @!attribute [r] functions
# @return [Hash] the function names mapped to their implementing procs
Expand Down
2 changes: 2 additions & 0 deletions lib/cadenza/source_tree_renderer.rb
@@ -1,6 +1,8 @@
require 'stringio'

module Cadenza
# This renderer will output a string representing the AST in a tree format. It is intended to be used
# for debugging purposes.
class SourceTreeRenderer < BaseRenderer
# Renders the given AST root node as a source tree (helpful for debugging)
# @todo move this to a module
Expand Down
3 changes: 2 additions & 1 deletion lib/cadenza/standard_library.rb
@@ -1,5 +1,6 @@

module Cadenza
module Cadenza\
# The Standard Library is a collection of all the standard filters, block and functions defined in Cadenza
module StandardLibrary
extend Cadenza::Library

Expand Down
1 change: 1 addition & 0 deletions lib/cadenza/tree_node.rb
@@ -1,5 +1,6 @@

module Cadenza
# This module contains the common methods to all nodes in the AST
module TreeNode
def to_tree
SourceTreeRenderer.render(self)
Expand Down
8 changes: 4 additions & 4 deletions spec/parser/filtered_value_spec.rb
Expand Up @@ -14,12 +14,12 @@
end

it 'parses multiple params' do
expect_parsing("{{ name | somefilter: 'foo', 3.14159 }}").to
equal_syntax_tree 'filtered_value/single_filter_with_multiple_params.yml'
expect_parsing("{{ name | somefilter: 'foo', 3.14159 }}").to \
equal_syntax_tree 'filtered_value/single_filter_with_multiple_params.yml'
end

it 'parses multiple filters with multiple params' do
expect_parsing("{{ name | trim | somefilter: 'foo', 3.14159 }}").to
equal_syntax_tree 'filtered_value/multiple_filters_with_params.yml'
expect_parsing("{{ name | trim | somefilter: 'foo', 3.14159 }}").to \
equal_syntax_tree 'filtered_value/multiple_filters_with_params.yml'
end
end
4 changes: 2 additions & 2 deletions spec/text_renderer_spec.rb
Expand Up @@ -96,8 +96,8 @@
it "should render a for-block's children once for each iterated object" do
context = Cadenza::Context.new(alphabet: %w(a b c))

expect_rendering("{% for x in alphabet %}{{ forloop.counter }}: {{ x }}\n{% endfor %}", context).to
eq "1: a\n2: b\n3: c\n"
expect_rendering("{% for x in alphabet %}{{ forloop.counter }}: {{ x }}\n{% endfor %}", context).to \
eq "1: a\n2: b\n3: c\n"
end

it "should render default blocks in it's children" do
Expand Down

0 comments on commit 71575dd

Please sign in to comment.