mirror of
https://github.com/danog/sass-site.git
synced 2024-11-30 04:29:17 +01:00
Build YARD docs from the sass-site repo
This avoids needing to run nested bundler processes, which doesn't work well on Heroku.
This commit is contained in:
parent
04aad7ab6e
commit
2696bbae5b
1
.gitignore
vendored
1
.gitignore
vendored
@ -17,3 +17,4 @@ bundle
|
||||
/source/documentation
|
||||
Thumbs.db
|
||||
.Trashes
|
||||
/.yardoc
|
||||
|
1
Gemfile
1
Gemfile
@ -24,6 +24,7 @@ group :development do
|
||||
gem 'tzinfo-data', '~> 1.2015.7', platforms: [:mswin, :mingw, :jruby]
|
||||
gem 'wdm', '~> 0.1.1', platforms: [:mswin, :mingw]
|
||||
gem 'therubyracer', '~> 0.12.3'
|
||||
gem 'yard', '~> 0.9'
|
||||
end
|
||||
|
||||
gem 'middleman-minify-html', '~> 3.4.1'
|
||||
|
@ -200,6 +200,7 @@ GEM
|
||||
json (>= 1.8.0)
|
||||
xpath (2.1.0)
|
||||
nokogiri (~> 1.3)
|
||||
yard (0.9.12)
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
@ -227,6 +228,7 @@ DEPENDENCIES
|
||||
typogruby (~> 1.0.18)
|
||||
tzinfo-data (~> 1.2015.7)
|
||||
wdm (~> 0.1.1)
|
||||
yard (~> 0.9)
|
||||
|
||||
RUBY VERSION
|
||||
ruby 2.4.1p111
|
||||
|
87
Rakefile
87
Rakefile
@ -1,14 +1,8 @@
|
||||
require 'yard'
|
||||
|
||||
# This is a helper function that properly sets up
|
||||
# the environment in the .sass folder for bundle commands to work
|
||||
def bundle(cmd)
|
||||
Bundler.with_clean_env do
|
||||
sh %{bundle #{cmd}}
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
task :sass do
|
||||
namespace :sass do
|
||||
# Check out the latest stable version of Ruby Sass into the .sass directory.
|
||||
task :checkout do
|
||||
unless Dir.exists?(".sass")
|
||||
sh %{git clone git://github.com/sass/sass .sass}
|
||||
end
|
||||
@ -22,31 +16,78 @@ task :sass do
|
||||
# Check out the most recent released stable version
|
||||
sh %{git checkout #{File.read("VERSION").strip}}
|
||||
end
|
||||
|
||||
bundle %{install}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
task :sass_version => :sass do
|
||||
task :version => :checkout do
|
||||
require 'yaml'
|
||||
version = File.read(".sass/VERSION").strip
|
||||
name = File.read(".sass/VERSION_NAME").strip
|
||||
File.open('data/version.yml', 'w') {|f| f.write(YAML.dump({'number' => version, 'name' => name}))}
|
||||
end
|
||||
end
|
||||
|
||||
task :sass_docs => :sass do
|
||||
ENV["RUBOCOP"] = "false"
|
||||
Dir.chdir(".sass") { bundle %{exec rake doc}}
|
||||
YARD::Rake::YardocTask.new(:doc) do |t|
|
||||
t.before = lambda do
|
||||
t.files = FileList.new('.sass/lib/**/*.rb') do |list|
|
||||
list.exclude('.sass/lib/sass/plugin/merb.rb')
|
||||
list.exclude('.sass/lib/sass/plugin/rails.rb')
|
||||
end.to_a
|
||||
t.options += FileList.new('.sass/yard/*.rb').to_a.map {|f| ['-e', f]}.flatten
|
||||
files = FileList.new('.sass/doc-src/*').to_a.sort_by {|s| s.size} + %w[.sass/MIT-LICENSE .sass/VERSION]
|
||||
t.options << '--files' << files.join(',')
|
||||
t.options << '--main' << '.sass/README.md'
|
||||
end
|
||||
|
||||
t.after = lambda do
|
||||
sh %{rm -rf source/documentation}
|
||||
sh %{cp -r .sass/doc source/documentation}
|
||||
sh %{mv doc source/documentation}
|
||||
Dir['source/documentation/**/*.html'].each do |path|
|
||||
contents = File.read(path)
|
||||
File.open(path, 'w') {|file| file.write(contents.gsub(%r{css/common\.css}, '../assets/css/docs.css'))}
|
||||
end
|
||||
end
|
||||
|
||||
desc "Import information from Sass."
|
||||
task :import_sass => [:sass_version, :sass_docs]
|
||||
require 'nokogiri'
|
||||
doc = Nokogiri::HTML(File.read('source/documentation/file.SASS_REFERENCE.html'))
|
||||
|
||||
doc.css("#filecontents").css("h1, h2, h3, h4, h5, h6").each do |h|
|
||||
next if h.inner_text.empty?
|
||||
h['id'] =
|
||||
case h.inner_text
|
||||
when "Referencing Parent Selectors: &"; "parent-selector"
|
||||
when /^Comments:/; "comments"
|
||||
when "Strings"; "sass-script-strings"
|
||||
when "Division and /"; "division-and-slash"
|
||||
when /^Subtraction,/; "subtraction"
|
||||
when "& in SassScript"; "parent-script"
|
||||
when "@-Rules and Directives"; "directives"
|
||||
when "@extend-Only Selectors"; "placeholders"
|
||||
when "@extend-Only Selectors"; "placeholders"
|
||||
when "@each"; "each-directive"
|
||||
when "Multiple Assignment"; "each-multi-assign"
|
||||
when "Mixin Directives"; "mixins"
|
||||
when /^Defining a Mixin:/; "defining_a_mixin"
|
||||
when /^Including a Mixin:/; "including_a_mixin"
|
||||
when "Arguments"; "mixin-arguments"
|
||||
when "Passing Content Blocks to a Mixin"; "mixin-content"
|
||||
else
|
||||
h.inner_text.downcase.gsub(/[^a-z _-]/, '').gsub(' ', '_')
|
||||
end
|
||||
end
|
||||
|
||||
# Give each option an anchor.
|
||||
doc.css("#filecontents li p strong code").each do |c|
|
||||
c['id'] = c.inner_text.gsub(/:/, '') + '-option'
|
||||
end
|
||||
|
||||
File.write('source/documentation/file.SASS_REFERENCE.html', doc.to_html)
|
||||
end
|
||||
end
|
||||
Rake::Task['sass:doc'].prerequisites.insert(0, 'sass:checkout')
|
||||
Rake::Task['sass:doc'].instance_variable_set('@comment', nil)
|
||||
|
||||
desc "Import information from Sass."
|
||||
task :import => [:doc, :version]
|
||||
end
|
||||
|
||||
desc "Build the middleman-controlled portion of the site."
|
||||
task :middleman do
|
||||
@ -54,7 +95,7 @@ task :middleman do
|
||||
end
|
||||
|
||||
desc "Build the site."
|
||||
task :build => [:import_sass, :middleman]
|
||||
task :build => ["sass:import", :middleman]
|
||||
|
||||
task :check_ready_to_deploy do
|
||||
if `git config remote.heroku.url`.strip != "git@heroku.com:sass-lang.git"
|
||||
|
Loading…
Reference in New Issue
Block a user