Commit 826a77f9 authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Allow Markdown file to be used with --welcome.

Added additional styles for the welcome page so that when it's
rendered from Markdown, the default result will look OK.
parent 96048f41
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -30,7 +30,7 @@ module JsDuck
      doc_formatter.relations = @relations

      @images = Images.new(@opts.images)
      @welcome = Welcome.create(@opts.welcome)
      @welcome = Welcome.create(@opts.welcome, doc_formatter)
      @guides = Guides.create(@opts.guides, doc_formatter, @opts)
      @videos = Videos.create(@opts.videos)
      @examples = Examples.create(@opts.examples, @opts)
+4 −2
Original line number Diff line number Diff line
@@ -292,9 +292,11 @@ module JsDuck
        end

        opts.on('--welcome=PATH',
          "HTML file with content for welcome page.",
          "File with content for welcome page.",
          "",
          "It should only contain the <body> part of a HTML page.",
          "Either HTML or Markdown file with content for welcome page.",
          "HTML file must only contain the <body> part of the page.",
          "Markdown file must have a .md or .markdown extension.",
          "",
          "See also: https://github.com/senchalabs/jsduck/wiki/Welcome-page") do |path|
          @welcome = canonical(path)
+7 −4
Original line number Diff line number Diff line
@@ -5,17 +5,20 @@ module JsDuck

  class Welcome
    # Creates Welcome object from filename.
    def self.create(filename)
    def self.create(filename, doc_formatter)
      if filename
        Welcome.new(filename)
        Welcome.new(filename, doc_formatter)
      else
        Util::NullObject.new(:to_html => "")
      end
    end

    # Parses welcome HTML file with content for welcome page.
    def initialize(filename)
    # Parses welcome HTML or Markdown file with content for welcome page.
    def initialize(filename, doc_formatter)
      @html = Util::IO.read(filename)
      if filename =~ /\.(md|markdown)\Z/i
        @html = '<div class="markdown">' + doc_formatter.format(@html) + '</div>'
      end
    end

    # Returns the HTML
+39 −1
Original line number Diff line number Diff line
@@ -25,6 +25,44 @@
    padding: 1em 0 0.4em 0;
    font-weight: normal; } }

// When welcome text rendered from Markdown.
#welcomeindex .markdown {
  margin: 2em;
  color: $docs-text-color;
  p {
    margin-bottom: 1em; }
  h1 {
    color: $docs-heading-color;
    font-family: $docs-heading-font;
    font-size: 2em; }
  h2 { @include guides-h2-heading; }
  h3 { @include guides-h3-heading; }
  h3 { font-weight: bold; font-size: 1.1em; }
  h4 { font-weight: bold; }
  ul {
    margin: 0 0 1em 2em;
    li {
      list-style: disc outside; } }
  ol {
    margin: 0 0 1em 2em;
    li {
      list-style: decimal outside; } }
  em {
    font-style: italic; }
  strong {
    font-weight: bold; }
  pre {
    background-color: #f7f7f7;
    border: solid 1px #e8e8e8;
    @include border-radius(5px);
    color: #314e64;
    font-family: $docs-monospace-font;
    padding: 10px 12px;
    margin: 10px 0 14px 0;
    overflow-x: auto;
    overflow-y: hidden; } }


.class-overview, .guide-container, .comments-index {
  // Style only the body area, or the toolbar will get styled too
  .x-panel-body {
@@ -32,7 +70,7 @@
    .clr {
      clear: both; }
    p, ul, ol {
      color: #484848;
      color: $docs-text-color;
      max-width: 900px; }
    p {
      padding: 0;