diff --git a/doc-src/README.markdown b/doc-src/README.markdown index 169dd854..c4c63b99 100644 --- a/doc-src/README.markdown +++ b/doc-src/README.markdown @@ -87,9 +87,11 @@ After adding the example and adjusting the metadata, go to the reference page an ### How to Add New Reference Documentation -In the appropriate directory under content/reference add a haml file. You will probably find it convenient to copy another reference item and edit it. +Generate a reference file for a stylesheet: -The item metadata (at the top of the file) must provide some details about what stylesheet is being documented. For instance, here is the metadata for the blueprint color module item: + ./bin/thor generate:reference ../frameworks/compass/stylesheets/_compass.sass + +The item metadata (at the top of the file) provides some details about what stylesheet is being documented. For instance, here is the metadata for the blueprint color module item: --- title: Blueprint Color Module @@ -104,4 +106,4 @@ The `title` and `crumb` attributes are the H1 and the Breadcrumb label respectiv There are some shared partials that do most of the sass file inspection and formatting. __Most of the docs are kept in the source code__, but if there are times when you need more control, you can drop down to more powerful tools. -All source comments are formatted in Markdown. \ No newline at end of file +All source comments are formatted in Markdown. diff --git a/doc-src/content/stylesheets/main.sass b/doc-src/content/stylesheets/main.sass index 029c6a30..92fd809c 100644 --- a/doc-src/content/stylesheets/main.sass +++ b/doc-src/content/stylesheets/main.sass @@ -79,4 +79,6 @@ ol#breadcrumbs li:after content: " > " li.last:after - content: "" \ No newline at end of file + content: "" + li.last + visibility: hidden \ No newline at end of file diff --git a/doc-src/layouts/reference.haml b/doc-src/layouts/reference.haml new file mode 100644 index 00000000..bd8959db --- /dev/null +++ b/doc-src/layouts/reference.haml @@ -0,0 +1,9 @@ += render "partials/breadcrumbs" + +%h1= item[:title] + += yield + += render "partials/reference/imports" + += render "partials/reference/mixins" diff --git a/doc-src/tasks/generators.thor b/doc-src/tasks/generators.thor index fe219b5d..6e238a97 100644 --- a/doc-src/tasks/generators.thor +++ b/doc-src/tasks/generators.thor @@ -1,7 +1,10 @@ +$: << File.join(File.dirname(__FILE__), '..', '..', 'lib') require 'fileutils' +require 'compass' class Generate < Thor desc "example IDENTIFIER", "Generate a new example." + method_options :title => :string, :framework => :string, :stylesheet => :string, :mixin => :string def example(identifier) identifier = identifier.dup identifier << "/" unless identifier[identifier.length - 1] == ?/ @@ -49,7 +52,56 @@ class Generate < Thor end end - desc "reference FRAMEWORK STYLESHEET", "Generate a reference page for the given stylesheet." - def reference(identifier) + desc "reference ../frameworks/fmwk/stylesheets/path/to/_module.sass", "Generate a reference page for the given stylesheet." + method_options :title => :string + def reference(stylesheet) + stylesheet = dereference(stylesheet) + identifier = "reference/#{stylesheet[:framework]}/#{stylesheet[:stylesheet]}" + identifier.gsub!(%r{/_},'/') + identifier.gsub!(/\.sass/,'') + identifier.gsub!(%r{/#{stylesheet[:framework]}/#{stylesheet[:framework]}/},"/#{stylesheet[:framework]}/") + + module_name = File.basename(identifier).gsub(/\.[^.]+$/,'').capitalize + framework_name = stylesheet[:framework].capitalize + + title = @options[:title] || "#{framework_name} #{module_name}" + crumb = @options[:title] || module_name + + file_name = "content/#{identifier}.haml" + directory = File.dirname(file_name) + + puts "DIRECTORY #{directory}" + FileUtils.mkdir_p directory + + puts " CREATE #{file_name}" + open(file_name, "w") do |reference_file| + contents = <<-CONTENTS + | --- + | title: #{title} + | crumb: #{crumb} + | framework: #{stylesheet[:framework]} + | stylesheet: #{stylesheet[:stylesheet]} + | classnames: + | - reference + | --- + | - render 'reference' do + | %p + | Lorem ipsum dolor sit amet. + CONTENTS + reference_file.puts contents.gsub(/^ +\| /, '') + + puts " ITEM /#{identifier}/" + end end -end \ No newline at end of file + + private + def dereference(stylesheet) + stylesheet = File.expand_path(stylesheet) + framework = Compass::Frameworks::ALL.find{|f| stylesheet.index(f.stylesheets_directory) == 0} + raise "No Framework found for #{stylesheet}" unless framework + { + :framework => framework.name, + :stylesheet => stylesheet[framework.stylesheets_directory.length+1..-1] + } + end +end