From e078110853acf455816ee799e7cc4f811b124029 Mon Sep 17 00:00:00 2001 From: Nathan Weizenbaum Date: Sun, 10 May 2009 02:04:40 -0700 Subject: [PATCH] [Sass] Fix an old merge error. --- lib/sass.rb | 2 +- lib/sass/engine.rb | 66 ---------------------------------------------- lib/sass/files.rb | 27 +++++++++++++++++++ 3 files changed, 28 insertions(+), 67 deletions(-) diff --git a/lib/sass.rb b/lib/sass.rb index c5354c23..2cbe26fd 100644 --- a/lib/sass.rb +++ b/lib/sass.rb @@ -991,7 +991,7 @@ require 'haml/version' # or `width = !main_width`. # By default, either syntax is valid. # -# `cache` +# {#cache} `cache` # : Whether parsed Sass files should be cached, # allowing greater speed. Defaults to true. # diff --git a/lib/sass/engine.rb b/lib/sass/engine.rb index 801eda2e..acfaf80a 100644 --- a/lib/sass/engine.rb +++ b/lib/sass/engine.rb @@ -468,71 +468,5 @@ END Tree::FileNode.new(filename) end.flatten end -<<<<<<< HEAD:lib/sass/engine.rb -======= - - # Find the full filename of a Sass or CSS file to import. - # This follows Sass's import rules: - # if the filename given ends in `".sass"` or `".css"`, - # it will try to find that type of file; - # otherwise, it will try to find the corresponding Sass file - # and fall back on CSS if it's not available. - # - # Any Sass filename returned will correspond to - # an actual Sass file on the filesystem. - # CSS filenames, however, may not; - # they're expected to be put through directly to the stylesheet - # as CSS `@import` statements. - # - # @param filename [String] The filename to search for - # @param load_paths [Array] The set of filesystem paths - # to search for Sass files. - # @return [String] The filename of the imported file. - # This is an absolute path if the file is a `".sass"` file. - # @raise [Sass::SyntaxError] if `filename` ends in ``".sass"`` - # and no corresponding Sass file could be found. - def self.find_file_to_import(filename, load_paths) - was_sass = false - original_filename = filename - - if filename[-5..-1] == ".sass" - filename = filename[0...-5] - was_sass = true - elsif filename[-4..-1] == ".css" - return filename - end - - new_filename = find_full_path("#{filename}.sass", load_paths) - - return new_filename if new_filename - return filename + '.css' unless was_sass - raise SyntaxError.new("File to import not found or unreadable: #{original_filename}.", @line) - end - - # Checks each of the paths in `load_paths` for a file named `filename`. - # - # This will also find files with the same name as `filename` - # but with an underscore prefixing the basename. - # For example, if filename is `"foo/bar/baz.sass"`, - # this will look for `"foo/bar/baz.sass"` **and** `"foo/bar/_baz.sass"`. - # - # @param filename [String] The filename to search for - # @param load_paths [Array] The set of filesystem paths - # to search for Sass files - # @return [String] The absolute path of the matching file, - # or nil if no matching file is found - def self.find_full_path(filename, load_paths) - segments = filename.split(File::SEPARATOR) - segments.push "_#{segments.pop}" - partial_name = segments.join(File::SEPARATOR) - load_paths.each do |path| - [partial_name, filename].each do |name| - full_path = File.join(path, name) - return full_path if File.readable?(full_path) - end - end - nil - end ->>>>>>> yard:lib/sass/engine.rb end end diff --git a/lib/sass/files.rb b/lib/sass/files.rb index 7b5dc7a1..4cf69418 100644 --- a/lib/sass/files.rb +++ b/lib/sass/files.rb @@ -6,6 +6,13 @@ module Sass module Files extend self + # Returns the {Sass::Tree} for the given file, + # reading it from the Sass cache if possible. + # + # @param filename [String] The path to the Sass file + # @param options [Hash] The options hash. + # Only the [`:cache_location`](../Sass.html#cache) option is used + # @raise [Sass::SyntaxError] if there's an error in the document def tree_for(filename, options) options = Sass::Engine::DEFAULT_OPTIONS.merge(options) text = File.read(filename) @@ -33,6 +40,26 @@ module Sass root end + # Find the full filename of a Sass or CSS file to import. + # This follows Sass's import rules: + # if the filename given ends in `".sass"` or `".css"`, + # it will try to find that type of file; + # otherwise, it will try to find the corresponding Sass file + # and fall back on CSS if it's not available. + # + # Any Sass filename returned will correspond to + # an actual Sass file on the filesystem. + # CSS filenames, however, may not; + # they're expected to be put through directly to the stylesheet + # as CSS `@import` statements. + # + # @param filename [String] The filename to search for + # @param load_paths [Array] The set of filesystem paths + # to search for Sass files. + # @return [String] The filename of the imported file. + # This is an absolute path if the file is a `".sass"` file. + # @raise [Sass::SyntaxError] if `filename` ends in ``".sass"`` + # and no corresponding Sass file could be found. def find_file_to_import(filename, load_paths) was_sass = false original_filename = filename