mirror of
https://github.com/haml/haml.git
synced 2022-11-09 12:33:31 -05:00
Merge branch 'stable'
This commit is contained in:
commit
92db5333ca
11 changed files with 64 additions and 64 deletions
|
@ -60,7 +60,7 @@ Then any Sass files in `public/stylesheets/sass`
|
||||||
will be compiled CSS files in `public/stylesheets` on every request.
|
will be compiled CSS files in `public/stylesheets` on every request.
|
||||||
|
|
||||||
To use Haml and Sass programatically,
|
To use Haml and Sass programatically,
|
||||||
check out the [YARD documentation](http://haml-lang.com/docs/yardoc).
|
check out the [YARD documentation](http://haml-lang.com/docs/yardoc/).
|
||||||
|
|
||||||
## Formatting
|
## Formatting
|
||||||
|
|
||||||
|
|
19
Rakefile
19
Rakefile
|
@ -222,6 +222,17 @@ end
|
||||||
begin
|
begin
|
||||||
require 'yard'
|
require 'yard'
|
||||||
|
|
||||||
|
namespace :yard do
|
||||||
|
task :sass do
|
||||||
|
require File.dirname(__FILE__) + '/lib/sass'
|
||||||
|
Dir[File.dirname(__FILE__) + "/yard/default/**/*.sass"].each do |sass|
|
||||||
|
File.open(sass.gsub(/sass$/, 'css'), 'w') do |f|
|
||||||
|
f.write(Sass::Engine.new(File.read(sass)).render)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
YARD::Rake::YardocTask.new do |t|
|
YARD::Rake::YardocTask.new do |t|
|
||||||
t.files = FileList.new('lib/**/*.rb') do |list|
|
t.files = FileList.new('lib/**/*.rb') do |list|
|
||||||
list.exclude('lib/haml/template/*.rb')
|
list.exclude('lib/haml/template/*.rb')
|
||||||
|
@ -231,12 +242,14 @@ begin
|
||||||
t.options += FileList.new('yard/*.rb').to_a.map {|f| ['-e', f]}.flatten
|
t.options += FileList.new('yard/*.rb').to_a.map {|f| ['-e', f]}.flatten
|
||||||
files = FileList.new('doc-src/*').to_a.sort_by {|s| s.size} + %w[MIT-LICENSE VERSION]
|
files = FileList.new('doc-src/*').to_a.sort_by {|s| s.size} + %w[MIT-LICENSE VERSION]
|
||||||
t.options << '--files' << files.join(',')
|
t.options << '--files' << files.join(',')
|
||||||
|
t.options << '--template-path' << File.dirname(__FILE__) + '/yard'
|
||||||
end
|
end
|
||||||
Rake::Task['yardoc'].instance_variable_set('@comment', nil)
|
Rake::Task['yard'].prerequisites.insert(0, 'yard:sass')
|
||||||
|
Rake::Task['yard'].instance_variable_set('@comment', nil)
|
||||||
|
|
||||||
desc "Generate Documentation"
|
desc "Generate Documentation"
|
||||||
task :doc => :yardoc
|
task :doc => :yard
|
||||||
task :redoc => :yardoc
|
task :redoc => :yard
|
||||||
rescue LoadError
|
rescue LoadError
|
||||||
desc "Generate Documentation"
|
desc "Generate Documentation"
|
||||||
task :doc => :rdoc
|
task :doc => :rdoc
|
||||||
|
|
|
@ -22,7 +22,7 @@ HAML_GEMSPEC = Gem::Specification.new do |spec|
|
||||||
but it can function as a stand-alone templating engine.
|
but it can function as a stand-alone templating engine.
|
||||||
END
|
END
|
||||||
|
|
||||||
spec.add_development_dependency 'yard', '>= 0.2.3'
|
spec.add_development_dependency 'yard', '>= 0.4.0'
|
||||||
spec.add_development_dependency 'maruku', '>= 0.5.9'
|
spec.add_development_dependency 'maruku', '>= 0.5.9'
|
||||||
|
|
||||||
# We need the revision file to exist,
|
# We need the revision file to exist,
|
||||||
|
|
|
@ -10,10 +10,10 @@ module Haml
|
||||||
# Designates an XHTML/XML element.
|
# Designates an XHTML/XML element.
|
||||||
ELEMENT = ?%
|
ELEMENT = ?%
|
||||||
|
|
||||||
# Designates a <tt><div></tt> element with the given class.
|
# Designates a `<div>` element with the given class.
|
||||||
DIV_CLASS = ?.
|
DIV_CLASS = ?.
|
||||||
|
|
||||||
# Designates a <tt><div></tt> element with the given id.
|
# Designates a `<div>` element with the given id.
|
||||||
DIV_ID = ?#
|
DIV_ID = ?#
|
||||||
|
|
||||||
# Designates an XHTML/XML comment.
|
# Designates an XHTML/XML comment.
|
||||||
|
@ -77,7 +77,7 @@ module Haml
|
||||||
# - else
|
# - else
|
||||||
# %p no!
|
# %p no!
|
||||||
#
|
#
|
||||||
# The block is ended after <tt>%p no!</tt>, because <tt>else</tt>
|
# The block is ended after `%p no!`, because `else`
|
||||||
# is a member of this array.
|
# is a member of this array.
|
||||||
MID_BLOCK_KEYWORD_REGEX = /^-\s*(#{%w[else elsif rescue ensure when end].join('|')})\b/
|
MID_BLOCK_KEYWORD_REGEX = /^-\s*(#{%w[else elsif rescue ensure when end].join('|')})\b/
|
||||||
|
|
||||||
|
@ -201,7 +201,7 @@ END
|
||||||
# Processes a single line of Haml.
|
# Processes a single line of Haml.
|
||||||
#
|
#
|
||||||
# This method doesn't return anything; it simply processes the line and
|
# This method doesn't return anything; it simply processes the line and
|
||||||
# adds the appropriate code to <tt>@precompiled</tt>.
|
# adds the appropriate code to `@precompiled`.
|
||||||
def process_line(text, index)
|
def process_line(text, index)
|
||||||
@index = index + 1
|
@index = index + 1
|
||||||
|
|
||||||
|
@ -278,7 +278,7 @@ END
|
||||||
text[MID_BLOCK_KEYWORD_REGEX, 1]
|
text[MID_BLOCK_KEYWORD_REGEX, 1]
|
||||||
end
|
end
|
||||||
|
|
||||||
# Evaluates <tt>text</tt> in the context of the scope object, but
|
# Evaluates `text` in the context of the scope object, but
|
||||||
# does not output the result.
|
# does not output the result.
|
||||||
def push_silent(text, can_suppress = false)
|
def push_silent(text, can_suppress = false)
|
||||||
flush_merged_text
|
flush_merged_text
|
||||||
|
@ -286,7 +286,7 @@ END
|
||||||
@precompiled << "#{text};"
|
@precompiled << "#{text};"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Adds <tt>text</tt> to <tt>@buffer</tt> with appropriate tabulation
|
# Adds `text` to `@buffer` with appropriate tabulation
|
||||||
# without parsing it.
|
# without parsing it.
|
||||||
def push_merged_text(text, tab_change = 0, indent = true)
|
def push_merged_text(text, tab_change = 0, indent = true)
|
||||||
text = !indent || @dont_indent_next_line || @options[:ugly] ? text : "#{' ' * @output_tabs}#{text}"
|
text = !indent || @dont_indent_next_line || @options[:ugly] ? text : "#{' ' * @output_tabs}#{text}"
|
||||||
|
@ -294,7 +294,7 @@ END
|
||||||
@dont_indent_next_line = false
|
@dont_indent_next_line = false
|
||||||
end
|
end
|
||||||
|
|
||||||
# Concatenate <tt>text</tt> to <tt>@buffer</tt> without tabulation.
|
# Concatenate `text` to `@buffer` without tabulation.
|
||||||
def concat_merged_text(text)
|
def concat_merged_text(text)
|
||||||
@to_merge << [:text, text, 0]
|
@to_merge << [:text, text, 0]
|
||||||
end
|
end
|
||||||
|
@ -356,18 +356,18 @@ END
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Adds +text+ to <tt>@buffer</tt> while flattening text.
|
# Adds +text+ to `@buffer` while flattening text.
|
||||||
def push_flat(line)
|
def push_flat(line)
|
||||||
text = line.full.dup
|
text = line.full.dup
|
||||||
text = "" unless text.gsub!(/^#{@flat_spaces}/, '')
|
text = "" unless text.gsub!(/^#{@flat_spaces}/, '')
|
||||||
@filter_buffer << "#{text}\n"
|
@filter_buffer << "#{text}\n"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Causes <tt>text</tt> to be evaluated in the context of
|
# Causes `text` to be evaluated in the context of
|
||||||
# the scope object and the result to be added to <tt>@buffer</tt>.
|
# the scope object and the result to be added to `@buffer`.
|
||||||
#
|
#
|
||||||
# If <tt>opts[:preserve_script]</tt> is true, Haml::Helpers#find_and_flatten is run on
|
# If `opts[:preserve_script]` is true, Haml::Helpers#find_and_flatten is run on
|
||||||
# the result before it is added to <tt>@buffer</tt>
|
# the result before it is added to `@buffer`
|
||||||
def push_script(text, opts = {})
|
def push_script(text, opts = {})
|
||||||
raise SyntaxError.new("There's no Ruby code for = to evaluate.") if text.empty?
|
raise SyntaxError.new("There's no Ruby code for = to evaluate.") if text.empty?
|
||||||
return if options[:suppress_eval]
|
return if options[:suppress_eval]
|
||||||
|
@ -400,7 +400,7 @@ END
|
||||||
!(opts[:in_tag] || opts[:nuke_inner_whitespace] || @options[:ugly])])
|
!(opts[:in_tag] || opts[:nuke_inner_whitespace] || @options[:ugly])])
|
||||||
end
|
end
|
||||||
|
|
||||||
# Causes <tt>text</tt> to be evaluated, and Haml::Helpers#find_and_flatten
|
# Causes `text` to be evaluated, and Haml::Helpers#find_and_flatten
|
||||||
# to be run on it afterwards.
|
# to be run on it afterwards.
|
||||||
def push_flat_script(text, options = {})
|
def push_flat_script(text, options = {})
|
||||||
flush_merged_text
|
flush_merged_text
|
||||||
|
@ -416,13 +416,13 @@ END
|
||||||
push_and_tabulate([:haml_comment])
|
push_and_tabulate([:haml_comment])
|
||||||
end
|
end
|
||||||
|
|
||||||
# Closes the most recent item in <tt>@to_close_stack</tt>.
|
# Closes the most recent item in `@to_close_stack`.
|
||||||
def close
|
def close
|
||||||
tag, *rest = @to_close_stack.pop
|
tag, *rest = @to_close_stack.pop
|
||||||
send("close_#{tag}", *rest)
|
send("close_#{tag}", *rest)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Puts a line in <tt>@precompiled</tt> that will add the closing tag of
|
# Puts a line in `@precompiled` that will add the closing tag of
|
||||||
# the most recently opened tag.
|
# the most recently opened tag.
|
||||||
def close_element(value)
|
def close_element(value)
|
||||||
tag, nuke_outer_whitespace, nuke_inner_whitespace = value
|
tag, nuke_outer_whitespace, nuke_inner_whitespace = value
|
||||||
|
@ -474,8 +474,8 @@ END
|
||||||
@template_tabs -= 1
|
@template_tabs -= 1
|
||||||
end
|
end
|
||||||
|
|
||||||
# Iterates through the classes and ids supplied through <tt>.</tt>
|
# Iterates through the classes and ids supplied through `.`
|
||||||
# and <tt>#</tt> syntax, and returns a hash with them as attributes,
|
# and `#` syntax, and returns a hash with them as attributes,
|
||||||
# that can then be merged with another attributes hash.
|
# that can then be merged with another attributes hash.
|
||||||
def parse_class_and_id(list)
|
def parse_class_and_id(list)
|
||||||
attributes = {}
|
attributes = {}
|
||||||
|
@ -672,7 +672,7 @@ END
|
||||||
end
|
end
|
||||||
|
|
||||||
# Parses a line that will render as an XHTML tag, and adds the code that will
|
# Parses a line that will render as an XHTML tag, and adds the code that will
|
||||||
# render that tag to <tt>@precompiled</tt>.
|
# render that tag to `@precompiled`.
|
||||||
def render_tag(line)
|
def render_tag(line)
|
||||||
tag_name, attributes, attributes_hashes, object_ref, nuke_outer_whitespace,
|
tag_name, attributes, attributes_hashes, object_ref, nuke_outer_whitespace,
|
||||||
nuke_inner_whitespace, action, value, last_line = parse_tag(line)
|
nuke_inner_whitespace, action, value, last_line = parse_tag(line)
|
||||||
|
@ -803,7 +803,7 @@ END
|
||||||
end
|
end
|
||||||
|
|
||||||
# Renders a line that creates an XHTML tag and has an implicit div because of
|
# Renders a line that creates an XHTML tag and has an implicit div because of
|
||||||
# <tt>.</tt> or <tt>#</tt>.
|
# `.` or `#`.
|
||||||
def render_div(line)
|
def render_div(line)
|
||||||
render_tag('%div' + line)
|
render_tag('%div' + line)
|
||||||
end
|
end
|
||||||
|
@ -991,8 +991,8 @@ END
|
||||||
!flat? && @next_line.tabs > @line.tabs
|
!flat? && @next_line.tabs > @line.tabs
|
||||||
end
|
end
|
||||||
|
|
||||||
# Pushes value onto <tt>@to_close_stack</tt> and increases
|
# Pushes value onto `@to_close_stack` and increases
|
||||||
# <tt>@template_tabs</tt>.
|
# `@template_tabs`.
|
||||||
def push_and_tabulate(value)
|
def push_and_tabulate(value)
|
||||||
@to_close_stack.push(value)
|
@to_close_stack.push(value)
|
||||||
@template_tabs += 1
|
@template_tabs += 1
|
||||||
|
|
|
@ -107,15 +107,15 @@ module Sass
|
||||||
# Includes named mixin declared using MIXIN_DEFINITION_CHAR
|
# Includes named mixin declared using MIXIN_DEFINITION_CHAR
|
||||||
MIXIN_INCLUDE_CHAR = ?+
|
MIXIN_INCLUDE_CHAR = ?+
|
||||||
|
|
||||||
# The regex that matches properties of the form <tt>name: prop</tt>.
|
# The regex that matches properties of the form `name: prop`.
|
||||||
PROPERTY_NEW_MATCHER = /^[^\s:"\[]+\s*[=:](\s|$)/
|
PROPERTY_NEW_MATCHER = /^[^\s:"\[]+\s*[=:](\s|$)/
|
||||||
|
|
||||||
# The regex that matches and extracts data from
|
# The regex that matches and extracts data from
|
||||||
# properties of the form <tt>name: prop</tt>.
|
# properties of the form `name: prop`.
|
||||||
PROPERTY_NEW = /^([^\s=:"]+)(\s*=|:)(?:\s+|$)(.*)/
|
PROPERTY_NEW = /^([^\s=:"]+)(\s*=|:)(?:\s+|$)(.*)/
|
||||||
|
|
||||||
# The regex that matches and extracts data from
|
# The regex that matches and extracts data from
|
||||||
# properties of the form <tt>:name prop</tt>.
|
# properties of the form `:name prop`.
|
||||||
PROPERTY_OLD = /^:([^\s=:"]+)\s*(=?)(?:\s+|$)(.*)/
|
PROPERTY_OLD = /^:([^\s=:"]+)\s*(=?)(?:\s+|$)(.*)/
|
||||||
|
|
||||||
# The default options for Sass::Engine.
|
# The default options for Sass::Engine.
|
||||||
|
|
|
@ -5,7 +5,7 @@ module Sass::Script
|
||||||
class Color < Literal
|
class Color < Literal
|
||||||
class << self; include Haml::Util; end
|
class << self; include Haml::Util; end
|
||||||
|
|
||||||
# A hash from color names to [red, green, blue] value arrays.
|
# A hash from color names to `[red, green, blue]` value arrays.
|
||||||
HTML4_COLORS = map_vals({
|
HTML4_COLORS = map_vals({
|
||||||
'black' => 0x000000,
|
'black' => 0x000000,
|
||||||
'silver' => 0xc0c0c0,
|
'silver' => 0xc0c0c0,
|
||||||
|
@ -24,7 +24,7 @@ module Sass::Script
|
||||||
'teal' => 0x008080,
|
'teal' => 0x008080,
|
||||||
'aqua' => 0x00ffff
|
'aqua' => 0x00ffff
|
||||||
}) {|color| (0..2).map {|n| color >> (n << 3) & 0xff}.reverse}
|
}) {|color| (0..2).map {|n| color >> (n << 3) & 0xff}.reverse}
|
||||||
# A hash from [red, green, blue] value arrays to color names.
|
# A hash from `[red, green, blue]` value arrays to color names.
|
||||||
HTML4_COLORS_REVERSE = map_hash(HTML4_COLORS) {|k, v| [v, k]}
|
HTML4_COLORS_REVERSE = map_hash(HTML4_COLORS) {|k, v| [v, k]}
|
||||||
|
|
||||||
# Constructs an RGB or RGBA color object.
|
# Constructs an RGB or RGBA color object.
|
||||||
|
@ -189,10 +189,7 @@ END
|
||||||
# {Color}
|
# {Color}
|
||||||
# : Multiplies each of the RGB color channels together.
|
# : Multiplies each of the RGB color channels together.
|
||||||
#
|
#
|
||||||
# {Literal}
|
# @param other [Number, Color] The right-hand side of the operator
|
||||||
# : See {Literal#times}.
|
|
||||||
#
|
|
||||||
# @param other [Literal] The right-hand side of the operator
|
|
||||||
# @return [Color] The resulting color
|
# @return [Color] The resulting color
|
||||||
# @raise [Sass::SyntaxError] if `other` is a number with units
|
# @raise [Sass::SyntaxError] if `other` is a number with units
|
||||||
def times(other)
|
def times(other)
|
||||||
|
@ -235,10 +232,7 @@ END
|
||||||
# {Color}
|
# {Color}
|
||||||
# : Takes each of this color's RGB color channels modulo the other color's.
|
# : Takes each of this color's RGB color channels modulo the other color's.
|
||||||
#
|
#
|
||||||
# {Literal}
|
# @param other [Number, Color] The right-hand side of the operator
|
||||||
# : See {Literal#mod}.
|
|
||||||
#
|
|
||||||
# @param other [Literal] The right-hand side of the operator
|
|
||||||
# @return [Color] The resulting color
|
# @return [Color] The resulting color
|
||||||
# @raise [Sass::SyntaxError] if `other` is a number with units
|
# @raise [Sass::SyntaxError] if `other` is a number with units
|
||||||
def mod(other)
|
def mod(other)
|
||||||
|
|
|
@ -8,16 +8,16 @@ module Sass
|
||||||
class Lexer
|
class Lexer
|
||||||
# A struct containing information about an individual token.
|
# A struct containing information about an individual token.
|
||||||
#
|
#
|
||||||
# `type`: [{Symbol}]
|
# `type`: \[{Symbol}\]
|
||||||
# : The type of token.
|
# : The type of token.
|
||||||
#
|
#
|
||||||
# `value`: [{Object}]
|
# `value`: \[{Object}\]
|
||||||
# : The Ruby object corresponding to the value of the token.
|
# : The Ruby object corresponding to the value of the token.
|
||||||
#
|
#
|
||||||
# `line`: [{Fixnum}]
|
# `line`: \[{Fixnum}\]
|
||||||
# : The line of the source file on which the token appears.
|
# : The line of the source file on which the token appears.
|
||||||
#
|
#
|
||||||
# `offset`: [{Fixnum}]
|
# `offset`: \[{Fixnum}\]
|
||||||
# : The number of bytes into the line the SassScript token appeared.
|
# : The number of bytes into the line the SassScript token appeared.
|
||||||
Token = Struct.new(:type, :value, :line, :offset)
|
Token = Struct.new(:type, :value, :line, :offset)
|
||||||
|
|
||||||
|
|
1
yard/default/.gitignore
vendored
Normal file
1
yard/default/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
*.css
|
|
@ -9,7 +9,7 @@
|
||||||
float: none
|
float: none
|
||||||
margin: 0 2em
|
margin: 0 2em
|
||||||
|
|
||||||
.section.readme
|
#filecontents
|
||||||
*:target, dt:target + dd
|
*:target, dt:target + dd
|
||||||
background-color: #ccf
|
background-color: #ccf
|
||||||
border: 1px solid #88b
|
border: 1px solid #88b
|
12
yard/default/layout/html/footer.erb
Normal file
12
yard/default/layout/html/footer.erb
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
<%= superb :footer %>
|
||||||
|
<% if ENV["ANALYTICS"] %>
|
||||||
|
<script type="text/javascript">
|
||||||
|
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
|
||||||
|
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
|
||||||
|
</script>
|
||||||
|
<script type="text/javascript">
|
||||||
|
try {
|
||||||
|
var pageTracker = _gat._getTracker("<%= ENV["ANALYTICS"] %>");
|
||||||
|
pageTracker._trackPageview();
|
||||||
|
} catch(err) {}</script>
|
||||||
|
<% end %>
|
|
@ -1,20 +0,0 @@
|
||||||
require File.dirname(__FILE__) + "/../lib/sass"
|
|
||||||
|
|
||||||
class YARD::Generators::FullDocGenerator
|
|
||||||
protected
|
|
||||||
|
|
||||||
def generate_assets_with_haml
|
|
||||||
generate_assets_without_haml
|
|
||||||
|
|
||||||
if format == :html && serializer
|
|
||||||
template_file = find_template template_path(css_file)
|
|
||||||
haml_style = Sass::Engine.new(File.read(
|
|
||||||
File.dirname(__FILE__) + "/haml-style.sass")).render
|
|
||||||
serializer.serialize(css_file, File.read(template_file) + haml_style)
|
|
||||||
end
|
|
||||||
|
|
||||||
true
|
|
||||||
end
|
|
||||||
alias_method :generate_assets_without_haml, :generate_assets
|
|
||||||
alias_method :generate_assets, :generate_assets_with_haml
|
|
||||||
end
|
|
Loading…
Add table
Reference in a new issue