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.
|
||||
|
||||
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
|
||||
|
||||
|
|
19
Rakefile
19
Rakefile
|
@ -222,6 +222,17 @@ end
|
|||
begin
|
||||
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|
|
||||
t.files = FileList.new('lib/**/*.rb') do |list|
|
||||
list.exclude('lib/haml/template/*.rb')
|
||||
|
@ -231,12 +242,14 @@ begin
|
|||
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]
|
||||
t.options << '--files' << files.join(',')
|
||||
t.options << '--template-path' << File.dirname(__FILE__) + '/yard'
|
||||
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"
|
||||
task :doc => :yardoc
|
||||
task :redoc => :yardoc
|
||||
task :doc => :yard
|
||||
task :redoc => :yard
|
||||
rescue LoadError
|
||||
desc "Generate Documentation"
|
||||
task :doc => :rdoc
|
||||
|
|
|
@ -22,7 +22,7 @@ HAML_GEMSPEC = Gem::Specification.new do |spec|
|
|||
but it can function as a stand-alone templating engine.
|
||||
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'
|
||||
|
||||
# We need the revision file to exist,
|
||||
|
|
|
@ -10,10 +10,10 @@ module Haml
|
|||
# Designates an XHTML/XML element.
|
||||
ELEMENT = ?%
|
||||
|
||||
# Designates a <tt><div></tt> element with the given class.
|
||||
# Designates a `<div>` element with the given class.
|
||||
DIV_CLASS = ?.
|
||||
|
||||
# Designates a <tt><div></tt> element with the given id.
|
||||
# Designates a `<div>` element with the given id.
|
||||
DIV_ID = ?#
|
||||
|
||||
# Designates an XHTML/XML comment.
|
||||
|
@ -77,7 +77,7 @@ module Haml
|
|||
# - else
|
||||
# %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.
|
||||
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.
|
||||
#
|
||||
# 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)
|
||||
@index = index + 1
|
||||
|
||||
|
@ -278,7 +278,7 @@ END
|
|||
text[MID_BLOCK_KEYWORD_REGEX, 1]
|
||||
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.
|
||||
def push_silent(text, can_suppress = false)
|
||||
flush_merged_text
|
||||
|
@ -286,7 +286,7 @@ END
|
|||
@precompiled << "#{text};"
|
||||
end
|
||||
|
||||
# Adds <tt>text</tt> to <tt>@buffer</tt> with appropriate tabulation
|
||||
# Adds `text` to `@buffer` with appropriate tabulation
|
||||
# without parsing it.
|
||||
def push_merged_text(text, tab_change = 0, indent = true)
|
||||
text = !indent || @dont_indent_next_line || @options[:ugly] ? text : "#{' ' * @output_tabs}#{text}"
|
||||
|
@ -294,7 +294,7 @@ END
|
|||
@dont_indent_next_line = false
|
||||
end
|
||||
|
||||
# Concatenate <tt>text</tt> to <tt>@buffer</tt> without tabulation.
|
||||
# Concatenate `text` to `@buffer` without tabulation.
|
||||
def concat_merged_text(text)
|
||||
@to_merge << [:text, text, 0]
|
||||
end
|
||||
|
@ -356,18 +356,18 @@ END
|
|||
end
|
||||
end
|
||||
|
||||
# Adds +text+ to <tt>@buffer</tt> while flattening text.
|
||||
# Adds +text+ to `@buffer` while flattening text.
|
||||
def push_flat(line)
|
||||
text = line.full.dup
|
||||
text = "" unless text.gsub!(/^#{@flat_spaces}/, '')
|
||||
@filter_buffer << "#{text}\n"
|
||||
end
|
||||
|
||||
# Causes <tt>text</tt> to be evaluated in the context of
|
||||
# the scope object and the result to be added to <tt>@buffer</tt>.
|
||||
# Causes `text` to be evaluated in the context of
|
||||
# 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
|
||||
# the result before it is added to <tt>@buffer</tt>
|
||||
# If `opts[:preserve_script]` is true, Haml::Helpers#find_and_flatten is run on
|
||||
# the result before it is added to `@buffer`
|
||||
def push_script(text, opts = {})
|
||||
raise SyntaxError.new("There's no Ruby code for = to evaluate.") if text.empty?
|
||||
return if options[:suppress_eval]
|
||||
|
@ -400,7 +400,7 @@ END
|
|||
!(opts[:in_tag] || opts[:nuke_inner_whitespace] || @options[:ugly])])
|
||||
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.
|
||||
def push_flat_script(text, options = {})
|
||||
flush_merged_text
|
||||
|
@ -416,13 +416,13 @@ END
|
|||
push_and_tabulate([:haml_comment])
|
||||
end
|
||||
|
||||
# Closes the most recent item in <tt>@to_close_stack</tt>.
|
||||
# Closes the most recent item in `@to_close_stack`.
|
||||
def close
|
||||
tag, *rest = @to_close_stack.pop
|
||||
send("close_#{tag}", *rest)
|
||||
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.
|
||||
def close_element(value)
|
||||
tag, nuke_outer_whitespace, nuke_inner_whitespace = value
|
||||
|
@ -474,8 +474,8 @@ END
|
|||
@template_tabs -= 1
|
||||
end
|
||||
|
||||
# Iterates through the classes and ids supplied through <tt>.</tt>
|
||||
# and <tt>#</tt> syntax, and returns a hash with them as attributes,
|
||||
# Iterates through the classes and ids supplied through `.`
|
||||
# and `#` syntax, and returns a hash with them as attributes,
|
||||
# that can then be merged with another attributes hash.
|
||||
def parse_class_and_id(list)
|
||||
attributes = {}
|
||||
|
@ -672,7 +672,7 @@ END
|
|||
end
|
||||
|
||||
# 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)
|
||||
tag_name, attributes, attributes_hashes, object_ref, nuke_outer_whitespace,
|
||||
nuke_inner_whitespace, action, value, last_line = parse_tag(line)
|
||||
|
@ -803,7 +803,7 @@ END
|
|||
end
|
||||
|
||||
# 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)
|
||||
render_tag('%div' + line)
|
||||
end
|
||||
|
@ -991,8 +991,8 @@ END
|
|||
!flat? && @next_line.tabs > @line.tabs
|
||||
end
|
||||
|
||||
# Pushes value onto <tt>@to_close_stack</tt> and increases
|
||||
# <tt>@template_tabs</tt>.
|
||||
# Pushes value onto `@to_close_stack` and increases
|
||||
# `@template_tabs`.
|
||||
def push_and_tabulate(value)
|
||||
@to_close_stack.push(value)
|
||||
@template_tabs += 1
|
||||
|
|
|
@ -107,15 +107,15 @@ module Sass
|
|||
# Includes named mixin declared using MIXIN_DEFINITION_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|$)/
|
||||
|
||||
# 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+|$)(.*)/
|
||||
|
||||
# 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+|$)(.*)/
|
||||
|
||||
# The default options for Sass::Engine.
|
||||
|
|
|
@ -5,7 +5,7 @@ module Sass::Script
|
|||
class Color < Literal
|
||||
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({
|
||||
'black' => 0x000000,
|
||||
'silver' => 0xc0c0c0,
|
||||
|
@ -24,7 +24,7 @@ module Sass::Script
|
|||
'teal' => 0x008080,
|
||||
'aqua' => 0x00ffff
|
||||
}) {|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]}
|
||||
|
||||
# Constructs an RGB or RGBA color object.
|
||||
|
@ -189,10 +189,7 @@ END
|
|||
# {Color}
|
||||
# : Multiplies each of the RGB color channels together.
|
||||
#
|
||||
# {Literal}
|
||||
# : See {Literal#times}.
|
||||
#
|
||||
# @param other [Literal] The right-hand side of the operator
|
||||
# @param other [Number, Color] The right-hand side of the operator
|
||||
# @return [Color] The resulting color
|
||||
# @raise [Sass::SyntaxError] if `other` is a number with units
|
||||
def times(other)
|
||||
|
@ -235,10 +232,7 @@ END
|
|||
# {Color}
|
||||
# : Takes each of this color's RGB color channels modulo the other color's.
|
||||
#
|
||||
# {Literal}
|
||||
# : See {Literal#mod}.
|
||||
#
|
||||
# @param other [Literal] The right-hand side of the operator
|
||||
# @param other [Number, Color] The right-hand side of the operator
|
||||
# @return [Color] The resulting color
|
||||
# @raise [Sass::SyntaxError] if `other` is a number with units
|
||||
def mod(other)
|
||||
|
|
|
@ -8,16 +8,16 @@ module Sass
|
|||
class Lexer
|
||||
# A struct containing information about an individual token.
|
||||
#
|
||||
# `type`: [{Symbol}]
|
||||
# `type`: \[{Symbol}\]
|
||||
# : The type of token.
|
||||
#
|
||||
# `value`: [{Object}]
|
||||
# `value`: \[{Object}\]
|
||||
# : 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.
|
||||
#
|
||||
# `offset`: [{Fixnum}]
|
||||
# `offset`: \[{Fixnum}\]
|
||||
# : The number of bytes into the line the SassScript token appeared.
|
||||
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
|
||||
margin: 0 2em
|
||||
|
||||
.section.readme
|
||||
#filecontents
|
||||
*:target, dt:target + dd
|
||||
background-color: #ccf
|
||||
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