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

Add --head-html and --body-html options.

The --body-html replaces --append-html.

The canonical URL and description are now added through --head-html -
so they aren't hardcoded and can be changed when JSDuck is used for
something else than ExtJS 4.
parent 48af037b
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -71,10 +71,15 @@ end
def run_jsduck_export(extra_options, ext_dir)
  load_sdk_vars
  rev = `git rev-parse HEAD`.slice(0, 7)
  head_html = <<-EOHTML
    <link rel="canonical" href="http://docs.sencha.com/ext-js/4-0/" />
    <meta name="description" content="Ext JS 4.0 API Documentation from Sencha. Class documentation, Guides and Videos on how to create Javascript applications with Ext JS 4">
  EOHTML

  run_jsduck([
    "--title", "Ext JS 4.0.2a API Documentation",
    "--footer", "ExtJS 4.0.2a Documentation from Sencha. Generated with <a href='https://github.com/senchalabs/jsduck'>JSDuck</a> revison #{rev}",
    "--head-html", head_html,
    "#{SDK_DIR}/extjs/src",
    "#{SDK_DIR}/platform/src",
    "#{SDK_DIR}/platform/core/src",
@@ -92,7 +97,7 @@ desc "Run JSDuck on ExtJS SDK to create release version of docs app"
task :export do
  load_sdk_vars
  run_jsduck_export([
    "--append-html", <<-EOHTML
    "--body-html", <<-EOHTML
    <div id="notice-text" style="display: none">
      Use <a href="http://docs.sencha.com/ext-js/4-0">http://docs.sencha.com/ext-js/4-0</a> for up to date documentation and features
    </div>
@@ -104,7 +109,7 @@ desc "Run JSDuck on ExtJS SDK to create live docs app"
task :live_docs do
  load_sdk_vars
  run_jsduck_export([
    "--append-html", <<-EOHTML
    "--body-html", <<-EOHTML
    <script type="text/javascript">
      var _gaq = _gaq || [];
      _gaq.push(['_setAccount', 'UA-1396058-10']);
+6 −2
Original line number Diff line number Diff line
@@ -71,8 +71,12 @@ opts = OptionParser.new do | opts |
    app.footer = text
  end

  opts.on('--append-html=HTML', "Extra code to append to the index.html page.", " ") do |html|
    app.append_html = html
  opts.on('--head-html=HTML', "HTML to append to the <head> section of index.html.", " ") do |html|
    app.head_html = html
  end

  opts.on('--body-html=HTML', "HTML to append to the <body> section index.html.", " ") do |html|
    app.body_html = html
  end

  opts.on('--guides=PATH', "Path to guides directory.",
+6 −3
Original line number Diff line number Diff line
@@ -40,7 +40,8 @@ module JsDuck
    attr_accessor :title
    attr_accessor :footer
    attr_accessor :extjs_path
    attr_accessor :append_html
    attr_accessor :head_html
    attr_accessor :body_html

    def initialize
      @output_dir = nil
@@ -60,7 +61,8 @@ module JsDuck
      @title = "Ext JS API Documentation"
      @footer = 'Generated with <a href="https://github.com/senchalabs/jsduck">JSDuck</a>.'
      @extjs_path = "extjs/ext-all.js"
      @append_html = ""
      @head_html = ""
      @body_html = ""
      @timer = Timer.new
      @parallel = ParallelWrap.new
    end
@@ -283,9 +285,10 @@ module JsDuck
      html.gsub!("{title}", @title)
      html.gsub!("{footer}", @footer)
      html.gsub!("{extjs_path}", @extjs_path)
      html.gsub!("{append_html}", @append_html)
      html.gsub!("{guides}", @guides.to_html)
      html.gsub!("{categories}", @categories.to_html)
      html.gsub!("{head_html}", @head_html)
      html.gsub!("{body_html}", @body_html)
      FileUtils.rm(dir+"/index.html")
      File.open(dir+"/index.html", 'w') {|f| f.write(html) }
    end
+3 −3
Original line number Diff line number Diff line
@@ -3,10 +3,8 @@
<head>
  <title>{title}</title>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <meta name="Description" content="Ext JS 4.0 API Documentation from Sencha. Class documentation, Guides and Videos on how to create Javascript applications with Ext JS 4">

  <link rel="shortcut icon" type="image/ico" href="favicon.ico" />
  <link rel="canonical" href="http://docs.sencha.com/ext-js/4-0/" />
  <link rel="stylesheet" href="resources/css/reset.css" type="text/css" />
  <link rel="stylesheet" href="resources/css/docs-ext.css" type="text/css" />
  <link rel="stylesheet" href="resources/css/scrollbars.css" type="text/css" />
@@ -28,6 +26,8 @@
  <script type="text/javascript" src="output/tree.js"></script>
  <script type="text/javascript" src="output/searchData.js"></script>

  {head_html}

</head>
<body id="ext-body" class="iScroll">
    <div id="loading"><span class="title"></span><span class="logo"></span></div>
@@ -38,6 +38,6 @@
    {guides}
    {categories}
    <div id="footer-content" style="display: none">{footer}</div>
    {append_html}
    {body_html}
</body>
</html>