Skip to content

Commit

Permalink
Add Jekyll tag to isolate "production-only" doc components. (0.9 vers…
Browse files Browse the repository at this point in the history
…ion)

Author: Patrick Wendell <pwendell@gmail.com>

Closes #57 from pwendell/jekyll-prod-0.9 and squashes the following commits:

69a7614 [Patrick Wendell] Add Jekyll tag to isolate "production-only" doc components.
  • Loading branch information
pwendell committed Mar 3, 2014
1 parent f2bf44a commit 267d96c
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 5 deletions.
18 changes: 15 additions & 3 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,21 @@ We include the Spark documentation as part of the source (as opposed to using a

In this directory you will find textfiles formatted using Markdown, with an ".md" suffix. You can read those text files directly if you want. Start with index.md.

To make things quite a bit prettier and make the links easier to follow, generate the html version of the documentation based on the src directory by running `jekyll` in the docs directory. Use the command `SKIP_SCALADOC=1 jekyll` to skip building and copying over the scaladoc which can be timely. To use the `jekyll` command, you will need to have Jekyll installed, the easiest way to do this is via a Ruby Gem, see the [jekyll installation instructions](https://github.com/mojombo/jekyll/wiki/install). This will create a directory called _site containing index.html as well as the rest of the compiled files. Read more about Jekyll at https://github.com/mojombo/jekyll/wiki.

In addition to generating the site as html from the markdown files, jekyll can serve up the site via a webserver. To build and run a webserver use the command `jekyll --server` which (currently) runs the webserver on port 4000, then visit the site at http://localhost:4000.
The markdown code can be compiled to HTML using the
[Jekyll tool](http://jekyllrb.com). To use the `jekyll` command, you will
need to have Jekyll installed. The easiest way to do this is via a Ruby Gem, see the
[jekyll installation instructions](http://jekyllrb.com/docs/installation).
Compiling the site with Jekyll will create a directory called
_site containing index.html as well as the rest of the compiled files.

You can modify the default Jekyll build as follows:

# Skip generating API docs (which takes a while)
$ SKIP_SCALADOC=1 jekyll build
# Serve content locally on port 4000
$ jekyll serve --watch
# Build the site with extra features used on the live page
$ PRODUCTION=1 jekyll build

## Pygments

Expand Down
4 changes: 2 additions & 2 deletions docs/_layouts/global.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@

<link rel="stylesheet" href="css/pygments-default.css">

{% production %}
<!-- Google analytics script -->
<script type="text/javascript">
/*
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-32518208-1']);
_gaq.push(['_trackPageview']);
Expand All @@ -36,8 +36,8 @@
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
*/
</script>
{% endproduction %}

</head>
<body>
Expand Down
14 changes: 14 additions & 0 deletions docs/_plugins/production_tag.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module Jekyll
class ProductionTag < Liquid::Block

def initialize(tag_name, markup, tokens)
super
end

def render(context)
if ENV['PRODUCTION'] then super else "" end
end
end
end

Liquid::Template.register_tag('production', Jekyll::ProductionTag)

0 comments on commit 267d96c

Please sign in to comment.