Skip to content

Commit aa1be2f

Browse files
committed
Add Jest documentation
1 parent 22461b0 commit aa1be2f

13 files changed

Lines changed: 95 additions & 1 deletion

File tree

assets/images/docs.png

705 Bytes
Loading

assets/images/[email protected]

1.54 KB
Loading

assets/javascripts/news.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[
22
[
33
"2017-05-14",
4-
"New documentation: <a href=\"/liquid/\">Liquid</a>"
4+
"New documentations: <a href=\"/jest/\">Jest</a> and <a href=\"/liquid/\">Liquid</a>"
55
], [
66
"2017-04-30",
77
"New documentation: <a href=\"/openjdk/\">OpenJDK</a>"

assets/javascripts/templates/pages/about_tmpl.coffee

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,11 @@ credits = [
283283
'2015 InfluxData, Inc.',
284284
'MIT',
285285
'https://github.com/influxdata/docs.influxdata.com/blob/master/LICENSE'
286+
], [
287+
'Jest',
288+
'2014-present Facebook Inc.',
289+
'BSD',
290+
'https://raw.githubusercontent.com/facebook/jest/master/LICENSE'
286291
], [
287292
'jQuery',
288293
'Packt Publishing<br>&copy; jQuery Foundation and other contributors',

assets/javascripts/views/pages/simple.coffee

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ app.views.ExpressPage =
2828
app.views.GoPage =
2929
app.views.ImmutablePage =
3030
app.views.InfluxdataPage =
31+
app.views.JestPage =
3132
app.views.KnockoutPage =
3233
app.views.KotlinPage =
3334
app.views.LaravelPage =

assets/stylesheets/global/_icons.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
%icon-clipboard-white { background-position: -1rem -2rem; }
4444
%icon-close-white { background-position: -2rem -2rem; }
4545

46+
._icon-jest:before { background-position: 0 0; }
4647
._icon-liquid:before { background-position: -1rem 0; }
4748
._icon-openjdk:before { background-position: -2rem 0; }
4849
._icon-codeceptjs:before { background-position: -3rem 0; }

assets/stylesheets/pages/_simple.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
._haxe,
2929
._immutable,
3030
._influxdata,
31+
._jest,
3132
._less,
3233
._lodash,
3334
._marionette,
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
module Docs
2+
class Jest
3+
class CleanHtmlFilter < Filter
4+
def call
5+
@doc = at_css('.mainContainer .post')
6+
7+
at_css('h1').content = 'Jest' if root_page?
8+
9+
css('.edit-page-link', '.hash-link', 'hr').remove
10+
11+
css('.postHeader', 'article', 'div:not([class])').each do |node|
12+
node.before(node.children).remove
13+
end
14+
15+
css('.anchor[name]').each do |node|
16+
node.parent['id'] = node['name']
17+
node.remove
18+
end
19+
20+
css('pre').each do |node|
21+
node['data-language'] = node['class'][/language-(\w+)/, 1]
22+
node.content = node.content
23+
end
24+
25+
doc
26+
end
27+
end
28+
end
29+
end

lib/docs/filters/jest/entries.rb

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
module Docs
2+
class Jest
3+
class EntriesFilter < Docs::EntriesFilter
4+
def get_name
5+
at_css('.mainContainer h1').content
6+
end
7+
8+
def get_type
9+
type = at_css('.navItemActive').ancestors('.navGroup').first.at_css('h3').content
10+
11+
if type == 'Introduction'
12+
'Guides: Introduction'
13+
elsif type == 'API Reference'
14+
self.name
15+
else
16+
type
17+
end
18+
end
19+
20+
def additional_entries
21+
return [] unless !root_page? && self.type == self.name # api page
22+
23+
at_css('.mainContainer ul').css('li > a').map do |node|
24+
name = node.at_css('code').content.strip
25+
name.sub! %r{\(.*\)}, '()'
26+
name.remove! %r{[\s=<].*}
27+
name.prepend 'jest ' if name.start_with?('--')
28+
name.prepend 'Config: ' if slug == 'configuration'
29+
id = node['href'].remove('#')
30+
[name, id]
31+
end
32+
end
33+
end
34+
end
35+
end

lib/docs/scrapers/jest.rb

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
module Docs
2+
class Jest < UrlScraper
3+
self.type = 'jest'
4+
self.release = '20.0.1'
5+
self.base_url = 'https://facebook.github.io/jest/docs/en/'
6+
self.root_path = 'getting-started.html'
7+
self.links = {
8+
home: 'https://facebook.github.io/jest/',
9+
code: 'https://github.com/facebook/jest'
10+
}
11+
12+
html_filters.push 'jest/entries', 'jest/clean_html'
13+
14+
options[:container] = '.docMainWrapper'
15+
16+
options[:attribution] = <<-HTML
17+
&copy; 2014&ndash;present Facebook Inc.<br>
18+
Licensed under the BSD License.
19+
HTML
20+
end
21+
end

0 commit comments

Comments
 (0)