Webpack 1.9 documentation

This commit is contained in:
Yosi Attias 2015-06-19 17:24:18 +03:00 committed by Thibaut
parent 79822f8ebc
commit ba165ae8b4
8 changed files with 161 additions and 0 deletions

View file

@ -67,5 +67,6 @@
'pages/socketio',
'pages/sphinx',
'pages/underscore',
'pages/webpack',
'pages/yard',
'pages/yii';

View file

@ -68,4 +68,5 @@
'pages/sphinx',
'pages/underscore',
'pages/yard',
'pages/webpack',
'pages/yii';

View 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
}
}

View 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

View 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

View 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
&copy; 2012&ndash;2015 Tobias Koppers<br>
Licensed under the MIT License.
HTML
end
end

Binary file not shown.

After

Width:  |  Height:  |  Size: 51 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB