Commit a8ac27dc authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Add --css option.

To include additional CSS to the page.
The CSS will get appended to the CSS generated by Tag classes.
parent 7d83dcb1
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ module JsDuck
    attr_accessor :footer
    attr_accessor :head_html
    attr_accessor :body_html
    attr_accessor :css
    attr_accessor :message
    attr_accessor :welcome
    attr_accessor :guides
@@ -99,6 +100,7 @@ module JsDuck
      @footer = "Generated with <a href='https://github.com/senchalabs/jsduck'>JSDuck</a> #{@version}."
      @head_html = ""
      @body_html = ""
      @css = ""
      @message = ""
      @welcome = nil
      @guides = nil
@@ -294,6 +296,14 @@ module JsDuck
          @body_html += html
        end

        opts.on('--css=CSS',
          "Extra CSS rules to include to the page.",
          "",
          "This option can be used repeatedly to append multiple",
          "chunks of CSS.") do |css|
          @css += css
        end

        opts.on('--message=HTML',
          "(Warning) message to show prominently.",
          "",
+6 −2
Original line number Diff line number Diff line
@@ -4,12 +4,16 @@ require 'jsduck/util/md5'
module JsDuck
  module Web

    # Writes the CSS gathered from Tag classes into given file.
    # Writes the CSS gathered from Tag classes and --css option into given file.
    # Then Renames the file so it contains an MD5 hash inside it,
    # returning the resulting fingerprinted name.
    class Css
      def initialize(opts)
        @opts = opts
      end

      def write(filename)
        File.open(filename, 'w') {|f| f.write(TagRegistry.css) }
        File.open(filename, 'w') {|f| f.write(TagRegistry.css + @opts.css) }
        Util::MD5.rename(filename)
      end
    end
+1 −1
Original line number Diff line number Diff line
@@ -51,7 +51,7 @@ module JsDuck
        # Remember the MD5-fingerprinted filenames
        paths = {
          :data => Web::Data.new(@relations, @assets, @opts).write(@opts.output_dir+"/data.js"),
          :css => Web::Css.new.write(@opts.output_dir+"/styles.css"),
          :css => Web::Css.new(@opts).write(@opts.output_dir+"/styles.css"),
        }

        Web::IndexHtml.new(@assets, @opts, paths).write