Commit 203f3345 authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Eliminate :header attribute from options.

Only leave the :title and calculate later the header from it in
Web::IndexHtml class.
parent 13eaa24d
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -177,7 +177,6 @@ module JsDuck
        separator ""

        attribute :title, "Documentation - JSDuck"
        attribute :header, "<strong>Documentation</strong> JSDuck"
        option('--title=TEXT',
          "Custom title text for the documentation.",
          "",
@@ -187,7 +186,6 @@ module JsDuck
          "the header of the page.  Inside page header the left",
          "part (from ' - ' separator) will be shown in bold.") do |text|
          @opts.title = text
          @opts.header = text.sub(/^(.*?) +- +/, "<strong>\\1</strong> ")
        end

        attribute :footer, "Generated on {DATE} by {JSDUCK} {VERSION}."
+7 −3
Original line number Diff line number Diff line
@@ -35,7 +35,7 @@ module JsDuck
        write_template(in_file, out_file, {
          "{title}" => @opts.title,
          "{mobile_redirect}" => @opts.seo ? include_script(@opts.template+"/mobile-redirect.js") : "",
          "{header}" => @opts.header,
          "{header}" => header,
          "{footer}" => footer,
          "{extjs_path}" => @opts.extjs_path,
          "{data_path}" => File.basename(@paths[:data]),
@@ -52,7 +52,7 @@ module JsDuck
      def create_print_template_html(in_file, out_file)
        write_template(in_file, out_file, {
          "{title}" => @opts.title,
          "{header}" => @opts.header,
          "{header}" => header,
          "{css_path}" => File.basename(@paths[:css]),
        })
      end
@@ -63,7 +63,7 @@ module JsDuck

        write_template(in_file, out_file, {
          "{title}" => @opts.title,
          "{header}" => @opts.header,
          "{header}" => header,
          "{categories}" => categories ? "<h1>API Documentation</h1> #{categories}" : "",
          "{guides}" => guides ? "<h1>Guides</h1> #{guides}" : "",
          "{css_path}" => File.basename(@paths[:css]),
@@ -74,6 +74,10 @@ module JsDuck
        "<script type='text/javascript'>\n" + Util::IO.read(filename) + "\n</script>"
      end

      def header
        @opts.title.sub(/^(.*?) +- +/, "<strong>\\1</strong> ")
      end

      def footer
        jsduck = "<a href='https://github.com/senchalabs/jsduck'>JSDuck</a>"
        date = Time.new.strftime('%a %d %b %Y %H:%M:%S')
+1 −14
Original line number Diff line number Diff line
@@ -111,20 +111,6 @@ describe JsDuck::Options::Parser do
    end
  end

  describe :title do
    it "defaults to 'Documentation - JSDuck'" do
      opts = parse()
      opts.title.should == 'Documentation - JSDuck'
      opts.header.should == "<strong>Documentation</strong> JSDuck"
    end

    it "sets both title and header" do
      opts = parse("--title", "Docs - MyApp")
      opts.title.should == "Docs - MyApp"
      opts.header.should == "<strong>Docs</strong> MyApp"
    end
  end

  describe :import do
    it "defaults to empty array" do
      parse().import.should == []
@@ -251,6 +237,7 @@ describe JsDuck::Options::Parser do
  # Simple setters
  {
    :encoding => "--encoding",
    :title => ["--title", "Documentation - JSDuck"],
    :footer => ["--footer", "Generated on {DATE} by {JSDUCK} {VERSION}."],
    :welcome => "--welcome",
    :guides => "--guides",