mirror of
https://github.com/freeCodeCamp/devdocs
synced 2024-11-16 19:48:10 +01:00
Webpack 1.9 documentation
This commit is contained in:
parent
79822f8ebc
commit
ba165ae8b4
8 changed files with 161 additions and 0 deletions
|
@ -67,5 +67,6 @@
|
|||
'pages/socketio',
|
||||
'pages/sphinx',
|
||||
'pages/underscore',
|
||||
'pages/webpack',
|
||||
'pages/yard',
|
||||
'pages/yii';
|
||||
|
|
|
@ -68,4 +68,5 @@
|
|||
'pages/sphinx',
|
||||
'pages/underscore',
|
||||
'pages/yard',
|
||||
'pages/webpack',
|
||||
'pages/yii';
|
||||
|
|
55
assets/stylesheets/pages/_webpack.scss
Normal file
55
assets/stylesheets/pages/_webpack.scss
Normal file
|
@ -0,0 +1,55 @@
|
|||
._webpack {
|
||||
> h2 { @extend %block-heading; }
|
||||
> h3 { @extend %block-label, %label-blue; }
|
||||
> h4 { font-size: 1em; }
|
||||
|
||||
/*
|
||||
Copied from the original webpack css
|
||||
https://webpack.github.io/docs/css/doc.css
|
||||
*/
|
||||
code .comment {
|
||||
color: #998;
|
||||
font-style: italic
|
||||
}
|
||||
|
||||
code .keyword {
|
||||
color: #333;
|
||||
font-weight: 700
|
||||
}
|
||||
|
||||
code .number {
|
||||
color: #099
|
||||
}
|
||||
|
||||
code .string {
|
||||
color: #d14
|
||||
}
|
||||
|
||||
code .tag {
|
||||
color: navy;
|
||||
font-weight: 400
|
||||
}
|
||||
|
||||
code .attribute {
|
||||
color: teal
|
||||
}
|
||||
|
||||
code .regexp {
|
||||
color: #009926
|
||||
}
|
||||
|
||||
code .preprocessor {
|
||||
color: #999;
|
||||
font-weight: 700
|
||||
}
|
||||
|
||||
code .deletion {
|
||||
background: #fdd;
|
||||
display: block
|
||||
}
|
||||
|
||||
code .addition {
|
||||
background: #dfd;
|
||||
display: block
|
||||
}
|
||||
}
|
46
lib/docs/filters/webpack/clean_html.rb
Normal file
46
lib/docs/filters/webpack/clean_html.rb
Normal file
|
@ -0,0 +1,46 @@
|
|||
module Docs
|
||||
class Webpack
|
||||
class CleanHtmlFilter < Filter
|
||||
def call
|
||||
root_page? ? root : other
|
||||
doc
|
||||
end
|
||||
|
||||
def root
|
||||
@doc = at_css(".container > .row > .col-md-9")
|
||||
|
||||
# Remove all introdcution before the hr,
|
||||
# The introduction about the documentation site which isn't relevant
|
||||
# in devdocs.
|
||||
hr_index = doc.children.find_index { |node| node.name == "hr" }
|
||||
doc.children[0..hr_index].each(&:remove)
|
||||
|
||||
# Add a page header :)
|
||||
page_header_node = Nokogiri::XML::Node.new "h1", @doc
|
||||
page_header_node.content = "Webpack"
|
||||
@doc.children.first.add_previous_sibling page_header_node
|
||||
end
|
||||
|
||||
|
||||
def other
|
||||
# Re-create the header element
|
||||
page_header = at_css("#wikititle").content.upcase
|
||||
page_header_node = Nokogiri::XML::Node.new "h1", @doc
|
||||
page_header_node.content = page_header
|
||||
|
||||
# Change the scope of the page
|
||||
@doc = at_css("#wiki")
|
||||
|
||||
# Add the page header
|
||||
@doc.children.first.add_previous_sibling page_header_node
|
||||
|
||||
# Remove the sidebar links in each page
|
||||
css(".contents").remove
|
||||
|
||||
# Remove all anchors
|
||||
css("a.anchor").remove
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
41
lib/docs/filters/webpack/entries.rb
Normal file
41
lib/docs/filters/webpack/entries.rb
Normal file
|
@ -0,0 +1,41 @@
|
|||
module Docs
|
||||
class Webpack
|
||||
class EntriesFilter < Docs::EntriesFilter
|
||||
def get_name
|
||||
entry_link.content.strip.titleize
|
||||
end
|
||||
|
||||
def get_type
|
||||
link_li = entry_link.parent
|
||||
type_links_list = link_li.parent
|
||||
current_type = type_links_list.parent
|
||||
|
||||
# current type is a
|
||||
# <li>
|
||||
# TYPE
|
||||
# <li> <ul> .. links .. </ul> </li>
|
||||
# </li>
|
||||
#
|
||||
# Grab the first children (which is the text nodes whose contains the type)
|
||||
current_type.children.first.content.strip.titleize
|
||||
end
|
||||
|
||||
|
||||
def additional_entries
|
||||
return [] unless root_page?
|
||||
|
||||
css('.sidebar a').each_with_object [] do |link, entries|
|
||||
name = link.content.strip
|
||||
entries << [name, link['href']]
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def entry_link
|
||||
at_css("a[href='#{self.path}']")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
17
lib/docs/scrapers/webpack.rb
Normal file
17
lib/docs/scrapers/webpack.rb
Normal file
|
@ -0,0 +1,17 @@
|
|||
module Docs
|
||||
class Webpack < UrlScraper
|
||||
self.name = 'Webpack'
|
||||
self.type = 'webpack'
|
||||
self.version = '1.9'
|
||||
self.base_url = 'https://webpack.github.io/docs/'
|
||||
self.root_path = 'index.html'
|
||||
|
||||
html_filters.push 'webpack/entries', 'webpack/clean_html'
|
||||
|
||||
|
||||
options[:attribution] = <<-HTML
|
||||
© 2012–2015 Tobias Koppers<br>
|
||||
Licensed under the MIT License.
|
||||
HTML
|
||||
end
|
||||
end
|
BIN
public/icons/docs/webpack/16.png
Normal file
BIN
public/icons/docs/webpack/16.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 51 KiB |
BIN
public/icons/docs/webpack/16@2x.png
Normal file
BIN
public/icons/docs/webpack/16@2x.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.7 KiB |
Loading…
Reference in a new issue