forked from freeCodeCamp/devdocs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request freeCodeCamp#882 from jmerle/enzyme
Add Enzyme documentation
- Loading branch information
Showing
4 changed files
with
103 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
module Docs | ||
class Enzyme | ||
class CleanHtmlFilter < Filter | ||
def call | ||
@doc = at_css('.page-inner > section') | ||
|
||
# Remove badges | ||
if root_page? | ||
css('a > img').each do |node| | ||
node.parent.remove | ||
end | ||
end | ||
|
||
# Clean headers | ||
css('h1').each do |node| | ||
node.content = node.content | ||
end | ||
|
||
# Make headers on reference pages bigger | ||
if subpath.include?('api/') | ||
css('h3, h4').each do |node| | ||
node.name = 'h2' | ||
end | ||
end | ||
|
||
# Make code blocks detectable by Prism | ||
css('pre').each do |node| | ||
cls = node.at_css('code')['class'] | ||
|
||
unless cls.nil? | ||
node['data-language'] = cls.split('-')[1] | ||
end | ||
|
||
node.content = node.content | ||
end | ||
|
||
doc | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
module Docs | ||
class Enzyme | ||
class EntriesFilter < Docs::EntriesFilter | ||
def get_name | ||
name = at_css('.page-inner h1').content | ||
|
||
if name.include?('(') | ||
until_parenthesis = name[0..name.index('(')] | ||
|
||
if until_parenthesis.include?(' ') | ||
until_parenthesis[0..-3] | ||
else | ||
until_parenthesis + ')' | ||
end | ||
else | ||
name | ||
end | ||
end | ||
|
||
def get_type | ||
active_level = at_css('.chapter.active')['data-level'] | ||
|
||
# It's a parent level if it contains only one dot | ||
if active_level.count('.') == 1 | ||
at_css('.chapter.active > a').content | ||
else | ||
parent_level = active_level[0..active_level.rindex('.') - 1] | ||
at_css(".chapter[data-level=\"#{parent_level}\"] > a").content | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
module Docs | ||
class Enzyme < UrlScraper | ||
self.type = 'simple' | ||
self.release = '3.10.0' | ||
self.base_url = 'https://airbnb.io/enzyme/' | ||
self.root_path = 'index.html' | ||
self.links = { | ||
code: 'https://github.com/airbnb/enzyme' | ||
} | ||
|
||
html_filters.push 'enzyme/entries', 'enzyme/clean_html' | ||
|
||
options[:skip] = %w(CHANGELOG.html docs/future.html docs/guides.html docs/api/ CONTRIBUTING.html) | ||
|
||
options[:attribution] = <<-HTML | ||
© 2015 Airbnb, Inc.<br> | ||
Licensed under the MIT License. | ||
HTML | ||
|
||
def get_latest_version(opts) | ||
get_npm_version('enzyme', opts) | ||
end | ||
end | ||
end |