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

New behavior for --title option.

The --title now specifies both the <title> and the contents of the header
at the very top of docs app.  The new default is "Sencha Docs - Ext JS".

The title is no more used in classes index page.  This has now static heading
"API Documentation".  Also the guides, videos, examples index pages have
headings without "Ext JS" in them - so the headings will work also for
Touch and whatever else.

Finally the title is also used in print version.  For this did some
refactoring with writing the template files in app.rb.
parent af4da3d6
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -79,7 +79,7 @@ def run_jsduck_export(extra_options)
  EOHTML

  run_jsduck([
    "--title", "Ext JS 4.0 API Documentation",
    "--title", "Sencha Docs - Ext JS 4.0",
    "--footer", "Ext JS 4.0.5 Documentation from Sencha. Generated with <a href='https://github.com/senchalabs/jsduck'>JSDuck</a> revison #{rev}",
    "--head-html", head_html,
    "#{SDK_DIR}/extjs/src",
@@ -170,8 +170,7 @@ task :charts do
  load_sdk_vars
  system(*[
    "ruby", "bin/jsduck",
    "--title", "Sencha Touch Charts API Documentation",
    "--external", "Error",
    "--title", "Sencha Docs - Touch Charts",
    "--ignore-global",
    "--guides", "#{SDK_DIR}/charts/guides",
    "--output", "#{OUT_DIR}",
@@ -187,7 +186,8 @@ task :touch do
  load_sdk_vars
  system(*[
    "ruby", "bin/jsduck",
    "--title", "Sencha Touch API Documentation",
    "--title", "Sencha Docs - Touch 1.0",
    "--seo",
    "--categories", "#{SDK_DIR}/touch/doc-resources/categories.json",
    "--output", "#{OUT_DIR}",
    "#{SDK_DIR}/touch/src/core",
+33 −13
Original line number Diff line number Diff line
@@ -93,6 +93,7 @@ module JsDuck
          copy_template
        end
        create_template_html
        create_print_template_html
        if !@opts.seo
          FileUtils.rm(@opts.output_dir+"/index.php")
          FileUtils.cp(@opts.output_dir+"/template.html", @opts.output_dir+"/index.html")
@@ -242,19 +243,38 @@ module JsDuck
    end

    def create_template_html
      Logger.instance.log("Creating #{@opts.output_dir}/template.html...")
      html = IO.read(@opts.template_dir+"/template.html")
      html.gsub!("{title}", @opts.title)
      html.gsub!("{footer}", "<div id='footer-content' style='display: none'>#{@opts.footer}</div>")
      html.gsub!("{extjs_path}", @opts.extjs_path)
      html.gsub!("{local_storage_db}", @opts.local_storage_db)
      html.gsub!("{welcome}", @welcome.to_html)
      html.gsub!("{categories}", @categories.to_html)
      html.gsub!("{guides}", @guides.to_html)
      html.gsub!("{head_html}", @opts.head_html)
      html.gsub!("{body_html}", @opts.body_html)
      FileUtils.rm(@opts.output_dir+"/template.html")
      File.open(@opts.output_dir+"/template.html", 'w') {|f| f.write(html) }
      write_template("template.html", {
        "{title}" => @opts.title,
        "{header}" => @opts.header,
        "{footer}" => "<div id='footer-content' style='display: none'>#{@opts.footer}</div>",
        "{extjs_path}" => @opts.extjs_path,
        "{local_storage_db}" => @opts.local_storage_db,
        "{welcome}" => @welcome.to_html,
        "{categories}" => @categories.to_html,
        "{guides}" => @guides.to_html,
        "{head_html}" => @opts.head_html,
        "{body_html}" => @opts.body_html,
      })
    end

    def create_print_template_html
      write_template("print-template.html", {
        "{title}" => @opts.title,
        "{header}" => @opts.header,
      })
    end

    # Opens file in template dir, replaces {keys} inside it, writes to output dir
    def write_template(filename, replacements)
      in_file = @opts.template_dir + '/' + filename
      out_file = @opts.output_dir + '/' + filename
      Logger.instance.log("Creating #{out_file}...")
      html = IO.read(in_file)
      html.gsub!(/\{.*?\}/) do |key|
        replacements[key] ? replacements[key] : key
      end
      FileUtils.rm(out_file)
      File.open(out_file, 'w') {|f| f.write(html) }
    end
  end

+7 −4
Original line number Diff line number Diff line
@@ -14,6 +14,7 @@ module JsDuck

    # Customizing output
    attr_accessor :title
    attr_accessor :header
    attr_accessor :footer
    attr_accessor :head_html
    attr_accessor :body_html
@@ -67,7 +68,8 @@ module JsDuck
      @verbose = false

      # Customizing output
      @title = "Ext JS API Documentation"
      @title = "Sencha Docs - Ext JS"
      @header = "<strong>Sencha Docs</strong> Ext JS"
      @footer = 'Generated with <a href="https://github.com/senchalabs/jsduck">JSDuck</a>.'
      @head_html = ""
      @body_html = ""
@@ -131,13 +133,14 @@ module JsDuck
        opts.separator ""

        opts.on('--title=TEXT',
          "Custom title for the documentation @",
          "Defaults to 'ExtJS API Documentation'", " ") do |text|
          "Custom title text for the documentation.",
          "Defaults to 'Sencha Docs - Ext JS'", " ") do |text|
          @title = text
          @header = text.sub(/^(.*?) +- +/, "<strong>\\1 </strong>")
        end

        opts.on('--footer=TEXT',
          "Custom footer text for the documentation @",
          "Custom footer text for the documentation.",
          "Defaults to: 'Generated with JSDuck.'", " ") do |text|
          @footer = text
        end
+1 −1
Original line number Diff line number Diff line
@@ -4,7 +4,7 @@
Ext.define('Docs.controller.Classes', {
    extend: 'Docs.controller.Content',
    baseUrl: '#!/api',
    title: 'Classes',
    title: 'API Documentation',

    requires: [
        'Docs.History',
+1 −1
Original line number Diff line number Diff line
@@ -41,7 +41,7 @@ Ext.define('Docs.view.Viewport', {
                            {
                                xtype: 'container',
                                flex: 1,
                                html: '<div class="logo"><span>Sencha Docs</span> Ext JS 4.0</div>'
                                contentEl: 'header-content'
                            },
                            {
                                xtype: 'searchcontainer',
Loading