Skip to content

Commit 69a7614

Browse files
committed
Add Jekyll tag to isolate "production-only" doc components.
1 parent f2bf44a commit 69a7614

File tree

3 files changed

+31
-5
lines changed

3 files changed

+31
-5
lines changed

docs/README.md

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,21 @@ We include the Spark documentation as part of the source (as opposed to using a
1010

1111
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.
1212

13-
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.
14-
15-
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.
13+
The markdown code can be compiled to HTML using the
14+
[Jekyll tool](http://jekyllrb.com). To use the `jekyll` command, you will
15+
need to have Jekyll installed. The easiest way to do this is via a Ruby Gem, see the
16+
[jekyll installation instructions](http://jekyllrb.com/docs/installation).
17+
Compiling the site with Jekyll will create a directory called
18+
_site containing index.html as well as the rest of the compiled files.
19+
20+
You can modify the default Jekyll build as follows:
21+
22+
# Skip generating API docs (which takes a while)
23+
$ SKIP_SCALADOC=1 jekyll build
24+
# Serve content locally on port 4000
25+
$ jekyll serve --watch
26+
# Build the site with extra features used on the live page
27+
$ PRODUCTION=1 jekyll build
1628

1729
## Pygments
1830

docs/_layouts/global.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@
2424

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

27+
{% production %}
2728
<!-- Google analytics script -->
2829
<script type="text/javascript">
29-
/*
3030
var _gaq = _gaq || [];
3131
_gaq.push(['_setAccount', 'UA-32518208-1']);
3232
_gaq.push(['_trackPageview']);
@@ -36,8 +36,8 @@
3636
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
3737
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
3838
})();
39-
*/
4039
</script>
40+
{% endproduction %}
4141

4242
</head>
4343
<body>

docs/_plugins/production_tag.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
module Jekyll
2+
class ProductionTag < Liquid::Block
3+
4+
def initialize(tag_name, markup, tokens)
5+
super
6+
end
7+
8+
def render(context)
9+
if ENV['PRODUCTION'] then super else "" end
10+
end
11+
end
12+
end
13+
14+
Liquid::Template.register_tag('production', Jekyll::ProductionTag)

0 commit comments

Comments
 (0)