Whitelist rather than blacklist constants.

This commit is contained in:
Nathan Weizenbaum 2010-04-20 03:11:30 -07:00
parent 7f10fc5c38
commit bb6765a37d
19 changed files with 9 additions and 53 deletions

View File

@ -4,6 +4,7 @@
--default-return ""
--title "Haml/Sass Documentation"
--query 'object.type != :classvariable'
--query 'object.type != :constant || @api && @api.text == "public"'
--hide-void-return
--protected
--no-private

View File

@ -17,6 +17,7 @@ module Haml
# A string representing the version of Haml.
# A more fine-grained representation is available from Haml.version.
# @api public
VERSION = version[:string] unless defined?(Haml::VERSION)
# Initializes Haml for Rails.

View File

@ -115,7 +115,6 @@ module Haml
@options[:input], @options[:output] = input, output
end
# @private
COLORS = { :red => 31, :green => 32, :yellow => 33 }
# Prints a status message about performing the given action,

View File

@ -327,6 +327,7 @@ END
end
# An alias for the Textile filter,
# since the only available Textile parser is RedCloth.
# @api public
RedCloth = Textile
Filters.defined['redcloth'] = RedCloth

View File

@ -500,7 +500,6 @@ MESSAGE
end
# Characters that need to be escaped to HTML entities from user input
# @private
HTML_ESCAPE = { '&'=>'&amp;', '<'=>'&lt;', '>'=>'&gt;', '"'=>'&quot;', "'"=>'&#039;', }
# Returns a copy of `text` with ampersands, angle brackets and quotes

View File

@ -146,7 +146,6 @@ module Haml
end
alias_method :to_haml, :render
# @private
TEXT_REGEXP = /^(\s*).*$/
# @see Hpricot

View File

@ -8,60 +8,46 @@ module Haml
include Haml::Util
# Designates an XHTML/XML element.
# @private
ELEMENT = ?%
# Designates a `<div>` element with the given class.
# @private
DIV_CLASS = ?.
# Designates a `<div>` element with the given id.
# @private
DIV_ID = ?#
# Designates an XHTML/XML comment.
# @private
COMMENT = ?/
# Designates an XHTML doctype or script that is never HTML-escaped.
# @private
DOCTYPE = ?!
# Designates script, the result of which is output.
# @private
SCRIPT = ?=
# Designates script that is always HTML-escaped.
# @private
SANITIZE = ?&
# Designates script, the result of which is flattened and output.
# @private
FLAT_SCRIPT = ?~
# Designates script which is run but not output.
# @private
SILENT_SCRIPT = ?-
# When following SILENT_SCRIPT, designates a comment that is not output.
# @private
SILENT_COMMENT = ?#
# Designates a non-parsed line.
# @private
ESCAPE = ?\\
# Designates a block of filtered text.
# @private
FILTER = ?:
# Designates a non-parsed line. Not actually a character.
# @private
PLAIN_TEXT = -1
# Keeps track of the ASCII values of the characters that begin a
# specially-interpreted line.
# @private
SPECIAL_CHARACTERS = [
ELEMENT,
DIV_CLASS,
@ -78,7 +64,6 @@ module Haml
# The value of the character that designates that a line is part
# of a multiline string.
# @private
MULTILINE_CHAR_VALUE = ?|
# Regex to match keywords that appear in the middle of a Ruby block
@ -94,15 +79,12 @@ module Haml
#
# The block is ended after `%p no!`, because `else`
# is a member of this array.
# @private
MID_BLOCK_KEYWORD_REGEX = /^-\s*(#{%w[else elsif rescue ensure when end].join('|')})\b/
# The Regex that matches a Doctype command.
# @private
DOCTYPE_REGEX = /(\d(?:\.\d)?)?[\s]*([a-z]*)/i
# The Regex that matches a literal string or symbol value
# @private
LITERAL_VALUE_REGEX = /:(\w*)|(["'])((?![\\#]|\2).|\\.)*\2/
private

View File

@ -2,5 +2,6 @@ module Haml
# The root directory of the Haml source tree.
# This may be overridden by the package manager
# if the lib directory is separated from the main source tree.
# @api public
ROOT_DIR = File.expand_path("../../..", __FILE__)
end

View File

@ -10,6 +10,7 @@ module Haml
extend self
# An array of ints representing the Ruby version number.
# @api public
RUBY_VERSION = ::RUBY_VERSION.split(".").map {|s| s.to_i}
# Returns the path of a file relative to the Haml root directory.

View File

@ -16,6 +16,7 @@ module Sass
# A string representing the version of Sass.
# A more fine-grained representation is available from {Haml::Version#version Sass.version}.
# @api public
VERSION = version[:string] unless defined?(Sass::VERSION)
end

View File

@ -79,60 +79,49 @@ module Sass
end
# The character that begins a CSS property.
# @private
PROPERTY_CHAR = ?:
# The character that designates that
# a property should be assigned to a SassScript expression.
# @private
SCRIPT_CHAR = ?=
# The character that designates the beginning of a comment,
# either Sass or CSS.
# @private
COMMENT_CHAR = ?/
# The character that follows the general COMMENT_CHAR and designates a Sass comment,
# which is not output as a CSS comment.
# @private
SASS_COMMENT_CHAR = ?/
# The character that follows the general COMMENT_CHAR and designates a CSS comment,
# which is embedded in the CSS document.
# @private
CSS_COMMENT_CHAR = ?*
# The character used to denote a compiler directive.
# @private
DIRECTIVE_CHAR = ?@
# Designates a non-parsed rule.
# @private
ESCAPE_CHAR = ?\\
# Designates block as mixin definition rather than CSS rules to output
# @private
MIXIN_DEFINITION_CHAR = ?=
# Includes named mixin declared using MIXIN_DEFINITION_CHAR
# @private
MIXIN_INCLUDE_CHAR = ?+
# The regex that matches properties of the form `name: prop`.
# @private
PROPERTY_NEW_MATCHER = /^[^\s:"\[]+\s*[=:](\s|$)/
# The regex that matches and extracts data from
# properties of the form `name: prop`.
# @private
PROPERTY_NEW = /^([^\s=:"]+)\s*(=|:)(?:\s+|$)(.*)/
# The regex that matches and extracts data from
# properties of the form `:name prop`.
# @private
PROPERTY_OLD = /^:([^\s=:"]+)\s*(=?)(?:\s+|$)(.*)/
# The default options for Sass::Engine.
# @api public
DEFAULT_OPTIONS = {
:style => :nested,
:load_paths => ['.'],
@ -562,7 +551,6 @@ WARNING
nil
end
# @private
MIXIN_DEF_RE = /^(?:=|@mixin)\s*(#{Sass::SCSS::RX::IDENT})(.*)$/
def parse_mixin_definition(line)
name, arg_string = line.text.scan(MIXIN_DEF_RE).first
@ -575,7 +563,6 @@ WARNING
Tree::MixinDefNode.new(name, args)
end
# @private
MIXIN_INCLUDE_RE = /^(?:\+|@include)\s*(#{Sass::SCSS::RX::IDENT})(.*)$/
def parse_mixin_include(line, root)
name, arg_string = line.text.scan(MIXIN_INCLUDE_RE).first

View File

@ -13,11 +13,9 @@ module Sass
# This module contains code that handles the parsing and evaluation of SassScript.
module Script
# The regular expression used to parse variables.
# @private
MATCH = /^[!\$](#{Sass::SCSS::RX::IDENT})\s*((?:\|\|)?=|:)\s*(.+?)(!(?i:default))?$/
# The regular expression used to validate variables without matching.
# @private
VALIDATE = /^[!\$]#{Sass::SCSS::RX::IDENT}$/
# Parses a string of SassScript

View File

@ -19,7 +19,6 @@ module Sass::Script
class << self; include Haml::Util; end
# A hash from color names to `[red, green, blue]` value arrays.
# @private
HTML4_COLORS = map_vals({
'black' => 0x000000,
'silver' => 0xc0c0c0,
@ -39,7 +38,6 @@ module Sass::Script
'aqua' => 0x00ffff
}) {|color| (0..2).map {|n| color >> (n << 3) & 0xff}.reverse}
# A hash from `[red, green, blue]` value arrays to color names.
# @private
HTML4_COLORS_REVERSE = map_hash(HTML4_COLORS) {|k, v| [v, k]}
# Constructs an RGB or HSL color object,

View File

@ -40,7 +40,6 @@ module Sass
attr_reader :offset
# A hash from operator strings to the corresponding token types.
# @private
OPERATORS = {
'+' => :plus,
'-' => :minus,
@ -67,10 +66,8 @@ module Sass
'{' => :lcurly,
}
# @private
OPERATORS_REVERSE = Haml::Util.map_hash(OPERATORS) {|k, v| [v, k]}
# @private
TOKEN_NAMES = Haml::Util.map_hash(OPERATORS_REVERSE) {|k, v| [k, v.inspect]}.merge({
:const => "variable (e.g. $foo)",
:ident => "identifier (e.g. middle)",
@ -79,16 +76,13 @@ module Sass
# A list of operator strings ordered with longer names first
# so that `>` and `<` don't clobber `>=` and `<=`.
# @private
OP_NAMES = OPERATORS.keys.sort_by {|o| -o.size}
# A sub-list of {OP_NAMES} that only includes operators
# with identifier names.
# @private
IDENT_OP_NAMES = OP_NAMES.select {|k, v| k =~ /^\w+/}
# A hash of regular expressions that are used for tokenizing.
# @private
REGULAR_EXPRESSIONS = {
:whitespace => /\s+/,
:comment => COMMENT,

View File

@ -30,6 +30,7 @@ module Sass::Script
# The precision with which numbers will be printed to CSS files.
# For example, if this is `1000.0`,
# `3.1415926` will be printed as `3.142`.
# @api public
PRECISION = 1000.0
# @param value [Numeric] The value of the number
@ -381,9 +382,7 @@ module Sass::Script
end
# A hash of unit names to their index in the conversion table
# @private
CONVERTABLE_UNITS = {"in" => 0, "cm" => 1, "pc" => 2, "mm" => 3, "pt" => 4}
# @private
CONVERSION_TABLE = [[ 1, 2.54, 6, 25.4, 72 ], # in
[ nil, 1, 2.36220473, 10, 28.3464567], # cm
[ nil, nil, 1, 4.23333333, 12 ], # pc

View File

@ -120,7 +120,6 @@ module Sass
new(*args).parse
end
# @private
PRECEDENCE = [
:comma, :single_eq, :concat, :or, :and,
[:eq, :neq],

View File

@ -15,7 +15,7 @@ module Sass::Script
# @return [Symbol] `:string` or `:identifier`
attr_reader :type
# In addition to setting the {#context} of the string,
# In addition to setting the \{#context} of the string,
# this sets the string to be an identifier if the context is `:equals`.
#
# @see Node#context=

View File

@ -99,7 +99,6 @@ module Sass
node << comment
end
# @private
DIRECTIVES = Set[:mixin, :include, :debug, :warn, :for, :while, :if, :import, :media]
def directive
@ -639,7 +638,6 @@ MESSAGE
result
end
# @private
EXPR_NAMES = {
:media_query => "media query (e.g. print, screen, print and screen)",
:media_expr => "media expression (e.g. (min-device-width: 800px)))",
@ -649,7 +647,6 @@ MESSAGE
:expr => "expression (e.g. 1px, bold)",
}
# @private
TOK_NAMES = Haml::Util.to_hash(
Sass::SCSS::RX.constants.map {|c| [Sass::SCSS::RX.const_get(c), c.downcase]}).
merge(IDENT => "identifier", /[;}]/ => '";"', /[=:]/ => '":"')

View File

@ -7,7 +7,6 @@ module Sass::Tree
# @see Sass::Tree
class RuleNode < Node
# The character used to include the parent selector
# @private
PARENT = '&'
# The CSS selector for this rule,