Skip to content

Commit

Permalink
Add support for sass style comment in .scss files as per trulia#235
Browse files Browse the repository at this point in the history
  • Loading branch information
infinityrobot committed Jun 23, 2016
1 parent bb479de commit 7f06499
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/hologram/doc_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def process_file(file, doc_block_collection)

#check if scss file has sass comments
if hologram_comments.length == 0 and file.end_with?('.scss')
hologram_comments = file_str.scan(/\s*\/\/doc\s*((( [^\n]*\n)|\n)+)/).map{ |arr| [arr[0].gsub(/^[ \t]{2}/,'')] }
hologram_comments = file_str.scan(/\s*\/\/doc\s*((([\/ \t]{2}[^\n]*\n)|\n)+)/).map{ |arr| [arr[0].gsub(/[ \t]{2}/,'').gsub(/^\/\//, '')] }
end
end
return unless hologram_comments
Expand Down
27 changes: 27 additions & 0 deletions spec/doc_parser_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,23 @@
eos
end

let(:scss_sass_doc) do
<<-eos
//doc
// ---
// title: sass documentation
// name: sass_doc
// category: Foo
// ---
//
// Some description
// on multiple lines
eos
end

let(:source_path) { 'spec/fixtures/source' }
let(:temp_doc) { File.join(source_path, 'components', 'button', 'skin', 'testSkin.css') }
let(:scss_temp_doc) { File.join(source_path, 'components', 'button', 'skin', 'scssComponents.scss') }
let(:plugins) {
plugins = double()
allow(plugins).to receive(:block)
Expand Down Expand Up @@ -225,5 +240,17 @@
objects = expect(pages['bar.html'][:md]).to match(/multi-parent.*multi-child/m)
end
end

context 'when a scss file contains a sass documentation block' do
around do |example|
File.open(scss_temp_doc, 'w'){ |io| io << scss_sass_doc }
example.run
FileUtils.rm(scss_temp_doc)
end

it 'should parse the comment properly' do
objects = expect(pages['foo.html'][:md]).to include 'Some description'
end
end
end
end

0 comments on commit 7f06499

Please sign in to comment.