diff --git a/.gitignore b/.gitignore index 8b22282640..01a28e203f 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ .bundle *.pxm *.sketch +*.pyc tmp public/assets public/fonts diff --git a/Gemfile b/Gemfile index 2dafff05d3..ba366107ae 100644 --- a/Gemfile +++ b/Gemfile @@ -1,12 +1,15 @@ source 'https://rubygems.org' -ruby '2.2.0' +ruby '2.3.0' +gem 'rake' gem 'thor' gem 'pry', '~> 0.10.0' -gem 'activesupport', '~> 4.0', require: false +gem 'activesupport', '~> 4.2', require: false gem 'yajl-ruby', require: false group :app do + gem 'capybara' + gem 'selenium-webdriver' gem 'rack' gem 'sinatra' gem 'sinatra-contrib' @@ -29,19 +32,15 @@ end group :docs do gem 'typhoeus' - gem 'nokogiri', '~> 1.6.0' + gem 'nokogiri' gem 'html-pipeline' gem 'progress_bar', require: false gem 'unix_utils', require: false + gem 'tty-pager', require: false end group :test do gem 'minitest' gem 'rr', require: false gem 'rack-test', require: false -end - -if ENV['SELENIUM'] == '1' - gem 'capybara' - gem 'selenium-webdriver' -end +end \ No newline at end of file diff --git a/Gemfile.lock b/Gemfile.lock index bf835bd818..e6ed08136f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,110 +1,118 @@ GEM remote: https://rubygems.org/ specs: - activesupport (4.2.0) + activesupport (4.2.6) i18n (~> 0.7) json (~> 1.7, >= 1.7.7) minitest (~> 5.1) thread_safe (~> 0.3, >= 0.3.4) tzinfo (~> 1.1) - backports (3.6.4) + backports (3.6.8) better_errors (2.1.1) coderay (>= 1.0.0) erubis (>= 2.6.6) rack (>= 0.9.0) - browser (0.8.0) - coderay (1.1.0) - coffee-script (2.3.0) + browser (2.0.3) + coderay (1.1.1) + coffee-script (2.4.1) coffee-script-source execjs - coffee-script-source (1.8.0) - daemons (1.1.9) + coffee-script-source (1.10.0) + concurrent-ruby (1.0.1) + daemons (1.2.3) erubis (2.7.0) - ethon (0.7.2) + ethon (0.8.1) ffi (>= 1.3.0) - eventmachine (1.0.4) - execjs (2.2.2) - ffi (1.9.6) - highline (1.6.21) - hike (1.2.3) - html-pipeline (1.11.0) - activesupport (>= 2) - nokogiri (~> 1.4) + eventmachine (1.2.0.1) + execjs (2.6.0) + ffi (1.9.10) + highline (1.7.8) + html-pipeline (2.4.0) + activesupport (>= 2, < 5) + nokogiri (>= 1.4) i18n (0.7.0) - json (1.8.2) + json (1.8.3) method_source (0.8.2) - mini_portile (0.6.2) - minitest (5.5.1) - multi_json (1.10.1) - nokogiri (1.6.5) - mini_portile (~> 0.6.0) + mini_portile2 (2.0.0) + minitest (5.8.4) + multi_json (1.11.2) + nokogiri (1.6.7.2) + mini_portile2 (~> 2.0.0.rc2) options (2.3.2) - progress_bar (1.0.3) - highline (~> 1.6.1) + progress_bar (1.0.5) + highline (~> 1.6) options (~> 2.3.0) - pry (0.10.1) + pry (0.10.3) coderay (~> 1.1.0) method_source (~> 0.8.1) slop (~> 3.4) - rack (1.6.0) + rack (1.6.4) rack-protection (1.5.3) rack rack-test (0.6.3) rack (>= 1.0) + rake (11.1.2) rr (1.1.2) - sass (3.4.9) - sinatra (1.4.5) - rack (~> 1.4) + sass (3.4.22) + sinatra (1.4.7) + rack (~> 1.5) rack-protection (~> 1.4) - tilt (~> 1.3, >= 1.3.4) - sinatra-contrib (1.4.2) + tilt (>= 1.3, < 3) + sinatra-contrib (1.4.7) backports (>= 2.0) multi_json rack-protection rack-test sinatra (~> 1.4.0) - tilt (~> 1.3) + tilt (>= 1.3, < 3) slop (3.6.0) - sprockets (2.12.3) - hike (~> 1.2) - multi_json (~> 1.0) - rack (~> 1.0) - tilt (~> 1.1, != 1.3.0) - sprockets-helpers (1.1.0) - sprockets (~> 2.0) - thin (1.6.3) + sprockets (3.6.0) + concurrent-ruby (~> 1.0) + rack (> 1, < 3) + sprockets-helpers (1.2.1) + sprockets (>= 2.2) + thin (1.6.4) daemons (~> 1.0, >= 1.0.9) - eventmachine (~> 1.0) + eventmachine (~> 1.0, >= 1.0.4) rack (~> 1.0) thor (0.19.1) - thread_safe (0.3.4) - tilt (1.4.1) - typhoeus (0.7.0) - ethon (>= 0.7.1) + thread_safe (0.3.5) + tilt (2.0.2) + tty-pager (0.4.0) + tty-screen (~> 0.5.0) + tty-which (~> 0.1.0) + verse (~> 0.4.0) + tty-screen (0.5.0) + tty-which (0.1.0) + typhoeus (1.0.1) + ethon (>= 0.8.0) tzinfo (1.2.2) thread_safe (~> 0.1) - uglifier (2.7.0) - execjs (>= 0.3.0) - json (>= 1.8.0) + uglifier (3.0.0) + execjs (>= 0.3.0, < 3) + unicode_utils (1.4.0) unix_utils (0.0.15) + verse (0.4.0) + unicode_utils (~> 1.4.0) yajl-ruby (1.2.1) PLATFORMS ruby DEPENDENCIES - activesupport (~> 4.0) + activesupport (~> 4.2) better_errors browser coffee-script erubis html-pipeline minitest - nokogiri (~> 1.6.0) + nokogiri progress_bar pry (~> 0.10.0) rack rack-test + rake rr sass sinatra @@ -113,7 +121,11 @@ DEPENDENCIES sprockets-helpers thin thor + tty-pager typhoeus uglifier unix_utils yajl-ruby + +BUNDLED WITH + 1.11.2 \ No newline at end of file diff --git a/assets/stylesheets/application.css.scss b/assets/stylesheets/application.css.scss index 9e246856f8..05328ddcf9 100644 --- a/assets/stylesheets/application.css.scss +++ b/assets/stylesheets/application.css.scss @@ -28,33 +28,31 @@ 'components/prism', 'components/mobile'; -@import 'pages/angular', +@import 'pages/base', + 'pages/angular', + 'pages/apache', 'pages/bower', 'pages/c', 'pages/chai', + 'pages/clojure', 'pages/coffeescript', - 'pages/cordova', 'pages/d3', 'pages/ember', 'pages/express', + 'pages/git', 'pages/go', 'pages/haskell', 'pages/jquery', 'pages/knockout', - 'pages/git', - 'pages/grunt', 'pages/laravel', - 'pages/less', - 'pages/lodash', - 'pages/marionette', - 'pages/markdown', - 'pages/maxcdn', + 'pages/lua', 'pages/mdn', + 'pages/meteor', 'pages/modernizr', 'pages/moment', - 'pages/mongoose', 'pages/nginx', 'pages/node', + 'pages/npm', 'pages/php', 'pages/phpunit', 'pages/postgres', @@ -64,7 +62,6 @@ 'pages/requirejs', 'pages/rethinkdb', 'pages/rfc', - 'pages/sinon', 'pages/socketio', 'pages/sphinx', 'pages/underscore', diff --git a/assets/stylesheets/components/_content.scss b/assets/stylesheets/components/_content.scss index 16c4f3f186..fc3e54d104 100644 --- a/assets/stylesheets/components/_content.scss +++ b/assets/stylesheets/components/_content.scss @@ -205,15 +205,16 @@ float: right; max-width: 15em; margin: .25rem 0 1.5rem 1.5rem; - padding: .75rem 1rem; + padding: .625rem 1rem; @extend %box; - + ._lined-heading { margin-top: 0; } + + h1, + ._lined-heading { margin-top: 0; } } ._toc-title { - margin: 0 0 .75em; + margin: 0 0 .5rem; font-size: inherit; + font-weight: bold; } ._toc-list { @@ -222,6 +223,8 @@ list-style: none; } +._toc-link { @extend %internal-link; } + // // Static page // @@ -425,6 +428,11 @@ ._splash-sponsor > ._maxcdn-logo { background-image: image-url('maxcdn-bw.png'); + @if $style == 'dark' { + filter: invert(100%); + -webkit-filter: invert(100%); + } + @media (-webkit-min-device-pixel-ratio: 1.5), (min-resolution: 144dpi) { background-image: image-url('maxcdn-bw@2x.png'); } @@ -443,6 +451,11 @@ ._splash-sponsor > ._shopify-logo { background-image: image-url('shopify-bw.png'); + @if $style == 'dark' { + filter: invert(100%); + -webkit-filter: invert(100%); + } + @media (-webkit-min-device-pixel-ratio: 1.5), (min-resolution: 144dpi) { background-image: image-url('shopify-bw@2x.png'); } diff --git a/assets/stylesheets/components/_header.scss b/assets/stylesheets/components/_header.scss index 39db0b4fe9..4c96aae661 100644 --- a/assets/stylesheets/components/_header.scss +++ b/assets/stylesheets/components/_header.scss @@ -98,7 +98,11 @@ top: 1rem; left: 1rem; opacity: .4; - @extend %icon, %icon-search; + @if $style == 'dark' { + @extend %icon, %icon-search-white; + } @else { + @extend %icon, %icon-search; + } } } @@ -132,7 +136,11 @@ opacity: .3; &:hover { opacity: .5; } - &:before { @extend %icon, %icon-clear; } + @if $style == 'dark' { + &:before { @extend %icon, %icon-close-white; } + } @else { + &:before { @extend %icon, %icon-clear; } + } ._search-active > & { display: block; } } diff --git a/assets/stylesheets/components/_mobile.scss b/assets/stylesheets/components/_mobile.scss index 96b41158e9..25af1a2bcd 100644 --- a/assets/stylesheets/components/_mobile.scss +++ b/assets/stylesheets/components/_mobile.scss @@ -36,8 +36,8 @@ float: none; width: auto; overflow: hidden; - padding-left: 0; - padding-right: 0; + padding-left: 2px; + padding-right: 2px; border-right: 0; &:before { left: .5rem; } diff --git a/assets/stylesheets/components/_page.scss b/assets/stylesheets/components/_page.scss index 30935d85a3..a7670f77a1 100644 --- a/assets/stylesheets/components/_page.scss +++ b/assets/stylesheets/components/_page.scss @@ -3,6 +3,10 @@ // ._page { + position: relative; + + ._page-error { position: static; } + > h1 { @extend ._lined-heading; } > h1:first-child { margin-top: 0; } @@ -22,6 +26,35 @@ } } +// +// Links +// + +._links { + position: absolute; + top: 0; + right: 0; + margin: 0; + line-height: 2em; + text-align: right; + + + h1 { margin-top: 0; } + + @media (max-width: 1023px) { display: none; } +} + +._links-link { + display: inline-block; + vertical-align: top; + padding: 0 .5rem; + background: $contentBackground; + @extend %internal-link; + + & + & { margin-left: .75rem; } + &:first-child { padding-left: 1rem; } + &:last-child { padding-right: 0; } +} + // // Attribution box // @@ -29,7 +62,7 @@ ._attribution { clear: both; margin: 2rem 0 1.5rem; - font-size: .75rem; + font-size: 80%; color: $textColorLight; text-align: center; -webkit-font-smoothing: subpixel-antialiased; diff --git a/assets/stylesheets/components/_prism.scss b/assets/stylesheets/components/_prism.scss index 43d6020daf..36926c56f4 100644 --- a/assets/stylesheets/components/_prism.scss +++ b/assets/stylesheets/components/_prism.scss @@ -17,7 +17,11 @@ .token.constant, .token.symbol, .token.deleted { - color: #905; + @if $style == 'dark' { + color: #eb8160; + } @else { + color: #905; + } } .token.selector, @@ -26,7 +30,11 @@ .token.char, .token.builtin, .token.inserted { - color: #5e8e01; + @if $style == 'dark' { + color: #ddcf88; + } @else { + color: #5e8e01; + } } .token.operator, @@ -34,23 +42,39 @@ .token.url, .language-css .token.string, .style .token.string { - color: #a67f59; + @if $style == 'dark' { + color: #b1c676; + } @else { + color: #a67f59; + } } .token.atrule, .token.attr-value, .token.keyword { - color: #0070a3; + @if $style == 'dark' { + color: #91b3ed; + } @else { + color: #0070a3; + } } .token.function { - color: #dd4a68; + @if $style == 'dark' { + color: #c79e6b; + } @else { + color: #dd4a68; + } } .token.regex, .token.important, .token.variable { - color: #e90; + @if $style == 'dark' { + color: #e9c062; + } @else { + color: #e90; + } } .token.important { diff --git a/assets/stylesheets/components/_sidebar.scss b/assets/stylesheets/components/_sidebar.scss index 0b5c7aa488..d029d27496 100644 --- a/assets/stylesheets/components/_sidebar.scss +++ b/assets/stylesheets/components/_sidebar.scss @@ -35,6 +35,17 @@ a:focus { outline: 0; } } +._resizer { + position: absolute; + z-index: $sidebarZ + 1; + top: $headerHeight; + bottom: 0; + left: $sidebarWidth; + margin-left: -2px; + width: 3px; + cursor: col-resize; +} + // // List // @@ -109,11 +120,9 @@ } } -._list-count { +._list-count, ._list-enable { float: right; font-size: .75rem; - color: $textColorLighter; - pointer-events: none; .focus > &, .active > & { @@ -121,6 +130,22 @@ } } +._list-count { + color: $textColorLighter; + pointer-events: none; + + ._list-disabled:hover > & { display: none; } +} + +._list-enable { + display: none; + color: $linkColor; + cursor: pointer; + + &:hover { text-decoration: underline; } + ._list-disabled:hover > & { display: block; } +} + // // List hierarchy // @@ -148,7 +173,11 @@ &:hover { opacity: .65; } &:before { - @extend %icon, %icon-dir; + @if $style == 'dark' { + @extend %icon, %icon-dir-white; + } @else { + @extend %icon, %icon-dir; + } .open > &, .open-title > & { -webkit-transform: rotate(90deg); @@ -214,19 +243,20 @@ } } -._list-noresults { +// +// List note +// + +._list-note { padding: .5rem .75rem; line-height: 1.25rem; font-size: .8125rem; color: $textColorLight; -} -._list-noresults-note { - display: block; - margin-top: .25rem; + & + & { padding-top: 0; } } -._list-noresults-link { cursor: pointer; } +._list-note-link { cursor: pointer; } // // List hover clone @@ -325,6 +355,7 @@ ._sidebar-footer-link { position: relative; display: block; + overflow: hidden; height: 2.5rem; line-height: 1rem; padding: .75rem; @@ -345,7 +376,31 @@ } ._sidebar-footer-edit { - &:before { @extend %icon-settings; } + @if $style == 'dark' { + &:before { @extend %icon-settings-white; } + } @else { + &:before { @extend %icon-settings; } + } +} + +._sidebar-footer-light { + float: right; + width: 2.5rem; + padding: 0; + opacity: .6; + + &:before { + float: none; + position: absolute; + top: .75rem; + left: .75rem; + + @if $style == 'dark' { + @extend %icon-light-white; + } @else { + @extend %icon-light; + } + } } ._sidebar-footer-save { @@ -355,5 +410,9 @@ box-shadow: inset 0 1px $noteGreenBorder, 1px 0 $noteGreenBorder; - &:before { @extend %icon-check; } + @if $style == 'dark' { + &:before { @extend %icon-check-white; } + } @else { + &:before { @extend %icon-check; } + } } diff --git a/assets/stylesheets/global/_base.scss b/assets/stylesheets/global/_base.scss index b69f16949a..728e234077 100644 --- a/assets/stylesheets/global/_base.scss +++ b/assets/stylesheets/global/_base.scss @@ -1,24 +1,3 @@ -html { - height: 100%; - font-size: 100%; - background: $contentBackground; - - @media #{$mediumScreen} { font-size: 93.75%; } -} - -body { - height: 100%; - margin: 0; - overflow: auto; - font: normal 1em/1.7 $baseFont; - color: $textColor; - word-wrap: break-word; - overflow-wrap: break-word; - -webkit-tap-highlight-color: rgba(black, 0); - -webkit-touch-callout: none; - -webkit-text-size-adjust: 100%; - -ms-text-size-adjust: 100%; -} a { color: $linkColor; @@ -55,7 +34,7 @@ b, strong { font-weight: bold; } small { font-size: .9em; } -ul, ol { +._page ul, ._page ol { margin: 1.5em 0; padding: 0 0 0 2em; list-style: disc outside; @@ -66,8 +45,8 @@ ol { list-style-type: decimal; } ol ol { list-style-type: lower-alpha; } ol ol ol { list-style-type: lower-roman; } -li + li { margin-top: .25em; } li > ul, li > ol, dd > ul, dd > ol { margin: .5em 0; } +li > p { margin-bottom: .25em; } dl { margin: 1.5em 0; } dt { font-weight: bold; } @@ -89,6 +68,7 @@ pre, code, samp, %pre, %code { font-family: $monoFont; font-weight: normal; font-style: normal; + font-size: .9em; color: $textColor; white-space: pre-wrap; -moz-tab-size: 2; @@ -101,7 +81,6 @@ pre, %pre { padding: .375rem .75rem; line-height: 1.5; overflow: auto; - font-size: .9em; @extend %box; } @@ -148,6 +127,10 @@ td { + td { border-left: 1px solid $boxBorderLight; } tr:last-child > & { border-bottom: 0; } + > pre:only-child, > p:only-child, > ul:only-child, > ol:only-child { + margin-top: 0; + margin-bottom: 0; + } > pre:last-child, > p:last-child, > ul:last-child, > ol:last-child { margin-bottom: 0; } } diff --git a/assets/stylesheets/global/_classes.scss b/assets/stylesheets/global/_classes.scss index 7e6bff788c..bdc301e369 100644 --- a/assets/stylesheets/global/_classes.scss +++ b/assets/stylesheets/global/_classes.scss @@ -54,7 +54,6 @@ %label { margin: 0 1px; padding: 1px 4px 2px; - background: $labelBackground; border-radius: 3px; } @@ -95,14 +94,9 @@ // %external-link { - &:after { - display: inline-block; - width: .5rem; - height: .4375rem; - margin: .125rem 0 0 .0625rem; - vertical-align: top; - @extend %icon, %icon-link; - } + background: url(../img/icon_external_link.png)center right no-repeat; + padding-right: 13px; + padding-top: 10px; } %internal-link:after { content: none !important; } diff --git a/assets/stylesheets/global/_icons.scss b/assets/stylesheets/global/_icons.scss index d3a2852165..0c968c4606 100644 --- a/assets/stylesheets/global/_icons.scss +++ b/assets/stylesheets/global/_icons.scss @@ -4,76 +4,100 @@ width: 1rem; height: 1rem; background-image: image-url('icons.png'); - background-size: 5rem 13rem; + background-size: 10rem 8rem; } @media (-webkit-min-device-pixel-ratio: 1.5), (min-resolution: 144dpi) { %icon { background-image: image-url('icons@2x.png'); } } +%darkIconFix { + @if $style == 'dark' { + filter: invert(100%) grayscale(100%); + -webkit-filter: invert(100%) grayscale(100%); + } +} + %icon-dir { background-position: 0 0; } %icon-search { background-position: -1rem 0; } %icon-link { background-position: -2.25rem -.25rem; } %icon-clear { background-position: -3rem 0; } %icon-close-white { background-position: -4rem 0; } -%icon-settings { background-position: 0 -1rem; } -%icon-check { background-position: -1rem -1rem; } -._icon-http:before { background-position: -2rem -1rem; } -._icon-jquery:before { background-position: -3rem -1rem; } -._icon-underscore:before { background-position: -4rem -1rem; } -._icon-html:before { background-position: 0 -2rem; } -._icon-css:before { background-position: -1rem -2rem; } -._icon-dom:before { background-position: -2rem -2rem; } -._icon-dom_events:before { background-position: -3rem -2rem; } -._icon-javascript:before { background-position: -4rem -2rem; } -._icon-backbone:before { background-position: 0 -3rem; } -._icon-node:before { background-position: -1rem -3rem; } -._icon-sass:before { background-position: -2rem -3rem; } -._icon-less:before { background-position: -3rem -3rem; } -._icon-angular:before { background-position: -4rem -3rem; } -._icon-coffeescript:before { background-position: 0 -4rem; } -._icon-ember:before { background-position: -1rem -4rem; } -%icon-menu { background-position: -2rem -4rem; } -%icon-home { background-position: -3rem -4rem; } -._icon-jqueryui:before { background-position: -4rem -4rem; } -._icon-jquerymobile:before { background-position: 0 -5rem; } -._icon-lodash:before { background-position: -1rem -5rem; } -._icon-php:before { background-position: -2rem -5rem; } -._icon-ruby:before { background-position: -3rem -5rem; } -._icon-rails:before { background-position: -4rem -5rem; } -._icon-python:before { background-position: 0 -6rem; } -._icon-python2:before { background-position: 0 -6rem; } -._icon-git:before { background-position: -1rem -6rem; } -._icon-redis:before { background-position: -2rem -6rem; } -._icon-postgresql:before { background-position: -3rem -6rem; } -._icon-d3:before { background-position: -4rem -6rem; } -._icon-knockout:before { background-position: 0 -7rem; } -._icon-moment:before { background-position: -1rem -7rem; } -._icon-c:before { background-position: -2rem -7rem; } -%icon-path { background-position: -3rem -7rem; } -._icon-yii:before { background-position: -4rem -7rem; } -._icon-cpp:before { background-position: 0 -8rem; } -._icon-go:before { background-position: -1rem -8rem; } -._icon-express:before { background-position: -2rem -8rem; } -._icon-grunt:before { background-position: -3rem -8rem; } -._icon-maxcdn:before { background-position: -4rem -8rem; } -._icon-laravel:before { background-position: 0 -9rem; } -._icon-haskell:before { background-position: -1rem -9rem; } -._icon-requirejs:before { background-position: -2rem -9rem; } -._icon-chai:before { background-position: -3rem -9rem; } -._icon-sinon:before { background-position: -4rem -9rem; } -._icon-cordova:before { background-position: 0 -10rem; } -._icon-markdown:before { background-position: -1rem -10rem; } -._icon-django:before { background-position: -2rem -10rem; } -._icon-xpath:before { background-position: -3rem -10rem; } -._icon-nginx:before { background-position: -4rem -10rem; } -._icon-svg:before { background-position: 0 -11rem; } -._icon-marionette:before { background-position: -1rem -11rem; } -._icon-mongoose:before { background-position: -2rem -11rem; } -._icon-phpunit:before { background-position: -3rem -11rem; } -._icon-nokogiri:before { background-position: -4rem -11rem; } -._icon-rethinkdb:before { background-position: 0 -12rem; } -._icon-react:before { background-position: -1rem -12rem; } -._icon-socketio:before { background-position: -2rem -12rem; } -._icon-modernizr:before { background-position: -3rem -12rem; } -._icon-bower:before { background-position: -4rem -12rem; } +%icon-settings { background-position: -5rem 0; } +%icon-check { background-position: -6rem 0; } +._icon-http:before { background-position: -7rem 0; @extend %darkIconFix !optional; } +._icon-jquery:before { background-position: -8rem 0; @extend %darkIconFix !optional; } +._icon-underscore:before { background-position: -9rem 0; @extend %darkIconFix !optional; } +._icon-html:before { background-position: 0 -1rem; } +._icon-css:before { background-position: -1rem -1rem; } +._icon-dom:before { background-position: -2rem -1rem; } +._icon-dom_events:before { background-position: -3rem -1rem; } +._icon-javascript:before { background-position: -4rem -1rem; } +._icon-backbone:before { background-position: -5rem -1rem; @extend %darkIconFix !optional; } +._icon-node:before { background-position: -6rem -1rem; } +._icon-sass:before { background-position: -7rem -1rem; } +._icon-less:before { background-position: -8rem -1rem; } +._icon-angular:before { background-position: -9rem -1rem; } +._icon-coffeescript:before { background-position: 0 -2rem; @extend %darkIconFix !optional; } +._icon-ember:before { background-position: -1rem -2rem; } +%icon-menu { background-position: -2rem -2rem; } +%icon-home { background-position: -3rem -2rem; } +._icon-jqueryui:before { background-position: -4rem -2rem; } +._icon-jquerymobile:before { background-position: -5rem -2rem; } +._icon-lodash:before { background-position: -6rem -2rem; } +._icon-php:before { background-position: -7rem -2rem; } +._icon-ruby:before, +._icon-minitest:before { background-position: -8rem -2rem; } +._icon-rails:before { background-position: -9rem -2rem; } +._icon-python:before, +._icon-python2:before { background-position: 0 -3rem; } +._icon-git:before { background-position: -1rem -3rem; } +._icon-redis:before { background-position: -2rem -3rem; } +._icon-postgresql:before { background-position: -3rem -3rem; } +._icon-d3:before { background-position: -4rem -3rem; } +._icon-knockout:before { background-position: -5rem -3rem; } +._icon-moment:before { background-position: -6rem -3rem; @extend %darkIconFix !optional; } +._icon-c:before { background-position: -7rem -3rem; } +%icon-path { background-position: -8rem -3rem; } +._icon-yii:before, +._icon-yii1:before { background-position: -9rem -3rem; } +._icon-cpp:before { background-position: 0 -4rem; } +._icon-go:before { background-position: -1rem -4rem; } +._icon-express:before { background-position: -2rem -4rem; } +._icon-grunt:before { background-position: -3rem -4rem; } + +._icon-laravel:before { background-position: -5rem -4rem; } +._icon-haskell:before { background-position: -6rem -4rem; } +._icon-requirejs:before { background-position: -7rem -4rem; } +._icon-chai:before { background-position: -8rem -4rem; } +._icon-sinon:before { background-position: -9rem -4rem; @extend %darkIconFix !optional; } +._icon-cordova:before { background-position: 0 -5rem; } +._icon-markdown:before { background-position: -1rem -5rem; @extend %darkIconFix !optional; } +._icon-django:before { background-position: -2rem -5rem; } +._icon-xpath:before { background-position: -3rem -5rem; } +._icon-nginx:before { background-position: -4rem -5rem; } +._icon-svg:before { background-position: -5rem -5rem; } +._icon-marionette:before { background-position: -6rem -5rem; } +._icon-mongoose:before { background-position: -7rem -5rem; } +._icon-phpunit:before { background-position: -8rem -5rem; } +._icon-nokogiri:before { background-position: -9rem -5rem; @extend %darkIconFix !optional; } +._icon-rethinkdb:before { background-position: 0 -6rem; } +._icon-react:before { background-position: -1rem -6rem; } +._icon-socketio:before { background-position: -2rem -6rem; } +._icon-modernizr:before { background-position: -3rem -6rem; } +._icon-bower:before { background-position: -4rem -6rem; } +%icon-search-white { background-position: -5rem -6rem; } +%icon-dir-white { background-position: -6rem -6rem; } +%icon-link-white { background-position: -7.25rem -6.25rem; } +%icon-settings-white { background-position: -8rem -6rem; } +%icon-check-white { background-position: -9rem -6rem; } +%icon-light { background-position: 0 -7rem; } +%icon-light-white { background-position: -1rem -7rem; } +._icon-iojs:before { background-position: -2rem -7rem; @extend %darkIconFix !optional; } +._icon-lua:before { background-position: -3rem -7rem; @extend %darkIconFix !optional; } +._icon-clojure:before { background-position: -4rem -7rem; } +._icon-symfony:before { background-position: -5rem -7rem; } +._icon-mocha:before { background-position: -6rem -7rem; } +._icon-meteor:before { background-position: -7rem -7rem; @extend %darkIconFix !optional; } +._icon-npm:before { background-position: -8rem -7rem; } +._icon-apache_http_server:before { background-position: -9rem -7rem; } diff --git a/assets/stylesheets/global/_variables.scss b/assets/stylesheets/global/_variables.scss index a2fc51b3b8..453bfcb6ea 100644 --- a/assets/stylesheets/global/_variables.scss +++ b/assets/stylesheets/global/_variables.scss @@ -1,5 +1,7 @@ $baseFont: 'Open Sans', Helvetica, Arial, sans-serif; -$monoFont: 'Source Code Pro', 'Inconsolata-g', Consolas, Menlo, monospace; +$monoFont: Consolas, 'Liberation Mono', Menlo, Courier, monospace; + +$style: 'light'; $headerHeight: 3rem; $sidebarWidth: 18rem; diff --git a/assets/stylesheets/global/variables-dark.scss b/assets/stylesheets/global/variables-dark.scss new file mode 100644 index 0000000000..53a589b1a7 --- /dev/null +++ b/assets/stylesheets/global/variables-dark.scss @@ -0,0 +1,82 @@ +$baseFont: 'Open Sans', Helvetica, Arial, sans-serif; +$monoFont: Consolas, 'Liberation Mono', Menlo, Courier, monospace; + +$style: 'dark'; + +$headerHeight: 3rem; +$sidebarWidth: 18rem; +$sidebarMediumWidth: 16rem; + +$contentBackground: #303030; + +$textColor: #c9c9c9; +$textColorLight: #858585; +$textColorLighter: #706f6f; + +$inputFocusBorder: #444; + +$focusBackground: #3d3d3e; +$focusBorder: #3d3d3e; +$focusText: #f7f2f2; + +$loadingText: #616161; +$splashText: #616161; +$promoText: #616161; + +$selectionBackground: #346fce; +$selectionBorder: #346fce; +$selectionText: #fff; + +$highlightBackground: #3d4449; + +$linkColor: #fff; +$linkColorHover: #fff; + +$headerBackground: #1c1c1c; +$headerBorder: #1c1c1c; + +$sidebarBackground: #262626; +$sidebarBorder: #262626; + +$scrollbarColor: #515151; +$scrollbarColorHover: #888; + +$pathBackground: $headerBackground; +$pathBorder: $headerBorder; + +$noticeBackground: #1c1c1c; +$noticeBorder: #1c1c1c; + +$boxBackground: #262626; +$boxBorder: #000; +$boxBorderLight: #000; +$boxHeaderBackground: #262626; + +$noteBackground: #3a4031; +$noteBorder: #000; + +$noteGreenBackground: #223e23; +$noteGreenBorder: #000; + +$noteBlueBackground: #223546; +$noteBlueBorder: #000; + +$noteOrangeBackground: #523121; +$noteOrangeBorder: #000; + +$noteRedBackground: #5b1f22; +$noteRedBorder: #000; + +$labelBackground: #3c3c3e; + +$notifBackground: rgba(#000, .85); +$notifColor: #fff; +$notifColorLight: #bbb; + +$mediumScreen: '(max-width: 800px)'; + +$contentZ: 1; +$sidebarZ: 2; +$headerZ: 3; +$noticeZ: 4; +$hoverZ: 5; diff --git a/assets/stylesheets/pages/.sass-cache/3a3912d3f706c7716d60ead2be49a2a2c584152d/_angular.scssc b/assets/stylesheets/pages/.sass-cache/3a3912d3f706c7716d60ead2be49a2a2c584152d/_angular.scssc new file mode 100644 index 0000000000..7f920d392c Binary files /dev/null and b/assets/stylesheets/pages/.sass-cache/3a3912d3f706c7716d60ead2be49a2a2c584152d/_angular.scssc differ diff --git a/assets/stylesheets/pages/_apache.scss b/assets/stylesheets/pages/_apache.scss new file mode 100644 index 0000000000..ff494bb52e --- /dev/null +++ b/assets/stylesheets/pages/_apache.scss @@ -0,0 +1,6 @@ +._apache { + @extend %simple; + + .note, .warning { @extend %note; } + .warning { @extend %note-red; } +} diff --git a/assets/stylesheets/pages/_base.scss b/assets/stylesheets/pages/_base.scss new file mode 100644 index 0000000000..59bfaf482c --- /dev/null +++ b/assets/stylesheets/pages/_base.scss @@ -0,0 +1,30 @@ +%simple { + padding-left: 1rem; + + h1, h2, h3 { margin-left: -1rem; } + h2 { @extend %block-heading; } + h3 { @extend %block-label, %label-blue; } + h4 { font-size: inherit; } + + ._mobile & { + padding-left: 0; + + h1, h2, h3 { margin-left: 0; } + } + + p > code, li > code { @extend %label; } + blockquote { @extend %note; } +} + +._cordova, +._grunt, +._less, +._lodash, +._marionette, +._markdown, +._mocha, +._mongoose, +._sinon { + @extend %simple; +} + diff --git a/assets/stylesheets/pages/_chai.scss b/assets/stylesheets/pages/_chai.scss index a74567e8ef..19c24ab594 100644 --- a/assets/stylesheets/pages/_chai.scss +++ b/assets/stylesheets/pages/_chai.scss @@ -1,13 +1,5 @@ ._chai { - padding-left: 1rem; - - > h1, > h2, h3 { margin-left: -1rem; } - > h2 { @extend %block-heading; } - h3 { @extend %block-label, %label-blue; } - h4 { font-size: 1em; } - - code { @extend %label; } - blockquote { @extend %note; } + @extend %simple; li.tag span { margin-right: 5px; } } diff --git a/assets/stylesheets/pages/_clojure.scss b/assets/stylesheets/pages/_clojure.scss new file mode 100644 index 0000000000..9f5e5db45a --- /dev/null +++ b/assets/stylesheets/pages/_clojure.scss @@ -0,0 +1,10 @@ +._clojure { + h2:not([id]) { @extend %block-heading; } + h2[id], h3 { @extend %block-label, %label-blue; } + + .type { + float: right; + font-size: .9em; + color: $textColorLight; + } +} diff --git a/assets/stylesheets/pages/_coffeescript.scss b/assets/stylesheets/pages/_coffeescript.scss index 99f7a5ef08..af4125fd76 100644 --- a/assets/stylesheets/pages/_coffeescript.scss +++ b/assets/stylesheets/pages/_coffeescript.scss @@ -1,10 +1,5 @@ ._coffeescript { - padding-left: 1rem; - - > h1, > h2 { margin-left: -1rem; } - > h2 { @extend %block-heading; } - - code { @extend %label; } + @extend %simple; // CoffeeScript / JavaScript code blocks > .code { diff --git a/assets/stylesheets/pages/_d3.scss b/assets/stylesheets/pages/_d3.scss index 0d34d1d97a..1843e84829 100644 --- a/assets/stylesheets/pages/_d3.scss +++ b/assets/stylesheets/pages/_d3.scss @@ -1,6 +1,6 @@ ._d3 { - > h2 { @extend %block-heading; } - > h3, > h4 { font-size: 1rem; } - > h6 { @extend %block-label, %label-blue; } + h2 { @extend %block-heading; } + h3, h4 { font-size: 1rem; } + h6 { @extend %block-label, %label-blue; } code { @extend %label; } } diff --git a/assets/stylesheets/pages/_express.scss b/assets/stylesheets/pages/_express.scss index 9b388a9d9f..de1bf21ec5 100644 --- a/assets/stylesheets/pages/_express.scss +++ b/assets/stylesheets/pages/_express.scss @@ -1,8 +1,6 @@ ._express { - padding-left: 1rem; + @extend %simple; - h1, h2, h3 { margin-left: -1rem; } - h2 { @extend %block-heading; } - h3 { @extend %block-label, %label-blue; } - p > code { @extend %label; } + .doc-box { @extend %note; } + .doc-warn { @extend %note-red; } } diff --git a/assets/stylesheets/pages/_go.scss b/assets/stylesheets/pages/_go.scss index 08c19bf929..218fa0df5d 100644 --- a/assets/stylesheets/pages/_go.scss +++ b/assets/stylesheets/pages/_go.scss @@ -1,7 +1,5 @@ ._go { - padding-left: 1rem; + @extend %simple; - h1, h2, #short-nav, table.dir { margin-left: -1rem; } - h2 { @extend %block-heading; } - h3 { @extend %block-label, %label-blue; } + #short-nav, table.dir { margin-left: -1rem; } } diff --git a/assets/stylesheets/pages/_lua.scss b/assets/stylesheets/pages/_lua.scss new file mode 100644 index 0000000000..68cca61e54 --- /dev/null +++ b/assets/stylesheets/pages/_lua.scss @@ -0,0 +1,5 @@ +._lua { + @extend %simple; + + .apii { float: right; } +} diff --git a/assets/stylesheets/pages/_mdn.scss b/assets/stylesheets/pages/_mdn.scss index cc103cae12..c640ddf604 100644 --- a/assets/stylesheets/pages/_mdn.scss +++ b/assets/stylesheets/pages/_mdn.scss @@ -4,7 +4,7 @@ -moz-columns: 16em; columns: 16em; - > span { + span { display: block; font-size: 1rem; font-weight: bold; diff --git a/assets/stylesheets/pages/_meteor.scss b/assets/stylesheets/pages/_meteor.scss new file mode 100644 index 0000000000..0de5a9bb36 --- /dev/null +++ b/assets/stylesheets/pages/_meteor.scss @@ -0,0 +1,15 @@ +._meteor { + @extend %simple; + + .note, .warning { @extend %note; } + .warning { @extend %note-red; } + + dl.args { margin-left: 1rem; } + + .locus, .src-code { float: right; } + .locus, .type, .src-code { + margin-left: .5em; + font-size: .9em; + } + .locus, .type { color: $textColorLight; } +} diff --git a/assets/stylesheets/pages/_moment.scss b/assets/stylesheets/pages/_moment.scss index eb5eb39928..17d39c1313 100644 --- a/assets/stylesheets/pages/_moment.scss +++ b/assets/stylesheets/pages/_moment.scss @@ -1,7 +1,7 @@ ._moment { - > h2 { @extend %block-heading; } - > h3 { @extend %block-label, %label-blue; } - > h3 > span { float: right;} + h2 { @extend %block-heading; } + h3 { @extend %block-label, %label-blue; } + h3 span { float: right;} h4 { font-size: 1em; } code { @extend %label; } } diff --git a/assets/stylesheets/pages/_nginx.scss b/assets/stylesheets/pages/_nginx.scss index 327811e840..57cdba9760 100644 --- a/assets/stylesheets/pages/_nginx.scss +++ b/assets/stylesheets/pages/_nginx.scss @@ -2,4 +2,5 @@ h4 { @extend %block-heading; } .note { @extend %note; } .directive { margin: 2.5em 0 1em; } + td > pre { margin: 0; } } diff --git a/assets/stylesheets/pages/_npm.scss b/assets/stylesheets/pages/_npm.scss new file mode 100644 index 0000000000..9bbcc74c5c --- /dev/null +++ b/assets/stylesheets/pages/_npm.scss @@ -0,0 +1,15 @@ +._npm { + @extend %simple; + + .pageColumns { + padding-left: 0; + list-style: none; + } + + .faint.heading { + font-size: .9em; + color: $textColorLight; + } + + .youtube-video iframe { width: 420px; height: 315px; } +} diff --git a/assets/stylesheets/pages/_php.scss b/assets/stylesheets/pages/_php.scss index 7ea8d4d45f..4386bd570e 100644 --- a/assets/stylesheets/pages/_php.scss +++ b/assets/stylesheets/pages/_php.scss @@ -23,8 +23,6 @@ .classsynopsis > .methodsynopsis, .classsynopsis > .fieldsynopsis { margin-left: 1em; } - .phpcode > pre { white-space: normal; } - blockquote.note { @extend %note; } blockquote.note > p { margin-bottom: 0; } diff --git a/assets/stylesheets/pages/_rdoc.scss b/assets/stylesheets/pages/_rdoc.scss index ae18b323c8..550c69d174 100644 --- a/assets/stylesheets/pages/_rdoc.scss +++ b/assets/stylesheets/pages/_rdoc.scss @@ -1,11 +1,11 @@ ._rdoc { - > .description, > .documentation-section { padding-left: 1rem; } - > .description > h2, header > h3, > h2 { @extend %block-heading; } - > .description > h2, header > h3, .method-heading { margin-left: -1rem; } + .description, > .documentation-section { padding-left: 1rem; } + .description > h2, header > h3, > h2 { @extend %block-heading; } + .description > h2, header > h3, .method-heading { margin-left: -1rem; } .description > h1 { font-size: 1rem; } .method-description > h2, h3, h4, h5, h6 { font-size: 1em; } - .method-heading { + .method-heading, .signature { font-weight: bold; @extend %block-label, %label-blue; diff --git a/assets/stylesheets/pages/_requirejs.scss b/assets/stylesheets/pages/_requirejs.scss index d186cca4fe..34fddb4cad 100644 --- a/assets/stylesheets/pages/_requirejs.scss +++ b/assets/stylesheets/pages/_requirejs.scss @@ -1,10 +1,5 @@ ._requirejs { - padding-left: 1rem; - - h1, h2, h3, ul.index { margin-left: -1rem; } - h2 { @extend %block-heading; } - h3 { @extend %block-label, %label-blue; } - h4 { font-size: 1em; } + @extend %simple; ul.index ul { margin: .5em 0; } } diff --git a/assets/stylesheets/pages/_rfc.scss b/assets/stylesheets/pages/_rfc.scss index ac2bd42d9d..b522b30890 100644 --- a/assets/stylesheets/pages/_rfc.scss +++ b/assets/stylesheets/pages/_rfc.scss @@ -1,6 +1,15 @@ -._rfc { - padding-left: 1rem; +._rfc-pre { + font-size: .8125rem; + min-width: 38rem; + @extend %code; - > h1, > h2 { margin-left: -1rem; } > h2 { @extend %block-heading; } + > h3 { @extend %block-label, %label-blue; } + > h4 { @extend %block-label; } + > h3, > h4 { font-size: .875rem; } + + > h1, > h2, > h3, > h4, > h5 { + margin: 0; + font-family: $baseFont; + } } diff --git a/assets/stylesheets/pages/_sphinx.scss b/assets/stylesheets/pages/_sphinx.scss index 44b9f1f3a9..5c87eae3fb 100644 --- a/assets/stylesheets/pages/_sphinx.scss +++ b/assets/stylesheets/pages/_sphinx.scss @@ -1,6 +1,6 @@ ._sphinx { h2, h3 { @extend %block-heading; } - dl:not(.docutils) > dt { @extend %block-label, %label-blue; } + dl:not(.docutils) dt { @extend %block-label, %label-blue; } dt + dt { margin-top: -.5em; } .note, .admonition, .versionadded, .versionchanged, .deprecated-removed { @extend %note; } diff --git a/file_scraper_docs/.download_index b/file_scraper_docs/.download_index new file mode 100644 index 0000000000..fa7c1ad59a --- /dev/null +++ b/file_scraper_docs/.download_index @@ -0,0 +1,4 @@ +C & c++: http://en.cppreference.com/w/Cppreference:Archives +python 2.7: https://docs.python.org/2.7/download.html +python 3: https://docs.python.org/3/download.html +django: https://docs.djangoproject.com/en/1.8/ \ No newline at end of file diff --git a/lib/app.rb b/lib/app.rb index 05e103892e..19977b6e97 100644 --- a/lib/app.rb +++ b/lib/app.rb @@ -4,6 +4,7 @@ class App < Sinatra::Application Bundler.require environment require 'sinatra/cookies' + require 'tilt/erubis' Rack::Mime::MIME_TYPES['.webapp'] = 'application/x-web-app-manifest+json' @@ -17,7 +18,7 @@ class App < Sinatra::Application set :assets_prefix, 'assets' set :assets_path, -> { File.join(public_folder, assets_prefix) } set :assets_manifest_path, -> { File.join(assets_path, 'manifest.json') } - set :assets_compile, %w(*.png docs.js application.js application.css) + set :assets_compile, %w(*.png docs.js docs.json application.js application.css application-dark.css) require 'yajl/json_gem' set :docs_prefix, 'docs' @@ -25,6 +26,7 @@ class App < Sinatra::Application set :docs_path, -> { File.join(public_folder, docs_prefix) } set :docs_manifest_path, -> { File.join(docs_path, 'docs.json') } set :docs, -> { Hash[JSON.parse(File.read(docs_manifest_path)).map! { |doc| [doc['slug'], doc] }] } + set :default_docs, %w(css dom dom_events html http javascript) set :news_path, -> { File.join(root, assets_prefix, 'javascripts', 'news.json') } set :news, -> { JSON.parse(File.read(news_path)) } @@ -37,6 +39,7 @@ class App < Sinatra::Application config.environment = sprockets config.prefix = "/#{assets_prefix}" config.public_path = public_folder + config.protocol = :relative end end @@ -56,14 +59,14 @@ class App < Sinatra::Application configure :production do set :static, false - set :docs_host, 'http://docs.devdocs.io' + set :docs_host, '//docs.devdocs.io' use Rack::ConditionalGet use Rack::ETag use Rack::Deflater use Rack::Static, root: 'public', - urls: %w(/assets /docs /images /favicon.ico /robots.txt /opensearch.xml /manifest.webapp), + urls: %w(/assets /docs/ /images /favicon.ico /robots.txt /opensearch.xml /manifest.webapp), header_rules: [ [:all, {'Cache-Control' => 'no-cache, max-age=0'}], ['/assets', {'Cache-Control' => 'public, max-age=604800'}], @@ -75,11 +78,15 @@ class App < Sinatra::Application Sprockets::Helpers.configure do |config| config.digest = true - config.asset_host = 'maxcdn.devdocs.io' + config.asset_host = 'cdn.devdocs.io' config.manifest = Sprockets::Manifest.new(sprockets, assets_manifest_path) end end + configure :test do + set :docs_manifest_path, -> { File.join(root, 'test', 'files', 'docs.json') } + end + helpers do include Sinatra::Cookies include Sprockets::Helpers @@ -88,19 +95,29 @@ def browser @browser ||= Browser.new ua: request.user_agent end + UNSUPPORTED_IE_VERSIONS = %w(6 7 8 9).freeze + def unsupported_browser? - browser.ie? && %w(6 7 8 9).include?(browser.version) + browser.ie? && UNSUPPORTED_IE_VERSIONS.include?(browser.version) end - def doc_index_urls - cookie = cookies[:docs] - return [] if cookie.nil? || cookie.empty? + def docs + @docs ||= begin + cookie = cookies[:docs] - cookie.split('/').inject [] do |result, slug| + if cookie.nil? || cookie.empty? + settings.default_docs + else + cookie.split('/') + end + end + end + + def doc_index_urls + docs.each_with_object [] do |slug, result| if doc = settings.docs[slug] result << File.join('', settings.docs_prefix, doc['index_path']) + "?#{doc['mtime']}" end - result end end @@ -111,12 +128,61 @@ def doc_index_page? def query_string_for_redirection request.query_string.empty? ? nil : "?#{request.query_string}" end + + def main_stylesheet_path + stylesheet_paths[dark_theme? ? :dark : :default] + end + + def alternate_stylesheet_path + stylesheet_paths[dark_theme? ? :default : :dark] + end + + def stylesheet_paths + @stylesheet_paths ||= { + default: stylesheet_path('application'), + dark: stylesheet_path('application-dark') + } + end + + def app_size + @app_size ||= cookies[:size].nil? ? '18rem' : "#{cookies[:size]}px" + end + + def app_layout + cookies[:layout] + end + + def app_theme + @app_theme ||= cookies[:dark].nil? ? 'default' : 'dark' + end + + def dark_theme? + app_theme == 'dark' + end + + def redirect_via_js(path) # courtesy of HTML5 App Cache + response.set_cookie :initial_path, value: path, expires: Time.now + 15, path: '/' + redirect '/', 302 + end + + def supports_js_redirection? + browser.modern? && !cookies.empty? + end end before do halt erb :unsupported if unsupported_browser? end + OUT_HOST = 'out.devdocs.io'.freeze + + before do + if request.host == OUT_HOST && !request.path.start_with?('/s/') + query_string = "?#{request.query_string}" unless request.query_string.empty? + redirect "http://devdocs.io#{request.path}#{query_string}", 302 + end + end + get '/manifest.appcache' do content_type 'text/cache-manifest' expires 0, :'no-cache' @@ -124,13 +190,17 @@ def query_string_for_redirection end get '/' do - return redirect '/' unless request.query_string.empty? + return redirect '/' unless request.query_string.empty? # courtesy of HTML5 App Cache erb :index end %w(offline about news help).each do |page| get "/#{page}" do - redirect "/#/#{page}", 302 + if supports_js_redirection? + redirect_via_js "/#{page}" + else + redirect "/#/#{page}", 302 + end end end @@ -142,12 +212,32 @@ def query_string_for_redirection 200 end - get '/s/maxcdn' do - redirect 'https://www.maxcdn.com/?utm_source=devdocs&utm_medium=banner&utm_campaign=devdocs' + %w(docs.json application.js application.css).each do |asset| + class_eval <<-CODE, __FILE__, __LINE__ + 1 + get '/#{asset}' do + redirect asset_path('#{asset}', protocol: 'http') + end + CODE end - get '/s/shopify' do - redirect 'http://www.shopify.com/careers?utm_source=devdocs&utm_medium=banner&utm_campaign=devdocs' + { + '/s/maxcdn' => 'https://www.maxcdn.com/?utm_source=devdocs&utm_medium=banner&utm_campaign=devdocs', + '/s/shopify' => 'https://www.shopify.com/careers?utm_source=devdocs&utm_medium=banner&utm_campaign=devdocs', + '/s/jetbrains' => 'https://www.jetbrains.com/?utm_source=devdocs&utm_medium=sponsorship&utm_campaign=devdocs', + '/s/jetbrains/ruby' => 'https://www.jetbrains.com/ruby/?utm_source=devdocs&utm_medium=sponsorship&utm_campaign=devdocs', + '/s/jetbrains/python' => 'https://www.jetbrains.com/pycharm/?utm_source=devdocs&utm_medium=sponsorship&utm_campaign=devdocs', + '/s/jetbrains/c' => 'https://www.jetbrains.com/clion/?utm_source=devdocs&utm_medium=sponsorship&utm_campaign=devdocs', + '/s/jetbrains/web' => 'https://www.jetbrains.com/webstorm/?utm_source=devdocs&utm_medium=sponsorship&utm_campaign=devdocs', + '/s/code-school' => 'http://www.codeschool.com/?utm_campaign=devdocs&utm_content=homepage&utm_source=devdocs&utm_medium=sponsorship', + '/s/tw' => 'https://twitter.com/intent/tweet?url=http%3A%2F%2Fdevdocs.io&via=DevDocs&text=All-in-one%2C%20offline%20API%20documentation%20browser%3A', + '/s/fb' => 'https://twitter.com/intent/tweet?url=http%3A%2F%2Fdevdocs.io&via=DevDocs&text=All-in-one%2C%20offline%20API%20documentation%20browser%3A', + '/s/re' => 'http://www.reddit.com/submit?url=http%3A%2F%2Fdevdocs.io&title=All-in-one%2C%20offline%20API%20documentation%20browser&resubmit=true' + }.each do |path, url| + class_eval <<-CODE, __FILE__, __LINE__ + 1 + get '#{path}' do + redirect '#{url}' + end + CODE end get %r{\A/feed(?:\.atom)?\z} do @@ -155,18 +245,6 @@ def query_string_for_redirection settings.news_feed end - get '/s/tw' do - redirect 'https://twitter.com/intent/tweet?url=http%3A%2F%2Fdevdocs.io&via=DevDocs&text=All-in-one%2C%20quickly%20searchable%20API%20docs%3A' - end - - get '/s/fb' do - redirect 'https://www.facebook.com/sharer/sharer.php?u=http%3A%2F%2Fdevdocs.io' - end - - get '/s/re' do - redirect 'http://www.reddit.com/submit?url=http%3A%2F%2Fdevdocs.io&title=All-in-one%2C%20quickly%20searchable%20API%20docs&resubmit=true' - end - get %r{\A/(\w+)(\-[\w\-]+)?(/.*)?\z} do |doc, type, rest| return 404 unless @doc = settings.docs[doc] @@ -174,6 +252,8 @@ def query_string_for_redirection redirect "/#{doc}#{type}/#{query_string_for_redirection}" elsif rest.length > 1 && rest.end_with?('/') redirect "/#{doc}#{type}#{rest[0...-1]}#{query_string_for_redirection}" + elsif docs.include?(doc) && supports_js_redirection? + redirect_via_js(request.path) else erb :other end diff --git a/lib/docs/core/doc.rb b/lib/docs/core/doc.rb index 6388c56804..1df17a88e4 100644 --- a/lib/docs/core/doc.rb +++ b/lib/docs/core/doc.rb @@ -4,18 +4,60 @@ class Doc DB_FILENAME = 'db.json' class << self - attr_accessor :name, :slug, :type, :version, :abstract + include Instrumentable + + attr_accessor :name, :slug, :type, :release, :abstract, :links def inherited(subclass) subclass.type = type end + def version(version = nil, &block) + return @version unless block_given? + + klass = Class.new(self) + klass.name = name + klass.slug = slug + klass.version = version + klass.release = release + klass.links = links + klass.class_exec(&block) + @versions ||= [] + @versions << klass + klass + end + + def version=(value) + @version = value.to_s + end + + def versions + @versions.presence || [self] + end + + def version? + version.present? + end + + def versioned? + @versions.presence + end + def name @name || super.try(:demodulize) end def slug - @slug || name.try(:downcase) + slug = @slug || name.try(:downcase) + version? ? "#{slug}~#{version_slug}" : slug + end + + def version_slug + slug = version.downcase + slug.gsub! '+', 'p' + slug.gsub! '#', 's' + slug.gsub! %r{[^a-z0-9\_\.]}, '_' + slug end def path @@ -31,12 +73,11 @@ def db_path end def as_json - { name: name, - slug: slug, - type: type, - version: version, - index_path: index_path, - db_path: db_path } + json = { name: name, slug: slug, type: type } + json[:links] = links if links.present? + json[:version] = version if version.present? || defined?(@version) + json[:release] = release if release.present? + json end def store_page(store, id) @@ -63,8 +104,8 @@ def store_pages(store) end if index.present? - store.write INDEX_FILENAME, index.to_json - store.write DB_FILENAME, pages.to_json + store_index(store, INDEX_FILENAME, index) + store_index(store, DB_FILENAME, pages) true else false @@ -77,6 +118,13 @@ def store_pages(store) def store_page?(page) page[:entries].present? end + + def store_index(store, filename, index) + old_json = store.read(filename) || '{}' + new_json = index.to_json + instrument "#{filename.remove('.json')}.doc", before: old_json, after: new_json + store.write(filename, new_json) + end end def initialize diff --git a/lib/docs/core/entry_index.rb b/lib/docs/core/entry_index.rb index 3c819c70b8..39df9b7092 100644 --- a/lib/docs/core/entry_index.rb +++ b/lib/docs/core/entry_index.rb @@ -1,21 +1,22 @@ require 'yajl/json_gem' module Docs - class EntryIndex + class EntryIndex < ReflyEntryIndex attr_reader :entries, :types def initialize @entries = [] + @index = Set.new @types = Hash.new { |hash, key| hash[key] = Type.new key } end - def add(entry) - if entry.is_a? Array - entry.each(&method(:add)) - else - add_entry(entry) unless entry.root? - end - end + # def add(entry) + # if entry.is_a? Array + # entry.each(&method(:add)) + # else + # add_entry(entry) unless entry.root? + # end + # end def empty? @entries.empty? @@ -38,8 +39,10 @@ def to_json private def add_entry(entry) - @entries << entry.dup - @types[entry.type].count += 1 if entry.type + if @index.add?(entry.as_json.to_s) + @entries << entry.dup + @types[entry.type].count += 1 if entry.type + end end def entries_as_json diff --git a/lib/docs/core/filesmodified.txt b/lib/docs/core/filesmodified.txt new file mode 100644 index 0000000000..e64c668d27 --- /dev/null +++ b/lib/docs/core/filesmodified.txt @@ -0,0 +1,2 @@ +entryindex.rb +entries.rb \ No newline at end of file diff --git a/lib/docs/core/filter.rb b/lib/docs/core/filter.rb index de1765449f..6d3d4b466e 100644 --- a/lib/docs/core/filter.rb +++ b/lib/docs/core/filter.rb @@ -20,6 +20,10 @@ def base_url context[:base_url] end + def links + context[:links] + end + def current_url context[:url] end diff --git a/lib/docs/core/manifest.rb b/lib/docs/core/manifest.rb index 5a00a1022f..8680ab5d7b 100644 --- a/lib/docs/core/manifest.rb +++ b/lib/docs/core/manifest.rb @@ -14,9 +14,11 @@ def store end def as_json - indexed_docs.map(&:as_json).each do |json| - json[:mtime] = doc_mtime(json) - json[:db_size] = doc_db_size(json) + indexed_docs.map do |doc| + json = doc.as_json + json[:mtime] = doc_mtime(doc) + json[:db_size] = doc_db_size(doc) + json end end @@ -33,11 +35,11 @@ def indexed_docs end def doc_mtime(doc) - [@store.mtime(doc[:index_path]).to_i, @store.mtime(doc[:db_path]).to_i].max + [@store.mtime(doc.index_path).to_i, @store.mtime(doc.db_path).to_i].max end def doc_db_size(doc) - @store.size(doc[:db_path]) + @store.size(doc.db_path) end end end diff --git a/lib/docs/core/models/refly_entry.rb b/lib/docs/core/models/refly_entry.rb new file mode 100644 index 0000000000..340f40b1cb --- /dev/null +++ b/lib/docs/core/models/refly_entry.rb @@ -0,0 +1,63 @@ +module Docs + class ReflyEntry < Docs::Entry + attr_accessor :name, :type, :path, :parsed_uri,:anchor, :parent_uri, :docset, :source_url + def initialize(name = nil, path = nil, type = nil, parsed_uri = nil, anchor = nil, parent_uri = nil, docset = nil, source_url = nil) + self.name = name + self.path = path + self.type = type + self.parsed_uri = parsed_uri + self.anchor = anchor + self.parent_uri = parent_uri + self.docset = docset + self.source_url = source_url + end + + def ==(other) + other.name == name && other.path == path && other.type == type + end + + def <=>(other) + name.to_s.casecmp(other.name.to_s) + end + + def docset=(value) + @docset = value.try :strip + end + + def parsed_uri=(value) + @parsed_uri = value.try :strip + end + + def anchor=(value) + @anchor = value.try :strip + end + + def parent_uri=(value) + @parent_uri = value.try :strip + end + + def source_url=(value) + @source_url = value.try :strip + end + + def name=(value) + @name = value.try :strip + end + + def type=(value) + @type = value.try :strip + end + + def root? + if anchor!='' + return false + else + return path == 'index' + end + end + + def as_json + { name: name, path: path, source_url: source_url, type: type, parsed_uri: parsed_uri, anchor: anchor, parent_uri: parent_uri, docset: docset } + end + end +end diff --git a/lib/docs/core/models/type.rb b/lib/docs/core/models/type.rb index 2460250b91..b9869ae7c3 100644 --- a/lib/docs/core/models/type.rb +++ b/lib/docs/core/models/type.rb @@ -7,8 +7,14 @@ def initialize(*args) self.count ||= 0 end + STARTS_WITH_INTEGER = /\A\d/ + def <=>(other) - name.to_s.casecmp(other.name.to_s) + if name && other && name =~ STARTS_WITH_INTEGER && other.name =~ STARTS_WITH_INTEGER + name.to_i <=> other.name.to_i + else + name.to_s.casecmp(other.name.to_s) + end end def slug diff --git a/lib/docs/core/parser.rb b/lib/docs/core/parser.rb index 43a0890428..b3bf79155c 100644 --- a/lib/docs/core/parser.rb +++ b/lib/docs/core/parser.rb @@ -11,7 +11,7 @@ def html private def document? - @content =~ /\A\s*])*>/ + return content.gsub!(re, '') + end + + def WrapPreContentWithCode(classname) + css('pre').each do |node| + node['class'] = classname + if !node.children[0] || node.children[0].name != 'code' + codetag = Nokogiri::XML::Node.new "code", @doc + codetag.children = node.children + node.children = codetag + end + end + end + + def WrapContentWithDivs(classname) + divremovable = Nokogiri::XML::Node.new "div", @doc + divcontainer = Nokogiri::XML::Node.new "div", @doc + divcontainer['class'] = classname + divcontainer.children = @doc + divremovable.children = divcontainer + @doc = divremovable + end + end +end diff --git a/lib/docs/core/refly_request.rb b/lib/docs/core/refly_request.rb new file mode 100644 index 0000000000..955b87a568 --- /dev/null +++ b/lib/docs/core/refly_request.rb @@ -0,0 +1,29 @@ +module Docs + class ReflyRequest < Typhoeus::Request + include Instrumentable + + USER_AGENTS = [ + 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6', + 'Mozilla/5.0 (X11; U; Linux i686; en-US) AppleWebKit/534.3 (KHTML, like Gecko)', + 'Chrome/6.0.472.63 Safari/534.3', + 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)', + 'Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)', + 'Yahoo! Slurp/Site Explorer', + 'Googlebot/2.1 ( http://www.googlebot.com/bot.html)', + 'msnbot/1.1 (+http://search.msn.com/msnbot.htm)', + 'Python-urllib/2.1', + 'Version/3.0 Mobile/1A543a Safari/419.3', + 'Version/6.0.0.141 Mobile Safari/534.1+', + ] + + def initialize(url, options = {}) + rand_user_agent = USER_AGENTS[rand(USER_AGENTS.length)] + default_options = { + followlocation: true, + headers: { 'User-Agent' => rand_user_agent } + } + super url.to_s, default_options.merge(options) + + end + end +end diff --git a/lib/docs/core/response.rb b/lib/docs/core/response.rb index 2908c10125..64ecc30262 100644 --- a/lib/docs/core/response.rb +++ b/lib/docs/core/response.rb @@ -4,6 +4,10 @@ def success? code == 200 end + def error? + code != 404 && code != 403 && code >= 400 && code <= 599 + end + def empty? body.empty? end diff --git a/lib/docs/core/scraper.rb b/lib/docs/core/scraper.rb index 634ee8576e..2d3b43eec9 100644 --- a/lib/docs/core/scraper.rb +++ b/lib/docs/core/scraper.rb @@ -3,7 +3,7 @@ module Docs class Scraper < Doc class << self - attr_accessor :base_url, :root_path, :initial_paths, :options, :html_filters, :text_filters + attr_accessor :base_url, :root_path, :initial_paths, :options, :html_filters, :text_filters, :stubs def inherited(subclass) super @@ -13,22 +13,30 @@ def inherited(subclass) autoload_all "docs/filters/#{to_s.demodulize.underscore}", 'filter' end + subclass.base_url = base_url subclass.root_path = root_path subclass.initial_paths = initial_paths.dup subclass.options = options.deep_dup subclass.html_filters = html_filters.inheritable_copy subclass.text_filters = text_filters.inheritable_copy + subclass.stubs = stubs.dup end def filters html_filters.to_a + text_filters.to_a end + + def stub(path, &block) + @stubs[path] = block + @stubs + end end include Instrumentable self.initial_paths = [] self.options = {} + self.stubs = {} self.html_filters = FilterStack.new self.text_filters = FilterStack.new @@ -36,6 +44,23 @@ def filters html_filters.push 'container', 'clean_html', 'normalize_urls', 'internal_urls', 'normalize_paths' text_filters.push 'inner_html', 'clean_text', 'attribution' + def initialize + super + initialize_stubs + end + + def initialize_stubs + self.class.stubs.each do |path, block| + Typhoeus.stub(url_for(path)).and_return do + Typhoeus::Response.new \ + effective_url: url_for(path), + code: 200, + headers: { 'Content-Type' => 'text/html' }, + body: self.instance_exec(&block) + end + end + end + def build_page(path) response = request_one url_for(path) result = handle_response(response) @@ -100,6 +125,7 @@ def options (options[:only] ||= []).concat initial_paths + (root_path? ? [root_path] : ['', '/']) end + options.merge!(additional_options) if respond_to?(:additional_options, true) options.freeze end end @@ -134,6 +160,9 @@ def handle_response(response) else instrument 'ignore_response.scraper', response: response end + rescue => e + puts "URL: #{response.url}" + raise e end def process_response(response) @@ -149,5 +178,75 @@ def pipeline_context(response) def parse(string) Parser.new(string).html end + + def with_filters(*filters) + stack = FilterStack.new + stack.push(*filters) + pipeline.instance_variable_set :@filters, stack.to_a.freeze + yield + ensure + @pipeline = nil + end + + module FixInternalUrlsBehavior + def self.included(base) + base.extend ClassMethods + end + + module ClassMethods + attr_reader :internal_urls + + def store_pages(store) + instrument 'info.doc', msg: 'Building internal urls...' + with_internal_urls do + instrument 'info.doc', msg: 'Building pages...' + super + end + end + + private + + def with_internal_urls + @internal_urls = new.fetch_internal_urls + yield + ensure + @internal_urls = nil + end + end + + def fetch_internal_urls + result = [] + build_pages do |page| + result << base_url.subpath_to(page[:response_url]) if page[:entries].present? + end + result + end + + def initial_urls + return super unless self.class.internal_urls + @initial_urls ||= self.class.internal_urls.map(&method(:url_for)).freeze + end + + private + + def additional_options + if self.class.internal_urls + { + only: self.class.internal_urls.to_set, + only_patterns: nil, + skip: nil, + skip_patterns: nil, + skip_links: nil, + fixed_internal_urls: true + } + else + {} + end + end + + def process_response(response) + super.merge! response_url: response.url + end + end end end diff --git a/lib/docs/core/scrapers/file_scraper.rb b/lib/docs/core/scrapers/file_scraper.rb index 8c08721396..58a252da2f 100644 --- a/lib/docs/core/scrapers/file_scraper.rb +++ b/lib/docs/core/scrapers/file_scraper.rb @@ -8,6 +8,7 @@ class << self def inherited(subclass) super subclass.base_url = base_url + subclass.dir = dir end end diff --git a/lib/docs/core/scrapers/url_scraper.rb b/lib/docs/core/scrapers/url_scraper.rb index cb918b1bfa..6843628190 100644 --- a/lib/docs/core/scrapers/url_scraper.rb +++ b/lib/docs/core/scrapers/url_scraper.rb @@ -2,14 +2,17 @@ module Docs class UrlScraper < Scraper class << self attr_accessor :params + attr_accessor :headers def inherited(subclass) super subclass.params = params.deep_dup + subclass.headers = headers.deep_dup end end self.params = {} + self.headers = { 'User-Agent' => 'devdocs.io' } private @@ -22,11 +25,63 @@ def request_all(urls, &block) end def request_options - { params: self.class.params } + { params: self.class.params, headers: self.class.headers } end def process_response?(response) + if response.error? + raise "Error status code (#{response.code}): #{response.url}" + end + response.success? && response.html? && base_url.contains?(response.effective_url) end + + module FixRedirectionsBehavior + def self.included(base) + base.extend ClassMethods + end + + module ClassMethods + attr_reader :redirections + + def store_pages(store) + instrument 'info.doc', msg: 'Fetching redirections...' + with_redirections do + instrument 'info.doc', msg: 'Building pages...' + super + end + end + + private + + def with_redirections + @redirections = new.fetch_redirections + yield + ensure + @redirections = nil + end + end + + def fetch_redirections + result = {} + with_filters 'container', 'normalize_urls', 'internal_urls' do + build_pages do |page| + next if page[:response_effective_path] == page[:response_path] + result[page[:response_path].downcase] = page[:response_effective_path] + end + end + result + end + + private + + def process_response(response) + super.merge! response_effective_path: response.effective_path, response_path: response.path + end + + def additional_options + { redirections: self.class.redirections } + end + end end end diff --git a/lib/docs/db_storage/import_docset.py b/lib/docs/db_storage/import_docset.py new file mode 100755 index 0000000000..75355a7bb8 --- /dev/null +++ b/lib/docs/db_storage/import_docset.py @@ -0,0 +1,33 @@ +from importer import DocImporter +from scraper import Scraper +import sys +import time +def main(argv): + print 'process started at ' + time.strftime("%d/%m/%Y %H:%M:%S") + docset = '' + mode = '' + action = '' + connstring = '' + for arg in argv: + if arg[:2]== '-a': + action = arg[2:] + elif arg[:2]== '-d': + docset = arg[2:] + elif arg[:2]== '-m': + mode = arg[2:] + elif arg[:3]== '-cs': + connstring = arg[3:] + + if mode=='' and docset!='': + mode = 'single' + if action == 'import': + importer = DocImporter(docset, mode, connstring) + elif action == 'scrap': + scraper = Scraper(docset, 'importer.cfg') + else: + scraper = Scraper(docset,'importer.cfg') + importer = DocImporter(docset, mode, connstring) + print 'process finished at ' + time.strftime("%d/%m/%Y %H:%M:%S") + +if __name__ == "__main__": + main(sys.argv[1:]) diff --git a/lib/docs/db_storage/importer.cfg b/lib/docs/db_storage/importer.cfg new file mode 100644 index 0000000000..0d2b52c688 --- /dev/null +++ b/lib/docs/db_storage/importer.cfg @@ -0,0 +1,970 @@ +[Connection] +User: postgres +Password: +Host: 127.0.0.1 +DBname: slashdb +[Path] +base_path: ../../../public/docs/ + +[Config] +debugMode: True +[angular] +name: AngularJS +parsed_name: angularjs +default_uri: /angularjs/ng +scraper_name: angular +version: 1.4.5 +zip_url: +sort: 1 +additional: false +active: true +[apache] +name: Apache +parsed_name: apache +default_uri: /apache/core +scraper_name: apache +version: 2.4.12 +zip_url: +sort: 2 +additional: false +active: true +[aspnet] +name: ASP.NET +parsed_name: asp.net +default_uri: /asp.net/index +scraper_name: +version: +zip_url: +sort: 3 +additional: false +active: false +[elixir] +name: Elixir +parsed_name: elixir +default_uri: /elixir/index +scraper_name: elixir +version: 1.1.1 +zip_url: +sort: 4 +additional: false +active: true +[backbone] +name: BackboneJS +parsed_name: backbonejs +default_uri: /backbonejs/backbone.$ +scraper_name: backbone +version: 1.2.3 +zip_url: +sort: 5 +additional: false +active: true +[bower] +name: Bower +parsed_name: bower +default_uri: /bower/creating_packages +scraper_name: bower +version: 1.4.1 +zip_url: +sort: 6 +additional: false +active: false +[bootstrap] +name: Bootstrap +parsed_name: bootstrap +default_uri: /bootstrap/getting_started +scraper_name: bootstrap +version: 3.3.35 +zip_url: +sort: 7 +additional: false +active: true +[browserify] +name: Browserify +parsed_name: browserify +default_uri: /browserify/getting_started +scraper_name: browserify +version: 11.0.1 +zip_url: +sort: 8 +additional: false +active: true +[c] +name: C +parsed_name: c +default_uri: /c/c_keywords +scraper_name: c +version: +zip_url: http://upload.cppreference.com/mwiki/images/6/6c/html_book_20141118.tar.gz +sort: 9 +additional: false +active: true +[chai] +name: Chai +parsed_name: chai +default_uri: /chai/api_reference +scraper_name: chai +version: +zip_url: +sort: 11 +additional: false +active: false +[chef] +name: Chef +parsed_name: chef +default_uri: chef/all_about_chef_... +scraper_name: chef +version: 12.4 +zip_url: +sort: 12 +additional: false +active: true +[clojure] +name: Clojure +parsed_name: clojure +default_uri: /clojure/clojure.core +scraper_name: clojure +version: 1.7 +zip_url: +sort: 13 +additional: false +active: true +[coffeescript] +name: CoffeeScript +parsed_name: coffeescript +default_uri: /coffeescript/index +scraper_name: coffeescript +version: 1.10.0 +zip_url: +sort: 14 +additional: false +active: true +[cordova] +name: Apache Cordova +parsed_name: apache_cordova +default_uri: /apache-cordova/overview +scraper_name: cordova +version: 5.1.1 +zip_url: +sort: 15 +additional: false +active: true +[cpp] +name: Cpp +parsed_name: cpp +default_uri: /cpp/c++_language +scraper_name: cpp +version: +zip_url: +sort: 16 +additional: false +active: true +[css] +name: CSS +parsed_name: css +default_uri: /css/universal_selectors +scraper_name: css +version: +zip_url: +sort: 0 +additional: false +active: true +[d3] +name: D3 +parsed_name: d3 +default_uri: /d3/namespaces +scraper_name: d3 +version: +zip_url: +sort: 17 +additional: false +active: false +[django] +name: Django +parsed_name: django +default_uri: /django/getting_started +scraper_name: django +version: 1.8.4 +zip_url: https://docs.djangoproject.com/m/docs/django-docs-1.8-en.zip +sort: 18 +additional: false +active: true +[dom] +name: DOM +parsed_name: dom +default_uri: /dom/document +scraper_name: dom +version: +zip_url: +sort: 10 +additional: false +active: true +[dojo] +name: Dojo +parsed_name: dojo +default_uri: /dojo/index +scraper_name: dojo +version: 1.10 +zip_url: +sort: 19 +additional: false +active: true +[dom_events] +name: DOM Events +parsed_name: dom_events +default_uri: /dom_events/click +scraper_name: dom_events +version: +zip_url: +sort: 20 +additional: false +active: true +[drupal] +name: Drupal +parsed_name: drupal +default_uri: /drupal +scraper_name: drupal +version: +zip_url: +sort: 21 +additional: false +active: false +[ember] +name: EmberJS +parsed_name: emberjs +default_uri: /ember/classes/namespace +scraper_name: ember +version: 2.0.1 +zip_url: +sort: 22 +additional: false +active: true +[express] +name: Express +parsed_name: express +default_uri: /express/express +scraper_name: express +version: +zip_url: +sort: 23 +additional: false +active: true +[flow] +name: Flow +parsed_name: flow +default_uri: /flow/index +scraper_name: flow +version: +zip_url: +sort: 24 +additional: false +active: false +[git] +name: Git +parsed_name: git +default_uri: /git/git +scraper_name: git +version: +zip_url: +sort: 25 +additional: false +active: false +[go] +name: Go +parsed_name: go +default_uri: /go/go_programming_language/community +scraper_name: go +version: 1.5.0 +zip_url: +sort: 26 +additional: false +active: true +[grunt] +name: Grunt +parsed_name: grunt +default_uri: /grunt/grunt +scraper_name: grunt +version: 0.4.5 +zip_url: +sort: 27 +additional: false +active: true +[html] +name: HTML +parsed_name: html +default_uri: /html/html_attribute_reference +scraper_name: html +version: +zip_url: +sort: 30 +additional: false +active: true +[http] +name: Http +parsed_name: http +default_uri: /http/200_ok +scraper_name: http +version: +zip_url: +sort: 28 +additional: false +active: true +[haskell] +name: Haskell +parsed_name: haskell +default_uri: /haskell/index +scraper_name: haskell +version: 7.10.2 +zip_url: +sort: 29 +additional: false +active: true +[iojs] +name: ioJS +parsed_name: iojs +default_uri: /iojs/index +scraper_name: iojs +version: 3.2.0 +zip_url: +sort: 31 +additional: false +active: true +[jasmine] +name: Jasmine +parsed_name: jasmine +default_uri: /jasmine/introduction +scraper_name: jasmine +version: edge +zip_url: +sort: 32 +additional: false +active: true +[javascript] +name: JavaScript +parsed_name: javascript +default_uri: /javascript/statements_and_declarations +scraper_name: javascript +version: +zip_url: +sort: 40 +additional: false +active: true +[java7se] +name: Java 7 SE +parsed_name: java7se +default_uri: /java7se/ +scraper_name: java7se +version: 7_se +zip_url: +sort: 33 +additional: false +active: true +[jest] +name: Jest +parsed_name: jest +default_uri: /jest/getting_started +scraper_name: jest +version: +zip_url: +sort: 34 +additional: false +active: false +[jquery] +name: JQuery +parsed_name: jquery +default_uri: /jquery/index +scraper_name: jquery_core +version: up_to_2.1.0 +zip_url: +sort: 35 +additional: false +active: true +[jqueryui] +name: JQuery UI +parsed_name: jquery_ui +default_uri: /jqueryui/color-animation +scraper_name: jquery_ui +version: 1.10.4 +zip_url: +sort: 36 +additional: false +active: true +[jquerymobile] +name: JQuery Mobile +parsed_name: jquery_mobile +default_uri: /jquerymobile/classes +scraper_name: jquery_mobile +version: 1.4.0 +zip_url: +sort: 37 +additional: false +active: true +[knex] +name: Knex +parsed_name: knex +default_uri: /knex/index +scraper_name: knex +version: 0.8.6 +zip_url: +sort: 38 +additional: false +active: true +[knockout] +name: KnockOut +parsed_name: knockout +default_uri: /knockout/knockout.js +scraper_name: knockout +version: 3.3.0 +zip_url: +sort: 39 +additional: false +active: true +[less] +name: Less +parsed_name: less +default_uri: /less/misc_functions +scraper_name: less +version: 2.5.0 +zip_url: +sort: 41 +additional: false +active: true +[laravel] +name: Laravel +parsed_name: laravel +default_uri: /laravel/namespaces +scraper_name: laravel +version: 5.1.1 +zip_url: +sort: 42 +additional: false +active: false +[lodash] +name: Lo-Dash +parsed_name: lodash +default_uri: /lodash/_ +scraper_name: lodash +version: 3.10.0 +zip_url: +sort: 43 +additional: false +active: true +[lua] +name: Lua +parsed_name: lua +default_uri: /lua/manual +scraper_name: lua +version: 5.3 +zip_url: +sort: 44 +additional: false +active: true +[marionette] +name: Marionette +parsed_name: marionette +default_uri: /marionette/api +scraper_name: marionette +version: 2.4.3 +zip_url: +sort: 45 +additional: false +active: true +[markdown] +name: MarkDown +parsed_name: markdown +default_uri: /markdown/inline_html +scraper_name: markdown +version: +zip_url: +sort: 46 +additional: false +active: true +[mocha] +name: Mocha +parsed_name: mocha +default_uri: /mocha/index +scraper_name: mocha +version: 2.2.1 +zip_url: +sort: 47 +additional: false +active: true +[modernizr] +name: Modernizr +parsed_name: modernizr +default_uri: /modernizr/index +scraper_name: modernizr +version: 2.8.3 +zip_url: +sort: 48 +additional: false +active: true +[moment] +name: Moment +parsed_name: moment +default_uri: /moment/index +scraper_name: moment +version: 2.10.2 +zip_url: +sort: 49 +additional: false +active: true +[mysql] +name: Mysql +parsed_name: mysql +default_uri: /mysql/index +scraper_name: mysql +version: 5.7 +zip_url: +sort: 51 +additional: false +active: true +[mongoosejs] +name: MongooseJS +parsed_name: mongoosejs +default_uri: /mongoosejs/index +scraper_name: mongoose +version: 4.1.6 +zip_url: +sort: 52 +additional: false +active: true +[nginx] +name: Nginx +parsed_name: nginx +default_uri: /nginx/guide/beginner’s_guide +scraper_name: nginx +version: 1.9.4 +zip_url: +sort: 53 +additional: false +active: true +[node] +name: NodeJS +parsed_name: node +default_uri: /nodejs/assert +scraper_name: node +version: 4.0.0 +zip_url: +sort: 54 +additional: false +active: true +[node_lts] +name: NodeJS LTS +parsed_name: node_lts +default_uri: /nodejs_lts/assert +scraper_name: node_lts +version: 4.2.1 +zip_url: +sort: 55 +additional: false +active: true +[nokogiri] +parsed_name: nokogiri +name: Nokogiri +default_uri: /nokogiri/top_level_namespace +scraper_name: nokogiri2 +version: +zip_url: +sort: 56 +additional: false +active: false +[npm] +name: npm +parsed_name: npm +default_uri: /npm/faq +scraper_name: npm +version: 2.13.0 +zip_url: +sort: 57 +additional: false +active: false +[opentsdb] +name: OpenTSDB +parsed_name: opentsdb +default_uri: /opentsdb/index +scraper_name: opentsdb +version: 2.1.0 +zip_url: +sort: 58 +additional: false +active: true +[perl] +name: Perl +parsed_name: perl +default_uri: /perl/index +scraper_name: perl +version: 5.22 +zip_url: http://perldoc.perl.org/perldoc-html.tar.gz +sort: 59 +additional: false +active: true +[php] +name: PHP +parsed_name: php +default_uri: /php/classes_and_objects +scraper_name: php2 +version: up_to_5.6.2 +zip_url: +sort: 61 +additional: false +active: true +[phpunit] +name: PHPUnit +parsed_name: phpunit +default_uri: /phpunit/phpunit_and_selenium +scraper_name: phpunit +version: 4.8 +zip_url: +sort: 62 +additional: false +active: true +[phalcon] +name: Phalcon +parsed_name: phalcon +default_uri: /phalcon/ +scraper_name: phalcon +version: 2.0.6 +zip_url: +sort: 63 +additional: false +active: true +[phaser] +name: Phaser +parsed_name: phaser +default_uri: /phaser/ +scraper_name: phaser +version: 2.4.1 +zip_url: +sort: 64 +additional: false +active: true +[phoenix] +name: Phoenix +parsed_name: phoenix +default_uri: /phoenix/ +scraper_name: phoenix +version: 1.0.3 +zip_url: +sort: 65 +additional: false +active: false +[postgresql] +name: PostgreSQL +parsed_name: postgresql +default_uri: /postgresql/select +scraper_name: postgresql +version: 9.4 +zip_url: +sort: 66 +additional: false +active: false +[python2] +name: Python2 +parsed_name: python2 +default_uri: /python2/keyword +scraper_name: python2 +version: 2.7.10 +zip_url: https://docs.python.org/2.7/archives/python-2.7.8-docs-html.zip +sort: 67 +additional: false +active: true +[python] +name: Python3 +parsed_name: python3 +default_uri: /python3/abc +scraper_name: python +version: 3.5.0 +zip_url: https://docs.python.org/3/archives/python-3.5.0-docs-html.zip +sort: 68 +additional: false +active: true +[q] +name: q +parsed_name: q +default_uri: /q/index +scraper_name: q +version: 1.4.1 +zip_url: +sort: 69 +additional: false +active: true +[rails] +name: Rails +parsed_name: rails +default_uri: /rails/rails +scraper_name: rails +version: 4.2.0 +zip_url: +sort: 70 +additional: false +active: true +[react] +name: React +parsed_name: react +default_uri: /react/thinking_in_react +scraper_name: react +version: 0.13.3 +zip_url: +sort: 71 +additional: false +active: true +[react_native] +name: React native +parsed_name: react_native +default_uri: /react/ +scraper_name: react_native +version: 0.10.0 +zip_url: +sort: 72 +additional: false +active: true +[react_router] +name: React Router +parsed_name: react_router +default_uri: /react/ +scraper_name: react_router +version: +zip_url: +sort: 73 +additional: false +active: false +[redis] +name: Redis +parsed_name: redis +default_uri: /redis/index +scraper_name: redis +version: up_to_3.0.4 +zip_url: +sort: 74 +additional: false +active: true +[reflux] +name: Reflux +parsed_name: reflux +default_uri: /reflux/index +scraper_name: reflux +version: 0.2.12 +zip_url: +sort: 75 +additional: false +active: true +[relay] +name: Relay +parsed_name: relay +default_uri: /relay/index +scraper_name: relay +version: 0.5 +zip_url: +sort: 76 +additional: false +active: true +[requirejs] +name: RequireJS +parsed_name: requirejs +default_uri: /requirejs/commonjs_notes +scraper_name: requirejs +version: 2.1.18 +zip_url: +sort: 77 +additional: false +active: true +[rethinkdb] +name: RethinkDB +parsed_name: rethinkdb +default_uri: /rethinkdb/index_list +scraper_name: rethinkdb +version: 2.1.2 +zip_url: +sort: 78 +additional: false +active: true +[ruby] +name: Ruby +parsed_name: ruby +default_uri: /ruby/class +scraper_name: ruby +version: 2.2.2 +zip_url: +sort: 79 +additional: false +active: true +[rust] +name: Rust +parsed_name: rust +default_uri: rust/2.2._hello._world! +scraper_name: rust +version: 1.2.0 +zip_url: +sort: 80 +additional: false +active: true +[sass] +name: Sass +parsed_name: sass +default_uri: /sass/list_functions +scraper_name: sass +version: 3.4.7 +zip_url: +sort: 81 +additional: false +active: true +[scala] +name: Scala +parsed_name: scala +default_uri: /scala/index +scraper_name: scala +version: 2.11 +zip_url: +sort: 82 +additional: false +active: true +[sinon] +name: SinonJS +parsed_name: sinonjs +default_uri: /sinonjs/spiapi +scraper_name: sinon +version: 1.16.1 +zip_url: +sort: 83 +additional: false +active: true +[socketio] +name: SocketIO +parsed_name: socketio +default_uri: /socketio/client_api +scraper_name: socketio +version: 1.3.6 +zip_url: +sort: 84 +additional: false +active: true +[sqlite] +name: SQLite +parsed_name: sqlite +default_uri: /sqlite/index +scraper_name: sqlite +version: 3.9.1 +zip_url: https://www.sqlite.org/2015/sqlite-doc-3090100.zip +sort: 85 +additional: false +active: true +[svg] +name: SVG +parsed_name: svg +default_uri: /svg/index +scraper_name: svg +version: +zip_url: +sort: 50 +additional: false +active: true +[swift] +name: Swift +parsed_name: swift +default_uri: /swift/index +scraper_name: swift +version: 12.4 +zip_url: +sort: 86 +additional: false +active: false +[swiftreference] +name: Swift +parsed_name: swift +default_uri: /swift/reference/index +scraper_name: swiftreference +version: 12.4 +zip_url: +sort: 87 +additional: true +active: true +[symfony] +name: Symfony +parsed_name: symfony +default_uri: /symfony/component/console/command/listcommand +scraper_name: symfony +version: 2.7 +zip_url: +sort: 88 +additional: false +active: true +[twig] +name: Twig +parsed_name: twig +default_uri: /twig/doc-index +scraper_name: twig +version: 5.7 +zip_url: +sort: 89 +additional: false +active: true +[underscore] +name: UnderscoreJS +parsed_name: underscorejs +default_uri: /underscorejs/all +scraper_name: underscore +version: 1.8.3 +zip_url: +sort: 90 +additional: false +active: true +[vue] +name: Vue +parsed_name: vue +default_uri: /vue/getting_started +scraper_name: vue +version: 0.12.9 +zip_url: +sort: 91 +additional: false +active: true +[vagrant] +name: Vagrant +parsed_name: vagrant +default_uri: /vagrant/index +scraper_name: vagrant +version: 1.7.4 +zip_url: +sort: 92 +additional: false +active: true +[webpack] +name: Webpack +parsed_name: webpack +default_uri: /webpack/installation +scraper_name: webpack +version: 1.12 +zip_url: +sort: 93 +additional: false +active: true +[xpath] +name: XPath +parsed_name: xpath +default_uri: /xpath/index +scraper_name: xpath +version: +zip_url: +sort: 60 +additional: false +active: true +[yii] +name: Yii +parsed_name: yii +default_uri: /yii/quick_start +scraper_name: yii +version: 2.0.2 +zip_url: +sort: 94 +additional: false +active: true +[yii1] +name: Yii1 +parsed_name: Yii1 +default_uri: /yii1 +scraper_name: yii1 +version: 1.1.16 +zip_url: +sort: 95 +additional: false +active: true diff --git a/lib/docs/db_storage/importer.py b/lib/docs/db_storage/importer.py new file mode 100755 index 0000000000..3d952d123d --- /dev/null +++ b/lib/docs/db_storage/importer.py @@ -0,0 +1,279 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +import json +import psycopg2 +import sys +import ConfigParser +import pprint +import os.path +import re +import time +import math +import logging + +from lxml import html + +class DocImporter(): + connection_string = '' + content_path = '' + debugMode = False + linkerrors = [] + additional = False + docset = '' + filename = '' + version = '' + docset_name = '' + docset_parsed_name = '' + index_path = '' + default_uri = '' + total_entries = 0 + links = {} + + #load config file + def __init__(self, _docset, _mode, _connectionstring): + self.config = ConfigParser.ConfigParser() + self.config.read('importer.cfg') + if(_connectionstring==''): + User = self.config.get('Connection', 'User', 0) + Password = self.config.get('Connection', 'Password', 0) + Host = self.config.get('Connection', 'Host', 0) + DBname = self.config.get('Connection', 'DBname', 0) + self.connection_string = "host='"+ Host + "' dbname='" + DBname + "' user='" + User + "' password='" + Password + "'" + else: + self.connection_string = _connectionstring + self.debugMode = bool(self.config.get('Config', 'debugMode', 0)) + self.content_path = self.config.get('Path', 'base_path', 0) + sections = self.config.sections() + if _mode == 'continue': + sections = sections[sections.index(_docset):] + elif _mode == 'single': + sections = [_docset] + conn = psycopg2.connect(self.connection_string) + self.processDocsets(sections) + + + def processDocsets(self, docsetlist): + for sect in docsetlist: + if sect not in ['Connection', 'Config', 'Path']: + if self.config.get(sect, 'active', 0) == 'true': + try: + self.docset = sect + self.docset_name = self.config.get(sect, 'name', 0) + self.docset_parsed_name = self.config.get(sect, 'parsed_name', 0) + self.default_uri = self.config.get(sect, 'default_uri', 0) + self.additional = self.config.get(sect, 'additional', 0) + self.version = self.config.get(sect, 'version', 0) + if self.version != '': + self.index_path = self.content_path + sect + '~' + self.version + '/index.json' + else: + self.index_path = self.content_path + sect + '/index.json' + print "\rImporting " + sect + "..." + self.importToDB() + except: + lastimportfile = open('lastimport.log', 'w') + lastimportfile.truncate() + lastimportfile.write(sect) + lastimportfile.close(); + + + + def processContent(self, content): + tree = html.fromstring(content) + links = tree.xpath('//a[@href]') + for alink in links: + anchor = '' + keymatch = '' + if alink.get('href')!=None: + match = alink.get('href') + keymatch = match.lower().replace('../', '').replace('%24', '$') + else: + match = '#' + keymatch = '#' + if not keymatch.startswith('http://') and not keymatch.startswith('https://') and not keymatch.startswith('ftp://') and not keymatch.startswith('irc://') and not keymatch.startswith('news://') and not keymatch.startswith('git://') and not keymatch.startswith('mailto:') and keymatch!= '': + if match.find('#')!=-1 and keymatch not in self.links.keys(): + anchor = keymatch[keymatch.find('#'):] + keymatch = keymatch[:keymatch.find('#')] + if keymatch in self.links.keys(): + #print '"' + keymatch + '" - "' + match + '" : "' + self.links[keymatch] + '"' + content = content.replace('"' + match + '"', '"' + self.links[keymatch] + anchor + '"',1) + if keymatch not in self.links and anchor == '' and alink.get('class') != 'broken': + hour = time.strftime("%d/%m/%Y %H:%M:%S") + self.linkerrors.append('- "' + keymatch + '" in ' + self.filename) + return content + + def importToDB(self): + conn = psycopg2.connect(self.connection_string) + try: + json_data = self.processJSON(self.index_path) + self.links = self.createLinkCollection(json_data) + self.initTable(conn) + previous_uri = '' + procesed_entries = {} + total = len(json_data) + i = 1 + for entry in json_data: + _name = entry['name'] + loading_value = int(math.ceil(float(50)/total*i)) + gap_value = 50 - loading_value + loading_bar = ("#" * loading_value) + (" " * gap_value) + sys.stdout.write('\r[' + loading_bar + '](' + str(i)+ '/' + str(total) + ')') + sys.stdout.flush() + i+=1 + if entry['path'].find('#')!= -1: + entry['path'] = entry['path'].split('#')[0] + filename = self.getFileName(self.content_path,self.docset, entry['path']) + #Avoid Process the same Page twice + if entry['path'] in procesed_entries.keys(): + _content = procesed_entries[entry['path']] + else: + self.filename = filename + _content = self.processContent(self.getContent(filename)) + procesed_entries[entry['path']] = _content + + if entry['parent_uri'] == 'null': + _parent_uri = None + else: + _parent_uri = entry['parent_uri'] + _type = entry['type'] + _docset = entry['docset'] + _uri = entry['parsed_uri'] + _anchor = entry['anchor'] + _source_url = entry['source_url'] + if previous_uri != _uri: + self.insertRow(conn, _name, _content, _parent_uri, _type, _docset, _uri, _anchor, _source_url) + previous_uri = _uri + if self.additional == 'false': + self.emptyTable(conn,self.docset_name) + self.moveToData(conn) + self.updateDocsets(conn,self.docset_name, self.default_uri, self.docset_parsed_name) + self.commit(conn) + except Exception, e: + hour = time.strftime("%d/%m/%Y %H:%M:%S") + self.ferrors = open('import_errors.log', 'a') + self.ferrors.write('\n\n\n######################################## ' + self.docset_name + ' ########################################\n\n\n') + self.rollback(conn) + self.initTable(conn) + self.linkerrors = [] + self.ferrors.write('- ' + hour + ' error in ' + self.docset_name + ': %s\n' % e) + self.ferrors.close() + print '========= ERROR =============' + print e + if len(self.linkerrors)>0: + brokenlinksfile = open('brokenlinks_' + self.docset_name +'.log', 'a') + hour = time.strftime("%d/%m/%Y %H:%M:%S") + brokenlinksfile.write('\n\n\n######################################## ' + hour + ' - ' + self.docset_name + ' ########################################\n\n\n') + for error in self.linkerrors: + brokenlinksfile.write(error + '\n') + self.linkerrors = [] + brokenlinksfile.close() + self.finish(conn) + + def createLinkCollection(self, entries): + links = {} + for entry in entries: + if entry['path'].lower() not in links.keys() or entry['anchor']=='': + links[entry['path'].lower()] = entry['parsed_uri'] + if entry['anchor']!= '': + links[entry['path'][entry['path'].find('/'):].lower()] = entry['parsed_uri'] + links[(entry['path'] + '#' + entry['anchor']).lower()] = entry['parsed_uri'] + links['#' + entry['anchor'].lower()] = entry['parsed_uri'] + # EXCEPTION FOR C++ this because the limitations of the documentation into the zip + if entry['docset'].lower() == 'cpp' or entry['docset'].lower() == 'c': + links[entry['path'][entry['path'].find('/')+1:].lower()] = entry['parsed_uri'] + links[entry['path'].replace('fs/', '').replace('io/', '').replace('experimental/', '')] = entry['parsed_uri'] + links[entry['path'].split('/')[-1]] = entry['parsed_uri'] + return links + + def getFileName(self, content_path, docset, path): + if not path.endswith('.html'): + path += '.html' + if self.version != '': + filename = content_path + docset + '~' + self.version + '/' + path + else: + filename = content_path + docset + '/' + path + return filename + + def getContent(self, filename): + with open(filename, 'r') as content_file: + content = content_file.read().decode('utf-8') + return content + + def processJSON(self,file_path): + if os.path.isfile(file_path): + with open(file_path) as json_file: + json_data = json.load(json_file) + self.total_entries = len(json_data['entries']) + return json_data['entries'] + else: + raise Exception("'index.json not found in docset " + self.docset_name) + + def connect(): + return psycopg2.connect(self.connection_string) + + def commit(self, conn): + conn.commit() + print '\n' + self.docset_name + ' imports ' + str(self.total_entries) + '\n' + + def rollback(self, conn): + conn.rollback() + + def insertRow(self, conn, _name, _content, _parent, _type, _docset, _uri, _anchor, _source_url): + pgcursor = conn.cursor() + sqlinsertitem = "INSERT INTO temp_refs (reference, source_url, parent, type, docset, uri, content_anchor) VALUES (%s, %s, %s, %s, %s, %s, %s);" + pgcursor.execute(sqlinsertitem,[_name, + _source_url, + _parent, + _type, + _docset, + _uri, + _anchor]) + + self.removedContent(conn, _source_url) + self.insertContent(conn, _content, _source_url) + + def insertContent(self, conn, _content, _source_url): + pgcursor = conn.cursor() + sqlinsertcontent = "INSERT INTO refs_content (source_url, content) VALUES(%s, %s);" + + pgcursor.execute(sqlinsertcontent,[_source_url, + _content]) + + def moveToData(self, conn): + sqlmovedata = 'INSERT INTO refs (reference, source_url, uri, content_anchor, parent_uri, type, docset) SELECT reference, source_url,uri,content_anchor,parent,type, docset FROM temp_refs;' + pgcursor = conn.cursor() + pgcursor.execute(sqlmovedata) + + + def emptyTable(self, conn, docset): + sqlemptytables = 'DELETE FROM refs WHERE docset=%s;' + pgcursor = conn.cursor() + pgcursor.execute(sqlemptytables, [docset]) + conn.commit() + + def removedContent(self, conn, _source_url): + sqlemptycontent = 'DELETE FROM refs_content WHERE source_url=%s;' + pgcursor = conn.cursor() + pgcursor.execute(sqlemptycontent, [_source_url]) + conn.commit() + + def initTable(self, conn): + sqlinittable = 'TRUNCATE TABLE temp_refs;' + pgcursor = conn.cursor() + pgcursor.execute(sqlinittable) + conn.commit() + + def updateDocsets(self, conn, docset, default_uri, parsed_name): + sqldocsetselect = "SELECT docset FROM docsets WHERE docset = %s;" + sqldocsetinsert = "INSERT INTO docsets (docset, default_uri, pub_date, update_date, active, parsed_name) VALUES (%s,%s,CURRENT_TIMESTAMP,CURRENT_TIMESTAMP,%s,%s);" + sqldocsetupdate = "UPDATE docsets SET default_uri = %s, update_date = CURRENT_TIMESTAMP, parsed_name = %s WHERE docset = %s" + pgcursor = conn.cursor() + pgcursor.execute(sqldocsetselect, [docset]) + docsetsrow = pgcursor.fetchone() + if docsetsrow: + pgcursor.execute(sqldocsetupdate, [default_uri, docset, parsed_name]) + else: + pgcursor.execute(sqldocsetinsert,[docset, default_uri, True, parsed_name]) + + def finish(self,conn): + self.initTable(conn) + conn.close() diff --git a/lib/docs/db_storage/lastimport.log b/lib/docs/db_storage/lastimport.log new file mode 100644 index 0000000000..e69de29bb2 diff --git a/lib/docs/db_storage/scraper.py b/lib/docs/db_storage/scraper.py new file mode 100644 index 0000000000..8dd7345557 --- /dev/null +++ b/lib/docs/db_storage/scraper.py @@ -0,0 +1,85 @@ +from importer import DocImporter +from collections import OrderedDict +import sys +import time +import subprocess, shlex +import ConfigParser +import pprint + +class Scraper(): + + def __init__(self, _docset, config_file): + self.config = ConfigParser.ConfigParser() + config_file = 'importer.cfg' + self.config.read(config_file) + unorderedsections = self.config.sections() + if _docset!='': + sections = [{'name':_docset, 'sort': 0}] + else: + sections = self.sortSections(unorderedsections) + self.downloadZips(sections) + self.scrapDocsets(sections) + + def sortSections(self, sectlist): + newlist = [] + for sect in sectlist: + if sect not in ['Connection', 'Config', 'Path']: + newitem ={ + 'name' : sect, + 'sort': int(self.config.get(sect, 'sort')) + } + newlist.append(newitem) + orderedsections = sorted(newlist, key=lambda key_value: key_value['sort']) + return orderedsections + + + def downloadZips(self, docsetlist): + working_directory = '../../../' + for sect in docsetlist: + if self.config.get(sect['name'], 'zip_url')!= '': + if self.config.get(sect['name'], 'active') == 'true': + scraper_name = self.config.get(sect['name'], 'scraper_name') + zip_url = self.config.get(sect['name'], 'zip_url') + if zip_url.endswith('.tar.gz'): + extension = 'tar.gz' + else: + extension = zip_url.split('.')[-1] + try: + sys.stdout.flush() + print "Downloading " + zip_url + "..." + subprocess.check_call("wget " + zip_url + " -O ./file_scraper_docs/" + scraper_name + "." + extension, shell=True, cwd=working_directory) + if extension == 'zip': + print "Extracting " + scraper_name + "." + extension + "..." + subprocess.check_call("unzip -o ./file_scraper_docs/" + scraper_name + ".zip -d ./file_scraper_docs/"+ scraper_name + "/", shell=True, cwd=working_directory) + else: + print "Extracting " + scraper_name + "." + extension + "..." + subprocess.check_call("mkdir -p ./file_scraper_docs/" + scraper_name + " && tar -zxvf ./file_scraper_docs/" + scraper_name + ".tar.gz -C ./file_scraper_docs/" + scraper_name, shell=True, cwd=working_directory) + print 'done' + except subprocess.CalledProcessError, e: + hour = time.strftime("%d/%m/%Y %H:%M:%S") + scraper_errors_file = open('scraper_errors.log', 'a') + message = "error downloading " + zip_url + " at" + hour + "\n\n" + str(e) + "###########################################\n\n\n" + scraper_errors_file.write(message) + scraper_errors_file.close() + + def scrapDocsets(self, docsetlist): + working_directory = '../../../' + for sect in docsetlist: + if self.config.get(sect['name'], 'active') == 'true': + scraper_name = self.config.get(sect['name'], 'scraper_name') + print "Processing " + scraper_name + "..." + try: + subprocess.check_call("thor docs generate " + scraper_name + " --force",shell=True, cwd=working_directory) + print 'done' + except subprocess.CalledProcessError, e: + hour = time.strftime("%d/%m/%Y %H:%M:%S") + scraper_errors_file = open('scraper_errors.log', 'a') + message = "error scrapping " + scraper_name + " at" + hour + "\n\n" + str(e) + "###########################################\n\n\n" + scraper_errors_file.write(message) + scraper_errors_file.close() + except Exception, e: + hour = time.strftime("%d/%m/%Y %H:%M:%S") + scraper_errors_file = open('scraper_errors.log', 'a') + message = "error scrapping " + scraper_name + " at" + hour + "\n\n" + str(e) + "###########################################\n\n\n" + scraper_errors_file.write(message) + scraper_errors_file.close() diff --git a/lib/docs/db_storage/tests/data/test_backbone.html b/lib/docs/db_storage/tests/data/test_backbone.html new file mode 100644 index 0000000000..35abd84aa1 --- /dev/null +++ b/lib/docs/db_storage/tests/data/test_backbone.html @@ -0,0 +1 @@ +
\ No newline at end of file diff --git a/lib/docs/db_storage/tests/data/test_backbone.json b/lib/docs/db_storage/tests/data/test_backbone.json new file mode 100644 index 0000000000..83a29f176d --- /dev/null +++ b/lib/docs/db_storage/tests/data/test_backbone.json @@ -0,0 +1,6 @@ +{"entries":[ +{"name":"Backbone.on","path":"index","type":"event","parsed_uri":"/backbonejs/backbone.on","anchor":"Events-on","parent_uri":"null","docset":"BackboneJS"}, +{"name":"Backbone.listenTo","path":"index","type":"event","parsed_uri":"/backbonejs/backbone.listento","anchor":"Events-listenTo","parent_uri":"null","docset":"BackboneJS"}, +{"name":"model.validate","path":"index","type":"function","parsed_uri":"/backbonejs/model.validate","anchor":"Model-validate","parent_uri":"null","docset":"BackboneJS"}, +{"name":"model.destroy","path":"index","type":"function","parsed_uri":"/backbonejs/model.destroy","anchor":"Model-destroy","parent_uri":"null","docset":"BackboneJS"} +]} \ No newline at end of file diff --git a/lib/docs/db_storage/tests/data/test_bower.html b/lib/docs/db_storage/tests/data/test_bower.html new file mode 100644 index 0000000000..0ea46e844a --- /dev/null +++ b/lib/docs/db_storage/tests/data/test_bower.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/lib/docs/db_storage/tests/data/test_bower.json b/lib/docs/db_storage/tests/data/test_bower.json new file mode 100644 index 0000000000..134b389bea --- /dev/null +++ b/lib/docs/db_storage/tests/data/test_bower.json @@ -0,0 +1,8 @@ +{"entries":[ +{"name":"analytics","path":"config","type":"configuration","parsed_uri":"/bower/analytics","anchor":"analytics","parent_uri":"null","docset":"Bower"}, +{"name":"cwd","path":"config","type":"configuration","parsed_uri":"/bower/cwd","anchor":"cwd","parent_uri":"null","docset":"Bower"}, +{"name":"https-proxy","path":"config","type":"configuration","parsed_uri":"/bower/https-proxy","anchor":"https-proxy","parent_uri":"null","docset":"Bower"}, +{"name":"color","path":"config","type":"configuration","parsed_uri":"/bower/color","anchor":"color","parent_uri":"null","docset":"Bower"}, +{"name":"Register","path":"creating-packages","type":"guide","parsed_uri":"/bower/register","anchor":"register","parent_uri":"null","docset":"Bower"}, +{"name":"init","path":"api","type":"api","parsed_uri":"/bower/init","anchor":"init","parent_uri":"null","docset":"Bower"} +]} \ No newline at end of file diff --git a/lib/docs/db_storage/tests/data/test_c.html b/lib/docs/db_storage/tests/data/test_c.html new file mode 100644 index 0000000000..9e19a8364a --- /dev/null +++ b/lib/docs/db_storage/tests/data/test_c.html @@ -0,0 +1 @@ +height, box-sizing, min-width, max-widthpercentage
\ No newline at end of file
diff --git a/lib/docs/db_storage/tests/data/test_css.json b/lib/docs/db_storage/tests/data/test_css.json
new file mode 100644
index 0000000000..266ec5d640
--- /dev/null
+++ b/lib/docs/db_storage/tests/data/test_css.json
@@ -0,0 +1,7 @@
+{"entries":[
+{"name":"height","path":"height","type":"property","parsed_uri":"/css/height","anchor":"","parent_uri":"null","docset":"CSS"},
+{"name":"box-sizing","path":"box-sizing","type":"property","parsed_uri":"/css/box-sizing","anchor":"","parent_uri":"null","docset":"CSS"},
+{"name":"min-width","path":"min-width","type":"property","parsed_uri":"/css/min-width","anchor":"","parent_uri":"null","docset":"CSS"},
+{"name":"max-width","path":"max-width","type":"property","parsed_uri":"/css/max-width","anchor":"","parent_uri":"null","docset":"CSS"},
+{"name":"EventTargetdocument.loadDocument.compatModeDocument.domConfigDocument.implementation
\ No newline at end of file
diff --git a/lib/docs/db_storage/tests/data/test_dom.json b/lib/docs/db_storage/tests/data/test_dom.json
new file mode 100644
index 0000000000..11b0e37c1e
--- /dev/null
+++ b/lib/docs/db_storage/tests/data/test_dom.json
@@ -0,0 +1,7 @@
+{"entries":[
+{"name":"EventTarget","path":"eventtarget","type":"object","parsed_uri":"/dom/eventtarget","anchor":"","parent_uri":"null","docset":"DOM"},
+{"name":"Document.loadOverlay","path":"document/loadoverlay","type":"others","parsed_uri":"/dom/document/loadoverlay","anchor":"","parent_uri":"/dom/document","docset":"DOM"},
+{"name":"Document.compatMode","path":"document/compatmode","type":"others","parsed_uri":"/dom/document/compatmode","anchor":"","parent_uri":"/dom/document","docset":"DOM"},
+{"name":"Document.compatMode","path":"document/compatmode","type":"others","parsed_uri":"/dom/document/compatmode","anchor":"","parent_uri":"/dom/document","docset":"DOM"},
+{"name":"Document.implementation","path":"document/implementation","type":"object","parsed_uri":"/dom/document/implementation","anchor":"","parent_uri":"/dom/document","docset":"DOM"}
+]}
diff --git a/lib/docs/db_storage/tests/data/test_dom_events.html b/lib/docs/db_storage/tests/data/test_dom_events.html
new file mode 100644
index 0000000000..018f095c9b
--- /dev/null
+++ b/lib/docs/db_storage/tests/data/test_dom_events.html
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/lib/docs/db_storage/tests/data/test_dom_events.json b/lib/docs/db_storage/tests/data/test_dom_events.json
new file mode 100644
index 0000000000..c8b8c757f1
--- /dev/null
+++ b/lib/docs/db_storage/tests/data/test_dom_events.json
@@ -0,0 +1,8 @@
+{"entries":[
+{"name":"loadstart","path":"loadstart","type":"event","parsed_uri":"/dom_events/loadstart","anchor":"","parent_uri":"null","docset":"DOM Events"},
+{"name":"error","path":"error_(progressevent)","type":"event","parsed_uri":"/dom_events/error_(progressevent)","anchor":"","parent_uri":"null","docset":"DOM Events"},
+{"name":"progress","path":"progress","type":"event","parsed_uri":"/dom_events/progress","anchor":"","parent_uri":"null","docset":"DOM Events"},
+{"name":"abort","path":"abort_(progressevent)","type":"event","parsed_uri":"/dom_events/abort_(progressevent)","anchor":"","parent_uri":"null","docset":"DOM Events"},
+{"name":"load","path":"load","type":"event","parsed_uri":"/dom_events/load","anchor":"","parent_uri":"null","docset":"DOM Events"},
+{"name":"loadend","path":"loadend","type":"event","parsed_uri":"/dom_events/loadend","anchor":"","parent_uri":"null","docset":"DOM Events"}
+]}
\ No newline at end of file
diff --git a/lib/docs/db_storage/tests/data/test_ember.html b/lib/docs/db_storage/tests/data/test_ember.html
new file mode 100644
index 0000000000..4abd4d47d2
--- /dev/null
+++ b/lib/docs/db_storage/tests/data/test_ember.html
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/lib/docs/db_storage/tests/data/test_ember.json b/lib/docs/db_storage/tests/data/test_ember.json
new file mode 100644
index 0000000000..04fecf9bf0
--- /dev/null
+++ b/lib/docs/db_storage/tests/data/test_ember.json
@@ -0,0 +1,5 @@
+{"entries":[
+{"name":"ember-views","path":"modules/ember-views","type":"modules","parsed_uri":"/ember/modules/ember-views","anchor":"","parent_uri":"/ember/modules","docset":"EmberJS"},
+{"name":"View","path":"classes/ember.view","type":"view","parsed_uri":"/ember/classes/view","anchor":"","parent_uri":"/ember/classes","docset":"EmberJS"},
+{"name":"View.views","path":"classes/ember.view","type":"view","parsed_uri":"/ember/classes/view.views","anchor":"property_views","parent_uri":"/ember/classes/view","docset":"EmberJS"}
+]}
\ No newline at end of file
diff --git a/lib/docs/db_storage/tests/data/test_express.html b/lib/docs/db_storage/tests/data/test_express.html
new file mode 100644
index 0000000000..b43690ac02
--- /dev/null
+++ b/lib/docs/db_storage/tests/data/test_express.html
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/lib/docs/db_storage/tests/data/test_express.json b/lib/docs/db_storage/tests/data/test_express.json
new file mode 100644
index 0000000000..9e1e771660
--- /dev/null
+++ b/lib/docs/db_storage/tests/data/test_express.json
@@ -0,0 +1,6 @@
+{"entries":[
+{"name":"req.baseUrl","path":"index","type":"request","parsed_uri":"/express/req.baseurl","anchor":"req.baseUrl","parent_uri":"null","docset":"Express"},
+{"name":"app.route()","path":"index","type":"application","parsed_uri":"/express/app.route","anchor":"app.route","parent_uri":"null","docset":"Express"},
+{"name":"app.METHOD()","path":"index","type":"application","parsed_uri":"/express/app.method","anchor":"app.METHOD","parent_uri":"null","docset":"Express"},
+{"name":"app.render()","path":"index","type":"application","parsed_uri":"/express/app.render","anchor":"app.render","parent_uri":"null","docset":"Express"}
+]}
\ No newline at end of file
diff --git a/lib/docs/db_storage/tests/data/test_git.html b/lib/docs/db_storage/tests/data/test_git.html
new file mode 100644
index 0000000000..bf89d8e3b8
--- /dev/null
+++ b/lib/docs/db_storage/tests/data/test_git.html
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/lib/docs/db_storage/tests/data/test_git.json b/lib/docs/db_storage/tests/data/test_git.json
new file mode 100644
index 0000000000..7634ae0a56
--- /dev/null
+++ b/lib/docs/db_storage/tests/data/test_git.json
@@ -0,0 +1,8 @@
+{"entries":[
+{"name":"gitattributes","path":"gitattributes","type":"function","parsed_uri":"/git/gitattributes","anchor":"","parent_uri":"null","docset":"Git"},
+{"name":"git annotate","path":"git-annotate","type":"function","parsed_uri":"/git/git-annotate","anchor":"","parent_uri":"null","docset":"Git"},
+{"name":"git upload-archive","path":"git-upload-archive","type":"function","parsed_uri":"/git/git-upload-archive","anchor":"","parent_uri":"null","docset":"Git"},
+{"name":"git blame","path":"git-blame","type":"lists","parsed_uri":"/git/git-blame","anchor":"","parent_uri":"null","docset":"Git"},
+{"name":"git-http-backend","path":"git-http-backend","type":"function","parsed_uri":"/git/git-http-backend","anchor":"","parent_uri":"null","docset":"Git"},
+{"name":"git log","path":"git-log","type":"lists","parsed_uri":"/git/git-log","anchor":"","parent_uri":"null","docset":"Git"}
+]}
\ No newline at end of file
diff --git a/lib/docs/db_storage/tests/data/test_go.html b/lib/docs/db_storage/tests/data/test_go.html
new file mode 100644
index 0000000000..40e9b1e4a6
--- /dev/null
+++ b/lib/docs/db_storage/tests/data/test_go.html
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/lib/docs/db_storage/tests/data/test_go.json b/lib/docs/db_storage/tests/data/test_go.json
new file mode 100644
index 0000000000..d2881cb331
--- /dev/null
+++ b/lib/docs/db_storage/tests/data/test_go.json
@@ -0,0 +1,6 @@
+{"entries":[
+{"name":"Sub-repositories","path":"index","type":"others","parsed_uri":"/go/go_programming_language/sub-repositories","anchor":"subrepo","parent_uri":"null","docset":"Go"},
+{"name":"Writer (zip)","path":"archive/zip/index","type":"function","parsed_uri":"/go/archive/zip/writer_zip","anchor":"Writer","parent_uri":"/go/archive/zip","docset":"Go"},
+{"name":"lzw","path":"compress/lzw/index","type":"function","parsed_uri":"/go/compress/lzw","anchor":"","parent_uri":"/go/compress","docset":"Go"},
+{"name":"Map() (bytes)","path":"bytes/index","type":"type","parsed_uri":"/go/bytes/map_bytes","anchor":"Map","parent_uri":"/go/bytes","docset":"Go"}
+]}
\ No newline at end of file
diff --git a/lib/docs/db_storage/tests/data/test_grunt.html b/lib/docs/db_storage/tests/data/test_grunt.html
new file mode 100644
index 0000000000..ea6f2da7c4
--- /dev/null
+++ b/lib/docs/db_storage/tests/data/test_grunt.html
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/lib/docs/db_storage/tests/data/test_grunt.json b/lib/docs/db_storage/tests/data/test_grunt.json
new file mode 100644
index 0000000000..f8af70d0ed
--- /dev/null
+++ b/lib/docs/db_storage/tests/data/test_grunt.json
@@ -0,0 +1,4 @@
+{"entries":[
+{"name":"Using the CLI","path":"using-the-cli","type":"others","parsed_uri":"/grunt/using-the-cli","anchor":"","parent_uri":"null","docset":"Grunt"},
+{"name":"grunt","path":"api/grunt","type":"others","parsed_uri":"/grunt/api/grunt","anchor":"","parent_uri":null,"docset":"Grunt"}
+]}
\ No newline at end of file
diff --git a/lib/docs/db_storage/tests/data/test_haskell.html b/lib/docs/db_storage/tests/data/test_haskell.html
new file mode 100644
index 0000000000..9622e3604f
--- /dev/null
+++ b/lib/docs/db_storage/tests/data/test_haskell.html
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/lib/docs/db_storage/tests/data/test_haskell.json b/lib/docs/db_storage/tests/data/test_haskell.json
new file mode 100644
index 0000000000..8c938d251d
--- /dev/null
+++ b/lib/docs/db_storage/tests/data/test_haskell.json
@@ -0,0 +1,7 @@
+{"entries":[
+{"name":"mapWithKey :: (k -> a -> b) -> Map k a -> Map k b","path":"containers-0.5.5.1/data-map-strict","type":"data","parsed_uri":"/haskell/data-map-strict/mapwithkey_--_k_->_a_->_b_->_map_k_a_->_map_k_b","anchor":"v:mapWithKey","parent_uri":"/haskell/data-map-strict","docset":"Haskell"},
+{"name":"IntMap a","path":"containers-0.5.5.1/data-intmap-strict","type":"data","parsed_uri":"/haskell/data-intmap-strict/intmap_a","anchor":"t:IntMap","parent_uri":"/haskell/data-intmap-strict","docset":"Haskell"},
+{"name":"Key = Int","path":"containers-0.5.5.1/data-intset","type":"data","parsed_uri":"/haskell/data-intset/key_=_int","anchor":"t:Key","parent_uri":"/haskell/data-intset","docset":"Haskell"},
+{"name":"Data.IntMap.Lazy","path":"containers-0.5.5.1/data-intmap-lazy","type":"data","parsed_uri":"/haskell/data-intmap-lazy","anchor":"","parent_uri":"/haskell/data-intmap-lazy","docset":"Haskell"},
+{"name":"foldrWithKey :: (k -> a -> b -> b) -> b -> Map k a -> b","path":"containers-0.5.5.1/data-map-strict","type":"data","parsed_uri":"/haskell/data-map-strict/foldrwithkey_--_k_->_a_->_b_->_b_->_b_->_map_k_a_->_b","anchor":"v:foldrWithKey","parent_uri":"/haskell/data-map-strict","docset":"Haskell"}
+]}
\ No newline at end of file
diff --git a/lib/docs/db_storage/tests/data/test_html.html b/lib/docs/db_storage/tests/data/test_html.html
new file mode 100644
index 0000000000..8caa7bce46
--- /dev/null
+++ b/lib/docs/db_storage/tests/data/test_html.html
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/lib/docs/db_storage/tests/data/test_html.json b/lib/docs/db_storage/tests/data/test_html.json
new file mode 100644
index 0000000000..4c593f77d1
--- /dev/null
+++ b/lib/docs/db_storage/tests/data/test_html.json
@@ -0,0 +1,10 @@
+{"entries":[
+{"name":"global attributes","path":"global_attributes","type":"standard","parsed_uri":"/html/global_attributes","anchor":"","parent_uri":"null","docset":"HTML"},
+{"name":"meter","path":"element/meter","type":"type","parsed_uri":"/html/element/meter","anchor":"","parent_uri":"/html/element","docset":"HTML"},
+{"name":"basefont","path":"element/basefont","type":"obsolete","parsed_uri":"/html/element/basefont","anchor":"","parent_uri":"/html/element","docset":"HTML"},
+{"name":"base","path":"element/base","type":"standard","parsed_uri":"/html/element/base","anchor":"","parent_uri":"/html/element","docset":"HTML"},
+{"name":"html","path":"element/html","type":"standard","parsed_uri":"/html/element/html","anchor":"","parent_uri":"/html/element","docset":"HTML"},
+{"name":"option","path":"element/option","type":"standard","parsed_uri":"/html/element/option","anchor":"","parent_uri":"/html/element","docset":"HTML"},
+{"name":"link","path":"element/link","type":"standard","parsed_uri":"/html/element/link","anchor":"","parent_uri":"/html/element","docset":"HTML"},
+{"name":"meter","path":"element/meter","type":"type","parsed_uri":"/html/element/meter","anchor":"","parent_uri":"/html/element","docset":"HTML"}
+]}
\ No newline at end of file
diff --git a/lib/docs/db_storage/tests/data/test_javascript.html b/lib/docs/db_storage/tests/data/test_javascript.html
new file mode 100644
index 0000000000..d93f22a12c
--- /dev/null
+++ b/lib/docs/db_storage/tests/data/test_javascript.html
@@ -0,0 +1 @@
+BlockbreakcontinueEmptyif...elseswitchthrowtry...catchtry...catchtry...catchargumentsLIKESIMILAR TO Regular ExpressionsTransitionGroup and CSSTransitionGroupLinkedStateMixinclassSetclassstyleexternalResourcesRequireddxdyheight, box-sizing, min-width, max-widthpercentage')
+
+ def test_D3(self):
+ importer = DocImporter('d3')
+ entries = importer.processJSON('tests/data/test_d3.json')
+ importer.links = importer.CreateLinkCollection(entries)
+ content = importer.ProcessContent(importer.getContent('tests/data/test_d3.html'))
+ errorcounter = self.Uris_x_parent_uris("css","../../../public/docs/d3/index.json")
+ anchornotfound = self.CheckAnchors('d3')
+ self.assertEqual(anchornotfound, 0)
+ self.assertEqual(errorcounter, 0)
+ self.assertEqual(content, u'')
+
+ def test_DOM(self):
+ importer = DocImporter('dom')
+ entries = importer.processJSON('tests/data/test_dom.json')
+ importer.links = importer.CreateLinkCollection(entries)
+ content = importer.ProcessContent(importer.getContent('tests/data/test_dom.html'))
+ errorcounter = self.Uris_x_parent_uris("dom","../../../public/docs/dom/index.json")
+ anchornotfound = self.CheckAnchors('dom')
+ self.assertEqual(anchornotfound, 0)
+ self.assertEqual(errorcounter, 0)
+ self.assertEqual(content, u'EventTargetdocument.loadDocument.compatModeDocument.domConfigDocument.implementation')
+
+ def test_DOM_EVENTS(self):
+ importer = DocImporter('dom_events')
+ entries = importer.processJSON('tests/data/test_dom_events.json')
+ importer.links = importer.CreateLinkCollection(entries)
+ content = importer.ProcessContent(importer.getContent('tests/data/test_dom_events.html'))
+ errorcounter = self.Uris_x_parent_uris("dom_events","../../../public/docs/dom_events/index.json")
+ anchornotfound = self.CheckAnchors('dom_events')
+ self.assertEqual(anchornotfound, 0)
+ self.assertEqual(errorcounter, 0)
+ self.assertEqual(content, u'')
+
+ def test_Ember(self):
+ importer = DocImporter('ember')
+ entries = importer.processJSON('tests/data/test_ember.json')
+ importer.links = importer.CreateLinkCollection(entries)
+ content = importer.ProcessContent(importer.getContent('tests/data/test_ember.html'))
+ errorcounter = self.Uris_x_parent_uris("ember","../../../public/docs/ember/index.json")
+ anchornotfound = self.CheckAnchors('ember')
+ self.assertEqual(anchornotfound, 0)
+ self.assertEqual(errorcounter, 0)
+ self.assertEqual(content, u'')
+
+ def test_Express(self):
+ importer = DocImporter('express')
+ entries = importer.processJSON('tests/data/test_express.json')
+ importer.links = importer.CreateLinkCollection(entries)
+ content = importer.ProcessContent(importer.getContent('tests/data/test_express.html'))
+ errorcounter = self.Uris_x_parent_uris("express","../../../public/docs/express/index.json")
+ anchornotfound = self.CheckAnchors('express')
+ self.assertEqual(anchornotfound, 0)
+ self.assertEqual(errorcounter, 0)
+ self.assertEqual(content, u'')
+
+ def test_Git(self):
+ importer = DocImporter('git')
+ entries = importer.processJSON('tests/data/test_git.json')
+ importer.links = importer.CreateLinkCollection(entries)
+ content = importer.ProcessContent(importer.getContent('tests/data/test_git.html'))
+ errorcounter = self.Uris_x_parent_uris("git","../../../public/docs/git/index.json")
+ anchornotfound = self.CheckAnchors('git')
+ self.assertEqual(anchornotfound, 0)
+ self.assertEqual(errorcounter, 0)
+ self.assertEqual(content, u'')
+
+ def test_Go(self):
+ importer = DocImporter('go')
+ entries = importer.processJSON('tests/data/test_go.json')
+ importer.links = importer.CreateLinkCollection(entries)
+ content = importer.ProcessContent(importer.getContent('tests/data/test_go.html'))
+ errorcounter = self.Uris_x_parent_uris("go","../../../public/docs/go/index.json")
+ anchornotfound = self.CheckAnchors('go')
+ self.assertEqual(anchornotfound, 0)
+ self.assertEqual(errorcounter, 0)
+ self.assertEqual(content, u'')
+
+ def test_Grunt(self):
+ importer = DocImporter('grunt')
+ entries = importer.processJSON('tests/data/test_grunt.json')
+ importer.links = importer.CreateLinkCollection(entries)
+ content = importer.ProcessContent(importer.getContent('tests/data/test_grunt.html'))
+ errorcounter = self.Uris_x_parent_uris("grunt","../../../public/docs/grunt/index.json")
+ anchornotfound = self.CheckAnchors('grunt')
+ self.assertEqual(anchornotfound, 0)
+ self.assertEqual(errorcounter, 0)
+ self.assertEqual(content, u'')
+
+ def test_Haskell(self):
+ importer = DocImporter('haskell')
+ entries = importer.processJSON('tests/data/test_haskell.json')
+ importer.links = importer.CreateLinkCollection(entries)
+ content = importer.ProcessContent(importer.getContent('tests/data/test_haskell.html'))
+ errorcounter = self.Uris_x_parent_uris("haskell","../../../public/docs/haskell/index.json")
+ anchornotfound = self.CheckAnchors('haskell')
+ anchornotfound = self.CheckAnchors('haskell')
+ self.assertEqual(anchornotfound, 0)
+ self.assertEqual(anchornotfound, 0)
+ self.assertEqual(errorcounter, 0)
+ self.assertEqual(content, u'')
+
+ def test_HTML(self):
+ importer = DocImporter('html')
+ entries = importer.processJSON('tests/data/test_html.json')
+ importer.links = importer.CreateLinkCollection(entries)
+ content = importer.ProcessContent(importer.getContent('tests/data/test_html.html'))
+ errorcounter = self.Uris_x_parent_uris("html","../../../public/docs/html/index.json")
+ anchornotfound = self.CheckAnchors('html')
+ self.assertEqual(anchornotfound, 0)
+ self.assertEqual(errorcounter, 0)
+ self.assertEqual(content, u'')
+
+ def test_HTTP(self):
+ importer = DocImporter('http')
+ errorcounter = self.Uris_x_parent_uris("html","../../../public/docs/http/index.json")
+ anchornotfound = self.CheckAnchors('http')
+ self.assertEqual(anchornotfound, 0)
+ self.assertEqual(errorcounter, 0)
+
+ def test_JavaScript(self):
+ importer = DocImporter('javascript')
+ entries = importer.processJSON('tests/data/test_javascript.json')
+ importer.links = importer.CreateLinkCollection(entries)
+ content = importer.ProcessContent(importer.getContent('tests/data/test_javascript.html'))
+ errorcounter = self.Uris_x_parent_uris("javascript","../../../public/docs/javascript/index.json")
+ anchornotfound = self.CheckAnchors('javascript')
+ self.assertEqual(anchornotfound, 0)
+ self.assertEqual(errorcounter, 0)
+ self.assertEqual(content, u'BlockbreakcontinueEmptyif...elseswitchthrowtry...catchtry...catchtry...catchargumentsLIKESIMILAR TO Regular ExpressionsTransitionGroup and CSSTransitionGroupLinkedStateMixinclassSetclassstyleexternalResourcesRequireddxdy#{node.inner_html}
").remove + end + + css('h2:not([id]) a[id]:not([href])').each do |node| + node.parent['id'] = node['id'] + node.before(node.children).remove + end + fixLinks + WrapPreContentWithCode 'hljs apache' + WrapContentWithDivs '_page _apache' + doc + end + + def fixLinks + css('a[href]').each do |node| + node['href'] = CleanWrongCharacters(node['href']).downcase.remove '_(event)' + if REPLACED_LINKS[node['href'].downcase.remove! '../'] + node['href'] = REPLACED_LINKS[node['href'].remove '../'] + elsif !node['href'].start_with? 'http://' and !node['href'].start_with? '#' and !node['href'].start_with? 'https://' and !node['href'].start_with? 'ftp://' and !node['href'].start_with? 'irc://' and !node['href'].start_with? 'news://' and !node['href'].start_with? 'mailto:' + if node['class'] == 'new' + node['class'] = 'broken' + node['title'] = '' + elsif BROKEN_LINKS.include? node['href'].downcase.remove! '../' + node['class'] = 'broken' + else + sluglist = slug.split('/') + if context[:url].to_s.end_with? 'html' + sluglist.pop + end + if sluglist.size>1 + sluglist.pop + end + nodelist = sluglist + node['href'].split('/') + newhref = [] + nodelist.each do |item| + if item == '..' + newhref.pop + elsif item != '' + newhref << item + end + end + node['href'] = newhref.join('/') + end + end + end + end + end + end +end diff --git a/lib/docs/filters/apache/entries.rb b/lib/docs/filters/apache/entries.rb new file mode 100644 index 0000000000..8727ddb8b3 --- /dev/null +++ b/lib/docs/filters/apache/entries.rb @@ -0,0 +1,103 @@ +module Docs + class Apache + class EntriesFilter < Docs::ReflyEntriesFilter + def get_name + if slug == 'mod/' + 'Modules' + elsif slug == 'programs/' + 'Programs' + elsif slug == 'mod/core' + 'core' + else + name = at_css('h1').content.strip + name.remove! %r{\ Support\z}i + name.remove! %r{in\ Apache\z} + name.remove! %r{\ documentation\z}i + name.remove! %r{\AApache\ (httpd\ )?(Tutorial:\ )?}i + name.remove! 'HTTP Server Tutorial: ' + name.sub! 'Module mod_', 'mod_' + name.remove! %r{\ \-.*} if slug.start_with?('programs') + name + end + end + + def get_docset + docset = context[:root_title] + docset + end + + def get_parsed_uri_by_name(name) + parsed_uri = get_custom_parent_uri + '/' + self.urilized(name) + parsed_uri + end + + def get_parsed_uri + if get_parent_uri == 'null' + parsed_uri = context[:docset_uri] + '/' + self.urilized(get_name) + else + parsed_uri = get_parent_uri + '/' + self.urilized(get_name) + end + parsed_uri + end + + def get_parent_uri + get_custom_parent_uri + # parent_uri = 'null' + end + + def get_custom_parent_uri + if slug.start_with?('howto') + parent_uri = 'null' + elsif slug.start_with?('platform/') and !slug.end_with? 'platform/' and !slug.end_with? 'index' + parent_uri = '/apache/platform_specific_notes' + elsif slug.start_with?('programs/') and !slug.end_with? 'programs/' and !slug.end_with? 'index' + parent_uri = '/apache/programs' + elsif slug.start_with?('misc/') and !slug.end_with? 'misc/' and !slug.end_with? 'index' + parent_uri = '/apache/miscellaneous' + elsif slug.start_with?('mod/') and !slug.end_with? 'mod/' and !slug.end_with? 'index' + parent_uri = '/apache/modules' + elsif slug.start_with?('ssl/') and !slug.end_with? 'ssl/' and !slug.end_with? 'index' + parent_uri = '/apache/ssltls_encryption' + elsif slug.start_with?('rewrite/') and !slug.end_with? 'rewrite/' and !slug.end_with? 'index' + parent_uri = '/apache/mod_rewrite' + elsif slug.start_with?('vhosts/') and !slug.end_with? 'vhosts/' and !slug.end_with? 'index' + parent_uri = '/apache/virtual_host' + else + parent_uri = 'null' + end + parent_uri + end + def get_type + if slug.start_with?('howto') + 'guide' + elsif slug.start_with?('platform') + 'platforms' + elsif slug.start_with?('programs') + 'programs' + elsif slug.start_with?('misc') + 'others' + elsif slug.start_with?('mod/') + 'modules' + elsif slug.start_with?('ssl/') + 'guide' + elsif slug.start_with?('rewrite/') + 'guide' + elsif slug.start_with?('vhosts/') + 'guide' + else + 'others' + end + end + + def additional_entries + css('.directive-section > h2').each_with_object [] do |node, entries| + name = node.content.strip + next unless name.sub!(/\ Directive\z/, '') + name.prepend "#{self.name.start_with?('MPM') ? 'MPM' : self.name}: " + custom_parsed_uri = get_parsed_uri_by_name(name) + entries << [name, node['id'], get_type, custom_parsed_uri, get_custom_parent_uri, get_docset] + end + end + end + end +end diff --git a/lib/docs/filters/backbone/clean_html.rb b/lib/docs/filters/backbone/clean_html.rb index 89fe58d6e5..294a7693bb 100644 --- a/lib/docs/filters/backbone/clean_html.rb +++ b/lib/docs/filters/backbone/clean_html.rb @@ -1,7 +1,9 @@ module Docs class Backbone - class CleanHtmlFilter < Filter + class CleanHtmlFilter < Docs::ReflyFilter def call + #change the classname to avoid conflicts with css classes + doc['class'] = 'cnt' # Remove Introduction, Upgrading, etc. while doc.child['id'] != 'Events' doc.child.remove @@ -15,9 +17,11 @@ def call css('#faq', '.run').remove css('tt').each do |node| - node.name = 'code' + node.name = 'pre' end + WrapPreContentWithCode 'hljs javascript' + WrapContentWithDivs '_page _underscore' doc end end diff --git a/lib/docs/filters/backbone/entries.rb b/lib/docs/filters/backbone/entries.rb index d637a46c86..795aba2209 100644 --- a/lib/docs/filters/backbone/entries.rb +++ b/lib/docs/filters/backbone/entries.rb @@ -1,27 +1,74 @@ module Docs class Backbone - class EntriesFilter < Docs::EntriesFilter + class EntriesFilter < Docs::ReflyEntriesFilter + + + def get_docset + docset = context[:root_title] + docset + end + + def get_parsed_uri_by_name(name) + parsed_uri = context[:docset_uri] + '/' + self.urilized(name) + parsed_uri + end + + def get_parsed_uri + if get_parent_uri == 'null' + parsed_uri = context[:docset_uri] + '/' + self.urilized(get_name) + else + parsed_uri = get_parent_uri + '/' + self.urilized(get_name) + end + parsed_uri + end + + def get_parent_uri + parent_uri = 'null' + end + + def get_type + parent_uri = 'others' + end + + def get_type_by_name(typename) + if typename == 'events' + 'event' + elsif typename == 'router' or typename == 'Utility' or typename == 'sync' or typename == 'model' or typename == 'history' + 'function' + elsif typename == 'collection' + 'collection' + elsif typename == 'view' + 'view' + else + 'others' + end + end + + def include_default_entry? + return false + end + def additional_entries entries = [] type = nil - + css('[id]').each do |node| # Module if node.name == 'h2' type = node.content.remove 'Backbone.' - if type.capitalize! # sync, history - entries << [node.content, node['id'], type] - end + name = node.content + custom_parsed_uri = get_parsed_uri_by_name(name) + entries << [name, node['id'], get_type_by_name(type.downcase), custom_parsed_uri, get_parent_uri, get_docset] next end - # Built-in events if node['id'] == 'Events-catalog' node.next_element.css('li').each do |li| name = "#{li.at_css('b').content.delete('"').strip} event" id = name.parameterize li['id'] = id - entries << [name, id, type] unless name == entries.last[0] + custom_parsed_uri = get_parsed_uri_by_name(name) + entries << [name, id, get_type_by_name(type.downcase), custom_parsed_uri, get_parent_uri, get_docset] unless name == entries.last[0] end next end @@ -35,7 +82,8 @@ def additional_entries name = [type.downcase, li.at_css('a').content.split.first].join('.') id = name.parameterize li['id'] = id - entries << [name, id, type] + custom_parsed_uri = get_parsed_uri_by_name(name) + entries << [name, id, get_type_by_name(type.downcase), custom_parsed_uri, get_parent_uri, get_docset] end next end @@ -51,8 +99,8 @@ def additional_entries elsif type != 'Utility' name.prepend "#{type.downcase}." end - - entries << [name, node['id'], type] + custom_parsed_uri = get_parsed_uri_by_name(name) + entries << [name, node['id'], get_type_by_name(type.downcase), custom_parsed_uri, get_parent_uri, get_docset] end entries diff --git a/lib/docs/filters/bootstrap/clean_html.rb b/lib/docs/filters/bootstrap/clean_html.rb new file mode 100644 index 0000000000..ded7c43a4c --- /dev/null +++ b/lib/docs/filters/bootstrap/clean_html.rb @@ -0,0 +1,56 @@ +module Docs + class Bootstrap + class CleanHtmlFilter < Docs::ReflyFilter + BROKEN_LINKS = [] + REPLACED_LINKS = {} + def call + css('.container-fluid', 'nav').remove + css('.highlight > pre').each do |node| + node.content = node.content.gsub(' ', ' ') + end + fixLinks + css('li span').each do |node| + node.inner_html = node.inner_html + '' + signature + '' + end + end + + def fixLinks + css('a[href]').each do |node| + # puts 'ini: ' + node['href'] + if REPLACED_LINKS[node['href'].downcase.remove! '../'] + node['href'] = REPLACED_LINKS[node['href'].remove '../'] + elsif !node['href'].start_with? 'http://' and !node['href'].start_with? '#' and !node['href'].start_with? '#' and !node['href'].start_with? 'https://' and !node['href'].start_with? 'ftp://' and !node['href'].start_with? 'irc://' and !node['href'].start_with? 'news://' and !node['href'].start_with? 'mailto:' + if node['class'] == 'new' + node['class'] = 'broken' + node['title'] = '' + elsif BROKEN_LINKS.include? node['href'].downcase.remove! '../' + node['class'] = 'broken' + else + # puts slug + sluglist = slug.gsub(/%21/, '-').split('/') + if sluglist.size>1 + sluglist.pop + end + nodelist = sluglist + node['href'].split('/') + newhref = [] + nodelist.each do |item| + if item == '..' + newhref.pop + elsif item != '' + newhref << item + end + end + node['href'] = newhref.join('/') + end + end + # puts 'fin: ' + node['href'] + end + end + end + end +end diff --git a/lib/docs/filters/drupal/entries.rb b/lib/docs/filters/drupal/entries.rb new file mode 100644 index 0000000000..64e4cca73b --- /dev/null +++ b/lib/docs/filters/drupal/entries.rb @@ -0,0 +1,59 @@ +module Docs + class Drupal + class EntriesFilter < Docs::ReflyEntriesFilter + + def get_name + name = at_css('#page-subtitle').content + name.remove! %r{(abstract|public|static|protected|final|function|class)\s+} + name + end + + def get_docset + docset = context[:root_title] + docset + end + + def get_parsed_uri + if get_parent_uri == 'null' + parsed_uri = context[:docset_uri] + '/' + self.urilized(get_name) + else + parsed_uri = get_parent_uri + '/' + self.urilized(get_name) + end + parsed_uri + end + + def get_parent_uri + parent_uri = 'null' + end + + def get_type + if at_css('#page-subtitle').content.include? '::' + type = 'method' + elsif at_css('#page-subtitle').content.include? 'class' + type = 'class' + elsif at_css('#page-subtitle').content.include? 'taxonomy' + type = 'function' + elsif at_css('#page-subtitle').content.include? 'taxonomy' + type = 'function' + elsif at_css('#page-subtitle').content.include? 'form' or at_css('#page-subtitle').content.include? 'theme' or at_css('#page-subtitle').content.include? 'Field' + type = 'view' + elsif at_css('#page-subtitle').content.include? 'function' + type = 'function' + else + type = css('.breadcrumb > a')[1].content.strip + if type.include? '.inc' or type.include? 'node' + type = 'guide' + elsif type.include? 'module' + type = 'module' + end + type = type.split('.').first + end + type + end + + def include_default_entry? + !initial_page? + end + end + end +end diff --git a/lib/docs/filters/drupal/internal_urls.rb b/lib/docs/filters/drupal/internal_urls.rb new file mode 100644 index 0000000000..bc3e7bb9fb --- /dev/null +++ b/lib/docs/filters/drupal/internal_urls.rb @@ -0,0 +1,12 @@ +module Docs + class Drupal + class InternalUrlsFilter < Docs::InternalUrlsFilter + def internal_path_to(url) + url = index_url if url == root_url + path = effective_url.relative_path_to(url) + URL.new(path: Drupal::fixUri(path), query: url.query, fragment: url.fragment).to_s + end + end + end +end + diff --git a/lib/docs/filters/drupal/normalize_paths.rb b/lib/docs/filters/drupal/normalize_paths.rb new file mode 100644 index 0000000000..61ad560811 --- /dev/null +++ b/lib/docs/filters/drupal/normalize_paths.rb @@ -0,0 +1,11 @@ +module Docs + class Drupal + class NormalizePathsFilter < Docs::NormalizePathsFilter + + def store_path + p = Drupal::fixUri(@path) + File.extname(p) != '.html' ? "#{p}.html" : p + end + end + end +end \ No newline at end of file diff --git a/lib/docs/filters/elixir/clean_html.rb b/lib/docs/filters/elixir/clean_html.rb new file mode 100644 index 0000000000..1b32db98b2 --- /dev/null +++ b/lib/docs/filters/elixir/clean_html.rb @@ -0,0 +1,77 @@ +module Docs + class Elixir + class CleanHtmlFilter < Docs::ReflyFilter + REPLACED_LINKS = {} + BROKEN_LINKS = [] + def call + at_css('footer', '.view-source').remove + + css('section section.docstring h2').each do |node| + node.name = 'h4' + end + + css('h1 .hover-link', '.detail-link').each do |node| + node.parent['id'] = node['href'].remove('#') + node.remove + end + + css('.details-list').each do |list| + type = list['id'].remove(/s\z/) + list.css('.detail-header').each do |node| + node.name = 'h3' + node['class'] += " #{type}" + end + end + + css('.summary h2').each { |node| node.parent.before(node) } + css('.summary').each { |node| node.name = 'dl' } + css('.summary-signature').each { |node| node.name = 'dt' } + css('.summary-synopsis').each { |node| node.name = 'dd' } + + css('section', 'div:not(.type-detail)', 'h2 a').each do |node| + node.before(node.children).remove + end + + fixLinks + WrapPreContentWithCode 'hljs javascript' + WrapContentWithDivs '_page _elixir' + doc + end + + def fixLinks + css('a[href]').each do |node| + node['href'] = CleanWrongCharacters(node['href']).downcase + if REPLACED_LINKS[node['href'].downcase.remove! '../'] + node['href'] = REPLACED_LINKS[node['href'].remove '../'] + elsif !node['href'].start_with? '#' and !node['href'].start_with? 'http://' and !node['href'].start_with? '#' and !node['href'].start_with? 'https://' and !node['href'].start_with? 'ftp://' and !node['href'].start_with? 'irc://' and !node['href'].start_with? 'news://' and !node['href'].start_with? 'mailto:' + if node['class'] == 'new' + node['class'] = 'broken' + node['title'] = '' + else + sluglist = slug.split('/') + sluglist.pop + if slug== 'elixir/extra-api-reference' + sluglist.shift + end + nodelist = sluglist + node['href'].split('/') + newhref = [] + nodelist.each do |item| + if item == '..' + newhref.pop + elsif item != '' + newhref << item + end + end + node['href'] = newhref.join('/') + end + end + if BROKEN_LINKS.include? node['href'].downcase.remove! '../' + node['class'] = 'broken' + end + node['href'] = REPLACED_LINKS[node['href']] || node['href'] + end + end + + end + end +end diff --git a/lib/docs/filters/elixir/entries.rb b/lib/docs/filters/elixir/entries.rb new file mode 100644 index 0000000000..6b8fbe2808 --- /dev/null +++ b/lib/docs/filters/elixir/entries.rb @@ -0,0 +1,82 @@ +module Docs + class Elixir + class EntriesFilter < Docs::ReflyEntriesFilter + REPLACE_TYPES = { + 'Kernel' => 'function', + 'Access' => 'function', + 'Base' => 'function', + 'Atom' => 'function', + 'Bitwise' => 'operator', + 'API' => 'api', + 'Application' => 'module', + 'ExUnit' => 'module', + 'IEx' => 'module', + 'Agent' => 'module', + 'Behaviour' => 'module', + 'Code' => 'function', + 'Enum' => 'data' + } + def get_name + at_css('h1').content.split(' ').first.strip + end + + def get_docset + docset = context[:root_title] + docset + end + + def get_parsed_uri + if get_parent_uri == 'null' + parsed_uri = context[:docset_uri] + '/' + self.urilized(get_name) + else + parsed_uri = get_parent_uri + '/' + self.urilized(get_name) + end + parsed_uri + end + + def get_parsed_uri_by_name(name) + parsed_uri = context[:docset_uri] + '/' + self.urilized(name) + parsed_uri + end + + def get_parent_uri + 'null' + end + + def get_type + case at_css('h1 small').try(:content) + when 'exception' + 'exception' + when 'protocol' + 'others' + else + REPLACE_TYPES[get_name.split('.').first] || 'others' + end + + end + + def additional_entries + return [] if type == 'exception' + + css('.detail-header .signature').map do |node| + id = node.parent['id'] + name = node.content.strip + name.remove! %r{\(.*\)} + name.remove! 'left ' + name.remove! ' right' + name.sub! 'sigil_', '~' + if name == '::' + name.prepend 'unary ' + end + + unless node.parent['class'].end_with?('macro') || self.name.start_with?('Kernel') + name.prepend "#{self.name}." + name << " (#{id.split('/').last})" + end + custom_parsed_uri = get_parsed_uri_by_name(name) + [name, id, get_type || 'others', custom_parsed_uri, get_parsed_uri, get_docset] + end + end + end + end +end diff --git a/lib/docs/filters/ember/clean_html.rb b/lib/docs/filters/ember/clean_html.rb index a00ba96957..6d6810830c 100644 --- a/lib/docs/filters/ember/clean_html.rb +++ b/lib/docs/filters/ember/clean_html.rb @@ -1,8 +1,10 @@ module Docs class Ember - class CleanHtmlFilter < Filter + class CleanHtmlFilter < Docs::ReflyFilter def call root_page? ? root : other + WrapPreContentWithCode 'hljs javascript' + WrapContentWithDivs '_page _ember' doc end @@ -53,7 +55,27 @@ def other node.before(div).parent = div div.add_child(div.next_element) while div.next_element.name == 'span' end - + # fix links + css('a[href]').each do |node| + if !node['href'].start_with? 'http://' and !node['href'].start_with? 'https://' + sluglist = slug.split('/') + nodelist = node['href'].split('/') + newhref = [] + nodelist.each do |item| + if item == '..' + sluglist.pop + else + newhref << item + end + end + sluglist.pop + if sluglist.size>0 + node['href'] = sluglist.join('/') + '/' + newhref.join('/') + else + node['href'] = newhref.join('/') + end + end + end # Remove code highlighting css('.highlight').each do |node| node.content = node.at_css('.code pre').content diff --git a/lib/docs/filters/ember/entries.rb b/lib/docs/filters/ember/entries.rb index 7753c7fb6a..d7c8f991fc 100644 --- a/lib/docs/filters/ember/entries.rb +++ b/lib/docs/filters/ember/entries.rb @@ -1,39 +1,103 @@ module Docs class Ember - class EntriesFilter < Docs::EntriesFilter - def include_default_entry? - name != 'Handlebars Helpers' - end + class EntriesFilter < Docs::ReflyEntriesFilter + ADDITIONAL_ENTRIES = { + 'modules/ember' => [ + %w(Modules nil others /emberjs/modules null EmberJS)], + 'data/classes/DS.Store' => [ + %w(Data/Classes nil others /emberjs/data/classes null EmberJS)], + 'classes/Libraries' => [ + %w(Classes nil others /emberjs/classes null EmberJS)], + 'data/modules/ember-data' => [ + %w(Data/Modules nil others /emberjs/data/modules null EmberJS)]} def get_name - name = at_css('.api-header').content.split.first + if at_css('.api-header') + name = at_css('.api-header').content.split.first + else + name = 'EmberJS' + end # Remove "Ember." prefix if the next character is uppercase name.sub! %r{\AEmber\.([A-Z])(?!EATURES)}, '\1' name == 'Handlebars.helpers' ? 'Handlebars Helpers' : name end + def get_docset + docset = context[:root_title] + docset + end + + def get_parsed_uri_by_name(name) + if get_parent_uri == 'null' + parsed_uri = context[:docset_uri] + '/' + self.urilized(name) + else + parsed_uri = get_parent_uri + '/' + self.urilized(name) + end + parsed_uri + end + + def get_parsed_uri + if get_parent_uri == 'null' + parsed_uri = context[:docset_uri] + '/' + self.urilized(get_name) + else + parsed_uri = get_parent_uri + '/' + self.urilized(get_name) + end + parsed_uri + end + + def get_parent_uri + subpath = *path.split('/') + if subpath.size > 1 + parent_uri = (context[:docset_uri]+ '/' + subpath[0,subpath.size-1].join('/')).downcase + else + parent_uri = 'null' + end + parent_uri + end + def get_type - if at_css('.api-header').content.include?('Module') - 'Modules' - elsif name.start_with? 'DS' - 'Data' - elsif name.start_with? 'RSVP' - 'RSVP' - elsif name.start_with? 'Test' - 'Test' + name = get_name + if name.include? 'Class' + 'class' + elsif name.include? 'helper' or name.include? 'inject' or name.include? 'Libraries' or name.include? 'Namespace' + 'namespace' + elsif name.include? 'Module' + 'module' + elsif name.include? 'Data' or name.include? 'Promise' or name.include? 'DS' or name.include? 'Binding' or name.include? 'Deferred' or name.include? 'RSVP' or name.include? 'Adapter' or name.include? 'ProxyMixin' + 'data' + elsif name.downcase.include? 'controller' or name.include? 'test' + 'function' + elsif name.include? 'Array' or name.include? 'Set' or name.include? 'Enumerable' or name.include? 'SortableMixin' + 'collection' + elsif name.include? 'Application' or name.include? 'Observable' or name.include? 'Router' or name.include? 'Logger' or name.include? 'Instrumentation' + 'core' + elsif name.include? 'Handle' or name.include? 'Event' or name.include? 'TargetAction' + 'event' + elsif name.include? 'Location' or name.include? 'HTML' or name.include? 'Route' + 'network' + elsif name.include? 'Object' or name.include? 'Comparable' or name.include? 'Copyable' or name.include? 'ComputedProperty' or name.include? 'Component' or name.include? 'String' or name.include? 'Freezable' or name.include? 'Error' or name.include? 'Date' or name.include? 'Namespace' + 'object' + elsif name.include? 'View' or name.include? 'TextArea' or name.include? 'TextField' or name.include? 'Checkbox' or name.include? 'Select' or name.include? 'InjectedProperty' or name.include? 'DefaultResolver' + 'view' + elsif name.include? 'Ember' + 'core' else - name + 'others' end end def additional_entries + if ADDITIONAL_ENTRIES.include? slug + return ADDITIONAL_ENTRIES[slug] + end css('.item-entry').map do |node| heading = node.at_css('h2') - name = heading.content.strip + name = heading.content.strip.tr('#', '.') if self.name == 'Handlebars Helpers' name << ' (handlebars helper)' - next [name, heading['id']] + custom_parsed_uri = get_parsed_uri_by_name(name) + next [name.tr('#', '.'), heading['id'], type, custom_parsed_uri, get_parsed_uri, get_docset] end # Give their own type to "Ember.platform", "Ember.run", etc. @@ -48,8 +112,8 @@ def additional_entries name << '()' if node['class'].include? 'method' name << ' event' if node['class'].include? 'event' - - [name, heading['id'], type] + custom_parsed_uri = get_parsed_uri_by_name(name) + [name, heading['id'], get_type, custom_parsed_uri, get_parsed_uri, get_docset] end end end diff --git a/lib/docs/filters/express/clean_html.rb b/lib/docs/filters/express/clean_html.rb index 2f21922c9b..f2b984e405 100644 --- a/lib/docs/filters/express/clean_html.rb +++ b/lib/docs/filters/express/clean_html.rb @@ -1,17 +1,34 @@ module Docs class Express - class CleanHtmlFilter < Filter + class CleanHtmlFilter < Docs::ReflyFilter + BROKEN_LINKS = [] + REPLACED_LINKS = { + # '4x/starter/installing' => 'starter/installing', + # '4x/starter/hello-world' => 'starter/hello-world', + # '4x/starter/generator' => 'starter/generator', + # '4x/starter/basic-routing' => 'starter/basic-routing', + # '4x/starter/static-files' => 'starter/static-files', + # '4x/starter/faq' => 'starter/faq', + # '4x/guide/routing' => 'guide/routing', + # '4x/guide/writing-middleware' => 'guide/writing-middleware', + # '4x/guide/using-template-engines' => 'guide/using-template-engines', + # '4x/starter/installing' => 'starter/installing', + # '4x/guide/debugging' => 'guide/debugging', + # '4x/guide/behind-proxies' => 'guide/behind-proxies', + # '' => '', + # '' => '', + # '' => '', + # '' => '', + } def call - at_css('h1').remove - - css('section').each do |node| + css('section', 'div.highlighter-rouge').each do |node| node.before(node.children).remove end + css('#navmenu').remove # Put id attributes on headings - css('h2 + a[name]').each do |node| - node.previous_element['id'] = node['name'] - node.remove + css('h2', 'h3', 'h4').each do |node| + node['id'] = node.content.downcase.tr(' ', '-') end css('table[border]').each do |node| @@ -19,10 +36,56 @@ def call end # Remove code highlighting - css('pre').each do |node| + css('figure.highlight').each do |node| + node['data-language'] = node.at_css('code[data-lang]')['data-lang'] node.content = node.content + node.name = 'pre' end + css('a[href]').each do |node| + node['href'] = CleanWrongCharacters(node['href']).downcase.remove '_(event)' + if REPLACED_LINKS[node['href'].downcase.remove! '../'] + node['href'] = REPLACED_LINKS[node['href'].remove '../'] + elsif !node['href'].start_with? 'http://' and !node['href'].start_with? 'https://' and !node['href'].start_with? 'ftp://' and !node['href'].start_with? 'irc://' and !node['href'].start_with? 'mailto:' + if node['class'] == 'new' or node['title'] == 'The documentation about this has not yet been written; please consider contributing!' + node['class'] = 'broken' + node['title'] = '' + # node['href'] = context[:domain] + '/help#brokenlink' + elsif BROKEN_LINKS.include? node['href'].downcase.remove! '../' + node['class'] = 'broken' + # node['href'] = context[:domain] + '/help#brokenlink' + else + sluglist = slug.split('/') + nodelist = node['href'].split('/') + newhref = [] + nodelist.each do |item| + if item == '..' + sluglist.pop + else + newhref << item + end + end + sluglist.pop + if sluglist.size>0 + node['href'] = sluglist.join('/') + '/' + newhref.join('/') + else + node['href'] = newhref.join('/') + end + end + if REPLACED_LINKS[node['href'].downcase.remove! '../'] + node['href'] = REPLACED_LINKS[node['href'].remove '../'] + end + if node['href'].start_with? '4x/' + node['href'] = node['href'].tr('x4/','') + end + end + end + css('pre > code').each do |node| + node.parent['data-language'] = node['class'][/language-(\w+)/, 1] if node['class'] + node.parent.content = node.parent.content + end + WrapPreContentWithCode 'hljs actionscript' + WrapContentWithDivs '_page _express' doc end end diff --git a/lib/docs/filters/express/entries.rb b/lib/docs/filters/express/entries.rb index bd3330ee0e..8855df5cdb 100644 --- a/lib/docs/filters/express/entries.rb +++ b/lib/docs/filters/express/entries.rb @@ -1,22 +1,78 @@ module Docs class Express - class EntriesFilter < Docs::EntriesFilter - def additional_entries - type = 'Application' + class EntriesFilter < Docs::ReflyEntriesFilter + def get_name + name = css('h1').first.content + # puts name + name + end + def get_docset + docset = context[:root_title] + docset + end + + def get_parsed_uri_by_name(name) + parsed_uri = get_parsed_uri + '/' + self.urilized(name) + parsed_uri + end - doc.children.each_with_object [] do |node, entries| + def get_parsed_uri + if get_parent_uri == 'null' + parsed_uri = context[:docset_uri] + '/' + self.urilized(get_name) + else + parsed_uri = get_parent_uri + '/' + self.urilized(get_name) + end + parsed_uri + end + + def get_parent_uri + 'null' + end + + def get_type + 'guide' + end + + def get_type_by_name(name, id) + # name = 'uu' + # id = 'oo' + if name.include? 'req.' or name.include? 'Request' or id.include? 'req.' + 'request' + elsif name.include? 'app.' or name.include? 'Application' or id.include? 'app.' + 'application' + elsif name.include? 'res.' or name.include? 'Response' or id.include? 'res.' + 'response' + elsif name.include? 'router.' or name.include? 'Router' or id.include? 'router.' + 'router' + else + 'others' + end + end + + def additional_entries + entries = [] + css('h2', 'h3', 'h4').each do |node| if node.name == 'h2' - type = node.content - entries << [type, node['id'], 'Application'] if type == 'Middleware' + name = node.content + type = name + custom_parsed_uri = get_parsed_uri_by_name(name) + entries << [name, node['id'], get_type_by_name(name, node['id']), custom_parsed_uri, get_parsed_uri, get_docset] if type == 'Middleware' + next + elsif node.name == 'h4' + name = node.content + type = name + custom_parsed_uri = get_parsed_uri_by_name(name) + entries << [name, node['id'], get_type_by_name(name, node['id']), custom_parsed_uri, get_parsed_uri, get_docset] next elsif node.name == 'h3' next if type == 'Middleware' name = node.content.strip name.sub! %r{\(.+\)}, '()' - - entries << [name, node['id'], type] + custom_parsed_uri = get_parsed_uri_by_name(name) + entries << [name, node['id'], get_type_by_name(name, node['id']), custom_parsed_uri, get_parsed_uri, get_docset] end end + entries end end end diff --git a/lib/docs/filters/git/clean_html.rb b/lib/docs/filters/git/clean_html.rb index f3ce151a86..3c4735d9b0 100644 --- a/lib/docs/filters/git/clean_html.rb +++ b/lib/docs/filters/git/clean_html.rb @@ -1,8 +1,11 @@ module Docs class Git - class CleanHtmlFilter < Filter + class CleanHtmlFilter < Docs::ReflyFilter + def call root_page? ? root : other + WrapPreContentWithCode 'hljs prolog' + WrapContentWithDivs '_page _git' doc end @@ -13,6 +16,34 @@ def root def other css('h1 + h2', '#_git + div', '#_git').remove + css('a[href]').each do |node| + if !node['href'].start_with? 'http://' and !node['href'].start_with? 'https://' + if node['href'].start_with? ':' + node['class'] = 'broken' + # node['href'] = context[:domain] + '/help#brokenlink' + elsif node['href'].start_with? 'howto/' + node['href'] = 'https://github.com/git/git/blob/master/Documentation/' + node['href'] + '.txt' + else + sluglist = slug.split('/') + nodelist = node['href'].split('/') + newhref = [] + nodelist.each do |item| + if item == '..' + sluglist.pop + else + newhref << item + end + end + sluglist.pop + if sluglist.size>0 + node['href'] = sluglist.join('/') + '/' + newhref.join('/') + else + node['href'] = newhref.join('/') + end + end + end + end + css('> div', 'pre > tt', 'pre > em', 'div.paragraph').each do |node| node.before(node.children).remove end @@ -38,6 +69,14 @@ def other css('tt', 'p > em').each do |node| node.name = 'code' end + + # Fix confictive links + css('a').each do |node| + if !node['href'].nil? + node['href'] = node['href'].remove('http://git-scm.com/docs/').remove('/docs/').remove('docs/') + end + end + end end end diff --git a/lib/docs/filters/git/entries.rb b/lib/docs/filters/git/entries.rb index afdca02307..6d3e91a3f8 100644 --- a/lib/docs/filters/git/entries.rb +++ b/lib/docs/filters/git/entries.rb @@ -1,9 +1,44 @@ module Docs class Git - class EntriesFilter < Docs::EntriesFilter + class EntriesFilter < Docs::ReflyEntriesFilter def get_name - slug.sub '-', ' ' + name = path + name end + + def get_docset + docset = context[:root_title] + docset + end + + def get_parsed_uri + parsed_uri = context[:docset_uri] + '/' + path + parsed_uri + end + + def get_parent_uri + parent_uri = 'null' + end + + def get_type + node = css('p') + if node[0] + if node[0].inner_text.downcase.include? ' show ' + 'lists' + elsif node[0].inner_text.downcase.include? ' list ' + return 'lists' + elsif node[0].inner_text.downcase.include? ' ' + 'function' + elsif node[2].inner_text.downcase.include? ' method ' + return 'method' + else + 'function' + end + else + 'others' + end + end + end end end diff --git a/lib/docs/filters/go/clean_html.rb b/lib/docs/filters/go/clean_html.rb index 78e798a31b..a9c2b317e0 100644 --- a/lib/docs/filters/go/clean_html.rb +++ b/lib/docs/filters/go/clean_html.rb @@ -1,6 +1,11 @@ module Docs class Go - class CleanHtmlFilter < Filter + class CleanHtmlFilter < ReflyFilter + REPLACED_LINKS = { + '..' => 'index' + } + BROKEN_LINKS = [ + ] def call if root_page? at_css('h1').content = 'Go Programming Language' @@ -13,7 +18,30 @@ def call node.previous_element.content = node.previous_element.content end end - + css('a[href]').each do |node| + if !node['href'].start_with? 'http://' and !node['href'].start_with? 'https://' + node['href'] = CleanWrongCharacters(node['href']) + if BROKEN_LINKS.include? node['href'].downcase.remove! '../' + node['class'] = 'broken' + elsif !node['href'].start_with? '#' + sluglist = slug.split('/') + nodelist = node['href'].split('/') + newhref = [] + nodelist.each do |item| + if item == '..' + sluglist.pop + else + newhref << item + end + end + if sluglist.size>0 + node['href'] = sluglist.join('/') + '/' + newhref.join('/') + else + node['href'] = newhref.join('/') + end + end + end + end css('#plusone', '#nav', '.pkgGopher', '#footer', '.collapsed').remove # Remove triangle character @@ -38,9 +66,13 @@ def call node.children = node.at_css('.code').children node.name = 'pre' end - + WrapPreContentWithCode 'hljs go' + WrapContentWithDivs '_page _go' doc end + def CleanWrongCharacters(href) + href.gsub('%23', '#').gsub('%28', '(').gsub('%29', ')').gsub('%21', '!').gsub('%7b', '{').gsub('%7e', '~').gsub('%2a', '*').gsub('%2b', '+').gsub('%3d', '=') + end end end end diff --git a/lib/docs/filters/go/entries.rb b/lib/docs/filters/go/entries.rb index e833967957..a468de7382 100644 --- a/lib/docs/filters/go/entries.rb +++ b/lib/docs/filters/go/entries.rb @@ -1,14 +1,58 @@ module Docs class Go - class EntriesFilter < Docs::EntriesFilter + class EntriesFilter < Docs::ReflyEntriesFilter + FUNCTION_TYPES = %w(math text image crypto time hash archive compress regexp) + IO_TYPES = %w(io bufio mime encoding path fmt ) + CORE_TYPES = %w(syscall go log builtin os runtime debug unsafe testing) + TYPE_TYPES = %w(strings bytes unicode sync reflect sort expvar flag container strconv) + NETWORK_TYPES = %w(net html database) def get_name name = at_css('h1').content name.remove! 'Package ' + name.remove! 'Directory /src/' name end + def get_docset + docset = context[:root_title] + docset + end + + def get_parsed_uri_by_name(name) + parsed_uri = get_parsed_uri + '/' + self.urilized(name) + parsed_uri + end + + def get_parsed_uri + if get_parent_uri == 'null' + parsed_uri = context[:docset_uri] + '/' + self.urilized(get_name) + else + parsed_uri = get_parent_uri + '/' + self.urilized(get_name) + end + parsed_uri + end + + def get_parent_uri + parent_uri = 'null' + parent_uri + end + def get_type - subpath[/\A[^\/]+/] + type = subpath[/\A[^\/]+/] + if FUNCTION_TYPES.include? type + type = 'function' + elsif IO_TYPES.include? type + type = 'io' + elsif CORE_TYPES.include? type + type = 'core' + elsif TYPE_TYPES.include? type + type = 'type' + elsif NETWORK_TYPES.include? type + type = 'network' + else + type = 'others' + end + type end def additional_entries @@ -23,15 +67,19 @@ def additional_entries name = "#{self.name} constants" when 'Variables' name = "#{self.name} variables" + else + name = node.content + end + custom_parsed_uri = get_parsed_uri_by_name(name) + #TODO + if get_parsed_uri == '/go/go_programming_language' + entries << [name, node['href'][1..-1], get_type, custom_parsed_uri, 'null', get_docset] if name + else + entries << [name, node['href'][1..-1], get_type, custom_parsed_uri, get_parsed_uri, get_docset] if name end - - entries << [name, node['href'][1..-1]] if name end end - def include_default_entry? - !at_css('h1 + table.dir') - end end end end diff --git a/lib/docs/filters/grunt/clean_html.rb b/lib/docs/filters/grunt/clean_html.rb index f1ddf5e9f1..7c54322003 100644 --- a/lib/docs/filters/grunt/clean_html.rb +++ b/lib/docs/filters/grunt/clean_html.rb @@ -1,11 +1,16 @@ module Docs class Grunt - class CleanHtmlFilter < Filter + class CleanHtmlFilter < Docs::ReflyFilter + BROKEN_LINKS = [ + ] + REPLACED_LINKS = { + 'index' => 'getting-started' + } def call @doc = at_css('.hero-unit') if root_page? - at_css('h1').content = 'Grunt' + at_css('h1').content = 'Grunt' if at_css('h1') end css('.end-link').remove @@ -15,14 +20,32 @@ def call node.parent['id'] = node['name'] node.before(node.children).remove end + # Fix wrong links + css('a[href]').each do |node| + if !node['href'].start_with? 'http://' and !node['href'].start_with? 'https://' + node['href'] = CleanWrongCharacters(node['href']).remove '../' + if REPLACED_LINKS[node['href'].downcase.remove! '../'] + node['href'] = REPLACED_LINKS[node['href'].remove '../'] + elsif node['href'].include? '/grunt.log#grunt.log.error' + node['href'] = '#grunt.log.error-grunt.verbose.error' + elsif BROKEN_LINKS.include? node['href'].downcase.remove! '../' + node['class'] = 'broken' + # node['href'] = context[:domain] + '/help#brokenlink' + end + end + end # Remove code highlighting css('pre').each do |node| node.content = node.content end - + WrapPreContentWithCode 'hljs stylus' + WrapContentWithDivs '_page _grunt' doc end + def CleanWrongCharacters(href) + href.gsub('%23', '#').gsub('%28', '(').gsub('%29', ')').gsub('%21', '!').gsub('%7b', '{').gsub('%7e', '~').gsub('%2a', '*').gsub('%2b', '+').gsub('%3d', '=') + end end end end diff --git a/lib/docs/filters/grunt/entries.rb b/lib/docs/filters/grunt/entries.rb index 01b453e129..0551ea313f 100644 --- a/lib/docs/filters/grunt/entries.rb +++ b/lib/docs/filters/grunt/entries.rb @@ -1,15 +1,49 @@ module Docs class Grunt - class EntriesFilter < Docs::EntriesFilter + class EntriesFilter < Docs::ReflyEntriesFilter + def get_name - at_css('h1').content + if at_css('h1') + name = at_css('h1').content + else + name = 'Grunt' + end + name + end + + def get_docset + docset = context[:root_title] + docset + end + + def get_parsed_uri_by_name(name) + get_parsed_uri + '/' + self.urilized(name) + end + + def get_parsed_uri + parsed_uri = context[:docset_uri] + '/' + self.urilized(get_name) + parsed_uri + end + + def get_parent_uri + 'null' end def get_type - if name.starts_with?('grunt') || name == 'Inside Tasks' - name + 'others' + end + + def get_type_by_name(name) + if name.downcase.include? 'config' + 'configuration' + elsif name.downcase.include? 'event' + 'event' + elsif name.downcase.include? 'fail' + 'error' + elsif name.downcase.include? 'file' + 'file' else - 'Miscellaneous' + 'others' end end @@ -21,14 +55,11 @@ def additional_entries name.remove! %r{\s.+\z} next if name == self.name - - entries << [name, node['id']] + custom_parsed_uri = get_parsed_uri_by_name(name) + entries << [name, node['id'], get_type_by_name(name), custom_parsed_uri, get_parsed_uri, get_docset] end end - def include_default_entry? - name != 'Inside Tasks' - end end end end diff --git a/lib/docs/filters/haskell/clean_html.rb b/lib/docs/filters/haskell/clean_html.rb index 130dfe69fc..58a3800d1e 100644 --- a/lib/docs/filters/haskell/clean_html.rb +++ b/lib/docs/filters/haskell/clean_html.rb @@ -1,8 +1,31 @@ module Docs class Haskell - class CleanHtmlFilter < Filter + class CleanHtmlFilter < Docs::ReflyFilter + BROKEN_LINKS = [ + 'containers-0.5.5.1/$', + 'bytestring-0.10.4.0/$', + 'haskell98-2.0.0.3/control-exception-exception', + 'base-4.7.0.0/control-exception-exception', + 'deepseq-1.3.0.2/control-parallel', + 'hoopl-3.10.0.1/fallthrough', + 'bytestring-0.10.4.0/data-bytestring-builder-ascii', + 'template-haskell-2.9.0.0/hello', + 'control-monad-trans-state', + 'base-4.7.0.0/data-generics-basics', + 'base-4.7.0.0/data-generics-instances', + 'base-4.7.0.0/data-array-st', + 'base-4.7.0.0/foreign-foreignptr', + 'base-4.7.0.0/if', + 'bytestring-0.10.4.0/)\'' + ] + REPLACED_LINKS = { + 'text-prettyprint-hughespj' => 'pretty-1.1.1.1/text-prettyprint-hughespj' + } def call root_page? ? root : other + fixLinks + WrapPreContentWithCode 'hljs haskell' + WrapContentWithDivs '_page _haskell' doc end @@ -37,6 +60,7 @@ def other css('a[name]').each do |node| node['id'] = node['name'] node.remove_attribute('name') + node.name = 'span' end css('p.caption').each do |node| @@ -52,9 +76,43 @@ def other node['class'] = 'version' end end - doc end + def fixLinks + css('a[href]').each do |node| + node['href'] = CleanWrongCharacters(node['href']).downcase + if REPLACED_LINKS[node['href'].downcase.remove! '../'] + node['href'] = REPLACED_LINKS[node['href'].remove '../'] + elsif !node['href'].start_with? 'http://' and !node['href'].start_with? '#' and !node['href'].start_with? 'https://' and !node['href'].start_with? 'ftp://' and !node['href'].start_with? 'irc://' and !node['href'].start_with? 'news://' and !node['href'].start_with? 'mailto:' + if node['class'] == 'new' + node['class'] = 'broken' + node['title'] = '' + else + # puts 'ini: ' + node['href'] + sluglist = slug.split('/') + if context[:url].to_s.include? '.html' + sluglist.pop + end + nodelist = sluglist + node['href'].split('/') + newhref = [] + nodelist.each do |item| + if item == '..' + newhref.pop + elsif item != '' + newhref << item + end + end + node['href'] = newhref.join('/') + end + # puts 'fin: ' + node['href'] + end + if BROKEN_LINKS.include? node['href'].downcase.remove! '../' + node['class'] = 'broken' + end + node['href'] = REPLACED_LINKS[node['href']] || node['href'] + end + + end end end end diff --git a/lib/docs/filters/haskell/entries.rb b/lib/docs/filters/haskell/entries.rb index edfaabae16..7d9431b531 100644 --- a/lib/docs/filters/haskell/entries.rb +++ b/lib/docs/filters/haskell/entries.rb @@ -1,6 +1,7 @@ module Docs class Haskell - class EntriesFilter < Docs::EntriesFilter + class EntriesFilter < Docs::ReflyEntriesFilter + #NULL_PARENT_URIs = %w(haskell98-2.0.0.3) IGNORE_ENTRIES_PATHS = %w( bytestring-0.10.4.0/Data-ByteString-Lazy.html bytestring-0.10.4.0/Data-ByteString-Char8.html @@ -17,38 +18,79 @@ class EntriesFilter < Docs::EntriesFilter unix-2.7.0.1/System-Posix-Terminal-ByteString.html) def get_name - at_css('#module-header .caption').content.strip + if at_css('#module-header .caption') + at_css('#module-header .caption').content.strip + else + 'Index' + end end - def get_type - %w(System.Posix System.Win32 Control.Monad).each do |type| - return type if name.start_with?(type) + + def get_docset + docset = context[:root_title] + docset + end + + def get_parsed_uri_by_name(name) + if get_parent_uri == 'null' + parsed_uri = context[:docset_uri] + '/' + self.urilized(name) + else + parsed_uri = get_parent_uri + '/' + self.urilized(name) end + parsed_uri + end - if name.start_with?('Data') - name.split('.')[0..1].join('.') + def get_parsed_uri + if get_parent_uri == 'null' + parsed_uri = context[:docset_uri] + '/' + self.urilized(get_name) else - name.split('.').first + parsed_uri = get_parent_uri + '/' + self.urilized(get_name) end + parsed_uri + end + + def get_parent_uri + parent_uri = 'null' + parent_uri + end + + def get_type + name = get_name + if name.include? 'Data' + 'data' + elsif %w(Complex Array Char Numeric Maybe).include? name or name.include? 'Foreign' + 'type' + elsif %w(List Prelude IO Ratio Random Debug.Trace).include? name or name.include? 'Text' or name.include? 'Trace' or name.include? 'Control' + 'function' + elsif name.include? 'GHC' or name.include? 'Compiler' or name.include? 'System' or name.include? 'GHC' + 'module' + elsif name.include? 'Language' + 'language' + elsif name.include? 'Ix' + 'class' + else + 'others' + end + end def additional_entries return [] if IGNORE_ENTRIES_PATHS.include?(subpath) - css('#synopsis > ul > li').each_with_object [] do |node, entries| link = node.at_css('a') next unless link['href'].start_with?('#') name = node.content.strip name.remove! %r{\A(?:module|data|newtype|class|type family m|type)\s+} name.sub! %r{\A\((.+?)\)}, '\1' - name.sub!(/ (?:\:\: (\w+))?.+\z/) { |_| $1 ? " (#{$1})" : '' } + #name.sub!(/ (?:\:\: (\w+))?.+\z/) { |_| $1 ? " (#{$1})" : '' } next if name == self.name - entries << [name, link['href'].remove('#')] + custom_parsed_uri = get_parsed_uri_by_name(name) + entries << [name, link['href'].remove('#'),get_type, custom_parsed_uri, get_parsed_uri, get_docset] end end def include_default_entry? - at_css('#synopsis > ul > li') + true #at_css('#synopsis > ul > li') end end end diff --git a/lib/docs/filters/html/clean_html.rb b/lib/docs/filters/html/clean_html.rb index 60b49b296e..7d80c57a98 100644 --- a/lib/docs/filters/html/clean_html.rb +++ b/lib/docs/filters/html/clean_html.rb @@ -1,19 +1,75 @@ module Docs class Html - class CleanHtmlFilter < Filter + class CleanHtmlFilter < Docs::ReflyFilter + + BROKEN_LINKS = [ + 'en-us/docs/web/guide/prefixes', + 'tutorials', + 'portfolio', + 'element/decorator', + 'element/en-us/docs/web/api/htmltableheadercellelement', + 'screen/en/dom/window.screen.top' + ] + REPLACED_LINKS = { + 'https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/element/en-US/docs/Web/API/HTMLTableHeaderCellElement' => '', + 'en-us/docs/web/api/htmltableheadercellelement' => 'https://developer.mozilla.org/en-US/docs/Web/API/HTMLTableHeaderCellElement', + 'strict_mode' => 'strict_mode', + 'www.schema.org' => 'http://www.schema.org', + 'element/webkit-meter-optimum-value' => 'https://developer.mozilla.org/en-US/docs/Web/CSS/::-webkit-meter-optimum-value', + 'element/webkit-meter-even-less-good-value' => 'https://developer.mozilla.org/en-US/docs/Web/CSS/::-webkit-meter-even-less-good-value', + } + def call root_page? ? root : other + WrapPreContentWithCode 'hljs html' doc end def root + #Cleaning content + css('footer','div.article-meta', '.submenu', 'div.wiki-block', 'nav', '.toc', '#nav-access', '#main-header', '.title').remove css('p').each do |node| node.remove if node.content.lstrip.start_with? 'The symbol' end end def other + #Cleaning content + css('footer','div.article-meta', '.submenu', 'div.wiki-block', 'nav', '.toc', '#nav-access', '#main-header', '.title').remove + css('a[href]').each do |node| + node['href'] = CleanWrongCharacters(node['href']).downcase.remove '_(event)' + if REPLACED_LINKS[node['href'].downcase.remove! '../'] + node['href'] = REPLACED_LINKS[node['href'].remove '../'] + elsif !node['href'].start_with? 'http://' and !node['href'].start_with? 'https://' and !node['href'].start_with? 'ftp://' and !node['href'].start_with? 'irc://' and !node['href'].start_with? 'mailto:' + if node['class'] == 'new' or node['title'] == 'The documentation about this has not yet been written; please consider contributing!' + node['class'] = 'broken' + node['title'] = '' + # node['href'] = context[:domain] + '/help#brokenlink' + elsif BROKEN_LINKS.include? node['href'].downcase.remove! '../' + node['class'] = 'broken' + # node['href'] = context[:domain] + '/help#brokenlink' + else + sluglist = slug.split('/') + nodelist = node['href'].split('/') + newhref = [] + nodelist.each do |item| + if item == '..' + sluglist.pop + else + newhref << item + end + end + sluglist.pop + if sluglist.size>0 + node['href'] = sluglist.join('/') + '/' + newhref.join('/') + else + node['href'] = newhref.join('/') + end + end + end + end end + end end end diff --git a/lib/docs/filters/html/entries.rb b/lib/docs/filters/html/entries.rb index c352662046..decfd6c73a 100644 --- a/lib/docs/filters/html/entries.rb +++ b/lib/docs/filters/html/entries.rb @@ -1,51 +1,92 @@ module Docs class Html - class EntriesFilter < Docs::EntriesFilter + class EntriesFilter < Docs::ReflyEntriesFilter HTML5 = %w(content element video) OBSOLETE = %w(frame frameset hgroup noframes) - ADDITIONAL_ENTRIES = { 'Element/Heading_Elements' => (1..6).map { |n| ["h#{n}"] } } + EXCLUDED_PATH = ['MDN','Web technology for developers', 'HTML'] def get_name - name = super - name.remove!('Element.').try(:downcase!) + name = css('h1').first.content name end + def get_docset + docset = context[:root_title] + docset + end + + def get_parsed_uri_by_name(name) + if get_parent_uri == 'null' + parsed_uri = context[:docset_uri] + '/' + self.urilized(name) + else + parsed_uri = get_parsed_uri + '/' + self.urilized(name) + end + parsed_uri + end + + def get_parsed_uri + if get_parent_uri == 'null' + parsed_uri = context[:docset_uri] + '/' + self.urilized(get_name) + else + parsed_uri = get_parent_uri + '/' + self.urilized(get_name) + end + parsed_uri + end + + def get_parent_uri + parent_uri = context[:docset_uri] + css('.crumb a').each do |node| + link = node.content + if not EXCLUDED_PATH.include? link + parent_uri += '/' + self.urilized(link) + end + end + if parent_uri == context[:docset_uri] + parent_uri = 'null' + end + parent_uri + end + def get_type slug = self.slug.remove('Element/') if at_css('.obsoleteHeader', '.deprecatedHeader', '.nonStandardHeader') || OBSOLETE.include?(slug) - 'Obsolete' + 'obsolete' else spec = css('.standard-table').last.try(:content) if (spec && html5_spec?(spec)) || HTML5.include?(slug) - 'HTML5' + 'type' else - 'Standard' + 'standard' end end end - def include_default_entry? - !%w(Attributes Link_types Element/Heading_Elements).include?(slug) - end def additional_entries - return ADDITIONAL_ENTRIES[slug] if ADDITIONAL_ENTRIES.key?(slug) if slug == 'Attributes' css('.standard-table td:first-child').map do |node| name = node.content.strip - id = node.parent['id'] = name.parameterize - [name, id, 'Attributes'] + id = node.parent['id'] = name.parameterize + 'tr' + custom_parsed_uri = get_parsed_uri_by_name(name) + [name, id, 'attribute', custom_parsed_uri, get_parsed_uri, get_docset] end elsif slug == 'Link_types' css('.standard-table td:first-child > code').map do |node| name = node.content.strip - id = node.parent.parent['id'] = name.parameterize + id = node.parent.parent['id'] = name.parameterize + 'tr' name.prepend 'rel: ' - [name, id, 'Attributes'] + custom_parsed_uri = get_parsed_uri_by_name(name) + [name, id, 'attribute', custom_parsed_uri, get_parsed_uri, get_docset] end + elsif slug == 'Element/Heading_Elements' + (1..6).map do |n| + name = 'h' + n.to_s + id = 'All_headings' + custom_parsed_uri = get_parsed_uri_by_name(name) + [name, id, 'element', custom_parsed_uri, get_parsed_uri, get_docset] + end else [] end diff --git a/lib/docs/filters/http/clean_html.rb b/lib/docs/filters/http/clean_html.rb index fa49531325..1e6fd6b41c 100644 --- a/lib/docs/filters/http/clean_html.rb +++ b/lib/docs/filters/http/clean_html.rb @@ -1,48 +1,42 @@ module Docs class Http - class CleanHtmlFilter < Filter + class CleanHtmlFilter < Docs::ReflyFilter def call - root_page? ? root : other - doc - end - - def root - # Change title - title = at_css 'h2' - title.name = 'h1' - title.inner_html = 'Hypertext Transfer Protocol — HTTP/1.1' - - # Remove "..." following each link - css('span').each do |node| - node.inner_html = node.first_element_child if node.first_element_child + WrapContentWithDivs '_page _rfc' + if root_page? + doc.inner_html = '
tags and remove indentation
- css('pre').each do |node|
- while (sibling = node.next_element) && sibling.name == 'pre'
- node.inner_html += "\n#{sibling.inner_html}"
- sibling.remove
- end
- node.inner_html = node.inner_html.strip_heredoc
+ css('.selflink').each do |node|
+ node.parent['id'] = node['name']
+ node.before(node.children).remove
end
+ WrapPreContentWithCode 'hljs http'
+ html = doc.inner_html.strip
+ html.remove! %r[\.{2,}$]
+ html.gsub! %r[(^\n$){3,}], "\n"
+ doc.inner_html = %(#{html})
+ doc
end
end
end
diff --git a/lib/docs/filters/http/entries.rb b/lib/docs/filters/http/entries.rb
index 3d65a60655..3cb96175f7 100644
--- a/lib/docs/filters/http/entries.rb
+++ b/lib/docs/filters/http/entries.rb
@@ -1,19 +1,118 @@
module Docs
class Http
- class EntriesFilter < Docs::EntriesFilter
+ class EntriesFilter < Docs::ReflyEntriesFilter
+
+ REPLACE_TYPES = {
+ 'Caching' => 'caching',
+ 'Range Requests' => 'requests',
+ 'Conditional Requests' => 'requests',
+ 'Semantics and Content' => 'semantics',
+ 'Message Syntax and Routing' => 'message',
+ 'Authentication' => 'authentication' }
+
+ def get_name
+ name = at_css('h1').content
+ name.remove! %r{\A.+\:}
+ name.remove! %r{\A.+\-\-}
+ "#{rfc}: #{name.strip}"
+ end
+
def get_type
- at_css('h1').content.sub(/\A\s*HTTP\s+(.+)\s+Definitions\s*\z/, '\1').pluralize
+ if at_css('h1').content.split(':')[1]
+ REPLACE_TYPES[at_css('h1').content.split(':')[1].strip] || at_css('h1').content.split(':')[1].strip
+ else
+ 'others'
+ end
+ end
+
+ def get_parsed_uri_by_name(name)
+ context[:docset_uri] + '/' + self.urilized(name)
+ end
+
+ def get_parent_uri
+ subpath = *path.split('/')
+ if subpath.length > 1
+ parent_uri = (context[:docset_uri]+ '/' + subpath[0,subpath.size-1].join('/')).downcase
+ else
+ parent_uri = 'null'
+ end
end
+ def rfc
+ slug.sub('rfc', 'RFC ')
+ end
+ SECTIONS = {
+ 'rfc2616' => [
+ [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 15],
+ [14],
+ []
+ ],
+ 'rfc7230' => [
+ (2..9).to_a,
+ [],
+ []
+ ],
+ 'rfc7231' => [
+ [3, 8, 9],
+ [],
+ [4, 5, 6, 7]
+ ],
+ 'rfc7232' => [
+ [5, 6, 7, 8],
+ [2, 3, 4],
+ []
+ ],
+ 'rfc7233' => [
+ [5, 6],
+ [2, 3, 4],
+ []
+ ],
+ 'rfc7234' => [
+ [3, 6, 7, 8],
+ [4, 5],
+ []
+ ],
+ 'rfc7235' => [
+ [2, 5, 6],
+ [3, 4],
+ []
+ ]
+ }
def include_default_entry?
false
end
+ LEVEL_1 = /\A(\d+)\z/
+ LEVEL_2 = /\A(\d+)\.\d+\z/
+ LEVEL_3 = /\A(\d+)\.\d+\.\d+\z/
+
def additional_entries
return [] if root_page?
+ type = nil
+
+ css('a[href^="#section-"]').each_with_object([]) do |node, entries|
+ id = node['href'].remove('#')
+ break entries if entries.any? { |e| e[1] == id }
- css(type == 'Status Codes' ? 'h3' : 'h2').map do |node|
- [node.content, node['id']]
+ content = node.next.content.strip
+ content.remove! %r{\s*\.+\d*\z}
+ content.remove! %r{\A[\.\s]+}
+ name = "#{content} (#{rfc})"
+ number = node.content.strip
+ custom_parsed_uri = get_parsed_uri_by_name(name)
+ if number =~ LEVEL_1
+ if SECTIONS[slug][0].include?($1.to_i)
+ entries << [name, id, get_type, custom_parsed_uri, get_parent_uri, get_docset]
+ end
+
+ type = content.sub(/\ Definitions\z/, 's')
+ type = 'Request Header Fields' if type.include?('Header Fields') && type.exclude?('Response')
+ type = 'Response Status Codes' if type.include?('Status Codes')
+ type = self.name unless type.start_with?('Request ') || type.start_with?('Response ')
+ elsif (number =~ LEVEL_2 && SECTIONS[slug][1].include?($1.to_i)) ||
+ (number =~ LEVEL_3 && SECTIONS[slug][2].include?($1.to_i))
+ entries << [name, id, get_type, custom_parsed_uri, get_parent_uri, get_docset]
+ end
end
end
end
diff --git a/lib/docs/filters/jasmine/clean_html.rb b/lib/docs/filters/jasmine/clean_html.rb
new file mode 100644
index 0000000000..9e71a60013
--- /dev/null
+++ b/lib/docs/filters/jasmine/clean_html.rb
@@ -0,0 +1,56 @@
+module Docs
+ class Jasmine
+ class CleanHtmlFilter < Docs::ReflyFilter
+ BROKEN_LINKS = []
+ REPLACED_LINKS = {}
+ def call
+
+ css('.title-banner', '.jump_to', '.pilwrap').remove
+ #changing tables for divs
+ css('table', 'tr', 'thead', 'td').each do |node|
+ node.name = 'div'
+ end
+
+ css('h4', 'h3', 'h2').each do |node|
+ node.parent.parent['id'] = node.content.capitalize.strip.tr(' ', '_')
+ end
+ fixLinks
+ WrapPreContentWithCode 'hljs javascript'
+ WrapContentWithDivs '_page _jasmine'
+ doc
+ end
+ def fixLinks
+ css('a[href]').each do |node|
+ node['href'] = CleanWrongCharacters(node['href']).downcase
+ if REPLACED_LINKS[node['href'].downcase.remove! '../']
+ node['href'] = REPLACED_LINKS[node['href'].remove '../']
+ elsif !node['href'].start_with? '#' and !node['href'].start_with? 'http://' and !node['href'].start_with? '#' and !node['href'].start_with? 'https://' and !node['href'].start_with? 'ftp://' and !node['href'].start_with? 'irc://' and !node['href'].start_with? 'news://' and !node['href'].start_with? 'mailto:'
+ if node['class'] == 'new'
+ node['class'] = 'broken'
+ node['title'] = ''
+ else
+ sluglist = slug.split('/')
+ if context[:url].to_s.include? '.html'
+ sluglist.pop
+ end
+ nodelist = sluglist + node['href'].split('/')
+ newhref = []
+ nodelist.each do |item|
+ if item == '..'
+ newhref.pop
+ elsif item != '' and !newhref.include? item
+ newhref << item
+ end
+ end
+ node['href'] = newhref.join('/')
+ end
+ end
+ if BROKEN_LINKS.include? node['href'].downcase.remove! '../'
+ node['class'] = 'broken'
+ end
+ node['href'] = REPLACED_LINKS[node['href']] || node['href']
+ end
+ end
+ end
+ end
+end
diff --git a/lib/docs/filters/jasmine/entries.rb b/lib/docs/filters/jasmine/entries.rb
new file mode 100644
index 0000000000..21c3de2c09
--- /dev/null
+++ b/lib/docs/filters/jasmine/entries.rb
@@ -0,0 +1,65 @@
+module Docs
+ class Jasmine
+ class EntriesFilter < Docs::ReflyEntriesFilter
+
+ AVOIDED_ENTRIES = ['changelog', 'license', 'browserify']
+
+ REPLACE_TYPES = {
+ 'custom_matcher' => 'function',
+ 'custom_equality' => 'function',
+ 'custom_boot' => 'function',
+ 'custom_reporter' => 'function',
+ 'python_egg' => 'platforms',
+ 'ruby_gem' => 'platforms',
+ 'node' => 'platforms',
+ 'ajax' => 'platforms',
+ 'upgrading' => 'guide',
+ 'introduction' => 'guide',
+ 'focused_specs' => 'guide',
+ 'boot' => 'guide',
+ }
+ def get_name
+ css('h1').first.content.remove('.js').strip
+ end
+
+ def get_docset
+ docset = context[:root_title]
+ docset
+ end
+
+ def get_parsed_uri
+ if get_parent_uri == 'null'
+ parsed_uri = context[:docset_uri] + '/' + self.urilized(get_name)
+ else
+ parsed_uri = get_parent_uri + '/' + self.urilized(get_name)
+ end
+ parsed_uri
+ end
+
+ def get_parsed_uri_by_name(name)
+ parsed_uri = context[:docset_uri] + '/' + self.urilized(name)
+ parsed_uri
+ end
+
+ def get_parent_uri
+ 'null'
+ end
+
+ def get_type
+ REPLACE_TYPES[slug] || slug
+ end
+
+ def additional_entries
+ entries = []
+ type = 'others'
+ css('h2','h3','h4').each do |node|
+ name = node.content.strip
+ next if AVOIDED_ENTRIES.include? name
+ custom_parsed_uri = get_parsed_uri_by_name(name)
+ entries << [name, node.parent.parent['id'].remove('#'), get_type, custom_parsed_uri, get_parent_uri, get_docset]
+ end
+ entries
+ end
+ end
+ end
+end
diff --git a/lib/docs/filters/java7se/clean_html.rb b/lib/docs/filters/java7se/clean_html.rb
new file mode 100644
index 0000000000..2bf1567067
--- /dev/null
+++ b/lib/docs/filters/java7se/clean_html.rb
@@ -0,0 +1,62 @@
+module Docs
+ class Java7se
+ class CleanHtmlFilter < Docs::ReflyFilter
+
+ BROKEN_LINKS = []
+ REPLACED_LINKS = {
+ 'allclasses-noframe' => 'http://docs.oracle.com/javase/7/docs/api/allclasses-noframe.html',
+ 'overview-tree' => 'http://docs.oracle.com/javase/7/docs/api/overview-tree.html',
+ 'constant-values' => 'http://docs.oracle.com/javase/7/docs/api/constant-values.html',
+ 'deprecated-list' => 'http://docs.oracle.com/javase/7/docs/api/deprecated-list.html',
+ 'java/applet/package-summary' => 'http://docs.oracle.com/javase/7/docs/api/java/applet/package-summary.html',
+ 'index-files/index-1' => 'http://docs.oracle.com/javase/7/docs/api/index-files/index-1.html',
+ 'synth.dtd' => 'http://docs.oracle.com/javase/7/docs/api/synth.dtd',
+ "org/w3c/dom/ls/'http:/www.ietf.org/rfc/rfc2396.txt'" => "http://www.ietf.org/rfc/rfc2396.txt"
+
+ }
+ def call
+ css('.blockList').each do |node|
+ node.name = 'div'
+ end
+ css('.topNav','.subNav', '.bottomNav', '.legalCopy', '.bottomNav', '.bar', 'noscript', '.subTitle', '.inheritance', 'ul li[type]').remove
+ fixLinks
+ WrapPreContentWithCode 'hljs java'
+ WrapContentWithDivs '_page _javase'
+ doc
+ end
+
+ def fixLinks
+ css('a[href]').each do |node|
+ # puts 'node ini: ' + node['href']
+ node['href'] = CleanWrongCharacters(node['href']).downcase
+ if REPLACED_LINKS[node['href'].downcase.remove! '../']
+ node['href'] = REPLACED_LINKS[node['href'].remove '../']
+ elsif !node['href'].start_with? 'http://' and !node['href'].start_with? '#' and !node['href'].start_with? 'https://' and !node['href'].start_with? 'ftp://' and !node['href'].start_with? 'irc://' and !node['href'].start_with? 'news://' and !node['href'].start_with? 'mailto:'
+ if node['class'] == 'new'
+ node['class'] = 'broken'
+ node['title'] = ''
+ else
+ sluglist = slug.split('/')
+ if context[:url].to_s.include? '.html'
+ sluglist.pop
+ end
+ nodelist = sluglist + node['href'].split('/')
+ newhref = []
+ nodelist.each do |item|
+ if item == '..'
+ newhref.pop
+ elsif item != ''
+ newhref << item
+ end
+ end
+ node['href'] = newhref.join('/')
+ end
+ end
+ node['href'] = REPLACED_LINKS[node['href']] || node['href']
+ # puts 'node fin: ' + node['href']
+ end
+
+ end
+ end
+ end
+end
diff --git a/lib/docs/filters/java7se/entries.rb b/lib/docs/filters/java7se/entries.rb
new file mode 100644
index 0000000000..17f7c3620c
--- /dev/null
+++ b/lib/docs/filters/java7se/entries.rb
@@ -0,0 +1,90 @@
+module Docs
+ class Java7se
+ class EntriesFilter < Docs::ReflyEntriesFilter
+ EXCLUDED_SLUGS = [
+ 'allclasses-noframe',
+ 'overview-tree',
+ 'constant-values',
+ 'deprecated-list',
+ 'Nokogiri',
+ 'java/applet/package-summary',
+ 'index-files/index-1'
+ ]
+
+ def get_name
+ if css('ul.inheritance li').to_s != ''
+ name = css('ul.inheritance li').last.content.strip
+ elsif css('h2.title').to_s != ''
+ name = css('h2.title').first.content.strip
+ elsif css('h1').to_s != ''
+ name = css('h1').first.content.strip
+ else
+ name = slug
+ end
+ name = name.gsub('Uses of Class', 'Uses of Class ')
+ name = name.gsub(/<.*>/, '')
+ name
+ end
+
+ def get_docset
+ docset = context[:root_title]
+ docset
+ end
+
+ def get_parsed_uri
+ if get_parent_uri == 'null'
+ parsed_uri = context[:docset_uri] + '/' + self.urilized(get_name)
+ else
+ parsed_uri = get_parent_uri + '/' + self.urilized(get_name)
+ end
+ parsed_uri
+ end
+
+ def get_parsed_uri_by_name(name)
+ if get_parent_uri == 'null'
+ parsed_uri = context[:docset_uri] + '/' + self.urilized(name)
+ else
+ parsed_uri = get_parent_uri + '/' + self.urilized(name)
+ end
+ parsed_uri
+ end
+
+ def get_parent_uri
+ parent_uri = context[:docset_uri]
+ css('ul.inheritance li a:first-child').each do |node|
+ link = node.content.strip.gsub(/<.>/, '')
+ parent_uri += '/' + self.urilized(link)
+ end
+ if parent_uri == context[:docset_uri]
+ parent_uri = 'null'
+ end
+ parent_uri
+ end
+
+ def get_type
+ type = 'others'
+ if css('h2.title').to_s != ''
+ type = css('h2.title').first.content.strip.downcase.split(' ').first
+ end
+ type
+ end
+
+ # def additional_entries
+ # entries = []
+ # css('span[name]').each do |node|
+ # name = node['name']
+ # name = name.capitalize.tr('_', ' ') if name.upcase != name
+ # custom_parsed_uri = get_parsed_uri_by_name(name)
+ # entries << [name, node['name'], get_type, custom_parsed_uri, get_parent_uri, get_docset]
+ # end
+
+ # entries
+ # end
+
+ def include_default_entry?
+ return false if EXCLUDED_SLUGS.include? slug
+ return true
+ end
+ end
+ end
+end
diff --git a/lib/docs/filters/javascript/clean_html.rb b/lib/docs/filters/javascript/clean_html.rb
index a4f07fc8ca..cfec06a009 100644
--- a/lib/docs/filters/javascript/clean_html.rb
+++ b/lib/docs/filters/javascript/clean_html.rb
@@ -1,17 +1,27 @@
module Docs
class Javascript
- class CleanHtmlFilter < Filter
+ class CleanHtmlFilter < Docs::ReflyFilter
+
+ BROKEN_LINKS = [
+ 'en-us/docs/web/guide/prefixes',
+ 'global_objects/simd/clamp',
+ 'webkit_nightly'
+ ]
+ REPLACED_LINKS = {
+ 'functions/strict_mode' => 'strict_mode',
+ 'strict_mode' => 'strict_mode'
+
+ }
def call
root_page? ? root : other
+ WrapPreContentWithCode 'hljs javascript'
+ WrapContentWithDivs '_page _javascript'
doc
end
def root
- # Move "Global Objects" lists to the same level as the other ones
- css('#Global_Objects + p').remove
- div = at_css '#Global_Objects + div'
- div.css('h3').each { |node| node.name = 'h2' }
- at_css('#Global_Objects').replace(div.children)
+ #Cleaning content
+ css('footer','div.article-meta', '.submenu', 'div.wiki-block', 'nav', '.toc', '#nav-access', '#main-header', '.title').remove
# Remove heading links
css('h2 > a').each do |node|
@@ -21,6 +31,39 @@ def root
end
def other
+ #Cleaning content
+ css('footer','div.article-meta', '.submenu', 'div.wiki-block', 'nav', '.toc', '#nav-access', '#main-header', '.title').remove
+ css('a[href]').each do |node|
+ node['href'] = CleanWrongCharacters(node['href']).remove '_(event)'
+ if !node['href'].start_with? 'http://' and !node['href'].start_with? 'https://' and !node['href'].start_with? 'ftp://' and !node['href'].start_with? 'irc://' and !node['href'].start_with? 'mailto:'
+ if node['class'] == 'new'
+ node['class'] = 'broken'
+ node['title'] = ''
+ elsif REPLACED_LINKS[node['href'].remove! '../']
+ node['href'] = REPLACED_LINKS[node['href'].remove! '../']
+ elsif BROKEN_LINKS.include?node['href'].downcase.remove! '../'
+ node['class'] = 'broken'
+ else
+ sluglist = slug.split('/')
+ nodelist = node['href'].split('/')
+ newhref = []
+ nodelist.each do |item|
+ if item == '..'
+ sluglist.pop
+ else
+ newhref << item
+ end
+ end
+ sluglist.pop
+ if sluglist.size>0
+ node['href'] = sluglist.join('/') + '/' + newhref.join('/')
+ else
+ node['href'] = newhref.join('/')
+ end
+ end
+ end
+ end
+
# Remove "style" attribute
css('.inheritsbox', '.overheadIndicator').each do |node|
node.remove_attribute 'style'
diff --git a/lib/docs/filters/javascript/entries.rb b/lib/docs/filters/javascript/entries.rb
index b8ed5eb170..784fe71a2c 100644
--- a/lib/docs/filters/javascript/entries.rb
+++ b/lib/docs/filters/javascript/entries.rb
@@ -1,66 +1,78 @@
module Docs
class Javascript
- class EntriesFilter < Docs::EntriesFilter
+ class EntriesFilter < Docs::ReflyEntriesFilter
TYPES = %w(Array ArrayBuffer Boolean DataView Date Function Intl JSON Map
Math Number Object Promise RegExp Set String Symbol TypedArray WeakMap
WeakSet)
INTL_OBJECTS = %w(Collator DateTimeFormat NumberFormat)
- def get_name
- if slug.start_with? 'Global_Objects/'
- name, method = *slug.sub('Global_Objects/', '').split('/')
- name.prepend 'Intl.' if INTL_OBJECTS.include?(name)
+ EXCLUDED_PATH = ['MDN','Web technology for developers', 'JavaScript']
+ def get_name
+ name = css('h1').first.content
+ if name == ''
+ name = slug
+ end
+ name
+ end
- if method
- unless method == method.upcase || method == 'NaN'
- method = method[0].downcase + method[1..-1] # e.g. Trim => trim
- end
- name << ".#{method}"
- end
+ def get_docset
+ docset = context[:root_title]
+ docset
+ end
- name
+ def get_parsed_uri
+ if get_parent_uri == 'null'
+ parsed_uri = context[:docset_uri] + '/' + self.urilized(get_name.remove '%')
else
- name = super
- name.remove! 'Functions.'
- name.remove! 'Functions and function scope.'
- name.remove! 'Operators.'
- name.remove! 'Statements.'
- name
+ parsed_uri = get_parent_uri + '/' + self.urilized(get_name.remove '%')
end
+ parsed_uri
+ end
+
+ def get_parent_uri
+ parent_uri = context[:docset_uri]
+ css('.crumb a').each do |node|
+ link = node.content
+ if not EXCLUDED_PATH.include? link
+ parent_uri += '/' + self.urilized(link)
+ end
+ end
+ if parent_uri == context[:docset_uri]
+ parent_uri = 'null'
+ end
+ parent_uri
end
def get_type
- if slug.start_with? 'Statements'
- 'Statements'
- elsif slug.start_with? 'Operators'
- 'Operators'
- elsif slug.start_with?('Functions_and_function_scope') || slug.start_with?('Functions') || slug.include?('GeneratorFunction')
- 'Function'
- elsif slug.start_with? 'Global_Objects'
- object, method = *slug.remove('Global_Objects/').split('/')
- if object.end_with? 'Error'
- 'Errors'
- elsif INTL_OBJECTS.include?(object)
- 'Intl'
- elsif method || TYPES.include?(object)
- object
- else
- 'Global Objects'
- end
+ node = css('#Syntax')
+ if node.inner_text == 'Constructor'
+ 'class'
+ elsif node.inner_text == 'Syntax'
+ 'method'
else
- 'Miscellaneous'
+ if slug.start_with? 'Statements'
+ 'statements'
+ elsif slug.start_with? 'Operators'
+ 'expression'
+ elsif slug.start_with?('Functions_and_function_scope') || slug.start_with?('Functions') || slug.include?('GeneratorFunction')
+ 'function'
+ elsif slug.start_with? 'Global_Objects'
+ 'class'
+ else
+ 'others'
+ end
end
end
def include_default_entry?
- node = doc.at_css '.overheadIndicator'
+ #node = doc.at_css '.overheadIndicator'
# Can't use :first-child because #doc is a DocumentFragment
- return true unless node && node.parent == doc && !node.previous_element
+ return true #unless node && node.parent == doc && !node.previous_element
- !node.content.include?('not on a standards track') &&
- !node.content.include?('removed from the Web') &&
- !node.content.include?('could be removed at any time')
+ #!node.content.include?('not on a standards track') &&
+ #!node.content.include?('removed from the Web') &&
+ #!node.content.include?('could be removed at any time')
end
end
end
diff --git a/lib/docs/filters/jest/clean_html.rb b/lib/docs/filters/jest/clean_html.rb
new file mode 100644
index 0000000000..ccb83682c2
--- /dev/null
+++ b/lib/docs/filters/jest/clean_html.rb
@@ -0,0 +1,68 @@
+module Docs
+ class Jest
+ class CleanHtmlFilter < Docs::ReflyFilter
+ BROKEN_LINKS = []
+ REPLACED_LINKS = {}
+ def call
+ @doc = at_css('.inner-content')
+
+ if root_page?
+ at_css('h1').content = 'React Documentation'
+ end
+ css('div.prism.language-javascript').each do |node|
+ node.name = 'pre'
+ node['class'] = ''
+ end
+ css('.docs-prevnext', '.hash-link', '.edit-page-link').remove
+
+ css('.highlight').each do |node|
+ node.name = 'pre'
+ node['data-lang'] = node.at_css('[data-lang]')['data-lang']
+ node.content = node.content
+ end
+
+ css('blockquote > p:first-child').each do |node|
+ node.remove if node.content.strip == 'Note:'
+ end
+
+ fixLinks
+ WrapPreContentWithCode 'hljs javascript'
+ WrapContentWithDivs '_page _jest'
+ doc
+ end
+ def fixLinks
+ css('a[href]').each do |node|
+ node['href'] = CleanWrongCharacters(node['href']).downcase
+ if REPLACED_LINKS[node['href'].downcase.remove! '../']
+ node['href'] = REPLACED_LINKS[node['href'].remove '../']
+ elsif !node['href'].start_with? 'http://' and !node['href'].start_with? '#' and !node['href'].start_with? 'https://' and !node['href'].start_with? 'ftp://' and !node['href'].start_with? 'irc://' and !node['href'].start_with? 'news://' and !node['href'].start_with? 'mailto:'
+ if node['class'] == 'new'
+ node['class'] = 'broken'
+ node['title'] = ''
+ else
+ sluglist = slug.split('/')
+ if context[:url].to_s.include? '.html'
+ sluglist.pop
+ end
+ nodelist = sluglist + node['href'].split('/')
+ newhref = []
+ nodelist.each do |item|
+ if item == '..'
+ newhref.pop
+ elsif item != ''
+ newhref << item
+ end
+ end
+ node['href'] = newhref.join('/')
+ end
+ end
+ if BROKEN_LINKS.include? node['href'].downcase.remove! '../'
+ node['class'] = 'broken'
+ end
+ node['href'] = REPLACED_LINKS[node['href']] || node['href']
+ end
+
+ end
+ end
+ end
+end
diff --git a/lib/docs/filters/jest/entries.rb b/lib/docs/filters/jest/entries.rb
new file mode 100644
index 0000000000..26bdc8dff6
--- /dev/null
+++ b/lib/docs/filters/jest/entries.rb
@@ -0,0 +1,85 @@
+module Docs
+ class Jest
+ class EntriesFilter < Docs::ReflyEntriesFilter
+ API_SLUGS = %w(
+ docs/getting-started
+ docs/tutorial
+ docs/tutorial-jquery
+ docs/tutorial-coffeescript
+ docs/tutorial-react
+ docs/common-js-testing
+ docs/automatic-mocking
+ docs/mock-functions
+ docs/manual-mocks
+ docs/timer-mocks
+ docs/api
+ )
+
+ def get_name
+ at_css('h1').child.content.strip
+ end
+
+ def get_docset
+ docset = context[:root_title]
+ docset
+ end
+
+ def get_parsed_uri_by_name(name)
+ if get_parent_uri == 'null'
+ parsed_uri = context[:docset_uri] + '/' + self.urilized(name)
+ else
+ parsed_uri = get_parent_uri + '/' + self.urilized(name)
+ end
+ parsed_uri
+ end
+
+ def get_parsed_uri
+ parsed_uri = context[:docset_uri] + '/' + self.urilized(get_name)
+ parsed_uri
+ end
+
+ def get_parent_uri
+ 'null'
+ end
+
+ def get_type
+ if slug.downcase.include? 'tutorial' or slug.downcase.include? 'manual'
+ 'guide'
+ elsif slug.downcase.include? 'functions' or slug.downcase.include? 'timer' or slug.downcase.include? 'mocking'
+ 'function'
+ elsif slug.downcase.include? 'event'
+ 'event'
+ elsif slug.downcase.include? 'api'
+ 'api'
+ else
+ 'others'
+ end
+ end
+
+ def additional_entries
+ if API_SLUGS.include?(slug)
+ css('.inner-content h3, .inner-content h4').map do |node|
+ name = node.content
+ name.remove! %r{[#\(\)]}
+ name.remove! %r{\w+\:}
+ id = node.at_css('.anchor')['name']
+ custom_parsed_uri = get_parsed_uri_by_name(name)
+ [name, id, get_type, custom_parsed_uri, get_parent_uri, get_docset]
+
+ end
+ else
+ css('.props > .prop > .propTitle').each_with_object([]) do |node, entries|
+ name = node.children.find(&:text?).try(:content)
+ next if name.blank?
+ sep = node.content.include?('static') ? '.' : '#'
+ name.prepend(self.name + sep)
+ name << '()' if node.css('.propType').last.content.start_with?('(')
+ id = node.at_css('.anchor')['name']
+ custom_parsed_uri = get_parsed_uri_by_name(name)
+ entries << [name, id, get_type, custom_parsed_uri, get_parent_uri, get_docset]
+ end
+ end
+ end
+ end
+ end
+end
diff --git a/lib/docs/filters/jquery/clean_html.rb b/lib/docs/filters/jquery/clean_html.rb
index 787021ec1e..3e1631b187 100644
--- a/lib/docs/filters/jquery/clean_html.rb
+++ b/lib/docs/filters/jquery/clean_html.rb
@@ -1,6 +1,13 @@
module Docs
class Jquery
- class CleanHtmlFilter < Filter
+ class CleanHtmlFilter < Docs::ReflyFilter
+ BROKEN_LINKS = [
+ 'content-grids'
+ ]
+ REPLACED_LINKS = {
+ 'stacking-elements' => 'theming/stacking-elements',
+ 'jquery.cssnumer' => 'jquery.cssnumber'
+ }
def call
css('hr', '.icon-link', '.entry-meta').remove
@@ -18,6 +25,19 @@ def call
end
end
+ #fix links
+ css('a[href]').each do |node|
+ if !node['href'].start_with? 'http://' and !node['href'].start_with? 'https://'
+ node['href'] = CleanWrongCharacters(node['href']).remove '../'
+ if BROKEN_LINKS.include? node['href'].downcase
+ node['class'] = 'broken'
+ # node['href'] = context[:domain] + '/help#brokenlink'
+ elsif REPLACED_LINKS[node['href'].downcase.remove! '../']
+ node['href'] = REPLACED_LINKS[node['href'].remove '../']
+ end
+ end
+ end
+
# Remove useless
css('.entry-header > .entry-title', 'header > .underline', 'header > h2:only-child').to_a.uniq.each do |node|
node.parent.replace node
@@ -33,7 +53,8 @@ def call
css('dd > dl').each do |node|
node.parent.replace(node)
end
-
+ WrapPreContentWithCode 'hljs javascript'
+ WrapContentWithDivs '_page _jquery'
doc
end
end
diff --git a/lib/docs/filters/jquery/clean_urls.rb b/lib/docs/filters/jquery/clean_urls.rb
index a7ad86c0a1..203e7e12fd 100644
--- a/lib/docs/filters/jquery/clean_urls.rb
+++ b/lib/docs/filters/jquery/clean_urls.rb
@@ -1,6 +1,6 @@
module Docs
class Jquery
- class CleanUrlsFilter < Filter
+ class CleanUrlsFilter < Docs::ReflyFilter
def call
html.gsub! 'local.api.jquery', 'api.jquery'
html
diff --git a/lib/docs/filters/jquery_core/entries.rb b/lib/docs/filters/jquery_core/entries.rb
index 218be381bb..879c6758c5 100644
--- a/lib/docs/filters/jquery_core/entries.rb
+++ b/lib/docs/filters/jquery_core/entries.rb
@@ -1,10 +1,24 @@
module Docs
class JqueryCore
- class EntriesFilter < Docs::EntriesFilter
+ class EntriesFilter < Docs::ReflyEntriesFilter
# Ordered by precedence
+ ENTRIES_SLUG = %w(api config creating-packages)
TYPES = ['Ajax', 'Selectors', 'Callbacks Object', 'Deferred Object',
'Data', 'Utilities', 'Events', 'Effects', 'Offset', 'Dimensions',
'Traversing', 'Manipulation']
+ REPLACE_TYPES = {
+ 'Traversing' => 'function',
+ 'Effects' => 'function',
+ 'Utilities' => 'function',
+ 'Ajax' => 'data',
+ 'Data' => 'data',
+ 'Events' => 'event',
+ 'Callbacks Object' => 'object',
+ 'Deferred Object' => 'object',
+ 'Selectors' => 'selector',
+ 'Manipulation' => 'method',
+ 'Offset' => 'method',
+ 'Dimensions' => 'property'}
def get_name
name = at_css('h1').content.strip
@@ -12,14 +26,60 @@ def get_name
name
end
+ def get_docset
+ docset = context[:root_title]
+ docset
+ end
+
+ def get_parsed_uri_by_name(name)
+ if get_parent_uri == 'null'
+ parsed_uri = context[:docset_uri] + '/' + self.urilized(name)
+ else
+ parsed_uri = get_parent_uri + '/' + self.urilized(name)
+ end
+ parsed_uri
+ end
+
+ def get_parsed_uri_by_name(name)
+ get_parsed_uri + '/' + self.urilized(name)
+ end
+
+ def get_parsed_uri
+ if get_parent_uri == 'null'
+ parsed_uri = context[:docset_uri] + '/' + self.urilized(get_name)
+ else
+ parsed_uri = get_parent_uri + '/' + self.urilized(get_name)
+ end
+ parsed_uri
+ end
+
+ def get_parent_uri
+ subpath = *path.sub('/index', '').split('/')
+ if subpath.length > 1
+ parent_uri = (context[:docset_uri]+ '/' + subpath[0,subpath.size-1].join('/')).downcase
+ else
+ parent_uri = 'null'
+ end
+ end
+
+ def additional_entries
+ return [] if root_page?
+
+ css('h3[id]', 'h2[id]').map do |node|
+ name = node.content
+ custom_parsed_uri = get_parsed_uri_by_name(name)
+ [name, node['id'], get_type, custom_parsed_uri, get_parent_uri, get_docset]
+ end
+ end
+
def get_type
- return 'Ajax' if slug == 'Ajax_Events'
+ return 'data' if slug == 'Ajax_Events'
categories = css 'span.category'
types = categories.map { |node| node.at_css('a').content.strip }
types.map! { |type| TYPES.index(type) }
types.compact!
types.sort!
- types.empty? ? 'Miscellaneous' : TYPES[types.first]
+ types.empty? ? 'others' : REPLACE_TYPES[TYPES[types.first]]
end
end
end
diff --git a/lib/docs/filters/jquery_mobile/entries.rb b/lib/docs/filters/jquery_mobile/entries.rb
index eb52c097dc..5e6281e8f2 100644
--- a/lib/docs/filters/jquery_mobile/entries.rb
+++ b/lib/docs/filters/jquery_mobile/entries.rb
@@ -1,8 +1,13 @@
module Docs
class JqueryMobile
- class EntriesFilter < Docs::EntriesFilter
+ class EntriesFilter < Docs::ReflyEntriesFilter
# Ordered by precedence
TYPES = %w(Widgets Events Properties Methods)
+ REPLACE_TYPES = {
+ 'Widgets' => 'function',
+ 'Events' => 'event',
+ 'Properties' => 'property',
+ 'Methods' => 'method'}
def get_name
name = at_css('h1').content.strip
@@ -12,13 +17,53 @@ def get_name
name
end
+ def get_docset
+ docset = context[:root_title]
+ docset
+ end
+
+ def get_parsed_uri_by_name(name)
+ get_parsed_uri + '/' + self.urilized(name)
+ end
+
+ def get_parsed_uri
+ if get_parent_uri == 'null'
+ parsed_uri = context[:docset_uri] + '/' + self.urilized(get_name)
+ else
+ parsed_uri = get_parent_uri + '/' + self.urilized(get_name)
+ end
+ parsed_uri
+ end
+
+ def get_parent_uri
+ subpath = *path.sub('/index', '').split('/')
+ if subpath.length > 1
+ parent_uri = (context[:docset_uri]+ '/' + subpath[0,subpath.size-1].join('/')).downcase
+ else
+ parent_uri = 'null'
+ end
+ end
+
def get_type
categories = css 'span.category'
types = categories.map { |node| node.at_css('a').content.strip }
types.map! { |type| TYPES.index(type) }
types.compact!
types.sort!
- types.empty? ? 'Miscellaneous' : TYPES[types.first]
+ types.empty? ? 'others' : REPLACE_TYPES[TYPES[types.first]]
+ end
+
+ def additional_entries
+ entries = []
+ return [] if root_page?
+ css('[id].api-item > h3').each do |node|
+ node.at_css('.returns').remove if node.at_css('.returns')
+ name = node.content
+ id = node.parent['id']
+ custom_parsed_uri = get_parsed_uri_by_name(name)
+ entries << [name, id, get_type, custom_parsed_uri, get_parent_uri, get_docset]
+ end
+ entries
end
end
end
diff --git a/lib/docs/filters/jquery_ui/entries.rb b/lib/docs/filters/jquery_ui/entries.rb
index 94e181d43d..9c809f7ead 100644
--- a/lib/docs/filters/jquery_ui/entries.rb
+++ b/lib/docs/filters/jquery_ui/entries.rb
@@ -1,8 +1,14 @@
module Docs
class JqueryUi
- class EntriesFilter < Docs::EntriesFilter
+ class EntriesFilter < Docs::ReflyEntriesFilter
# Ordered by precedence
TYPES = ['Widgets', 'Selectors', 'Effects', 'Interactions', 'Methods']
+ REPLACE_TYPES = {
+ 'Widgets' => 'function',
+ 'Selectors' => 'selector',
+ 'Effects' => 'function',
+ 'Interactions' => 'method',
+ 'Methods' => 'method'}
def get_name
name = at_css('h1').content.strip
@@ -11,14 +17,51 @@ def get_name
name
end
+ def get_docset
+ docset = context[:root_title]
+ docset
+ end
+
+ def get_parsed_uri_by_name(name)
+ get_parsed_uri + '/' + self.urilized(name)
+ end
+
+ def get_parsed_uri
+ parsed_uri = context[:docset_uri] + '/' + path.sub('/index', '')
+ parsed_uri
+ end
+
+ def get_parent_uri
+ subpath = *path.sub('/index', '').split('/')
+ if subpath.length > 1
+ parent_uri = (context[:docset_uri]+ '/' + subpath[0,subpath.size-1].join('/')).downcase
+ else
+ parent_uri = 'null'
+ end
+ end
+
def get_type
- categories = css 'span.category'
- types = categories.map { |node| node.at_css('a').content.strip }
+ categories = css 'span.category > a'
+ types = categories.map { |node| node.content.strip }
types.map! { |type| TYPES.index(type) }
types.compact!
types.sort!
- types.empty? ? 'Miscellaneous' : TYPES[types.first]
+ types.empty? ? 'others' : REPLACE_TYPES[TYPES[types.first]]
end
+
+ def additional_entries
+ entries = []
+ return [] if root_page?
+ css('[id].api-item > h3').each do |node|
+ node.at_css('.returns').remove if node.at_css('.returns')
+ name = node.content
+ id = node.parent['id']
+ custom_parsed_uri = get_parsed_uri_by_name(name)
+ entries << [name, id, get_type, custom_parsed_uri, get_parent_uri, get_docset]
+ end
+ entries
+ end
+
end
end
end
diff --git a/lib/docs/filters/knex/clean_html.rb b/lib/docs/filters/knex/clean_html.rb
new file mode 100644
index 0000000000..2292d9ecc9
--- /dev/null
+++ b/lib/docs/filters/knex/clean_html.rb
@@ -0,0 +1,51 @@
+module Docs
+ class Knex
+ class CleanHtmlFilter < Docs::ReflyFilter
+ BROKEN_LINKS = []
+ REPLACED_LINKS = {}
+ def call
+ css('p img').remove
+ fixLinks
+ WrapPreContentWithCode 'hljs javascript'
+ WrapContentWithDivs '_page _knex'
+ doc
+ end
+ def fixLinks
+ css('a[href]').each do |node|
+ node['href'] = CleanWrongCharacters(node['href']).downcase
+ if REPLACED_LINKS[node['href'].downcase.remove! '../']
+ node['href'] = REPLACED_LINKS[node['href'].remove '../']
+ elsif !node['href'].start_with? 'http://' and !node['href'].start_with? '#' and !node['href'].start_with? 'https://' and !node['href'].start_with? 'ftp://' and !node['href'].start_with? 'irc://' and !node['href'].start_with? 'news://' and !node['href'].start_with? 'mailto:'
+ if node['href'].start_with? 'javascript:'
+ node['href']='#'
+ node.name='span'
+ elsif node['class'] == 'new'
+ node['class'] = 'broken'
+ node['title'] = ''
+ else
+ sluglist = slug.split('/')
+ if context[:url].to_s.include? '.html'
+ sluglist.pop
+ end
+ nodelist = sluglist + node['href'].split('/')
+ newhref = []
+ nodelist.each do |item|
+ if item == '..'
+ newhref.pop
+ elsif item != ''
+ newhref << item
+ end
+ end
+ node['href'] = newhref.join('/')
+ end
+ end
+ if BROKEN_LINKS.include? node['href'].downcase.remove! '../'
+ node['class'] = 'broken'
+ end
+ node['href'] = REPLACED_LINKS[node['href']] || node['href']
+ end
+
+ end
+ end
+ end
+end
diff --git a/lib/docs/filters/knex/entries.rb b/lib/docs/filters/knex/entries.rb
new file mode 100644
index 0000000000..dfc17dba82
--- /dev/null
+++ b/lib/docs/filters/knex/entries.rb
@@ -0,0 +1,72 @@
+module Docs
+ class Knex
+ class EntriesFilter < Docs::ReflyEntriesFilter
+
+ def get_name
+ 'Index'
+ end
+
+ def get_docset
+ docset = context[:root_title]
+ docset
+ end
+
+ def get_parsed_uri_by_name(name)
+ if get_parent_uri == 'null'
+ parsed_uri = context[:docset_uri] + '/' + self.urilized(name)
+ else
+ parsed_uri = get_parent_uri + '/' + self.urilized(name)
+ end
+ parsed_uri
+ end
+
+ def get_parsed_uri
+ parsed_uri = context[:docset_uri] + '/' + self.urilized(get_name)
+ parsed_uri
+ end
+
+ def get_parent_uri
+ 'null'
+ end
+
+ def get_type
+ 'others'
+ end
+
+ def get_type_by_id(id)
+ if id.starts_with? 'Schema'
+ type = 'function'
+ elsif id.starts_with? 'Raw'
+ type = 'expression'
+ elsif id.starts_with? 'Chainable'
+ type = 'method'
+ elsif id.starts_with? 'Promises' or id.starts_with? 'Interfaces'
+ type = 'interface'
+ elsif id.starts_with? 'Events'
+ type = 'event'
+ elsif id.starts_with? 'Migrations'
+ type = 'migrations'
+ else
+ type = 'others'
+ end
+ type
+ end
+
+ def additional_entries
+ entries = []
+ css('h2[id]', 'h3[id]', 'p[id]').each do |node|
+ if node.name == 'p'
+ id = node['id']
+ name = node.css('b').first.content.strip.remove ':'
+ else
+ id = node['id']
+ name = node.content.strip.remove ':'
+ end
+ custom_parsed_uri = get_parsed_uri_by_name(name)
+ entries << [name, id, get_type_by_id(id), custom_parsed_uri, get_parent_uri, get_docset]
+ end
+ entries
+ end
+ end
+ end
+end
diff --git a/lib/docs/filters/knockout/clean_html.rb b/lib/docs/filters/knockout/clean_html.rb
index 17c1e60311..d70c2e6d69 100644
--- a/lib/docs/filters/knockout/clean_html.rb
+++ b/lib/docs/filters/knockout/clean_html.rb
@@ -1,13 +1,14 @@
module Docs
class Knockout
- class CleanHtmlFilter < Filter
+ class CleanHtmlFilter < Docs::ReflyFilter
def call
root_page? ? root : other
-
+ @doc['class'] = ''
css('pre > code').each do |node|
node.before(node.children).remove
end
-
+ WrapPreContentWithCode 'hljs actionscript'
+ WrapContentWithDivs '_page _knockout'
doc
end
diff --git a/lib/docs/filters/knockout/entries.rb b/lib/docs/filters/knockout/entries.rb
index 910c4d8bdf..bfef77379a 100644
--- a/lib/docs/filters/knockout/entries.rb
+++ b/lib/docs/filters/knockout/entries.rb
@@ -1,6 +1,6 @@
module Docs
class Knockout
- class EntriesFilter < Docs::EntriesFilter
+ class EntriesFilter < Docs::ReflyEntriesFilter
NAME_BY_SLUG = {
'custom-bindings' => 'Custom bindings',
'custom-bindings-controlling-descendant-bindings' => 'Descendant bindings',
@@ -22,18 +22,38 @@ def get_name
end
def get_type
+ name = get_name
if name =~ /observable/i || slug =~ /extender/
- 'Observables'
- elsif slug.include?('binding') && !name.end_with?('binding')
- 'Binding'
- elsif slug.include? 'binding'
- 'Bindings'
- elsif slug.include? 'plugin'
- 'Plugins'
+ 'object'
+ elsif slug.include?('binding')
+ 'binding'
+ elsif name.include? 'function'
+ 'function'
+ elsif name.include? 'Event'
+ 'event'
else
- 'Miscellaneous'
+ 'others'
end
end
+
+ def get_docset
+ docset = context[:root_title]
+ docset
+ end
+
+ def get_parsed_uri
+ if get_parent_uri == 'null'
+ parsed_uri = context[:docset_uri] + '/' + self.urilized(get_name)
+ else
+ parsed_uri = get_parent_uri + '/' + self.urilized(get_name)
+ end
+ parsed_uri
+ end
+
+ def get_parent_uri
+ 'null'
+ end
+
end
end
end
diff --git a/lib/docs/filters/laravel/clean_html.rb b/lib/docs/filters/laravel/clean_html.rb
index fca4d6444b..9738542269 100644
--- a/lib/docs/filters/laravel/clean_html.rb
+++ b/lib/docs/filters/laravel/clean_html.rb
@@ -1,25 +1,64 @@
module Docs
class Laravel
- class CleanHtmlFilter < Filter
+ class CleanHtmlFilter < Docs::ReflyFilter
+
+ BROKEN_LINKS = [
+ ]
+ REPLACED_LINKS = {
+ }
+
def call
if subpath.start_with?('/api')
api
else
other
end
+ css('a[href]').each do |node|
+ node['href'] = CleanWrongCharacters(node['href'])
+ if !node['href'].start_with? 'http://' and !node['href'].start_with? 'https://'
+ if REPLACED_LINKS[node['href'].downcase.remove! '../']
+ node['href'] = REPLACED_LINKS[node['href'].remove '../']
+ elsif BROKEN_LINKS.include? node['href'].downcase.remove! '../'
+ node['class'] = 'broken'
+ else
+ sluglist = slug.split('/')
+ nodelist = node['href'].split('/')
+ newhref = []
+ nodelist.each do |item|
+ if item == '..'
+ sluglist.pop
+ elsif item != 'api' and item != '5.0'
+ newhref << item
+ end
+ end
+ sluglist.pop
+ if sluglist.size>0
+ node['href'] = sluglist.join('/') + '/' + newhref.join('/')
+ else
+ node['href'] = newhref.join('/')
+ end
+ end
+ end
+ end
+ WrapPreContentWithCode 'hljs actionscript'
+ WrapContentWithDivs '_page _laravel'
doc
end
def api
- css('#footer', '.location').remove
-
+ css('#footer', '.location','#site-nav', '#left-column', '.namespace-breadcrumbs').remove
# Replace .header with
css('.header > h1').each do |node|
node.parent.before(node).remove
node.content = 'Laravel' if root_page?
end
+ # wrapping NameSpacelist
+ css('.namespace-list').first.name = 'ul' if css('.namespace-list') and css('.namespace-list').first
+ nodes = css('.namespace-list > a')
+ nodes.wrap("
")
+
# Remove
css('a > abbr').each do |node|
node.parent['title'] = node['title']
diff --git a/lib/docs/filters/laravel/entries.rb b/lib/docs/filters/laravel/entries.rb
index 3a0da2c9bc..a6e2685994 100644
--- a/lib/docs/filters/laravel/entries.rb
+++ b/lib/docs/filters/laravel/entries.rb
@@ -1,40 +1,144 @@
module Docs
class Laravel
- class EntriesFilter < Docs::EntriesFilter
+ class EntriesFilter < Docs::ReflyEntriesFilter
+ REPLACE_TYPE = {
+ 'Pagination' => 'class',
+ 'Cookie\Middleware' => 'network',
+ 'Routing\Controllers' => 'network',
+ 'Session' => 'network',
+ 'Routing' => 'network',
+ 'Console' => 'console',
+ 'Events' => 'event',
+ 'Auth' => 'security',
+ 'Filesystem' => 'io',
+ 'Bus' => 'network',
+ 'Container' => 'class',
+ 'Queue' => 'class',
+ 'Support' => 'class',
+ 'Validation' => 'class',
+ 'Workbench' => 'utils',
+ 'Exception' => 'object',
+ 'Html' => 'object',
+ 'Redis' => 'object',
+ 'Cache' => 'object',
+ 'Cookie' => 'object',
+ 'Foundation\Bus' => 'others',
+ 'Mail' => 'network',
+ 'Log' => 'object',
+ 'Encryption' => 'class',
+ 'Config' => 'configuration',
+ 'View' => 'class',
+ 'Translation' => 'class',
+ 'Auth.Middleware' => 'security',
+ 'Foundation.Auth' => 'security',
+ 'Contracts.Auth' => 'security',
+ 'Auth.Passwords' => 'security',
+ 'Auth.Console' => 'security',
+ 'Auth.Reminders' => 'security',
+ 'Foundation' => 'class',
+ 'Pipeline' => 'object',
+ 'Http' => 'network',
+ 'IlluminateQueueClosure' => 'class',
+ 'Illuminate' => 'class',
+ 'index' => 'others',
+ 'Hashing' => 'class',
+ }
+ EXCLUDED_PATH = []
def get_name
if api_page?
- at_css('h1').content.strip.split('\\').last
+ breadcrumbs = xpath('//ol[@class="breadcrumb"]/li')
+ if breadcrumbs.size>0
+ name = breadcrumbs.pop.content.strip
+ else
+ name = at_css('h1').content.strip
+ end
+ name
else
at_css('h1').content.strip
end
end
- def get_type
- if api_page?
- type = at_css('h1').content.strip.remove('Illuminate\\').remove(/\\\w+?\z/)
- type.end_with?('Console') ? type.split('\\').first : type
+ def get_docset
+ docset = context[:root_title]
+ docset
+ end
+
+ def get_parsed_uri_by_name(name)
+ if get_parent_uri == 'null'
+ parsed_uri = context[:docset_uri] + '/' + self.urilized(name)
+ else
+ parsed_uri = get_parent_uri + '/' + self.urilized(name)
+ end
+ parsed_uri
+ end
+
+ def get_parsed_uri
+ if get_parent_uri == 'null'
+ parsed_uri = context[:docset_uri] + '/' + self.urilized(get_name)
else
- 'Guides'
+ parsed_uri = get_parent_uri + '/' + self.urilized(get_name)
+ end
+ parsed_uri
+ end
+
+ def get_parent_uri
+ parent_uri = context[:docset_uri]
+ breadcrumbs = xpath('//ol[@class="breadcrumb"]//a/text()')
+ breadcrumbswithreference = xpath('//ol[@class="breadcrumb"]/li')
+ breadcrumbswithreference.shift
+ if breadcrumbs.size==breadcrumbswithreference.size and breadcrumbs.size>0
+ breadcrumbs.pop
+ end
+ breadcrumbs.each do |node|
+ link = node.content.strip
+ if not EXCLUDED_PATH.include? link
+ parent_uri += '/' + self.urilized(link)
+ end
+ end
+ if parent_uri == context[:docset_uri]
+ parent_uri = 'null'
+ end
+ parent_uri
+ end
+
+ def get_type
+ return 'guide' unless api_page?
+ type = slug.remove('api/5.0/').remove('Illuminate/').remove(/\/\w+?\z/).gsub('/', '.')
+ if type.start_with? 'Database'
+ type = 'database'
+ elsif type.include? 'Auth'
+ type = 'security'
+ elsif type.start_with?('Contracts')
+ type = 'class'
+ elsif type.include? '.'
+ type = 'class'
end
+ REPLACE_TYPE[type] || type
end
+
def additional_entries
- return [] unless api_page?
+ return [] if root_page? || !api_page?
+ base_name = self.name.remove(/\(.+\)/).strip
css('h3[id^="method_"]').each_with_object [] do |node, entries|
next if node.at_css('.location').content.start_with?('in')
name = node['id'].remove('method_')
- name.prepend "#{self.name}::"
+ name.prepend "#{base_name}::"
name << '()'
-
- entries << [name, node['id']]
+ custom_parsed_uri = get_parsed_uri_by_name(name)
+ entries << [name, node['id'], get_type, custom_parsed_uri, get_parsed_uri, get_docset]
end
end
def api_page?
subpath.start_with?('/api')
end
+
+ def include_default_entry?
+ subpath != '/api/5.0/classes.html'
+ end
end
end
-end
+end
\ No newline at end of file
diff --git a/lib/docs/filters/less/clean_html.rb b/lib/docs/filters/less/clean_html.rb
index 9075ae03e8..b59a31c888 100644
--- a/lib/docs/filters/less/clean_html.rb
+++ b/lib/docs/filters/less/clean_html.rb
@@ -1,6 +1,6 @@
module Docs
class Less
- class CleanHtmlFilter < Filter
+ class CleanHtmlFilter < Docs::ReflyFilter
def call
css('.anchor-target').each do |node|
node.parent['id'] = node['id']
@@ -29,6 +29,8 @@ def call
node.content = node.content
end
+ WrapPreContentWithCode 'hljs less'
+ WrapContentWithDivs '_page _less'
doc
end
end
diff --git a/lib/docs/filters/less/entries.rb b/lib/docs/filters/less/entries.rb
index b37295a7f8..962d1abf04 100644
--- a/lib/docs/filters/less/entries.rb
+++ b/lib/docs/filters/less/entries.rb
@@ -1,12 +1,41 @@
module Docs
class Less
- class EntriesFilter < Docs::EntriesFilter
- def name
+ class EntriesFilter < Docs::ReflyEntriesFilter
+ def get_name
at_css('h2').content
end
+ def get_docset
+ docset = context[:root_title]
+ docset
+ end
+
+ def get_parsed_uri_by_name(name)
+ context[:docset_uri] + '/' + self.urilized(name.strip)
+ end
+
+ def get_parsed_uri
+ parsed_uri = context[:docset_uri] + '/' + self.urilized(get_name)
+ parsed_uri
+ end
+
+ def get_parent_uri
+ subpath = *path.split('/')
+ if subpath.length > 1
+ parent_uri = (context[:docset_uri]+ '/' + subpath[0,subpath.size-1].join('/')).downcase
+ else
+ parent_uri = 'null'
+ end
+ end
+
def type
- root_page? ? 'Language' : nil
+ if slug.include? 'functions'
+ 'function'
+ elsif slug.include? 'features'
+ 'language'
+ else
+ 'others'
+ end
end
def additional_entries
@@ -19,27 +48,25 @@ def language_entries
css('h2').each do |node|
name = node.content.strip
name = 'Rulesets' if name == 'Passing Rulesets to Mixins'
- entries << [name, node['id']] unless name == 'Overview'
+ custom_parsed_uri = get_parsed_uri_by_name(name)
+ entries << [name, node['id'], get_type, custom_parsed_uri, get_parent_uri, get_docset] unless name == 'Overview'
end
css('h3[id^="import-options-"]').each do |node|
- entries << ["@import #{node.content}", node['id']]
+ name = "@import #{node.content}"
+ custom_parsed_uri = get_parsed_uri_by_name(name)
+ entries << [name, node['id'], get_type, custom_parsed_uri, get_parent_uri, get_docset]
end
entries.concat [
- ['@var', 'variables-feature'],
- ['@{} interpolation', 'variables-feature-variable-interpolation'],
- ['url()', 'variables-feature-urls'],
- ['@property', 'variables-feature-properties'],
- ['@@var', 'variables-feature-variable-names'],
- [':extend()', 'extend-feature'],
- [':extend(all)', 'extend-feature-extend-all-'],
- ['@arguments', 'mixins-parametric-feature-the-arguments-variable'],
- ['@rest', 'mixins-parametric-feature-advanced-arguments-and-the-rest-variable'],
- ['@import', 'import-directives-feature'],
- ['when', 'mixin-guards-feature'],
- ['.loop()', 'loops-feature'],
- ['+:', 'merge-feature'] ]
+ ['Pattern Matching', 'mixins-parametric-feature-pattern-matching', get_type, get_parsed_uri_by_name('Pattern Matching'), get_parent_uri, get_docset],
+ ['@{} interpolation', 'variables-feature-variable-interpolation', get_type, get_parsed_uri_by_name('@{} interpolation'), get_parent_uri, get_docset],
+ ['url()', 'variables-feature-urls', get_type, get_parsed_uri_by_name('url()'), get_parent_uri, get_docset],
+ ['@property', 'variables-feature-properties', get_type, get_parsed_uri_by_name('@property'), get_parent_uri, get_docset],
+ ['@@var', 'variables-feature-variable-names', get_type, get_parsed_uri_by_name('@@var'), get_parent_uri, get_docset],
+ [':extend(all)', 'extend-feature-extend-all-', get_type, get_parsed_uri_by_name('extend(all)'), get_parent_uri, get_docset],
+ ['@arguments', 'mixins-parametric-feature-the-arguments-variable', get_type, get_parsed_uri_by_name('@arguments'), get_parent_uri, get_docset],
+ ['@rest', 'mixins-parametric-feature-advanced-arguments-and-the-rest-variable', get_type, get_parsed_uri_by_name('@rest'), get_parent_uri, get_docset]]
entries
end
@@ -53,7 +80,9 @@ def function_entries
type = node.content
type.sub! %r{(.+) Functions}, 'Functions: \1'
elsif node.name == 'h4'
- entries << [node.content, node['id'], type]
+ name = node.content
+ custom_parsed_uri = get_parsed_uri_by_name(name)
+ entries << [node.content, node['id'], get_type, custom_parsed_uri, get_parent_uri, get_docset]
end
end
diff --git a/lib/docs/filters/lodash/clean_html.rb b/lib/docs/filters/lodash/clean_html.rb
index 2d4286e639..0588ab4fe5 100644
--- a/lib/docs/filters/lodash/clean_html.rb
+++ b/lib/docs/filters/lodash/clean_html.rb
@@ -1,6 +1,6 @@
module Docs
class Lodash
- class CleanHtmlFilter < Filter
+ class CleanHtmlFilter < Docs::ReflyFilter
def call
css('h3 + p', 'hr').remove
@@ -13,13 +13,8 @@ def call
css('h2', 'h3').each do |node|
node.content = node.content
end
-
- # Remove code highlighting
- css('pre').each do |node|
- node.inner_html = node.inner_html.gsub('
', "\n").gsub(' ', ' ')
- node.content = node.content
- end
-
+ WrapPreContentWithCode 'hljs coffeescript'
+ WrapContentWithDivs '_page _lodash'
doc
end
end
diff --git a/lib/docs/filters/lodash/entries.rb b/lib/docs/filters/lodash/entries.rb
index fb93b925f0..da554f7ce2 100644
--- a/lib/docs/filters/lodash/entries.rb
+++ b/lib/docs/filters/lodash/entries.rb
@@ -1,6 +1,66 @@
module Docs
class Lodash
- class EntriesFilter < Docs::EntriesFilter
+ class EntriesFilter < Docs::ReflyEntriesFilter
+ TYPENAMES = {
+ 'Methods' => 'method',
+ 'Chain' => 'method',
+ 'Math' => 'function',
+ 'Function' => 'function',
+ 'Utility' => 'function',
+ 'Lang' => 'function',
+ 'Collection' => 'collection',
+ 'Array' => 'collection',
+ 'Properties' => 'property',
+ 'Object' => 'object',
+ 'Number' => 'type',
+ 'Date' => 'type',
+ 'String' => 'type'
+ }
+ def get_docset
+ docset = context[:root_title]
+ docset
+ end
+
+ def get_parsed_uri_by_name(name)
+ if get_parent_uri == 'null'
+ parsed_uri = context[:docset_uri] + '/' + self.urilized(name)
+ else
+ parsed_uri = get_parent_uri + '/' + self.urilized(name)
+ end
+ parsed_uri
+ end
+
+ def get_parsed_uri
+ if get_parent_uri == 'null'
+ parsed_uri = context[:docset_uri] + '/' + self.urilized(get_name)
+ else
+ parsed_uri = get_parent_uri + '/' + self.urilized(get_name)
+ end
+ parsed_uri
+ end
+
+ def get_parent_uri
+ subpath = *path.split('/')
+ if subpath.size > 1
+ parent_uri = (context[:docset_uri]+ '/' + subpath[0,subpath.size-1].join('/')).downcase
+ else
+ parent_uri = 'null'
+ end
+ parent_uri
+ end
+
+ def get_type_by_name(type)
+ TYPENAMES[type] || type
+ end
+
+ def get_type
+ 'others'
+ end
+
+ def include_default_entry?
+ return false
+ end
+
def additional_entries
entries = []
@@ -11,11 +71,13 @@ def additional_entries
node.parent.css('h3').each do |heading|
name = heading.content
name.sub! %r{\(.+?\)}, '()'
- entries << [name, heading['id'], type]
+ custom_parsed_uri = get_parsed_uri_by_name(name)
+ entries << [name, heading['id'], get_type_by_name(type), custom_parsed_uri, get_parent_uri, get_docset]
if h4 = heading.parent.at_css('h4') and h4.content.strip == 'Aliases'
h4.next_element.content.split(',').each do |n|
- entries << ["#{n.strip}()", heading['id'], type]
+ custom_parsed_uri = get_parsed_uri_by_name(n)
+ entries << ["#{n.strip}()", heading['id'], get_type_by_name(type), custom_parsed_uri, get_parent_uri, get_docset]
end
end
end
diff --git a/lib/docs/filters/lua/clean_html.rb b/lib/docs/filters/lua/clean_html.rb
new file mode 100644
index 0000000000..4ba5b4ea15
--- /dev/null
+++ b/lib/docs/filters/lua/clean_html.rb
@@ -0,0 +1,32 @@
+module Docs
+ class Lua
+ class CleanHtmlFilter < Docs::ReflyFilter
+ def call
+ css('hr', 'h1 img', '.footer').remove
+
+ css('[name]').each do |node|
+ node['id'] = node['name']
+ node.remove_attribute('name')
+ end
+
+ css('h1 > a[id]', 'h2 > a[id]', 'h3 > a[id]').each do |node|
+ node.parent['id'] = node['id']
+ node.before(node.children).remove
+ end
+
+ 3.times { at_css('h1[id="1"]').previous_element.remove }
+
+ css('.apii').each do |node|
+ node.parent.previous_element << node
+ end
+
+ css('pre').each do |node|
+ node.content = node.content.remove(/\A\s*\n/).rstrip.strip_heredoc
+ end
+ WrapPreContentWithCode 'hljs c'
+ # WrapContentWithDivs '_page _lua'
+ doc
+ end
+ end
+ end
+end
diff --git a/lib/docs/filters/lua/entries.rb b/lib/docs/filters/lua/entries.rb
new file mode 100644
index 0000000000..97cf821244
--- /dev/null
+++ b/lib/docs/filters/lua/entries.rb
@@ -0,0 +1,69 @@
+module Docs
+ class Lua
+ class EntriesFilter < Docs::ReflyEntriesFilter
+ REPLACE_TYPES = {
+ 'Language' => 'language',
+ 'Standard Libraries' => 'function',
+ 'Auxiliary Library' => 'function',
+ 'Basic Concepts' => 'guide',
+ 'API' => 'api'
+ }
+ def get_name
+ 'Manual'
+ end
+
+ def get_docset
+ docset = context[:root_title]
+ docset
+ end
+
+ def get_parsed_uri_by_name(name)
+ parsed_uri = context[:docset_uri] + '/' + self.urilized(name)
+ parsed_uri
+ end
+
+ def get_parsed_uri
+ if get_parent_uri == 'null'
+ parsed_uri = context[:docset_uri] + '/' + self.urilized(get_name)
+ else
+ parsed_uri = get_parent_uri + '/' + self.urilized(get_name)
+ end
+ parsed_uri
+ end
+
+ def get_type
+ 'others'
+ end
+ def get_parent_uri
+ parent_uri = 'null'
+ parent_uri
+ end
+
+ def additional_entries
+ type = nil
+
+ doc.children.each_with_object [] do |node, entries|
+ if node.name == 'h1'
+ type = node.content.strip
+ type.remove! %r{.+\u{2013}\s+}
+ type.remove! 'The '
+ type = 'API' if type == 'Application Program Interface'
+ end
+
+ next if type && type.include?('Incompatibilities')
+ next if node.name == 'h2' && type.in?(%w(API Auxiliary\ Library Standard\ Libraries))
+
+ if node.name == 'h2' || node.name == 'h3'
+ name = node.content
+ name.remove! %r{.+\u{2013}\s+}
+ name.remove! %r{\[.+\]}
+ name.gsub! %r{\s+\(.*\)}, '()'
+ custom_parsed_uri = get_parsed_uri_by_name(name)
+ custom_parent_uri = '/lua/manual'
+ entries << [name, node['id'], REPLACE_TYPES[type] || type, custom_parsed_uri, custom_parent_uri, get_docset]
+ end
+ end
+ end
+ end
+ end
+end
diff --git a/lib/docs/filters/marionette/clean_html.rb b/lib/docs/filters/marionette/clean_html.rb
index e1337dd5d5..e3cff4a524 100644
--- a/lib/docs/filters/marionette/clean_html.rb
+++ b/lib/docs/filters/marionette/clean_html.rb
@@ -1,8 +1,10 @@
module Docs
class Marionette
- class CleanHtmlFilter < Filter
+ class CleanHtmlFilter < Docs::ReflyFilter
def call
root_page? ? root : other
+ WrapPreContentWithCode 'hljs actionscript'
+ WrapContentWithDivs '_page _marionette'
doc
end
diff --git a/lib/docs/filters/marionette/entries.rb b/lib/docs/filters/marionette/entries.rb
index 37cad2e892..4ad132cf28 100644
--- a/lib/docs/filters/marionette/entries.rb
+++ b/lib/docs/filters/marionette/entries.rb
@@ -1,12 +1,78 @@
module Docs
class Marionette
- class EntriesFilter < Docs::EntriesFilter
+ class EntriesFilter < Docs::ReflyEntriesFilter
+ REPLACED_TYPE = {
+ 'marionette.application' => 'core',
+ 'marionette.object' => 'object',
+ 'index' => 'others',
+ 'marionette.approuter' => 'configuration',
+ 'marionette.configuration' => 'configuration',
+ 'marionette.region' => 'configuration',
+ 'marionette.regionmanager' => 'configuration',
+ 'marionette.behavior' => 'function',
+ 'marionette.behaviors' => 'function',
+ 'marionette.functions' => 'function',
+ 'marionette.callbacks' => 'function',
+ 'marionette.view' => 'view',
+ 'marionette.itemview' => 'view',
+ 'marionette.collectionview' => 'view',
+ 'marionette.layoutview' => 'view',
+ 'marionette.compositeview' => 'view',
+ 'marionette.renderer' => 'view',
+ 'marionette.templatecache' => 'view',
+ 'marionette.controller' => 'module',
+ 'marionette.module' => 'module',
+ '' => '',
+
+ }
def get_name
name = at_css('h1').content.strip
name.remove!(/Marionette./)
name = name[0].upcase + name.from(1)
name
end
+
+ def get_docset
+ docset = context[:root_title]
+ docset
+ end
+
+ def get_parsed_uri_by_name(name)
+ if get_parent_uri == 'null'
+ parsed_uri = context[:docset_uri] + '/' + self.urilized(name)
+ else
+ parsed_uri = get_parsed_uri + '/' + self.urilized(name)
+ end
+ parsed_uri
+ end
+
+ def get_parsed_uri
+ if get_parent_uri == 'null'
+ parsed_uri = context[:docset_uri] + '/' + self.urilized(get_name)
+ else
+ parsed_uri = get_parent_uri + '/' + self.urilized(get_name)
+ end
+ parsed_uri
+ end
+
+ def get_parent_uri
+ 'null'
+ end
+
+ def get_type
+ REPLACED_TYPE[slug] || slug
+ end
+
+ def additional_entries
+ entries = []
+ css('h2').each do |node|
+ name = node.content.strip
+ custom_parsed_uri = get_parsed_uri_by_name(name)
+ entries << [name, node['id'], get_type, custom_parsed_uri, get_parsed_uri, get_docset]
+ end
+
+ entries
+ end
end
end
end
diff --git a/lib/docs/filters/markdown/clean_html.rb b/lib/docs/filters/markdown/clean_html.rb
index 84fcb90145..190d97ab93 100644
--- a/lib/docs/filters/markdown/clean_html.rb
+++ b/lib/docs/filters/markdown/clean_html.rb
@@ -1,6 +1,6 @@
module Docs
class Markdown
- class CleanHtmlFilter < Filter
+ class CleanHtmlFilter < Docs::ReflyFilter
def call
at_css('h1').content = 'Markdown'
@@ -10,6 +10,8 @@ def call
node.before(node.children).remove
end
+ WrapPreContentWithCode 'hljs asciidoc'
+ WrapContentWithDivs '_page _markdown'
doc
end
end
diff --git a/lib/docs/filters/markdown/entries.rb b/lib/docs/filters/markdown/entries.rb
index eb68ff27c8..8598c97948 100644
--- a/lib/docs/filters/markdown/entries.rb
+++ b/lib/docs/filters/markdown/entries.rb
@@ -1,18 +1,77 @@
module Docs
class Markdown
- class EntriesFilter < Docs::EntriesFilter
- def additional_entries
- type = nil
+ class EntriesFilter < Docs::ReflyEntriesFilter
+ REPLACE_TYPES = {
+ 'Philosophy' => 'guide',
+ 'Inline HTML' => 'guide',
+ 'Automatic Escaping for Special Characters' => 'guide',
+ 'Paragraphs and Line Breaks' => 'element',
+ 'Headers' => 'element',
+ 'Blockquotes' => 'element',
+ 'Lists' => 'element',
+ 'Code Blocks' => 'element',
+ 'Horizontal Rules' => 'element',
+ 'Links' => 'element',
+ 'Emphasis' => 'element',
+ 'Code' => 'element',
+ 'Images' => 'element',
+ 'Automatic Links' => 'others',
+ 'Backslash Escapes' => 'others'
+ }
+ def get_docset
+ docset = context[:root_title]
+ docset
+ end
+
+ def get_name
+ name = 'Markdown'
+ name
+ end
+
+ def get_parsed_uri_by_name(name)
+ context[:docset_uri] + '/' + self.urilized(name)
+ end
+
+ def get_parsed_uri
+ parsed_uri = context[:docset_uri] + '/' + path
+ parsed_uri
+ end
+
+ def get_parent_uri
+ subpath = *path.split('/')
+ if subpath.length > 1
+ parent_uri = (context[:docset_uri]+ '/' + subpath[0,subpath.size-1].join('/')).downcase
- doc.children.each_with_object [] do |node, entries|
+ else
+ parent_uri = 'null'
+ end
+ end
+
+ def get_type_by_name(typename)
+ REPLACE_TYPES[typename] || get_type
+ end
+
+ def get_type
+ 'others'
+ end
+
+ def additional_entries
+ type = 'others'
+ entries = []
+ css('h3','h2').each do |node|
if node.name == 'h2'
- type = node.content.strip
+ name = node.content.strip
+ type = name
+ custom_parsed_uri = get_parsed_uri_by_name(name)
+ entries << [name, node['id'], 'others', custom_parsed_uri, get_parent_uri, get_docset]
elsif node.name == 'h3'
- next if type == 'Overview'
name = node.content.strip
- entries << [name, node['id'], type]
+ type = name
+ custom_parsed_uri = get_parsed_uri_by_name(name)
+ entries << [name, node['id'], get_type_by_name(type), custom_parsed_uri, get_parent_uri, get_docset]
end
end
+ entries
end
end
end
diff --git a/lib/docs/filters/maxcdn/clean_html.rb b/lib/docs/filters/maxcdn/clean_html.rb
index 874e9a4539..b230de51bc 100644
--- a/lib/docs/filters/maxcdn/clean_html.rb
+++ b/lib/docs/filters/maxcdn/clean_html.rb
@@ -1,6 +1,6 @@
module Docs
class Maxcdn
- class CleanHtmlFilter < Filter
+ class CleanHtmlFilter < Docs::ReflyFilter
def call
css('hr', 'td:last-child:empty').remove
@@ -17,7 +17,8 @@ def call
css('[name]').each do |node|
node.remove_attribute 'name'
end
-
+ WrapPreContentWithCode 'hljs dart'
+ WrapContentWithDivs '_page _maxcdn'
doc
end
end
diff --git a/lib/docs/filters/maxcdn/entries.rb b/lib/docs/filters/maxcdn/entries.rb
index 1663852699..ef8eb16d7a 100644
--- a/lib/docs/filters/maxcdn/entries.rb
+++ b/lib/docs/filters/maxcdn/entries.rb
@@ -1,6 +1,54 @@
module Docs
class Maxcdn
- class EntriesFilter < Docs::EntriesFilter
+ class EntriesFilter < Docs::ReflyEntriesFilter
+
+ REPLACE_TYPES = {
+ 'SSL Certificate' => 'security',
+ 'Zones SSL' => 'security',
+ 'Users' => 'function',
+ 'Account' => 'function',
+ 'Raw Logs' => 'function',
+ 'Reports' => 'function',
+ }
+ def get_name
+ name = at_css('h1').content.strip
+ name
+ end
+
+ def get_docset
+ docset = context[:root_title]
+ docset
+ end
+
+ def get_parsed_uri_by_name(name)
+ if get_parent_uri == 'null'
+ parsed_uri = context[:docset_uri] + '/' + self.urilized(name)
+ else
+ parsed_uri = get_parsed_uri + '/' + self.urilized(name)
+ end
+ parsed_uri
+ end
+
+ def get_parsed_uri
+ if get_parent_uri == 'null'
+ parsed_uri = context[:docset_uri] + '/' + self.urilized(get_name)
+ else
+ parsed_uri = get_parent_uri + '/' + self.urilized(get_name)
+ end
+ parsed_uri
+ end
+
+ def get_parent_uri
+ 'null'
+ end
+
+ def get_type
+ 'others'
+ end
+ def get_type_by_name(name)
+ REPLACE_TYPES[name] || 'others'
+ end
+
def additional_entries
type = id_prefix = nil
@@ -20,8 +68,8 @@ def additional_entries
if name.ends_with?('Domain') && ['Push Zone', 'Pull Zone', 'VOD Zone'].include?(type)
name << " (#{type})"
end
-
- entries << [name, id, type]
+ custom_parsed_uri = get_parsed_uri_by_name(name)
+ entries << [name, id, get_type_by_name(type), custom_parsed_uri, get_parsed_uri, get_docset]
end
end
end
diff --git a/lib/docs/filters/mdn/clean_html.rb b/lib/docs/filters/mdn/clean_html.rb
index 1bc61e48f9..eea2369ffa 100644
--- a/lib/docs/filters/mdn/clean_html.rb
+++ b/lib/docs/filters/mdn/clean_html.rb
@@ -1,12 +1,13 @@
module Docs
class Mdn
- class CleanHtmlFilter < Filter
+ class CleanHtmlFilter < Docs::ReflyFilter
REMOVE_NODES = [
'#Summary', # "Summary" heading
'.htab', # "Browser compatibility" tabs
'.breadcrumbs', # (e.g. CSS/animation)
'.Quick_links', # (e.g. CSS/animation)
'.todo',
+ '.contributor-avatars',
'.draftHeader']
def call
@@ -16,12 +17,21 @@ def call
node.name = 'th'
end
+ #remove css links
+ css('link').each do |node|
+ node.remove
+ end
+
+ #remove meta
+ css('meta').each do |node|
+ node.remove
+ end
css('nobr').each do |node|
node.before(node.children).remove
end
css('h2[style]', 'pre[style]').remove_attr('style')
-
+ WrapContentWithDivs '_page _mdn'
doc
end
end
diff --git a/lib/docs/filters/mdn/contribute_link.rb b/lib/docs/filters/mdn/contribute_link.rb
index 66d8ce79f9..bd990e0f93 100644
--- a/lib/docs/filters/mdn/contribute_link.rb
+++ b/lib/docs/filters/mdn/contribute_link.rb
@@ -1,6 +1,6 @@
module Docs
class Mdn
- class ContributeLinkFilter < Filter
+ class ContributeLinkFilter < Docs::ReflyFilter
def call
html << <<-HTML.strip_heredoc
diff --git a/lib/docs/filters/meteor/clean_html.rb b/lib/docs/filters/meteor/clean_html.rb
new file mode 100644
index 0000000000..40a09d4527
--- /dev/null
+++ b/lib/docs/filters/meteor/clean_html.rb
@@ -0,0 +1,27 @@
+module Docs
+ class Meteor
+ class CleanHtmlFilter < Docs::ReflyFilter
+ def call
+ @doc = at_css('#introduction').parent
+
+ css('.github-ribbon').remove
+
+ css('.selflink', 'b > em').each do |node|
+ node.before(node.children).remove
+ end
+
+ css('pre').each do |node|
+ node['class'] = node.at_css('code')['class']
+ node.content = node.content
+ end
+
+ css('a.src-code').each do |node|
+ node.content = 'Source'
+ end
+ WrapPreContentWithCode 'hljs bash'
+ WrapContentWithDivs '_page _meteor'
+ doc
+ end
+ end
+ end
+end
diff --git a/lib/docs/filters/meteor/entries.rb b/lib/docs/filters/meteor/entries.rb
new file mode 100644
index 0000000000..01ed4d3e84
--- /dev/null
+++ b/lib/docs/filters/meteor/entries.rb
@@ -0,0 +1,84 @@
+module Docs
+ class Meteor
+ class EntriesFilter < Docs::ReflyEntriesFilter
+ REPLACE_TYPES = {
+ 'Check' => 'function',
+ 'Command line' => 'core',
+ 'Core' => 'core',
+ 'EJSON' => 'function',
+ 'mobile-config.js' => 'platforms',
+ 'Packages' => 'package',
+ 'package.js' => 'package',
+ 'Tracker' => 'function',
+ 'Passwords' => 'function',
+ 'Assets' => 'io',
+ 'Accounts' => 'function',
+ 'Templates' => 'function',
+ 'Blaze' => 'function',
+ 'Timers' => 'function',
+ 'Collections' => 'function',
+ 'Concepts' => 'guide',
+ 'Publish and subscribe' => 'guide',
+ 'Server connections' => 'network',
+ 'Email' => 'network',
+ 'HTTP' => 'network',
+ 'Methods' => 'method',
+ 'ReactiveVar' => 'object'
+ }
+ def get_name
+ 'Index'
+ end
+ def get_docset
+ docset = context[:root_title]
+ docset
+ end
+
+ def get_parsed_uri_by_name(name)
+ if get_parent_uri == 'null'
+ parsed_uri = context[:docset_uri] + '/' + self.urilized(name)
+ else
+ parsed_uri = get_parent_uri + '/' + self.urilized(name)
+ end
+ parsed_uri
+ end
+
+ def get_parsed_uri
+ parsed_uri = context[:docset_uri] + '/' + path
+ parsed_uri
+ end
+
+ def get_parent_uri
+ 'null'
+ end
+
+ def get_type
+ 'others'
+ end
+
+ def additional_entries
+ type = nil
+
+ at_css('.full-api-toc').element_children.each_with_object [] do |node, entries|
+ link = node.at_css('a')
+ next unless link
+
+ target = link['href'].remove('#/full/')
+ name = node.content
+ custom_parsed_uri = get_parsed_uri_by_name(name)
+ case node.name
+ when 'h1'
+ type = node.content.strip
+ when 'h2'
+ if type == 'Concepts'
+ entries << [name, target, REPLACE_TYPES[type] || type || 'others', custom_parsed_uri, get_parent_uri, get_docset]
+ else
+ type = node.content.strip
+ end
+ when 'h3', 'h4'
+ entries << [name, target, REPLACE_TYPES[type] || type || 'others', custom_parsed_uri, get_parent_uri, get_docset]
+ end
+ end
+ end
+ end
+ end
+end
diff --git a/lib/docs/filters/mocha/clean_html.rb b/lib/docs/filters/mocha/clean_html.rb
new file mode 100644
index 0000000000..1403f81306
--- /dev/null
+++ b/lib/docs/filters/mocha/clean_html.rb
@@ -0,0 +1,16 @@
+module Docs
+ class Mocha
+ class CleanHtmlFilter < Docs::ReflyFilter
+ def call
+ doc.child.remove until doc.child['id'] == 'installation'
+
+ css('pre').each do |node|
+ node.content = node.content
+ end
+ WrapPreContentWithCode 'hljs javascript'
+ WrapContentWithDivs '_page _mocha'
+ doc
+ end
+ end
+ end
+end
diff --git a/lib/docs/filters/mocha/entries.rb b/lib/docs/filters/mocha/entries.rb
new file mode 100644
index 0000000000..40f32af6be
--- /dev/null
+++ b/lib/docs/filters/mocha/entries.rb
@@ -0,0 +1,66 @@
+module Docs
+ class Mocha
+ class EntriesFilter < Docs::ReflyEntriesFilter
+ ENTRIES = {
+ 'asynchronous-code' => ['done()'],
+ 'hooks' => ['before()', 'after()', 'beforeEach()', 'afterEach()', 'suiteSetup()', 'suiteTeardown()', 'setup()', 'teardown()'],
+ 'exclusive-tests' => ['only()'],
+ 'inclusive-tests' => ['skip()'],
+ 'usage' => ['mocha'],
+ 'bdd-interface' => ['describe()', 'context()', 'it()'],
+ 'tdd-interface' => ['suite()', 'test()'],
+ 'exports-interface' => ['exports'],
+ 'qunit-interface' => ['QUnit'],
+ 'require-interface' => ['require'],
+ 'browser-setup' => ['setup()'],
+ 'mocha.opts' => ['mocha.opts'],
+ 'suite-specific-timeouts' => ['timeout()']
+ }
+ def get_name
+ 'Index'
+ end
+
+ def get_docset
+ docset = context[:root_title]
+ docset
+ end
+
+ def get_parsed_uri_by_name(name)
+ parsed_uri = context[:docset_uri] + '/' + self.urilized(name)
+ parsed_uri
+ end
+
+ def get_parsed_uri
+ if get_parent_uri == 'null'
+ parsed_uri = context[:docset_uri] + '/' + self.urilized(get_name)
+ else
+ parsed_uri = get_parent_uri + '/' + self.urilized(get_name)
+ end
+ parsed_uri
+ end
+
+ def get_type
+ 'others'
+ end
+ def get_parent_uri
+ parent_uri = 'null'
+ parent_uri
+ end
+
+ def additional_entries
+ ENTRIES.each_with_object [] do |(id, names), entries|
+ type = case id
+ when 'hooks' then 'function'
+ when /interface/ then 'interface'
+ else 'others' end
+
+ names.each do |name|
+ custom_parsed_uri = get_parsed_uri_by_name(name)
+ custom_parent_uri = '/mocha/index'
+ entries << [name, id, type, custom_parsed_uri, custom_parent_uri, get_docset]
+ end
+ end
+ end
+ end
+ end
+end
diff --git a/lib/docs/filters/modernizr/clean_html.rb b/lib/docs/filters/modernizr/clean_html.rb
index c37f0efa62..c8b876d931 100644
--- a/lib/docs/filters/modernizr/clean_html.rb
+++ b/lib/docs/filters/modernizr/clean_html.rb
@@ -1,6 +1,6 @@
module Docs
class Modernizr
- class CleanHtmlFilter < Filter
+ class CleanHtmlFilter < Docs::ReflyFilter
def call
css('pre').each do |node|
node.content = node.content
@@ -14,6 +14,8 @@ def call
node.name = node.name.sub(/\d/) { |i| i.to_i - 1 }
end
+ WrapPreContentWithCode 'hljs javascript'
+ WrapContentWithDivs '_page _modernizr'
doc
end
end
diff --git a/lib/docs/filters/modernizr/entries.rb b/lib/docs/filters/modernizr/entries.rb
index d2cb377a35..4ccccf5592 100644
--- a/lib/docs/filters/modernizr/entries.rb
+++ b/lib/docs/filters/modernizr/entries.rb
@@ -1,23 +1,64 @@
module Docs
class Modernizr
- class EntriesFilter < Docs::EntriesFilter
+ class EntriesFilter < Docs::ReflyEntriesFilter
+
+ def get_name
+ 'Index'
+ end
+
+ def get_docset
+ docset = context[:root_title]
+ docset
+ end
+
+ def get_parsed_uri_by_name(name)
+ parsed_uri = context[:docset_uri] + '/' + self.urilized(name)
+ parsed_uri
+ end
+
+ def get_parsed_uri
+ parsed_uri = context[:docset_uri] + '/' + self.urilized(get_name)
+ parsed_uri
+ end
+
+ def get_parent_uri
+ 'null'
+ end
+
+ def get_type
+ 'others'
+ end
+
+ def get_type_by_name(_type)
+ if _type.include? 'Miscellaneous features'
+ 'others'
+ elsif _type.include? 'Modernizr'
+ 'function'
+ elsif _type.include? 'CSS features'
+ 'css'
+ elsif _type.include? 'HTML5 features'
+ 'html5'
+ else
+ 'others'
+ end
+ end
def additional_entries
entries = []
-
css('h3[id]').each do |node|
- next unless name = node.content.strip[/\AModernizr\.\w+\(\)/]
- entries << [name, node['id'], 'Modernizr']
+ name = node.content
+ custom_parsed_uri = get_parsed_uri_by_name(name)
+ entries << [name, node['id'], 'function', custom_parsed_uri, 'null', get_docset]
end
-
css('section[id]').each do |node|
next unless heading = node.at_css('h3')
- next unless name = heading.content.strip[/\A(Modernizr\.)?\w+\(\)/]
+ name = heading.content
heading['id'] = node['id']
node.remove_attribute('id')
name.prepend('Modernizr.') unless name.start_with?('Modernizr')
- entries << [name, heading['id'], 'Modernizr']
+ custom_parsed_uri = get_parsed_uri_by_name(name)
+ entries << [name, heading['id'], 'function', custom_parsed_uri, 'null', get_docset]
end
css('h4[id^="features-"] + table').each do |table|
@@ -25,10 +66,11 @@ def additional_entries
type << ' features' unless type.end_with?('features')
table.css('tbody th[id]').each do |node|
- entries << [node.content, node['id'], type]
+ name = node.content.strip
+ custom_parsed_uri = get_parsed_uri_by_name(name)
+ entries << [node.content, node['id'], get_type_by_name(type), custom_parsed_uri, 'null', get_docset]
end
end
-
entries
end
end
diff --git a/lib/docs/filters/moment/clean_html.rb b/lib/docs/filters/moment/clean_html.rb
index 9ff36c7572..a324c86656 100644
--- a/lib/docs/filters/moment/clean_html.rb
+++ b/lib/docs/filters/moment/clean_html.rb
@@ -1,6 +1,6 @@
module Docs
class Moment
- class CleanHtmlFilter < Filter
+ class CleanHtmlFilter < Docs::ReflyFilter
def call
# Set id attributes on headings
css('a.docs-section-target', 'a.docs-method-target').each do |node|
@@ -20,6 +20,8 @@ def call
css('.docs-method-edit', '#plugins').remove
+ WrapPreContentWithCode 'hljs javascript'
+ WrapContentWithDivs '_page _moment'
doc
end
end
diff --git a/lib/docs/filters/moment/entries.rb b/lib/docs/filters/moment/entries.rb
index 3cecb237c0..2dae4a579a 100644
--- a/lib/docs/filters/moment/entries.rb
+++ b/lib/docs/filters/moment/entries.rb
@@ -1,12 +1,55 @@
module Docs
class Moment
- class EntriesFilter < Docs::EntriesFilter
+ class EntriesFilter < Docs::ReflyEntriesFilter
IGNORE_IDS = %w(
i18n-loading-into-nodejs
i18n-loading-into-browser
i18n-adding-locale
i18n-getting-locale)
+ REPLACE_TYPES = {
+ 'Customize' => 'function',
+ 'Manipulate' => 'method',
+ 'Display' => 'view',
+ 'Get + Set' => 'method',
+ 'Durations' => 'method',
+ 'Utilities' => 'function',
+ 'Query' => 'method',
+ 'Parse' => 'function',
+ 'i18n' => 'function'
+
+ }
+ def get_name
+ 'Index'
+ end
+
+ def get_docset
+ docset = context[:root_title]
+ docset
+ end
+
+ def get_parsed_uri_by_name(name)
+ if get_parent_uri == 'null'
+ parsed_uri = context[:docset_uri] + '/' + self.urilized(name)
+ else
+ parsed_uri = get_parent_uri + '/' + self.urilized(name)
+ end
+ parsed_uri
+ end
+
+ def get_parsed_uri
+ parsed_uri = context[:docset_uri] + '/' + path
+ parsed_uri
+ end
+
+ def get_parent_uri
+ 'null'
+ end
+
+ def get_type
+ 'others'
+ end
+
def additional_entries
entries = []
type = nil
@@ -22,8 +65,10 @@ def additional_entries
if node['id'] == 'utilities-invalid' # bug fix
name = 'moment.invalid()'
+ elsif node['id'] == 'customization-now'
+ name = 'moment.now'
elsif %w(Display Durations Get\ +\ Set i18n Manipulate Query Utilities).include?(type) ||
- %w(parsing-is-valid parsing-parse-zone parsing-unix-timestamp parsing-utc customization-relative-time-threshold).include?(node['id'])
+ %w(parsing-is-valid parsing-parse-zone parsing-unix-timestamp parsing-utc parsing-creation-data customization-relative-time-threshold).include?(node['id'])
name = node.next_element.content[/moment(?:\(.*?\))?\.(?:duration\(\)\.)?\w+/]
name.sub! %r{\(.*?\)\.}, '#'
name << '()'
@@ -37,7 +82,8 @@ def additional_entries
name.prepend 'Parse: ' if type == 'Parse'
end
- entries << [name, node['id'], type]
+ custom_parsed_uri = get_parsed_uri_by_name(name)
+ entries << [name, node['id'], REPLACE_TYPES[type], custom_parsed_uri, get_parent_uri, get_docset]
end
entries
diff --git a/lib/docs/filters/mongoose/clean_html.rb b/lib/docs/filters/mongoose/clean_html.rb
index 04ef6a126b..9ec193cc29 100644
--- a/lib/docs/filters/mongoose/clean_html.rb
+++ b/lib/docs/filters/mongoose/clean_html.rb
@@ -1,6 +1,13 @@
module Docs
class Mongoose
- class CleanHtmlFilter < Filter
+ class CleanHtmlFilter < Docs::ReflyFilter
+
+ BROKEN_LINKS = [
+ 'querycursor'
+ ]
+ REPLACED_LINKS = {
+ }
+
def call
css('hr', '.showcode', '.sourcecode').remove
@@ -19,11 +26,46 @@ def call
node.name = 'h2'
end
end
-
+ # fix links
+ css('a[href]').each do |node|
+ if node['href'] == 'index'
+ node.name = 'span'
+ end
+ node['href'] = CleanWrongCharacters(node['href']).downcase.remove '_(event)'
+ if REPLACED_LINKS[node['href'].downcase.remove! '../']
+ node['href'] = REPLACED_LINKS[node['href'].remove '../']
+ elsif !node['href'].start_with? 'http://' and !node['href'].start_with? 'https://' and !node['href'].start_with? 'ftp://' and !node['href'].start_with? 'irc://' and !node['href'].start_with? 'mailto:'
+ if node['class'] == 'new' or node['title'] == 'The documentation about this has not yet been written; please consider contributing!'
+ node['class'] = 'broken'
+ node['title'] = ''
+ elsif BROKEN_LINKS.include? node['href'].downcase.remove! '../'
+ node['class'] = 'broken'
+ else
+ sluglist = slug.split('/')
+ nodelist = node['href'].split('/')
+ newhref = []
+ nodelist.each do |item|
+ if item == '..'
+ sluglist.pop
+ else
+ newhref << item
+ end
+ end
+ sluglist.pop
+ if sluglist.size>0
+ node['href'] = sluglist.join('/') + '/' + newhref.join('/')
+ else
+ node['href'] = newhref.join('/')
+ end
+ end
+ end
+ end
css('pre > code', 'h1 + ul', '.module', '.item', 'h3 > a', 'h3 code').each do |node|
node.before(node.children).remove
end
+ WrapPreContentWithCode 'hljs javascript'
+ WrapContentWithDivs '_page _mongoose'
doc
end
end
diff --git a/lib/docs/filters/mongoose/entries.rb b/lib/docs/filters/mongoose/entries.rb
index dd57914636..f71e5f2158 100644
--- a/lib/docs/filters/mongoose/entries.rb
+++ b/lib/docs/filters/mongoose/entries.rb
@@ -1,35 +1,77 @@
module Docs
class Mongoose
- class EntriesFilter < Docs::EntriesFilter
+ class EntriesFilter < Docs::ReflyEntriesFilter
def get_name
- if slug == 'api'
- 'Mongoose'
+ if slug == 'index'
+ name = 'Getting Started'
else
- at_css('h1').content
+ name = at_css('h1').content
end
+ name
+ end
+
+ def get_docset
+ docset = context[:root_title]
+ docset
+ end
+
+ def get_parsed_uri_by_name(name)
+ if get_parent_uri == 'null'
+ parsed_uri = context[:docset_uri] + '/' + self.urilized(name)
+ else
+ parsed_uri = get_parent_uri + '/' + self.urilized(name)
+ end
+ parsed_uri
+ end
+
+ def get_parsed_uri
+ parsed_uri = context[:docset_uri] + '/' + self.urilized(get_name)
+ parsed_uri
+ end
+
+ def get_parent_uri
+ parent_uri = 'null'
end
def get_type
if slug == 'api'
- 'Mongoose'
+ 'language'
else
- 'Guides'
+ 'guide'
+ end
+ end
+
+ def get_type_name(name)
+ if name.include? 'Collection' or name.include? 'Array'
+ 'collection'
+ elsif name.include? 'Schema'
+ 'schema'
+ elsif name.include? 'Connection' or name.include? 'Query'
+ 'network'
+ elsif name.include? 'Mongoose' or name.include? 'VirtualType'
+ 'language'
+ elsif name.include? 'Object' or name.include? 'Validation'
+ 'object'
+ else
+ 'others'
end
end
def additional_entries
- return [] unless slug == 'api'
entries = []
+ entries << ['Getting Started', nil, 'others', '/mongoosejs/getting_started', 'null', get_docset] if slug == 'index'
+ return [] unless slug == 'api'
css('h3[id]').each do |node|
next if node['id'] == 'index_'
-
name = node.content.strip
name.sub! %r{\(.+\)}, '()'
- next if name.include?(' ')
+ next if name.include?(' ') or name == '()'
+ name = name.tr('#','.')
type = name.split(/[#\.\(]/).first
- entries << [name, node['id'], type]
+ custom_parsed_uri = get_parsed_uri_by_name(name)
+ entries << [name, node['id'], get_type_name(name), custom_parsed_uri, get_parsed_uri, get_docset]
end
entries
diff --git a/lib/docs/filters/mysql/clean_html.rb b/lib/docs/filters/mysql/clean_html.rb
new file mode 100644
index 0000000000..395fd6c314
--- /dev/null
+++ b/lib/docs/filters/mysql/clean_html.rb
@@ -0,0 +1,54 @@
+module Docs
+ class Mysql
+ class CleanHtmlFilter < Docs::ReflyFilter
+ BROKEN_LINKS = []
+ REPLACED_LINKS = {
+ 'http:://bugs.mysql.com/bug.php?id=24733' => 'http://bugs.mysql.com/bug.php?id=24733',
+ 'launchpad.net' => 'http://www.launchpad.net'
+ }
+ def call
+ fixLinks
+ WrapPreContentWithCode 'hljs sql'
+ WrapContentWithDivs '_page _mysql'
+ css('#docs-sidebar-search-box', '.right', '#docs-in-page-nav', '.docs-comment-disclaimer', '.docs-comments-header', '#docs-breadcrumbs', '.docs-sidebar-nav', '.text', '.docs-sidebar-accordian', '.docs-sidebar-header-text').remove
+ doc
+ end
+ def fixLinks
+ css('a[href]').each do |node|
+ node['href'] = CleanWrongCharacters(node['href']).downcase
+ node['href'] = node['href'].gsub /#\/\/.*/, ''
+ if REPLACED_LINKS[node['href'].downcase.remove! '../']
+ node['href'] = REPLACED_LINKS[node['href'].remove '../']
+ elsif !node['href'].start_with? '#' and !node['href'].start_with? 'http://' and !node['href'].start_with? '#' and !node['href'].start_with? 'https://' and !node['href'].start_with? 'ftp://' and !node['href'].start_with? 'irc://' and !node['href'].start_with? 'news://' and !node['href'].start_with? 'mailto:'
+ if node['class'] == 'new'
+ node['class'] = 'broken'
+ node['title'] = ''
+ else
+ sluglist = slug.split('/')
+ if context[:url].to_s.include? '.html'
+ sluglist.pop
+ end
+ if slug == 'docs/README.md'
+ sluglist.pop
+ end
+ nodelist = sluglist + node['href'].split('/')
+ newhref = []
+ nodelist.each do |item|
+ if item == '..'
+ newhref.pop
+ elsif item != '' and !newhref.include? item
+ newhref << item
+ end
+ end
+ node['href'] = newhref.join('/')
+ end
+ end
+ if BROKEN_LINKS.include? node['href'].downcase.remove! '../'
+ node['class'] = 'broken'
+ end
+ node['href'] = REPLACED_LINKS[node['href']] || node['href']
+ end
+ end
+ end
+ end
+end
diff --git a/lib/docs/filters/mysql/entries.rb b/lib/docs/filters/mysql/entries.rb
new file mode 100644
index 0000000000..7c2b549f8f
--- /dev/null
+++ b/lib/docs/filters/mysql/entries.rb
@@ -0,0 +1,87 @@
+module Docs
+ class Mysql
+ class EntriesFilter < Docs::ReflyEntriesFilter
+
+ EXCLUDED_PATH = ['MySQL 5.7 Reference Manual']
+
+ def get_name
+ # puts css('.title').first.content
+ name = css('.title').first.content.remove('Chapter ', 'Appendix B', 'Appendix C', 'Appendix A', 'Appendix E', 'Appendix D','Appendix', ' E ', 'D.', 'C.', 'A.', 'E.', 'B.').gsub(/\A[\d*\.]*/, "").strip
+ # puts name
+ name
+ end
+
+ def get_docset
+ docset = context[:root_title]
+ docset
+ end
+
+ def get_parsed_uri
+ if get_parent_uri == 'null'
+ parsed_uri = context[:docset_uri] + '/' + self.urilized(get_name)
+ else
+ parsed_uri = get_parent_uri + '/' + self.urilized(get_name)
+ end
+ parsed_uri
+ end
+
+ def get_parent_uri
+ parent_uri = context[:docset_uri]
+ if css('#hidden-breadcrumbs').to_s != ''
+ xpathsearch = '//span[@id="hidden-breadcrumbs"]//a/text()'
+ else
+ xpathsearch = '//div[@id="docs-breadcrumbs"]//a/text()'
+ end
+ xpath(xpathsearch).each do |node|
+ link = node.content.gsub(/\A[\d*\.]*/, "").remove('::').strip
+ if not EXCLUDED_PATH.include? link
+ parent_uri += '/' + self.urilized(link)
+ end
+ end
+ if parent_uri == context[:docset_uri]
+ parent_uri = 'null'
+ end
+ parent_uri
+ end
+
+ def get_type
+ type = 'others'
+ if css('#hidden-breadcrumbs').to_s != ''
+ xpathsearch = '//span[@id="hidden-breadcrumbs"]//a/text()'
+ else
+ xpathsearch = '//div[@id="docs-breadcrumbs"]//a/text()'
+ end
+ xpath(xpathsearch).each do |node|
+ link = node.content.remove('::').strip
+ if not EXCLUDED_PATH.include? link
+ type = link
+ end
+ end
+ if type.include? 'Function' or type.include? 'Math' or type.include? 'Spatial' or type.include? 'Unicode' or type.include? 'Transactions' or type.include? 'Cursors'
+ type = 'function'
+ elsif type.include? 'Optimizing' or type.include? 'Limits' or type.include? 'Questions' or type.include? 'Performance'
+ type = 'guide'
+ elsif type.include? 'Optimization' or type.include? 'Optimizer' or type.include? 'Information' or type.include? 'Unicode'
+ type = 'guide'
+ elsif type.include? 'Type' or type.include? 'InnoDB' or type.include? 'MyISAM' or type.include? 'Globalization' or type.include? 'Globalization' or type.include? 'Character' or type.include? 'Collation'
+ type = 'type'
+ elsif type.include? 'Statement' or type.include? 'Syntax'
+ type = 'statement'
+ elsif type.include? 'Operators'
+ type = 'operator'
+ elsif type.include? 'Variable' or type.include? 'Literal'
+ type = 'data'
+ elsif type.include? 'OpenGIS'
+ type = 'class'
+ elsif type.include? 'Utility' or type.include? 'Plugins'
+ type = 'utils'
+ elsif type.include? 'MySQL' or type.include? 'Server' or type.include? 'Storage' or type.include? 'Replication'
+ type = 'guide'
+ else
+ type = 'others'
+ end
+ type
+ end
+ end
+ end
+end
diff --git a/lib/docs/filters/nginx/clean_html.rb b/lib/docs/filters/nginx/clean_html.rb
index 0a7698f928..57cd153de1 100644
--- a/lib/docs/filters/nginx/clean_html.rb
+++ b/lib/docs/filters/nginx/clean_html.rb
@@ -1,6 +1,9 @@
module Docs
class Nginx
- class CleanHtmlFilter < Filter
+ class CleanHtmlFilter < Docs::ReflyFilter
+ BROKEN_LINKS = [
+
+ ]
def call
at_css('h2').name = 'h1'
@@ -22,8 +25,40 @@ def call
at_css('h1 + table').replace("- #{links.join('
- ')}
")
end
+ css('a[href]').each do |node|
+ node['href'] = CleanWrongCharacters(node['href'])
+ if !node['href'].start_with? 'http://' and !node['href'].start_with? 'https://'
+ if BROKEN_LINKS.include?node['href'].downcase
+ node['class'] = 'broken'
+ # node['href'] = context[:domain] + '/help#brokenlink'
+ else
+ sluglist = slug.split('/')
+ nodelist = node['href'].split('/')
+ newhref = []
+ nodelist.each do |item|
+ if item == '..'
+ sluglist.pop
+ else
+ newhref << item
+ end
+ end
+ sluglist.pop
+ if sluglist.size>0
+ node['href'] = sluglist.join('/') + '/' + newhref.join('/')
+ else
+ node['href'] = newhref.join('/')
+ end
+ end
+ end
+ end
+
+ WrapPreContentWithCode 'hljs nginx'
+ WrapContentWithDivs '_page _nginx'
doc
end
+ def CleanWrongCharacters(href)
+ href.gsub('%23', '#').gsub('%28', '(').gsub('%29', ')').gsub('%21', '!').gsub('%7b', '{').gsub('%7e', '~').gsub('%2a', '*').gsub('%2b', '+').gsub('%3d', '=').gsub('%40', '@')
+ end
end
end
end
diff --git a/lib/docs/filters/nginx/entries.rb b/lib/docs/filters/nginx/entries.rb
index 3d3a602de7..cc2e0f1acb 100644
--- a/lib/docs/filters/nginx/entries.rb
+++ b/lib/docs/filters/nginx/entries.rb
@@ -1,31 +1,68 @@
module Docs
class Nginx
- class EntriesFilter < Docs::EntriesFilter
+ class EntriesFilter < Docs::ReflyEntriesFilter
+ ADDITIONAL_ENTRIES = {
+ 'stream' => [
+ %w(Stream nil others /nginx/stream null Nginx)],
+ 'core' => [
+ %w(Core nil others /nginx/core null Nginx)],
+ 'module' => [
+ %w(Module nil others /nginx/module null Nginx)],
+ 'guide' => [
+ %w(Guide nil others /nginx/guide null Nginx)]}
+
def get_name
name = at_css('h1').content.strip
name.sub! %r{\AModule ngx}, 'ngx'
name
end
+ def get_docset
+ docset = context[:root_title]
+ docset
+ end
+
+ def get_parsed_uri_by_name(name)
+ context[:docset_uri] + '/' + self.urilized(name)
+ end
+
+ def get_parsed_uri
+ if get_parent_uri == 'null'
+ parsed_uri = context[:docset_uri] + '/' + self.urilized(get_name)
+ else
+ parsed_uri = get_parent_uri + '/' + self.urilized(get_name)
+ end
+ parsed_uri
+ end
+
+ def get_parent_uri
+ context[:docset_uri]+ '/' + self.urilized(get_type)
+ end
+
def get_type
- if name.starts_with?('ngx_')
- name
- elsif slug == 'ngx_core_module'
- 'Core'
+ if slug.include? 'stream'
+ 'stream'
+ elsif slug.include? 'core'
+ 'core'
+ elsif slug.include? 'module'
+ 'module'
else
- 'Guides'
+ 'guide'
end
end
def additional_entries
+ return ADDITIONAL_ENTRIES['stream'] if slug == 'control'
+ return ADDITIONAL_ENTRIES['core'] if slug == 'dirindex'
+ return ADDITIONAL_ENTRIES['module'] if slug == 'varindex'
+ return ADDITIONAL_ENTRIES['guide'] if slug == 'beginners_guide'
css('h1 + ul a').each_with_object [] do |node, entries|
name = node.content.strip
next if name =~ /\A[A-Z]/
-
id = node['href'].remove('#')
next if id.blank?
-
- entries << [name, id]
+ custom_parsed_uri = get_parsed_uri_by_name(name)
+ entries << [name, id, get_type, custom_parsed_uri, get_parent_uri, get_docset]
end
end
end
diff --git a/lib/docs/filters/node/clean_html.rb b/lib/docs/filters/node/clean_html.rb
index f2ab747f3d..5a272e8868 100644
--- a/lib/docs/filters/node/clean_html.rb
+++ b/lib/docs/filters/node/clean_html.rb
@@ -1,6 +1,15 @@
module Docs
class Node
- class CleanHtmlFilter < Filter
+ class CleanHtmlFilter < Docs::ReflyFilter
+ BROKEN_LINKS = [
+ 'cluster',
+ 'globals'
+ ]
+ REPLACED_ANCHOR = {
+ '#http_response_end_data_encoding' => '#http_response_end_data_encoding_callback',
+ '#http_response_write_chunk_encoding' => '#http_response_write_chunk_encoding_callback',
+ '#http_response_writehead_statuscode_reasonphrase_headers' => '#http_response_writehead_statuscode_statusmessage_headers'
+ }
def call
# Remove "#" links
css('.mark').each do |node|
@@ -16,6 +25,16 @@ def call
node.content = node.content
end
+ #fix anchors
+ css('a').each do |node|
+ if REPLACED_ANCHOR.has_key? node['href']
+ node['href'] = REPLACED_ANCHOR[node['href']]
+ elsif BROKEN_LINKS.include? node['href'].downcase.remove! '../'
+ node['class'] = 'broken'
+ end
+ end
+ WrapPreContentWithCode 'hljs javascript'
+ WrapContentWithDivs '_page _node'
doc
end
end
diff --git a/lib/docs/filters/node/entries.rb b/lib/docs/filters/node/entries.rb
index a7f254a5b5..e83c64264a 100644
--- a/lib/docs/filters/node/entries.rb
+++ b/lib/docs/filters/node/entries.rb
@@ -1,55 +1,122 @@
module Docs
class Node
- class EntriesFilter < Docs::EntriesFilter
+ class EntriesFilter < Docs::ReflyEntriesFilter
REPLACE_NAMES = {
'debugger' => 'Debugger',
'addons' => 'C/C++ Addons',
+ 'index' => 'Index',
'modules' => 'module' }
REPLACE_TYPES = {
- 'Addons' => 'Miscellaneous',
- 'Debugger' => 'Miscellaneous',
- 'os' => 'OS',
- 'StringDecoder' => 'String Decoder',
- 'TLS (SSL)' => 'TLS/SSL',
- 'UDP / Datagram Sockets' => 'UDP/Datagram',
- 'Executing JavaScript' => 'VM' }
-
- IGNORE_DEFAULT_ENTRY = %w(globals timers domain buffer)
+ 'Assert' => 'function',
+ 'Addons' => 'others',
+ 'Debugger' => 'others',
+ 'Cluster' => 'others',
+ 'Modules' => 'others',
+ 'Others' => 'others',
+ 'About this Documentation'=> 'others',
+ 'util' => 'others',
+ 'console' => 'core',
+ 'Path' => 'core',
+ 'File System' => 'core',
+ 'os' => 'core',
+ 'Child Process' => 'core',
+ 'process' => 'core',
+ 'Console' => 'core',
+ 'TTY' => 'core',
+ 'HTTPS' => 'network',
+ 'HTTP' => 'network',
+ 'TLS (SSL)' => 'network',
+ 'UDP / Datagram Sockets' => 'network',
+ 'URL' => 'network',
+ 'net' => 'network',
+ 'Domain' => 'network',
+ 'DNS' => 'network',
+ 'Smalloc' => 'function',
+ 'Zlib' => 'function',
+ 'StringDecoder' => 'function',
+ 'Timer' => 'function',
+ 'Timers' => 'function',
+ 'Crypto' => 'function',
+ 'REPL' => 'function',
+ 'Query String' => 'function',
+ 'Executing JavaScript' => 'function',
+ 'Readline' => 'function',
+ 'Process' => 'function',
+ 'Stream' => 'data',
+ 'Buffer' => 'data',
+ 'punycode' => 'data',
+ 'Events' => 'event',
+ 'Global Objects' => 'object'}
+
+ IGNORE_DEFAULT_ENTRY = %w()
def include_default_entry?
!IGNORE_DEFAULT_ENTRY.include?(slug)
end
def get_name
+ return 'Index' if slug == ''
REPLACE_NAMES[slug] || slug
end
+ def get_docset
+ docset = context[:root_title]
+ docset
+ end
+
+ def get_parsed_uri_by_name(name)
+ context[:docset_uri] + '/' + self.urilized(name)
+ end
+
+ def get_parsed_uri
+ if get_parent_uri == 'null'
+ parsed_uri = context[:docset_uri] + '/' + self.urilized(get_name)
+ else
+ parsed_uri = get_parent_uri + '/' + self.urilized(get_name)
+ end
+ parsed_uri
+ end
+
+ def get_parent_uri
+ subpath = *path.split('/')
+ if subpath.length > 1
+ parent_uri = (context[:docset_uri]+ '/' + subpath[0,subpath.size-1].join('/')).downcase
+ else
+ parent_uri = 'null'
+ end
+ end
+
def get_type
- type = at_css('h1').content.strip
- REPLACE_TYPES[type] || "#{type.first.upcase}#{type[1..-1]}"
+ if at_css('h1')
+ type = at_css('h1').content.strip
+ if type == 'Synopsis'
+ type = 'others'
+ end
+ else
+ type = 'others'
+ end
+ REPLACE_TYPES[type] || type
end
def additional_entries
- return [] if type == 'Miscellaneous'
-
klass = nil
entries = []
-
- css('> [id]').each do |node|
- next if node.name == 'h1'
+ css('[id]').each do |node|
+ next if node.name == 'h1' || node.name == 'div'
klass = nil if node.name == 'h2'
name = node.content.strip
+
# Skip constructors
if name.start_with? 'new '
next
end
-
# Ignore most global objects (found elsewhere)
- if type == 'Global Objects'
- entries << [name, node['id']] if name.start_with?('_') || name == 'global'
+ if type == 'object'
+ custom_parsed_uri = get_parsed_uri_by_name(name)
+ entries << [name, node['id'], get_type, custom_parsed_uri, get_parent_uri, get_docset] if name.start_with?('_') || name == 'global'
next
end
@@ -57,14 +124,16 @@ def additional_entries
if name.gsub! 'Class: ', ''
name.remove! 'events.' # EventEmitter
klass = name
- entries << [name, node['id']]
+ custom_parsed_uri = get_parsed_uri_by_name(name)
+ entries << [name, node['id'], get_type, custom_parsed_uri, get_parent_uri, get_docset]
next
end
# Events
if name.sub! %r{\AEvent: '(.+)'\z}, '\1'
- name << " event (#{klass || type})"
- entries << [name, node['id']]
+ name << " event (#{klass || get_type})"
+ custom_parsed_uri = get_parsed_uri_by_name(name)
+ entries << [name, node['id'], get_type, custom_parsed_uri, get_parent_uri, get_docset]
next
end
@@ -73,8 +142,7 @@ def additional_entries
name.remove! 'assert(), ' # assert/assert.ok
# Skip all that start with an uppercase letter ("Example") or include a space ("exports alias")
- next unless (name.first.upcase! && !name.include?(' ')) || name.start_with?('Class Method')
-
+ next unless name.first.upcase! || name.start_with?('Class Method')
# Differentiate server classes (http, https, net, etc.)
name.sub!('server.') { "#{(klass || 'https').sub('.', '_').downcase!}." }
# Differentiate socket classes (net, dgram, etc.)
@@ -92,10 +160,10 @@ def additional_entries
# Skip duplicates (listen, connect, etc.)
unless name == entries[-1].try(:first) || name == entries[-2].try(:first)
- entries << [name, node['id']]
+ custom_parsed_uri = get_parsed_uri_by_name(name)
+ entries << [name, node['id'], get_type, custom_parsed_uri, get_parent_uri, get_docset]
end
end
-
entries
end
end
diff --git a/lib/docs/filters/nokogiri2/clean_html.rb b/lib/docs/filters/nokogiri2/clean_html.rb
new file mode 100644
index 0000000000..cc80a7ccba
--- /dev/null
+++ b/lib/docs/filters/nokogiri2/clean_html.rb
@@ -0,0 +1,56 @@
+module Docs
+ class Nokogiri2
+ class CleanHtmlFilter < Docs::ReflyFilter
+ BROKEN_LINKS = [
+ ]
+ REPLACED_LINKS = {
+ }
+ def call
+ css('.box_info').remove
+ css('a[href]').each do |node|
+ node['href'] = CleanWrongCharacters(node['href'])
+ if REPLACED_LINKS[node['href'].downcase]
+ node['href'] = REPLACED_LINKS[node['href']]
+ elsif !node['href'].start_with? 'http://' and !node['href'].start_with? 'https://'
+ if node.content.strip.include? "\u{00B6}" or node['href'] == '#top'
+ node.remove
+ elsif node['href'].downcase.include? '/doc/syntax'
+ node['class'] = 'broken'
+ elsif BROKEN_LINKS.include? node['href'].downcase.remove! '../'
+ node['class'] = 'broken'
+ else
+ sluglist = slug.split('/')
+ nodelist = node['href'].split('/')
+ newhref = []
+ nodelist.each do |item|
+ if item == '..'
+ sluglist.pop
+ else
+ newhref << item
+ end
+ end
+ sluglist.pop
+ if sluglist.size>0
+ node['href'] = sluglist.join('/') + '/' + newhref.join('/')
+ else
+ node['href'] = newhref.join('/')
+ end
+ end
+ end
+ end
+
+ root_page? ? root : other
+
+ WrapPreContentWithCode 'hljs ruby'
+ WrapContentWithDivs '_page _rdoc'
+ doc
+ end
+
+ def root
+ end
+
+ def other
+ end
+ end
+ end
+end
\ No newline at end of file
diff --git a/lib/docs/filters/nokogiri2/entries.rb b/lib/docs/filters/nokogiri2/entries.rb
index 642ff73bc7..2361365fa8 100644
--- a/lib/docs/filters/nokogiri2/entries.rb
+++ b/lib/docs/filters/nokogiri2/entries.rb
@@ -1,10 +1,71 @@
module Docs
class Nokogiri2
- class EntriesFilter < Docs::Rdoc::EntriesFilter
+ class EntriesFilter < Docs::ReflyEntriesFilter
+ REPLACED_NAMES = {
+ 'README.rdoc' => 'README'
+ }
+ EXCLUDED_PATH = ['Libraries']
+ def get_name
+ if REPLACED_NAMES.include? slug
+ name = REPLACED_NAMES[slug]
+ elsif xpath('//div[@id="menu"]//span/text()')
+ namelist = xpath('//div[@id="menu"]//span/text()')
+ name = namelist[-1].content
+ else
+ name = slug
+ end
+ name.remove! 'Module: '
+ name.remove! 'Class: '
+ name
+ end
+
+ def get_docset
+ docset = context[:root_title]
+ docset
+ end
+
+ def get_parsed_uri_by_name(name)
+ parsed_uri = context[:docset_uri] + '/' + self.urilized(name)
+ parsed_uri
+ end
+
+ def get_parsed_uri
+ if get_parent_uri == 'null'
+ parsed_uri = context[:docset_uri] + '/' + self.urilized(get_name)
+ else
+ parsed_uri = get_parent_uri + '/' + self.urilized(get_name)
+ end
+ parsed_uri
+ end
+
+ def get_parent_uri
+ parent_uri = context[:docset_uri]
+ xpath('//div[@id="menu"]//a/text()').each do |node|
+ link = node.content.strip
+ if not EXCLUDED_PATH.include? link and !link.start_with? 'Index'
+ parent_uri += '/' + self.urilized(link)
+ end
+ end
+ if parent_uri == context[:docset_uri]
+ parent_uri = 'null'
+ end
+ parent_uri
+ end
+
def get_type
- type = name.dup
- type.remove! %r{#.+\z}
- type.split('::')[0..2].join('::')
+ if at_css('h1')
+ name = at_css('h1').content.strip
+ else
+ name = 'others'
+ end
+ if name.start_with? 'Module'
+ type = 'module'
+ elsif name.start_with? 'Class'
+ type = 'class'
+ else
+ type = 'others'
+ end
+ type
end
end
end
diff --git a/lib/docs/filters/npm/clean_html.rb b/lib/docs/filters/npm/clean_html.rb
new file mode 100644
index 0000000000..40311806bf
--- /dev/null
+++ b/lib/docs/filters/npm/clean_html.rb
@@ -0,0 +1,73 @@
+module Docs
+ class Npm
+ class CleanHtmlFilter < Docs::ReflyFilter
+ BROKEN_LINKS = [
+ 'misc/scopes',
+ 'cli/rm',
+ 'orgs/cli/team',
+ 'cli/npm-access'
+ ]
+ REPLACED_LINKS = {
+ }
+ def call
+ puts doc
+ if root_page?
+ css('#enterprise', '#policies', '#viewAll').remove
+ else
+ @doc = doc.at_css('#page')
+ css('meta', '.colophon').remove
+ end
+
+ css('> section', '.deep-link > a').each do |node|
+ node.before(node.children).remove
+ end
+
+ css('pre.editor').each do |node|
+ node.inner_html = node.inner_html.gsub(/<\/div>(?!\n|\z)/, "\n")
+ end
+
+ css('pre').each do |node|
+ node.content = node.content
+ end
+ css('a[href]').each do |node|
+ node['href'] = CleanWrongCharacters(node['href'])
+ if REPLACED_LINKS[node['href'].downcase]
+ node['href'] = REPLACED_LINKS[node['href']]
+ elsif !node['href'].start_with? 'http://' and !node['href'].start_with? 'https://' and !node['href'].start_with? 'ftp://' and !node['href'].start_with? 'irc://' and !node['href'].start_with? 'mailto:'
+ if node.content.strip.include? "\u{00B6}" or node['href'] == '#top'
+ node.remove
+ elsif node['href'].downcase.include? '/doc/syntax'
+ node['class'] = 'broken'
+ elsif BROKEN_LINKS.include? node['href'].downcase.remove! '../'
+ node['class'] = 'broken'
+ else
+ sluglist = slug.split('/')
+ nodelist = node['href'].split('/')
+ newhref = []
+ nodelist.each do |item|
+ if item == '..'
+ sluglist.pop
+ else
+ newhref << item
+ end
+ end
+ sluglist.pop
+ if sluglist.size>0
+ node['href'] = sluglist.join('/') + '/' + newhref.join('/')
+ else
+ node['href'] = newhref.join('/')
+ end
+ end
+ end
+ if BROKEN_LINKS.include? node['href'].downcase.remove! '../'
+ node['class'] = 'broken'
+ end
+ node['href'] = REPLACED_LINKS[node['href']] || node['href']
+ end
+ WrapPreContentWithCode 'hljs bash'
+ WrapContentWithDivs '_page _nom'
+ doc
+ end
+ end
+ end
+end
\ No newline at end of file
diff --git a/lib/docs/filters/npm/entries.rb b/lib/docs/filters/npm/entries.rb
new file mode 100644
index 0000000000..98fc45f56a
--- /dev/null
+++ b/lib/docs/filters/npm/entries.rb
@@ -0,0 +1,91 @@
+module Docs
+ class Npm
+ class EntriesFilter < Docs::ReflyEntriesFilter
+ REPLACED_TYPES = {
+ 'Getting Started' => 'guide',
+ 'Using npm' => 'guide',
+ 'Using npm programmatically' => 'function',
+ 'package.json' => 'others',
+ 'Configuring npm' => 'configuration',
+ 'Config' => 'configuration',
+ 'CLI Commands' => 'command',
+ }
+ def get_name
+ if slug.start_with?('api') && at_css('pre').content =~ /\A\s*npm\.([\w\-]+\.)*[\w\-]+/
+ name = $&.strip
+ elsif at_css('nav > section.active a.active')
+ name = at_css('nav > section.active a.active').content
+ else
+ name = 'Index'
+ end
+
+ name << ' (CLI)' if slug.start_with?('cli')
+ name
+ end
+
+ def get_docset
+ docset = context[:root_title]
+ docset
+ end
+
+ def get_parsed_uri_by_name(name)
+ parsed_uri = context[:docset_uri] + '/' + self.urilized(name)
+ parsed_uri
+ end
+
+ def get_parsed_uri
+ if get_parent_uri == 'null'
+ parsed_uri = context[:docset_uri] + '/' + self.urilized(get_name)
+ else
+ parsed_uri = get_parent_uri + '/' + self.urilized(get_name)
+ end
+ parsed_uri
+ end
+
+ def get_parent_uri
+ parent_uri = context[:docset_uri]
+ xpath('//nav[@class="crumbs"]//a/text()').each do |node|
+ link = node.content.strip
+ if not EXCLUDED_PATH.include? link
+ parent_uri += '/' + self.urilized(link)
+ end
+ end
+ if parent_uri == context[:docset_uri]
+ parent_uri = 'null'
+ end
+ parent_uri
+ end
+
+ def get_type
+ if slug == 'files/package.json'
+ type = 'package.json'
+ elsif slug == 'misc/config'
+ type = 'Config'
+ elsif at_css('nav > section.active > h2')
+ type = at_css('nav > section.active > h2').content.strip
+ else
+ type = 'others'
+ end
+ REPLACED_TYPES[type] || type
+ end
+
+ def additional_entries
+ case slug
+ when 'files/package.json'
+ css('#page > h2[id]').each_with_object [] do |node, entries|
+ next if node.content =~ /\A[A-Z]/
+ custom_parsed_uri = get_parsed_uri_by_name("package.json: #{node.content}")
+ entries << ["package.json: #{node.content}", node['id'], get_type, custom_parsed_uri, get_parsed_uri, get_docset]
+ end
+ when 'misc/config'
+ css('#config-settings ~ h3[id]').map do |node|
+ custom_parsed_uri = get_parsed_uri_by_name("config: #{node.content}")
+ ["config: #{node.content}", node['id'], 'configuration', custom_parsed_uri, get_parsed_uri, get_docset]
+ end
+ else
+ []
+ end
+ end
+ end
+ end
+end
\ No newline at end of file
diff --git a/lib/docs/filters/opentsdb/clean_html.rb b/lib/docs/filters/opentsdb/clean_html.rb
new file mode 100644
index 0000000000..6611d69818
--- /dev/null
+++ b/lib/docs/filters/opentsdb/clean_html.rb
@@ -0,0 +1,67 @@
+module Docs
+ class Opentsdb
+ class CleanHtmlFilter < Docs::ReflyFilter
+
+ BROKEN_LINKS = [
+ '_images/aggregation_average.png'
+ ]
+ REPLACED_LINKS = {}
+ def call
+ @doc = at_css('.documentwrapper > .bodywrapper > .body > .section')
+
+ css('> .section').each do |node|
+ node.before(node.children).remove
+ end
+
+ css('tt.literal').each do |node|
+ node.name = 'code'
+ node.content = node.content
+ end
+
+ css('div[class*=highlight] .highlight pre').each do |node|
+ node.parent.parent.before(node)
+ node.content = node.content.gsub(' ', ' ')
+ end
+
+ css('table').remove_attr('border')
+ fixLinks
+ WrapPreContentWithCode 'hljs stylus'
+ WrapContentWithDivs '_page _opentsdb'
+ doc
+ end
+ def fixLinks
+ css('a[href]').each do |node|
+ node['href'] = CleanWrongCharacters(node['href']).downcase.remove '_(event)'
+ if REPLACED_LINKS[node['href'].downcase.remove! '../']
+ node['href'] = REPLACED_LINKS[node['href'].remove '../']
+ elsif !node['href'].start_with? 'http://' and !node['href'].start_with? '#' and !node['href'].start_with? 'https://' and !node['href'].start_with? 'ftp://' and !node['href'].start_with? 'irc://' and !node['href'].start_with? 'news://' and !node['href'].start_with? 'mailto:'
+ if node['class'] == 'new'
+ node['class'] = 'broken'
+ node['title'] = ''
+ elsif BROKEN_LINKS.include? node['href'].downcase.remove! '../'
+ node['class'] = 'broken'
+ else
+ sluglist = slug.split('/')
+ if context[:url].to_s.end_with? 'html'
+ sluglist.pop
+ end
+ # if sluglist.size>1
+ # sluglist.pop
+ # end
+ nodelist = sluglist + node['href'].split('/')
+ newhref = []
+ nodelist.each do |item|
+ if item == '..'
+ newhref.pop
+ elsif item != ''
+ newhref << item
+ end
+ end
+ node['href'] = newhref.join('/')
+ end
+ end
+ end
+ end
+ end
+ end
+end
diff --git a/lib/docs/filters/opentsdb/entries.rb b/lib/docs/filters/opentsdb/entries.rb
new file mode 100644
index 0000000000..693bc38900
--- /dev/null
+++ b/lib/docs/filters/opentsdb/entries.rb
@@ -0,0 +1,61 @@
+module Docs
+ class Opentsdb
+ class EntriesFilter < Docs::ReflyEntriesFilter
+ REPLACE_TYPES = {
+ 'User Guide' => 'guide',
+ 'Development' => 'guide'
+ }
+ EXCLUDED_PATH = ['opentsdb_2.2_documentation']
+ def get_name
+ at_css('.section > h1').content
+ end
+
+ def get_docset
+ docset = context[:root_title]
+ docset
+ end
+
+ def get_parsed_uri
+ if get_parent_uri == 'null'
+ parsed_uri = context[:docset_uri] + '/' + self.urilized(get_name)
+ else
+ parsed_uri = get_parent_uri + '/' + self.urilized(get_name)
+ end
+ parsed_uri
+ end
+
+ def get_parent_uri
+ parent_uri = context[:docset_uri]
+ if breadcrumbs.length >= 2
+ breadcrumbs.each do |node|
+ if not EXCLUDED_PATH.include? self.urilized(node)
+ parent_uri += '/' + self.urilized(node)
+ end
+ end
+ else
+ parent_uri = 'null'
+ end
+ parent_uri
+ end
+
+ def get_type
+ if breadcrumbs.length >= 2 and (breadcrumbs[1].include? 'Guide' or breadcrumbs[1].include? 'Development')
+ type ='guide'
+ elsif subpath.start_with?('api_http')
+ type = 'api'
+ elsif slug.end_with?('/index')
+ type = [breadcrumbs[1], name].compact.join(': ')
+ elsif breadcrumbs.length < 2
+ type = 'others'
+ else
+ type = breadcrumbs[1]
+ end
+ REPLACE_TYPES[type] || type
+ end
+
+ def breadcrumbs
+ @breakcrumbs ||= at_css('.related').css('li:not(.right) a').map(&:content).reject(&:blank?)
+ end
+ end
+ end
+end
diff --git a/lib/docs/filters/perl/clean_html.rb b/lib/docs/filters/perl/clean_html.rb
new file mode 100644
index 0000000000..32e27e1562
--- /dev/null
+++ b/lib/docs/filters/perl/clean_html.rb
@@ -0,0 +1,69 @@
+module Docs
+ class Perl
+ class CleanHtmlFilter < Docs::ReflyFilter
+ BROKEN_LINKS = ['perlgit', 'deprecate', 'io/socket/ip',
+ 'io/compress/faq', 'tap/parser/sourcehandler', 'version',
+ 'cpan/meta/spec', 'cpan/meta', 'tap/parser/sourcehandler',
+ 'tap/parser/sourcehandler/executable', 'tap/parser/sourcehandler/perl', 'tap/parser/sourcehandler/file',
+ 'tap/parser/sourcehandler/rawtap', 'tap/parser/sourcehandler/handle', 'encode/supported',
+ 'pod/simple/subclassing', 'test/tutorial', 'arybase',
+ 'autodie/exception', 'encode/supported', 'encode/perlio',
+ 'zipdetails', 'ptargrep', 'unicode/collate/locale',
+ 'file:line', 'pl2pm', 'encoding/warnings',
+ 'autodie/hints', 'perlandroid', 'perlsynology',
+ 'perldoc.tar.gz', 'perldoc-html.tar.gz', 'cpan/meta/yaml'
+ ]
+ REPLACED_LINKS = {}
+ def call
+ css('ul').each do |node|
+ node.css('a[href]').each do |link|
+ if link['href']== '#NAME'
+ node.remove
+ end
+ end
+ end
+ fixLinks
+ WrapPreContentWithCode 'hljs perl'
+ WrapContentWithDivs '_page _perl'
+ doc
+ end
+
+ def fixLinks
+ css('a[href]').each do |node|
+ node['href'] = CleanWrongCharacters(node['href']).downcase
+ node['href'] = node['href'].gsub /#\/\/.*/, ''
+ if REPLACED_LINKS[node['href'].downcase.remove! '../']
+ node['href'] = REPLACED_LINKS[node['href'].remove '../']
+ elsif !node['href'].start_with? '#' and !node['href'].start_with? 'git://' and !node['href'].start_with? 'http://' and !node['href'].start_with? '#' and !node['href'].start_with? 'https://' and !node['href'].start_with? 'ftp://' and !node['href'].start_with? 'irc://' and !node['href'].start_with? 'news://' and !node['href'].start_with? 'mailto:'
+ if node['class'] == 'new'
+ node['class'] = 'broken'
+ node['title'] = ''
+ else
+ sluglist = slug.split('/')
+ if context[:url].to_s.include? '.html'
+ sluglist.pop
+ end
+ if slug == 'docs/README.md'
+ sluglist.pop
+ end
+ nodelist = sluglist + node['href'].split('/')
+ newhref = []
+ nodelist.each do |item|
+ if item == '..'
+ newhref.pop
+ elsif item != '' and !newhref.include? item
+ newhref << item
+ end
+ end
+ node['href'] = newhref.join('/')
+ end
+ end
+ if BROKEN_LINKS.include? node['href'].downcase.remove! '../'
+ node['class'] = 'broken'
+ end
+ node['href'] = REPLACED_LINKS[node['href']] || node['href']
+ end
+ end
+ end
+ end
+end
diff --git a/lib/docs/filters/perl/entries.rb b/lib/docs/filters/perl/entries.rb
new file mode 100644
index 0000000000..3f7bc016f0
--- /dev/null
+++ b/lib/docs/filters/perl/entries.rb
@@ -0,0 +1,97 @@
+module Docs
+ class Perl
+ class EntriesFilter < Docs::ReflyEntriesFilter
+
+ EXCLUDED_PATH = ['Language reference', 'Home', 'Index', 'History / Changes', 'Licence']
+ REPLACE_NAMES = {
+ 'Perl functions A-Z' => 'Functions'
+ }
+ def get_name
+ name = at_css('h1').content.strip
+ REPLACE_NAMES[name] || name
+ end
+
+ def get_docset
+ docset = context[:root_title]
+ docset
+ end
+
+ def get_parsed_uri_by_name(name)
+ get_parsed_uri + '/' + self.urilized(name)
+ end
+
+ def get_parsed_uri
+ if get_parent_uri == 'null'
+ parsed_uri = context[:docset_uri] + '/' + self.urilized(get_name.remove '%')
+ else
+ parsed_uri = get_parent_uri + '/' + self.urilized(get_name.remove '%')
+ end
+ parsed_uri
+ end
+
+ def get_parent_uri
+ parent_uri = context[:docset_uri]
+ xpath('//div[@id="breadcrumbs"]//a/text()').each do |node|
+ link = node.content.strip
+ if not EXCLUDED_PATH.include? link and !link.starts_with? 'Core modules'
+ parent_uri += '/' + self.urilized(link)
+ end
+ end
+ if parent_uri == context[:docset_uri]
+ parent_uri = 'null'
+ end
+ parent_uri
+ end
+
+ def get_type
+ parsed_uri = get_parsed_uri
+ name = get_name
+ if parsed_uri.include? 'functions' or parsed_uri.include? 'math' or parsed_uri.include? 'archive'
+ 'function'
+ elsif parsed_uri.include? 'perlop'
+ 'operator'
+ elsif parsed_uri.include? 'platform_specific'
+ 'platform'
+ elsif parsed_uri.include? 'perlvar'
+ 'variable'
+ elsif parsed_uri.include? 'perlvar'
+ 'variable'
+ elsif name.include? '::' or name== 'B'
+ 'object'
+ elsif parsed_uri.include? 'perlform'
+ 'view'
+ elsif parsed_uri.include? 'pragma'
+ 'pragma'
+ elsif parsed_uri.include? 'interface'
+ 'interface'
+ elsif parsed_uri.include? 'utilities'
+ 'util'
+ elsif parsed_uri.include? 'module'
+ 'module'
+ elsif parsed_uri.include? 'io--' or parsed_uri.include? 'file'
+ 'io'
+ else
+ 'others'
+ end
+ end
+
+ def include_default_entry?
+ return false if slug.starts_with? 'perl' and slug.end_with? 'delta'
+ return true
+ end
+
+ def additional_entries
+ entries = []
+ if !slug.include? 'index'
+ css('h2').each do |node|
+ custom_name = node.content.strip
+ id = custom_name.tr(' ','-').remove '%'
+ custom_parsed_uri = get_parsed_uri_by_name(custom_name)
+ entries << [custom_name, id, get_type, custom_parsed_uri, get_parsed_uri, get_docset]
+ end
+ end
+ entries
+ end
+ end
+ end
+end
diff --git a/lib/docs/filters/phalcon/clean_html.rb b/lib/docs/filters/phalcon/clean_html.rb
new file mode 100644
index 0000000000..241092cac7
--- /dev/null
+++ b/lib/docs/filters/phalcon/clean_html.rb
@@ -0,0 +1,83 @@
+module Docs
+ class Phalcon
+ class CleanHtmlFilter < Docs::ReflyFilter
+
+ BROKEN_LINKS = []
+ REPLACED_LINKS = {}
+ def call
+ @doc = at_css('.body')
+
+ if root_page?
+ at_css('h1').content = 'Phalcon'
+ end
+
+ css('#what-is-phalcon', '#other-formats').remove
+
+ css('#methods > p > strong, #constants > p > strong').each do |node|
+ node.parent.name = 'h3'
+ node.parent['id'] = node.content.parameterize
+ node.parent['class'] = 'method-signature'
+ node.parent.inner_html = node.parent.inner_html.sub(/inherited from .*/, '\0')
+ end
+
+ css('.headerlink').each do |node|
+ id = node['href'][1..-1]
+ node.parent['id'] ||= id
+ node.remove
+ end
+
+ css('div[class^="highlight-"]').each do |node|
+ code = node.at_css('pre').content
+ code.remove! %r{\A\s*<\?php\s*} unless code.include?(' ?>')
+ node.content = code
+ node.name = 'pre'
+ end
+
+ css('.section').each do |node|
+ node.before(node.children).remove
+ end
+
+ css('table[border]').each do |node|
+ node.remove_attribute('border')
+ end
+ fixLinks
+ WrapPreContentWithCode 'hljs php'
+ WrapContentWithDivs '_page _phalcon'
+ doc
+ end
+ def fixLinks
+ css('a[href]').each do |node|
+ node['href'] = CleanWrongCharacters(node['href']).downcase
+ if REPLACED_LINKS[node['href'].downcase.remove! '../']
+ node['href'] = REPLACED_LINKS[node['href'].remove '../']
+ elsif !node['href'].start_with? '#' and !node['href'].start_with? 'http://' and !node['href'].start_with? '#' and !node['href'].start_with? 'https://' and !node['href'].start_with? 'ftp://' and !node['href'].start_with? 'irc://' and !node['href'].start_with? 'news://' and !node['href'].start_with? 'mailto:'
+ if node['class'] == 'new'
+ node['class'] = 'broken'
+ node['title'] = ''
+ else
+ sluglist = slug.split('/')
+ if context[:url].to_s.include? '.html'
+ sluglist.pop
+ end
+ nodelist = sluglist + node['href'].split('/')
+ newhref = []
+ nodelist.each do |item|
+ if item == '..'
+ newhref.pop
+ elsif item != ''
+ newhref << item
+ end
+ end
+ node['href'] = newhref.join('/')
+ end
+ end
+ if BROKEN_LINKS.include? node['href'].downcase.remove! '../'
+ node['class'] = 'broken'
+ end
+ node['href'] = REPLACED_LINKS[node['href']] || node['href']
+ end
+
+ end
+ end
+ end
+end
diff --git a/lib/docs/filters/phalcon/entries.rb b/lib/docs/filters/phalcon/entries.rb
new file mode 100644
index 0000000000..1220d1c90e
--- /dev/null
+++ b/lib/docs/filters/phalcon/entries.rb
@@ -0,0 +1,83 @@
+module Docs
+ class Phalcon
+ class EntriesFilter < Docs::ReflyEntriesFilter
+ def get_name
+ (at_css('h1 > strong') || at_css('h1')).content.strip.remove('Phalcon\\')
+ end
+ def get_docset
+ docset = context[:root_title]
+ docset
+ end
+
+ def get_parsed_uri_by_name(name)
+ if get_parent_uri == 'null'
+ parsed_uri = context[:docset_uri] + '/' + self.urilized(name)
+ else
+ parsed_uri = get_parent_uri + '/' + self.urilized(name)
+ end
+ parsed_uri
+ end
+
+ def get_parsed_uri
+ parsed_uri = context[:docset_uri] + '/' + path
+ parsed_uri
+ end
+
+ def get_parent_uri
+ parent_uri = 'null'
+ end
+
+ def get_type
+ if slug.start_with?('reference')
+ type = 'guide'
+ elsif get_name.include? 'FETCH'
+ type = 'constant'
+ elsif get_name.downcase.include? 'class'
+ type = 'class'
+ elsif get_name.downcase.include? 'interface'
+ type = 'interface'
+ elsif get_name.include? 'FETCH'
+ type = 'constant'
+ elsif get_name.downcase.include? '::'
+ type = 'method'
+ else
+ type = 'others'
+ end
+ type
+ end
+
+ def get_type_by_name(name)
+ if slug.start_with?('reference')
+ type = 'guide'
+ elsif name.include? 'FETCH'
+ type = 'constant'
+ elsif name.downcase.include? 'class'
+ type = 'class'
+ elsif name.downcase.include? 'interface'
+ type = 'interface'
+ elsif name.downcase.include? '::'
+ type = 'method'
+ else
+ type = 'others'
+ end
+ type
+
+ end
+
+ def additional_entries
+ entries = []
+
+ css('.method-signature').each do |node|
+ next if node.content.include?('inherited from') || node.content.include?('protected ') || node.content.include?('private ')
+ name = node.at_css('strong').content.strip
+ next if name == '__construct' || name == '__toString'
+ name.prepend "#{self.name}::"
+ custom_parsed_uri = get_parsed_uri_by_name(name)
+ entries << [name, node['id'], get_type_by_name(name), custom_parsed_uri, get_parent_uri, get_docset]
+ end
+
+ entries
+ end
+ end
+ end
+end
diff --git a/lib/docs/filters/phaser/clean_html.rb b/lib/docs/filters/phaser/clean_html.rb
new file mode 100644
index 0000000000..0eef21ed37
--- /dev/null
+++ b/lib/docs/filters/phaser/clean_html.rb
@@ -0,0 +1,98 @@
+module Docs
+ class Phaser
+ class CleanHtmlFilter < Docs::ReflyFilter
+ BROKEN_LINKS = [ 'index']
+ REPLACED_LINKS = {}
+ def call
+ title = at_css('h1')
+
+ if root_page?
+ @doc = at_css('#docs-index')
+
+ # Remove first paragraph (old doc details)
+ at_css('table').remove
+
+ title.content = 'Phaser'
+ else
+ @doc = at_css('#docs')
+
+ # Remove useless markup
+ css('section > article').each do |node|
+ node.parent.replace(node.children)
+ end
+
+ css('dt > h4').each do |node|
+ dt = node.parent
+ dd = dt.next_element
+ dt.before(node).remove
+ dd.before(dd.children).remove
+ end
+
+ css('> div', '> section').each do |node|
+ node.before(node.children).remove
+ end
+
+ css('h3.subsection-title').each do |node|
+ node.name = 'h2'
+ end
+
+ css('h4.name').each do |node|
+ node.name = 'h3'
+ end
+
+ # Remove "Jump to" block
+ css('table').each do |table|
+ table.remove
+ end
+ end
+
+ doc.child.before(title)
+
+ # Clean code blocks
+ css('pre > code').each do |node|
+ node.before(node.children).remove
+ end
+ fixLinks
+ WrapPreContentWithCode 'hljs c'
+ WrapContentWithDivs '_page _phaser'
+ doc
+ end
+ def fixLinks
+ css('a[href]').each do |node|
+ node['href'] = CleanWrongCharacters(node['href']).downcase
+ node['href'] = node['href'].gsub /#\/\/.*/, ''
+ if REPLACED_LINKS[node['href'].downcase.remove! '../']
+ node['href'] = REPLACED_LINKS[node['href'].remove '../']
+ elsif !node['href'].start_with? '#' and !node['href'].start_with? 'http://' and !node['href'].start_with? '#' and !node['href'].start_with? 'https://' and !node['href'].start_with? 'ftp://' and !node['href'].start_with? 'irc://' and !node['href'].start_with? 'news://' and !node['href'].start_with? 'mailto:'
+ if node['class'] == 'new'
+ node['class'] = 'broken'
+ node['title'] = ''
+ else
+ sluglist = slug.split('/')
+ if context[:url].to_s.include? '.html'
+ sluglist.pop
+ end
+ if slug == 'docs/README.md'
+ sluglist.pop
+ end
+ nodelist = sluglist + node['href'].split('/')
+ newhref = []
+ nodelist.each do |item|
+ if item == '..'
+ newhref.pop
+ elsif item != '' and !newhref.include? item
+ newhref << item
+ end
+ end
+ node['href'] = newhref.join('/')
+ end
+ end
+ if BROKEN_LINKS.include? node['href'].downcase.remove! '../'
+ node['class'] = 'broken'
+ end
+ node['href'] = REPLACED_LINKS[node['href']] || node['href']
+ end
+ end
+ end
+ end
+end
diff --git a/lib/docs/filters/phaser/entries.rb b/lib/docs/filters/phaser/entries.rb
new file mode 100644
index 0000000000..cd8b88e34d
--- /dev/null
+++ b/lib/docs/filters/phaser/entries.rb
@@ -0,0 +1,84 @@
+module Docs
+ class Phaser
+ class EntriesFilter < Docs::ReflyEntriesFilter
+ REPLACE_TYPES = {
+ 'gameobjects' => 'object',
+ 'geom' => 'drawing',
+ 'tilemap' => 'view',
+ 'net' => 'network',
+ 'tween' => 'effect',
+ 'pixi' => 'drawing',
+ 'methods' => 'method',
+ 'animation' => 'effect',
+ 'sound' => 'io',
+ 'core' => 'class',
+ 'loader' => 'class',
+ 'system' => 'class',
+ 'input' => 'io',
+ 'math' => 'function',
+ 'global' => 'others',
+ 'utils' => 'class',
+ 'particles' => 'effect',
+ 'physics' => 'effect',
+ 'members' => 'class'
+ }
+
+ def get_name
+ name = at_css('.title-frame h1').content
+ name.remove!('Phaser.')
+ name.remove!('PIXI.')
+ name
+ end
+
+ def get_docset
+ docset = context[:root_title]
+ docset
+ end
+
+ def get_parsed_uri_by_name(name)
+ context[:docset_uri] + '/' + self.urilized(name.strip)
+ end
+ def get_parsed_uri
+ if get_parent_uri == 'null'
+ parsed_uri = context[:docset_uri] + '/' + self.urilized(get_name)
+ else
+ parsed_uri = get_parent_uri + '/' + self.urilized(get_name)
+ end
+ parsed_uri
+ end
+
+ def get_parent_uri
+ parent_uri = 'null'
+ parent_uri
+ end
+
+ def get_type
+ src = at_css('.container-overview .details > .tag-source > a')
+
+ if src
+ src = src.content.split('/').first
+ return REPLACE_TYPES[src.downcase] || src.capitalize
+ end
+
+ 'others'
+ end
+
+ def additional_entries
+ entries = []
+
+ %w(members methods).each do |type|
+ css("##{type} h4.name").each do |node|
+ sig = node.at_css('.type-signature')
+ next if node.parent.parent.at_css('.inherited-from') || (sig && sig.content.include?('internal'))
+ sep = sig && sig.content.include?('static') ? '.' : '#'
+ name = "#{self.name}#{sep}#{node['id']}#{'()' if type == 'methods'}"
+ custom_parsed_uri = get_parsed_uri_by_name(name)
+ entries << [name, node['id'], REPLACE_TYPES[type] || type, custom_parsed_uri, get_parent_uri, get_docset]
+ end
+ end
+
+ entries
+ end
+ end
+ end
+end
diff --git a/lib/docs/filters/php/clean_html.rb b/lib/docs/filters/php/clean_html.rb
index 24c02a6462..e10e8c441e 100644
--- a/lib/docs/filters/php/clean_html.rb
+++ b/lib/docs/filters/php/clean_html.rb
@@ -1,8 +1,10 @@
module Docs
class Php
- class CleanHtmlFilter < Filter
+ class CleanHtmlFilter < Docs::ReflyFilter
def call
root_page? ? root : other
+ WrapPreContentWithCode 'hljs php'
+ WrapContentWithDivs '_page _php'
doc
end
@@ -21,6 +23,7 @@ def other
# Put code blocks in tags
css('.phpcode > code').each do |node|
node.name = 'pre'
+ node['class'] = ''
end
end
end
diff --git a/lib/docs/filters/php/entries.rb b/lib/docs/filters/php/entries.rb
index 08eade8b9f..9cfbe44a1c 100644
--- a/lib/docs/filters/php/entries.rb
+++ b/lib/docs/filters/php/entries.rb
@@ -1,6 +1,6 @@
module Docs
class Php
- class EntriesFilter < Docs::EntriesFilter
+ class EntriesFilter < Docs::ReflyEntriesFilter
TYPE_BY_NAME_STARTS_WITH = {
'ArrayObject' => 'SPL',
'Collectable' => 'pthreads',
@@ -61,26 +61,9 @@ class EntriesFilter < Docs::EntriesFilter
'Stream' => 'Streams',
'Yaml' => 'YAML' }
- TYPE_GROUPS = {
- 'Classes and Functions' => ['Classes/Object', 'Function handling', 'Predefined Interfaces and Classes', 'runkit'],
- 'Encoding' => ['Gettext', 'iconv', 'Multibyte String'],
- 'Compression' => ['Bzip2', 'Zip', 'Zlib'],
- 'Cryptography' => ['Hash', 'Mcrypt', 'OpenSSL', 'Password Hashing'],
- 'Database' => ['DBA', 'ODBC', 'PDO'],
- 'Date and Time' => ['Calendar', 'Date/Time'],
- 'Errors' => ['Error Handling', 'Predefined Exceptions'],
- 'File System' => ['Directory', 'Fileinfo', 'Filesystem', 'Inotify'],
- 'HTML' => ['DOM', 'Tidy'],
- 'Language' => ['Control Structures', 'Misc.', 'PHP Options/Info', 'Predefined Variables'],
- 'Mail' => ['Mail', 'Mailparse'],
- 'Mathematics' => ['BC Math', 'Math', 'Statistic'],
- 'Networking' => ['GeoIP', 'Network', 'Output Control', 'SSH2', 'Socket', 'URL'],
- 'Process Control' => ['Eio', 'Libevent', 'POSIX', 'Program execution', 'pthreads'],
- 'String' => ['Ctype', 'PCRE', 'POSIX Regex', 'Taint'],
- 'Variables' => ['Filter', 'Variable handling'],
- 'XML' => ['libxml', 'SimpleXML', 'XML Parser', 'XML-RPC', 'XMLReader', 'XMLWriter', 'XSLT'] }
def get_name
+
return 'IntlException' if slug == 'class.intlexception'
name = css('> .sect1 > .title', 'h1', 'h2').first.content
name.remove! 'The '
@@ -89,22 +72,77 @@ def get_name
name
end
- def get_type
- type = at_css('.up').content.strip
- type = 'SPL/Iterators' if type.end_with? 'Iterator'
- type.remove! ' Functions'
+ def get_docset
+ docset = context[:root_title]
+ docset
+ end
- TYPE_BY_NAME_STARTS_WITH.each_pair do |key, value|
- break type = value if name.start_with?(key)
- end
+ def get_parsed_uri
+ parsed_uri = context[:docset_uri] + '/' + path
+ parsed_uri
+ end
- TYPE_GROUPS.each_pair do |replacement, types|
- types.each do |t|
- return replacement if type == t
- end
+ def get_parent_uri
+ subpath = *path.split('/')
+ if subpath.length > 1
+ parent_uri = (context[:docset_uri]+ '/' + subpath[0,subpath.size-1].join('/')).downcase
+ else
+ parent_uri = 'null'
end
+ end
- REPLACE_TYPES[type] || type
+ def get_type
+ if slug.include? 'types'
+ 'type'
+ elsif slug.include? 'interface'
+ 'interface'
+ elsif slug.include? 'variables'
+ 'variable'
+ elsif slug.include? 'language.constants'
+ 'constant'
+ elsif slug.include? 'appendices'
+ 'interface'
+ elsif slug.include? 'migration'
+ 'guide'
+ elsif slug.include? 'faq'
+ 'guide'
+ elsif slug.include? ' install'
+ 'guide'
+ elsif slug.include? 'basic'
+ 'guide'
+ elsif slug.include? 'language.expressions.'
+ 'guide'
+ elsif slug.include? 'language.operators.'
+ 'guide'
+ elsif slug.include? 'control-structures.'
+ 'function'
+ elsif slug.include? 'funcs.'
+ 'function'
+ elsif slug.include? 'cairocontext.'
+ 'function'
+ elsif slug.include? 'function.'
+ 'function'
+ elsif slug.include? 'language.oop5'
+ 'class'
+ elsif slug.include? 'class.'
+ 'class'
+ elsif slug.include? 'language.namespaces.'
+ 'namespace'
+ elsif slug.include? 'language.exceptions.'
+ 'class'
+ elsif slug.include? 'language.references.'
+ 'guide'
+ elsif slug.include? 'operators.'
+ 'variable'
+ elsif slug.include? 'context.'
+ 'guide'
+ elsif slug.include? '::.'
+ 'method'
+ elsif slug.include? 'wrappers.'
+ 'class'
+ else
+ 'others'
+ end
end
def include_default_entry?
diff --git a/lib/docs/filters/php/fix_urls.rb b/lib/docs/filters/php/fix_urls.rb
index 392f27cfae..efce8a520e 100644
--- a/lib/docs/filters/php/fix_urls.rb
+++ b/lib/docs/filters/php/fix_urls.rb
@@ -1,6 +1,6 @@
module Docs
class Php
- class FixUrlsFilter < Filter
+ class FixUrlsFilter < Docs::ReflyFilter
def call
html.gsub! File.join(Php.base_url, Php.root_path), Php.base_url
html.gsub! %r{http://www\.php\.net/manual/en/([^"']+?)\.html}, 'http://www.php.net/manual/en/\1.php'
diff --git a/lib/docs/filters/php/internal_urls.rb b/lib/docs/filters/php/internal_urls.rb
index d5dc384b94..96f44e4eab 100644
--- a/lib/docs/filters/php/internal_urls.rb
+++ b/lib/docs/filters/php/internal_urls.rb
@@ -1,6 +1,6 @@
module Docs
class Php
- class InternalUrlsFilter < Filter
+ class InternalUrlsFilter < Docs::ReflyFilter
def call
if subpath.start_with?('book.') || subpath.start_with?('class.')
result[:internal_urls] = internal_urls
diff --git a/lib/docs/filters/php2/clean_html.rb b/lib/docs/filters/php2/clean_html.rb
new file mode 100644
index 0000000000..7f75939068
--- /dev/null
+++ b/lib/docs/filters/php2/clean_html.rb
@@ -0,0 +1,63 @@
+module Docs
+ class Php2
+ class CleanHtmlFilter < Docs::ReflyFilter
+ BROKEN_LINKS = [
+ 'url.imagemagick.usage.color_mods.sigmoidal',
+ 'url.mongodb.dochub.maxWriteBatchSize',
+ 'url.mongodb.dochub.maxbsonobjectsize',
+ 'javascript:;',
+ 'mongo.configure;',
+ 'mongo.security;'
+ ]
+ def call
+ root_page? ? root : other
+ WrapPreContentWithCode 'hljs php'
+ WrapContentWithDivs '_page _php'
+ doc
+ end
+
+ def root
+ doc.inner_html = ' '
+ end
+
+ def other
+ css('#toTop').remove
+ css('.manualnavbar', 'hr').remove
+ css('.navbar.navbar-fixed-top').remove
+ css('.head').remove
+ css('.page-tools').remove
+ css('.layout-menu').remove
+ css('.navbar-inner.clearfix').remove
+ css('#usernotes').remove
+ css('#breadcrumbs').remove
+ css('#trick').remove
+ css('form').remove
+ css('footer').remove
+
+ # Remove top-level
+ if doc.elements.length == 1
+ @doc = doc.first_element_child
+ end
+ #fixing links
+ css('a[href]').each do |node|
+ if !node['href'].start_with? 'http://' and !node['href'].start_with? 'https://' and !node['href'].start_with? 'ftp://' and !node['href'].start_with? 'news://'
+ if BROKEN_LINKS.include? node['href']
+ node['class'] = 'broken'
+ # node['href'] = context[:domain] + '/help#brokenlink'
+ end
+ end
+ end
+
+ #replace all the classes function for phpfunction to avoid conflict with highlighterjs
+ css('.function').each do |node|
+ node['class'] = 'phpfunction'
+ end
+ # Put code blocks in tags
+ css('.phpcode > code').each do |node|
+ node.name = 'pre'
+ node['class'] = ''
+ end
+ end
+ end
+ end
+end
diff --git a/lib/docs/filters/php2/entries.rb b/lib/docs/filters/php2/entries.rb
new file mode 100644
index 0000000000..39758bb80c
--- /dev/null
+++ b/lib/docs/filters/php2/entries.rb
@@ -0,0 +1,113 @@
+module Docs
+ class Php2
+ class EntriesFilter < Docs::ReflyEntriesFilter
+ EXCLUDED_PATH = ['PHP Manual', 'Language Reference', 'Function Reference','Other Basic Extensions', 'Table of Contents']
+
+ def get_name
+
+ return 'IntlException' if slug == 'class.intlexception'
+ name = css('> .sect1 > .title','.refname', 'h1', 'h2', 'h4','.section > table > caption > strong').first.content
+ name.remove! 'The '
+ name.sub! ' class', ' (class)'
+ name.sub! ' interface', ' (interface)'
+ name
+ end
+
+ def get_alias
+ node = xpath('//li[@class="current"]/a/text()')
+ if node.nil? or get_name.include? '::' or path.start_with?('ref.pdo-sqlsrv.php')
+ _alias = name
+ else
+ _alias = node.to_s
+ end
+ _alias
+ end
+
+ def get_docset
+ docset = context[:root_title]
+ docset
+ end
+
+ def get_parsed_uri
+ if get_parent_uri == 'null'
+ parsed_uri = context[:docset_uri] + '/' + self.urilized(get_alias)
+ else
+ parsed_uri = get_parent_uri + '/' + self.urilized(get_alias)
+ end
+ parsed_uri
+ end
+
+ def get_parent_uri
+ parent_uri = context[:docset_uri]
+ xpath('//*[@id="breadcrumbs-inner"]//li/a/text()').each do |node|
+ link = node.content.strip
+ if not EXCLUDED_PATH.include? link
+ parent_uri += '/' + self.urilized(link)
+ end
+ end
+ if parent_uri == context[:docset_uri]
+ parent_uri = 'null'
+ end
+ parent_uri
+ end
+
+ def get_type
+ if slug.include? 'types'
+ 'type'
+ elsif slug.include? 'interface'
+ 'interface'
+ elsif slug.include? 'variables'
+ 'variable'
+ elsif slug.include? 'language.constants'
+ 'constant'
+ elsif slug.include? 'appendices'
+ 'interface'
+ elsif slug.include? 'migration'
+ 'guide'
+ elsif slug.include? 'faq'
+ 'guide'
+ elsif slug.include? ' install'
+ 'guide'
+ elsif slug.include? 'basic'
+ 'guide'
+ elsif slug.include? 'language.expressions.'
+ 'guide'
+ elsif slug.include? 'language.operators.'
+ 'guide'
+ elsif slug.include? 'control-structures.'
+ 'function'
+ elsif slug.include? 'funcs.'
+ 'function'
+ elsif slug.include? 'cairocontext.'
+ 'function'
+ elsif slug.include? 'function.'
+ 'function'
+ elsif slug.include? 'language.oop5'
+ 'class'
+ elsif slug.include? 'class.'
+ 'class'
+ elsif slug.include? 'language.namespaces.'
+ 'namespace'
+ elsif slug.include? 'language.exceptions.'
+ 'class'
+ elsif slug.include? 'language.references.'
+ 'guide'
+ elsif slug.include? 'operators.'
+ 'variable'
+ elsif slug.include? 'context.'
+ 'guide'
+ elsif slug.include? '::.'
+ 'method'
+ elsif slug.include? 'wrappers.'
+ 'class'
+ else
+ 'others'
+ end
+ end
+
+ def include_default_entry?
+ doc.at_css('.reference', '.refentry', '.sect1', 'section', '.set', '.legalnotice', '.book', '.chapter', '.appendix', '.preface', '.section', '.article','.part')
+ end
+ end
+ end
+end
diff --git a/lib/docs/filters/php2/fix_urls.rb b/lib/docs/filters/php2/fix_urls.rb
new file mode 100644
index 0000000000..e4c19141bc
--- /dev/null
+++ b/lib/docs/filters/php2/fix_urls.rb
@@ -0,0 +1,11 @@
+module Docs
+ class Php2
+ class FixUrlsFilter < Docs::ReflyFilter
+ def call
+ html.gsub! File.join(Php.base_url, Php.root_path), Php.base_url
+ html.gsub! %r{http://www\.php\.net/manual/en/([^"']+?)\.html}, 'http://php.net/manual/en/\1.php'
+ html
+ end
+ end
+ end
+end
diff --git a/lib/docs/filters/php2/internal_urls.rb b/lib/docs/filters/php2/internal_urls.rb
new file mode 100644
index 0000000000..42590ccd22
--- /dev/null
+++ b/lib/docs/filters/php2/internal_urls.rb
@@ -0,0 +1,19 @@
+module Docs
+ class Php2
+ class InternalUrlsFilter < Docs::ReflyFilter
+ def call
+ if subpath.start_with?('book.') || subpath.start_with?('class.') || subpath.start_with?('ref.') || subpath.start_with?('function.')
+ result[:internal_urls] = internal_urls
+ end
+ doc
+ end
+
+ def internal_urls
+ css('.book a', '.chunklist a', '.set a', '.chapter a', '.article a', '.refentry a', '.sect1 a', '.reference a', 'ul li a').inject [] do |urls, link|
+ urls << link['href'] if link.next.try(:text?) && link['href'].exclude?('ref.pdo-')
+ urls
+ end
+ end
+ end
+ end
+end
diff --git a/lib/docs/filters/phpunit/clean_html.rb b/lib/docs/filters/phpunit/clean_html.rb
index 8f0761ce22..61ad19993a 100644
--- a/lib/docs/filters/phpunit/clean_html.rb
+++ b/lib/docs/filters/phpunit/clean_html.rb
@@ -1,8 +1,10 @@
module Docs
class Phpunit
- class CleanHtmlFilter < Filter
+ class CleanHtmlFilter < Docs::ReflyFilter
def call
root_page? ? root : other
+ WrapPreContentWithCode 'hljs php'
+ WrapContentWithDivs '_page _phpunit'
doc
end
@@ -31,6 +33,19 @@ def other
node.before(node.children).remove
end
+ css('pre.screen').each do |node|
+ content = node.content
+ node.name = 'div'
+ node.content = ''
+ content.split(/\n/).each do |fragment|
+ span = Nokogiri::XML::Node.new "span", @doc
+ br = Nokogiri::XML::Node.new "br", @doc
+ span.content = fragment
+ node << span
+ node << br
+ end
+ end
+
css('[style], [border], [valign]').each do |node|
node.remove_attribute('style')
node.remove_attribute('border')
diff --git a/lib/docs/filters/phpunit/entries.rb b/lib/docs/filters/phpunit/entries.rb
index 545c55b8a0..9808f4cec8 100644
--- a/lib/docs/filters/phpunit/entries.rb
+++ b/lib/docs/filters/phpunit/entries.rb
@@ -1,23 +1,63 @@
module Docs
class Phpunit
- class EntriesFilter < Docs::EntriesFilter
+ class EntriesFilter < Docs::ReflyEntriesFilter
def get_name
- at_css('h1').content
+ if at_css('h1')
+ at_css('h1').content
+ else
+ 'PHPUnit'
+ end
+ end
+
+ def get_docset
+ docset = context[:root_title]
+ docset
+ end
+
+ def get_parsed_uri_by_name(name)
+ if get_parent_uri == 'null'
+ parsed_uri = context[:docset_uri] + '/' + self.urilized(name)
+ else
+ parsed_uri = get_parent_uri + '/' + self.urilized(name)
+ end
+ parsed_uri
+ end
+
+ def get_parsed_uri
+ if get_parent_uri == 'null'
+ parsed_uri = context[:docset_uri] + '/' + self.urilized(get_name)
+ else
+ parsed_uri = get_parent_uri + '/' + self.urilized(get_name)
+ end
+ parsed_uri
+ end
+
+ def get_parent_uri
+ subpath = *path.split('/')
+ if subpath.length > 1
+ parent_uri = (context[:docset_uri]+ '/' + subpath[0,subpath.size-1].join('/')).downcase
+ else
+ parent_uri = 'null'
+ end
end
def get_type
- if name.in?(%w(Assertions Annotations))
- name
+ if name.in?(%w(Assertions))
+ 'function'
+ elsif name.in?(%w(Annotations))
+ 'property'
else
- 'Guides'
+ 'guide'
end
end
def additional_entries
- return [] if type == 'Guides'
+ return [] if type == 'guide'
css('h2').map do |node|
- [node.content, node['id']]
+ name = node.content
+ custom_parsed_uri = get_parsed_uri_by_name(name)
+ [name, node['id'], get_type, custom_parsed_uri, get_parent_uri, get_docset]
end
end
end
diff --git a/lib/docs/filters/postgresql/clean_html.rb b/lib/docs/filters/postgresql/clean_html.rb
index a30e454350..d184ef33e6 100644
--- a/lib/docs/filters/postgresql/clean_html.rb
+++ b/lib/docs/filters/postgresql/clean_html.rb
@@ -1,8 +1,10 @@
module Docs
class Postgresql
- class CleanHtmlFilter < Filter
+ class CleanHtmlFilter < Docs::ReflyFilter
def call
root_page? ? root : other
+ WrapPreContentWithCode 'hljs sql'
+ WrapContentWithDivs '_page _postgres'
doc
end
diff --git a/lib/docs/filters/postgresql/entries.rb b/lib/docs/filters/postgresql/entries.rb
index c39ee4a295..002e8010db 100644
--- a/lib/docs/filters/postgresql/entries.rb
+++ b/lib/docs/filters/postgresql/entries.rb
@@ -1,6 +1,31 @@
module Docs
class Postgresql
- class EntriesFilter < Docs::EntriesFilter
+ class EntriesFilter < Docs::ReflyEntriesFilter
+
+ ADDITIONAL_ENTRIES = {
+ 'functions-geometry' => [
+ %w(Geometry nil others /postgresql/geometry null PostgreSQL) ],
+ 'functions-math' => [
+ %w(Math nil others /postgresql/math null PostgreSQL) ],
+ 'functions-json' => [
+ %w(JSON-functions nil others /postgresql/data null PostgreSQL) ],
+ 'functions-range' => [
+ %w(Range-functions nil others /postgresql/operator null PostgreSQL) ],
+ 'functions-net' => [
+ %w(Network-functions nil others /postgresql/network null PostgreSQL) ],
+ 'functions' => [
+ %w(Functions nil others /postgresql/function null PostgreSQL)],
+ 'runtime-config' => [
+ %w(Configurations nil others /postgresql/configuration null PostgreSQL)],
+ 'functions-string' => [
+ %w(Strings nil others /postgresql/string null PostgreSQL)],
+ 'datatype-character' => [
+ %w(Types nil others /postgresql/type null PostgreSQL)],
+ 'functions-binarystring' => [
+ %w(Binary-functions nil others /postgresql/binary_operators null PostgreSQL)]}
+
+ SLUG_TYPES = {
+ 'configuration' => %w(runtime-config-replication runtime-config-resource runtime-config-logging)}
REPLACE_NAMES = {
'Sorting Rows' => 'ORDER BY',
'Select Lists' => 'SELECT Lists',
@@ -10,6 +35,11 @@ class EntriesFilter < Docs::EntriesFilter
'Sequence Manipulation Functions' => 'Sequence Functions',
'System Administration Functions' => 'Administration Functions',
'System Information Functions' => 'Information Functions' }
+ SKIP_ENTRIES_ANCHOR = [
+ '34char34',
+ '124470',
+ '12447'
+ ]
PREPEND_TYPES = [
'Type Conversion',
@@ -26,20 +56,56 @@ class EntriesFilter < Docs::EntriesFilter
'Reliability and the Write-Ahead Log' => 'Write-Ahead Log' }
def base_name
- @base_name ||= clean_heading_name(at_css('h1').content)
+ if at_css('h1')
+ @base_name = clean_heading_name(at_css('h1').content)
+ else
+ @base_name = 'Reference'
+ end
end
+
def get_name
if %w(Overview Introduction).include?(base_name)
result[:pg_chapter_name]
- elsif PREPEND_TYPES.include?(type)
- "#{type}: #{base_name}"
+ elsif PREPEND_TYPES.include?(get_filtering_type)
+ "#{get_filtering_type}: #{base_name}"
else
REPLACE_NAMES[base_name] || base_name
end
end
- def get_type
+ def get_docset
+ docset = context[:root_title]
+ docset
+ end
+
+ def get_parsed_uri
+ if get_parent_uri == 'null'
+ parsed_uri = context[:docset_uri] + '/' + self.urilized(get_name)
+ else
+ parsed_uri = get_parent_uri + '/' + self.urilized(get_name)
+ end
+ parsed_uri
+ end
+
+ def get_parsed_uri_by_name(name)
+ if get_parent_uri == 'null'
+ parsed_uri = context[:docset_uri] + '/' + self.urilized(name)
+ else
+ parsed_uri = get_parent_uri + '/' + self.urilized(name)
+ end
+ parsed_uri
+ end
+
+ def get_parent_uri
+ if get_type == 'others'
+ parent_uri = 'null'
+ else
+ parent_uri = context[:docset_uri]+ '/' + self.urilized(get_type)
+ end
+ end
+
+ def get_filtering_type
return if initial_page?
if result[:pg_up_path] == 'sql-commands.html'
@@ -56,14 +122,37 @@ def get_type
end
end
+ def get_type
+ if SLUG_TYPES['configuration'].include? slug
+ 'configuration'
+ elsif slug.downcase.include? 'math'
+ 'math'
+ elsif slug.downcase.include? 'geometry'
+ 'geometry'
+ elsif slug.downcase.include? 'datatype' or slug.downcase.include? 'array'
+ 'type'
+ elsif slug.downcase.include? 'bitstring' or slug.downcase.include? 'functions-string'
+ 'string'
+ elsif slug.downcase.include? 'range' or slug.downcase.include? 'binarystring'
+ 'operator'
+ elsif slug.downcase.include? 'json'
+ 'data'
+ elsif slug.downcase.include? 'net'
+ 'network'
+ elsif slug.downcase.include? 'function' or slug.downcase.include? 'fulltext'
+ 'function'
+ else
+ 'others'
+ end
+ end
+
def additional_entries
return [] if skip_additional_entries?
- return config_additional_entries if type && type.include?('Configuration')
- return data_types_additional_entries if type == 'Data Types'
+ return config_additional_entries if get_filtering_type && get_filtering_type.include?('Configuration')
+ return data_types_additional_entries.concat ADDITIONAL_ENTRIES['datatype-character'] if get_filtering_type == 'Data Types'
return get_heading_entries('h3[id]') if slug == 'functions-xml'
entries = get_heading_entries('h2[id]')
-
case slug
when 'queries-union'
entries.concat get_custom_entries('p > .LITERAL:first-child')
@@ -77,11 +166,27 @@ def additional_entries
when 'functions-admin'
entries.concat get_custom_entries('.TABLE td:first-child > code')
when 'functions-string'
- entries.concat get_custom_entries('> div[id^="FUNC"] td:first-child > code')
+ entries.concat get_custom_entries('> div[id^="FUNC"] td:first-child > code').concat ADDITIONAL_ENTRIES[slug]
+ when 'functions-math'
+ entries.concat ADDITIONAL_ENTRIES[slug]
+ when 'functions-geometry'
+ entries.concat ADDITIONAL_ENTRIES[slug]
+ when 'runtime-config'
+ entries.concat ADDITIONAL_ENTRIES[slug]
+ when 'functions-json'
+ entries.concat ADDITIONAL_ENTRIES[slug]
+ when 'functions-range'
+ entries.concat ADDITIONAL_ENTRIES[slug]
+ when 'functions-net'
+ entries.concat ADDITIONAL_ENTRIES[slug]
+ when 'functions-binarystring'
+ entries.concat ADDITIONAL_ENTRIES[slug]
+ when 'functions'
+ entries.concat ADDITIONAL_ENTRIES[slug]
else
- if type && type.start_with?('Functions')
+ if get_filtering_type && get_filtering_type.start_with?('Functions')
entries.concat get_custom_entries('> .TABLE td:first-child > code:first-child')
- entries.concat %w(IS NULL BETWEEN DISTINCT\ FROM).map { |name| ["#{self.name}: #{name}"] } if slug == 'functions-comparison'
+ entries.concat %w(IS NULL BETWEEN DISTINCT\ FROM).map { |name| ["#{self.name}: #{name}", nil, get_type, get_parsed_uri_by_name(name), get_parent_uri, get_docset] } if slug == 'functions-comparison'
end
end
@@ -91,7 +196,8 @@ def additional_entries
def config_additional_entries
css('.VARIABLELIST dt[id]').map do |node|
name = node.at_css('.VARNAME').content
- ["Config: #{name}", node['id']]
+ custom_parsed_uri = get_parsed_uri_by_name(name)
+ ["Config: #{name}", node['id'], get_type, custom_parsed_uri, get_parent_uri, get_docset]
end
end
@@ -108,7 +214,7 @@ def data_types_additional_entries
end
def include_default_entry?
- !initial_page? && !at_css('.TOC')
+ true #!initial_page? && !at_css('.TOC')
end
SKIP_ENTRIES_SLUGS = [
@@ -128,7 +234,7 @@ def include_default_entry?
'Monitoring' ]
def skip_additional_entries?
- SKIP_ENTRIES_SLUGS.include?(slug) || SKIP_ENTRIES_TYPES.include?(type)
+ SKIP_ENTRIES_SLUGS.include?(slug) || SKIP_ENTRIES_TYPES.include?(get_filtering_type)
end
def clean_heading_name(name)
@@ -143,10 +249,12 @@ def get_heading_entries(selector)
css(selector).each_with_object([]) do |node, entries|
name = node.content
clean_heading_name(name)
- entries << ["#{additional_entry_prefix}: #{name}", node['id']] unless skip_heading?(name)
+ custom_parsed_uri = get_parsed_uri_by_name(name)
+ entries << ["#{name}", node['id'], get_type, custom_parsed_uri, parent_uri, docset] unless SKIP_ENTRIES_ANCHOR.include?(node['id'])
end
end
+
def get_custom_entries(selector)
css(selector).each_with_object([]) do |node, entries|
name = node.content
@@ -155,24 +263,25 @@ def get_custom_entries(selector)
name.squeeze! ' '
name.remove! %r{\([^\)]*\z} # bug fix: json_populate_record
name = '||' if name.include? ' || '
+ case slug
+ when 'functions-bitstring'
+ name.prepend 'Bitstring operator '
+ when 'functions-string'
+ name.prepend 'String operator '
+ end
id = name.gsub(/[^a-z0-9\-_]/) { |char| char.ord }
id = id.parameterize
- name.prepend "#{additional_entry_prefix}: "
-
unless entries.any? { |entry| entry[0] == name }
node['id'] = id
- entries << [name, id]
+ custom_parsed_uri = get_parsed_uri_by_name(name)
+ entries << [name, id, get_type, custom_parsed_uri, parent_uri, docset] unless SKIP_ENTRIES_ANCHOR.include?(id)
end
end
end
- def additional_entry_prefix
- type.dup.gsub!('Functions: ', '') || self.name
- end
-
def skip_heading?(name)
%w(Usage\ Patterns Portability Caveats Overview).include?(name) ||
- (type.start_with?('Functions') && slug != 'functions-xml' && name.split.first.upcase!)
+ (get_filtering_type.start_with?('Functions') && slug != 'functions-xml' && name.split.first.upcase!)
end
end
end
diff --git a/lib/docs/filters/postgresql/extract_metadata.rb b/lib/docs/filters/postgresql/extract_metadata.rb
index 50e15d8737..637e51fae7 100644
--- a/lib/docs/filters/postgresql/extract_metadata.rb
+++ b/lib/docs/filters/postgresql/extract_metadata.rb
@@ -1,6 +1,6 @@
module Docs
class Postgresql
- class ExtractMetadataFilter < Filter
+ class ExtractMetadataFilter < Docs::ReflyFilter
def call
extract_up_path
extract_chapter
diff --git a/lib/docs/filters/python/clean_html.rb b/lib/docs/filters/python/clean_html.rb
index b71e0649cf..48a8dc4d7b 100644
--- a/lib/docs/filters/python/clean_html.rb
+++ b/lib/docs/filters/python/clean_html.rb
@@ -1,22 +1,51 @@
module Docs
class Python
- class CleanHtmlFilter < Filter
- def call
- @doc = at_css '.body > .section'
+ class CleanHtmlFilter < Docs::ReflyFilter
+ BROKEN_LINKS = [
+ ]
+ def call
+ #@doc = at_css '.body > .section'
+ css('.related', '.footer', '.sphinxsidebarwrapper').remove
# Clean inline code elements
-
css('tt.literal').each do |node|
node.before(node.children).remove
end
+ # fix links
+ css('a[href]').each do |node|
+ if !node['href'].start_with? 'http://' and !node['href'].start_with? 'https://' and !node['href'].start_with? 'ftp://' and !node['href'].start_with? 'irc://'
+ node['href'] = CleanWrongCharacters(node['href'])
+ if BROKEN_LINKS.include?node['href'].downcase.remove! '../'
+ node['class'] = 'broken'
+ # node['href'] = context[:domain] + '/help#brokenlink'
+ elsif !node['href'].start_with? '#' and slug != 'library/index' and !node['href'].start_with? 'mailto:'
+ sluglist = slug.split('/')
+ nodelist = node['href'].split('/')
+ newhref = []
+ nodelist.each do |item|
+ if item == '..'
+ sluglist.pop
+ else
+ newhref << item
+ end
+ end
+ sluglist.pop
+ if sluglist.size>0
+ node['href'] = sluglist.join('/') + '/' + newhref.join('/')
+ else
+ node['href'] = newhref.join('/')
+ end
+ end
+ end
+ end
css('tt', 'span.pre').each do |node|
node.name = 'code'
node.remove_attribute 'class'
end
-
root_page? ? root : other
-
+ WrapPreContentWithCode 'hljs python'
+ WrapContentWithDivs '_page _sphinx'
doc
end
@@ -29,7 +58,10 @@ def other
css('.headerlink', 'hr').remove
# Clean headings
-
+ #replace all the classes function for pythonfunction to avoid conflict with highlighterjs
+ css('.function').each do |node|
+ node['class'] = 'pythonfunction'
+ end
at_css('h1').tap do |node|
node.content = node.content.sub!(/\A[\d\.]+/) { |str| @levelRegexp = /\A#{str}/; '' }
end
@@ -63,6 +95,14 @@ def other
node.remove_attribute 'border'
end
end
+
+ def HighLightCode
+ css('pre').each do |node|
+ html = CodeRay.scan(remove_html_tags(node.content), :Python, :class).html()
+ node.children = Nokogiri::HTML::fragment(html)
+ node['class'] = 'CodeRay'
+ end
+ end
end
end
end
diff --git a/lib/docs/filters/python/entries.rb b/lib/docs/filters/python/entries.rb
index 17a9082329..b870c2ce5f 100644
--- a/lib/docs/filters/python/entries.rb
+++ b/lib/docs/filters/python/entries.rb
@@ -1,17 +1,42 @@
module Docs
class Python
- class EntriesFilter < Docs::EntriesFilter
+ class EntriesFilter < Docs::ReflyEntriesFilter
+
REPLACE_TYPES = {
- 'Cryptographic' => 'Cryptography',
- 'Custom Interpreters' => 'Interpreters',
- 'Data Compression & Archiving' => 'Data Compression',
- 'Generic Operating System' => 'Operating System',
- 'Graphical User Interfaces with Tk' => 'Tk',
- 'Internet Data Handling' => 'Internet Data',
- 'Internet Protocols & Support' => 'Internet',
- 'Interprocess Communication & Networking' => 'Networking',
- 'Program Frameworks' => 'Frameworks',
- 'Structured Markup Processing Tools' => 'Structured Markup' }
+ 'Cryptographic' => 'function',
+ 'Custom Interpreters' => 'function',
+ 'Structured Markup Processing Tools' => 'function',
+ 'Numeric & Mathematical' => 'function',
+ 'Text Processing' => 'function',
+ 'Multimedia' => 'function',
+ 'Data Compression & Archiving' => 'data',
+ 'Internet Data' => 'data',
+ 'Generic Operating System' => 'core',
+ 'Program Frameworks' => 'core',
+ 'Concurrent Execution' => 'core',
+ 'MS Windows' => 'core',
+ 'Unix' => 'core',
+ 'Runtime' => 'core',
+ 'Graphical User Interfaces with Tk' => 'view',
+ 'Internet Data Handling' => 'network',
+ 'Internet Protocols & Support' => 'network',
+ 'Interprocess Communication & Networking' => 'network',
+ 'Binary Data' => 'data',
+ 'Data Persistence' => 'data',
+ 'array' => 'type',
+ 'Built-in Types' => 'type',
+ 'Software Packaging & Distribution' => 'others',
+ 'File & Directory Access' => 'others',
+ 'Miscellaneous' => 'others',
+ '' => 'others',
+ 'File Formats' => 'io',
+ 'Debugging & Profiling' => 'debugging',
+ 'Superseded' => 'deprecated',
+ 'Importing' => 'module',
+ 'Functional Programming' => 'module',
+ 'Development Tools' => 'module',
+ 'Internationalization' => 'language',
+ 'Data Types' => 'type'}
def get_name
name = at_css('h1').content
@@ -23,17 +48,81 @@ def get_name
name
end
- def get_type
- return 'Logging' if slug.start_with? 'library/logging'
+ def get_docset
+ docset = context[:root_title]
+ docset
+ end
- type = at_css('.related a[accesskey="U"]').content
+ def get_parsed_uri_by_name(name)
+ context[:docset_uri] + '/' + self.urilized(name)
+ end
+
+ def get_parsed_uri
+ parsed_uri = context[:docset_uri] + '/' + self.urilized(get_name)
+ parsed_uri
+ end
+
+ def get_parent_uri
+ parent_uri = 'null'
+ parent_uri
+ end
+
+ def get_type
+ return 'others' if slug.start_with? 'library/logging'
+ type = 'others'
+ type = at_css('.related a[accesskey="U"]').content if at_css('.related a[accesskey="U"]')
if type == 'The Python Standard Library'
type = at_css('h1').content
- elsif type.include?('I/O') || %w(select selectors).include?(name)
- type = 'Input/ouput'
+ if type.include? 'Constants'
+ type = 'data'
+ elsif type.include? 'Exceptions'
+ type = 'class'
+ elsif type.include? 'Functions'
+ type = 'function'
+ end
+ elsif type.include?('I/O') || %w(select selectors).include?(get_name)
+ type = 'io'
elsif type.start_with? '19'
- type = 'Internet Data Handling'
+ type = 'network'
+ elsif type.downcase.include? 'data'
+ type = 'data'
+ elsif type.include? 'Numeric'
+ type = 'function'
+ elsif type.include? 'Processing'
+ type = 'function'
+ elsif type.include? 'Debugging'
+ type = 'others'
+ elsif type.include? 'Directory'
+ type = 'io'
+ elsif type.include? 'Unix'
+ type = 'core'
+ elsif type.include? 'Functional'
+ type = 'function'
+ elsif type.include? 'Internationalization'
+ type = 'language'
+ elsif type.include? 'Importing'
+ type = 'io'
+ elsif type.include? 'Multimedia'
+ type = 'view'
+ elsif type.include? 'Logging'
+ type = 'others'
+ elsif type.include? 'Logging'
+ type = 'others'
+ elsif type.include? 'Windows'
+ type = 'core'
+ elsif type.include? 'File'
+ type = 'others'
+ elsif type.include? 'Constants'
+ type = 'data'
+ elsif type.include? 'Concurrent'
+ type = 'core'
+ elsif type.include? 'Tools'
+ type = 'class'
+ elsif type.include? 'Functions'
+ type = 'function'
+ elsif type.include? 'Exceptions'
+ type = 'exception'
end
type.remove! %r{\A\d+\.\s+} # remove list number
@@ -45,26 +134,33 @@ def get_type
end
def include_default_entry?
- !at_css('.body > .section:only-child > .toctree-wrapper:last-child') && !type.in?(%w(Language Superseded))
+ true
+ #!at_css('.body > .section:only-child > .toctree-wrapper:last-child') && !type.in?(%w(Language Superseded))
end
def additional_entries
- return [] if root_page? || !include_default_entry? || name == 'errno'
+ return [] if root_page? || !include_default_entry? || get_name == 'errno'
clean_id_attributes
entries = []
css('.class > dt[id]', '.exception > dt[id]', '.attribute > dt[id]').each do |node|
- entries << [node['id'], node['id']]
+ name = node['id'].remove(/\w+\-/)
+ custom_parsed_uri = get_parsed_uri_by_name(name)
+ entries << [name, node['id'], get_type, custom_parsed_uri, get_parent_uri, get_docset]
end
css('.data > dt[id]').each do |node|
if node['id'].split('.').last.upcase! # skip constants
- entries << [node['id'], node['id']]
+ name = node['id'].remove(/\w+\-/)
+ custom_parsed_uri = get_parsed_uri_by_name(name)
+ entries << [name, node['id'], get_type, custom_parsed_uri, get_parent_uri, get_docset]
end
end
css('.function > dt[id]', '.method > dt[id]', '.classmethod > dt[id]').each do |node|
- entries << [node['id'] + '()', node['id']]
+ name = node['id'].remove(/\w+\-/)
+ custom_parsed_uri = get_parsed_uri_by_name(name)
+ entries << [name + '()', node['id'], get_type, custom_parsed_uri, get_parsed_uri, get_docset]
end
entries
@@ -73,9 +169,9 @@ def additional_entries
def clean_id_attributes
css('.section > .target[id]').each do |node|
if dt = node.at_css('+ dl > dt')
- dt['id'] ||= node['id'].remove(/\w+\-/)
+ dt['id'] ||= node['id']
end
- node.remove
+ #node.remove
end
end
end
diff --git a/lib/docs/filters/python2/entries.rb b/lib/docs/filters/python2/entries.rb
index e091624350..5349f2238d 100644
--- a/lib/docs/filters/python2/entries.rb
+++ b/lib/docs/filters/python2/entries.rb
@@ -1,19 +1,42 @@
module Docs
class Python2
- class EntriesFilter < Docs::EntriesFilter
+ class EntriesFilter < Docs::ReflyEntriesFilter
REPLACE_TYPES = {
- 'compiler package' => 'Compiler',
- 'Cryptographic' => 'Cryptography',
- 'Custom Interpreters' => 'Interpreters',
- 'Data Compression & Archiving' => 'Data Compression',
- 'Generic Operating System' => 'Operating System',
- 'Graphical User Interfaces with Tk' => 'Tk',
- 'Internet Data Handling' => 'Internet Data',
- 'Internet Protocols & Support' => 'Internet',
- 'Interprocess Communication & Networking' => 'Networking',
- 'MacOSA' => 'Mac OS',
- 'Program Frameworks' => 'Frameworks',
- 'Structured Markup Processing Tools' => 'Structured Markup' }
+ 'compiler package' => 'function',
+ 'Cryptographic' => 'function',
+ 'Custom Interpreters' => 'function',
+ 'SGI IRIX' => 'function',
+ 'Numeric & Mathematical' => 'type',
+ 'String' => 'type',
+ 'Data Types' => 'type',
+ 'Graphical User Interfaces with Tk' => 'view',
+ 'Multimedia' => 'view',
+ 'Structured Markup Processing Tools' => 'view',
+ 'Internet Data Handling' => 'network',
+ 'Internet Protocols & Support' => 'network',
+ 'Interprocess Communication & Networking' => 'network',
+ 'Internationalization' => 'language',
+ 'Language' => 'language',
+ 'File & Directory Access' => 'io',
+ 'Importing' => 'io',
+ 'Data Compression & Archiving' => 'data',
+ 'Data Persistence' => 'data',
+ 'Generic Operating System' => 'core',
+ 'Runtime' => 'core',
+ 'Operating System' => 'core',
+ 'MacOSA' => 'core',
+ 'Unix' => 'core',
+ 'Optional Operating System' => 'core',
+ 'MS Windows' => 'core',
+ 'SunOS' => 'core',
+ 'Program Frameworks' => 'core',
+ 'Built-in Exceptions' => 'exception',
+ 'Development Tools' => 'others',
+ 'Debugging & Profiling' => 'others',
+ 'File Formats' => 'others',
+ 'Restricted Execution' => 'others',
+ 'Software Packaging & Distribution' => 'others'
+ }
def get_name
name = at_css('h1').content
@@ -24,20 +47,50 @@ def get_name
name.strip!
name
end
+
+ def get_docset
+ docset = context[:root_title]
+ docset
+ end
+
+ def get_parsed_uri_by_name(name)
+ context[:docset_uri] + '/' + self.urilized(name)
+ end
+
+ def get_parsed_uri
+ parsed_uri = context[:docset_uri] + '/' + self.urilized(get_name)
+ parsed_uri
+ end
+
+ def get_parent_uri
+ parent_uri = 'null'
+ parent_uri
+ end
def get_type
- return 'Logging' if slug.start_with? 'library/logging'
+ return 'others' if slug.start_with? 'library/logging'
- type = at_css('.related a[accesskey="U"]').content
+ if at_css('.related a[accesskey="U"]')
+ type = at_css('.related a[accesskey="U"]').content
+ else
+ type = 'others'
+ end
if type == 'The Python Standard Library'
type = at_css('h1').content
+ if type.include? 'Functions'
+ type = 'function'
+ elsif type.include? 'Built-in Types'
+ type = 'type'
+ elsif type.include? 'Built-in Constants'
+ type = 'data'
+ end
elsif type.include?('I/O') || %w(select selectors).include?(name)
- type = 'Input/ouput'
+ type = 'io'
elsif type.start_with? '18'
- type = 'Internet Data Handling'
+ type = 'network'
elsif type.include? 'Mac'
- type = 'Mac OS'
+ type = 'core'
end
type.remove! %r{\A\d+\.\s+} # remove list number
@@ -49,26 +102,32 @@ def get_type
end
def include_default_entry?
- !at_css('.body > .section:only-child > .toctree-wrapper:last-child') && !type.in?(%w(Language Superseded SunOS))
+ true #!(at_css('.body > .section:only-child > .toctree-wrapper:last-child') && !type.in?(%w(Language Superseded SunOS))) || slug == 'library/index'
end
def additional_entries
- return [] if root_page? || !include_default_entry? || name == 'errno'
+ return [] if !include_default_entry? || name == 'errno'
clean_id_attributes
entries = []
css('.class > dt[id]', '.exception > dt[id]', '.attribute > dt[id]').each do |node|
- entries << [node['id'], node['id']]
+ name = node['id']
+ custom_parsed_uri = get_parsed_uri_by_name(name)
+ entries << [name, node['id'], get_type, custom_parsed_uri, get_parsed_uri, get_docset]
end
css('.data > dt[id]').each do |node|
if node['id'].split('.').last.upcase! # skip constants
- entries << [node['id'], node['id']]
+ name = node['id']
+ custom_parsed_uri = get_parsed_uri_by_name(name)
+ entries << [name, node['id'], get_type, custom_parsed_uri, get_parsed_uri, get_docset]
end
end
css('.function > dt[id]', '.method > dt[id]', '.classmethod > dt[id]').each do |node|
- entries << [node['id'] + '()', node['id']]
+ name = node['id'] + '()'
+ custom_parsed_uri = get_parsed_uri_by_name(name)
+ entries << [name, node['id'], get_type, custom_parsed_uri, get_parsed_uri, get_docset]
end
entries
@@ -84,4 +143,4 @@ def clean_id_attributes
end
end
end
-end
+end
\ No newline at end of file
diff --git a/lib/docs/filters/q/clean_html.rb b/lib/docs/filters/q/clean_html.rb
new file mode 100644
index 0000000000..3cc107d85c
--- /dev/null
+++ b/lib/docs/filters/q/clean_html.rb
@@ -0,0 +1,19 @@
+module Docs
+ class Q
+ class CleanHtmlFilter < Docs::ReflyFilter
+ def call
+ css('.anchor').each do |node|
+ node.parent['id'] = node['href'].remove('#')
+ node.remove
+ end
+
+ css('.highlight > pre').each do |node|
+ node.content = node.content.gsub(' ', ' ')
+ end
+ WrapPreContentWithCode 'hljs javascript'
+ WrapContentWithDivs '_page _q'
+ doc
+ end
+ end
+ end
+end
diff --git a/lib/docs/filters/q/entries.rb b/lib/docs/filters/q/entries.rb
new file mode 100644
index 0000000000..44c429fd62
--- /dev/null
+++ b/lib/docs/filters/q/entries.rb
@@ -0,0 +1,72 @@
+module Docs
+ class Q
+ class EntriesFilter < Docs::ReflyEntriesFilter
+ REPLACE_TYPES = {
+ 'Custom Messaging' => 'function',
+ 'Q.defer()' => 'function'
+ }
+
+ def get_name
+ 'Index'
+ end
+
+ def get_docset
+ docset = context[:root_title]
+ docset
+ end
+
+ def get_parsed_uri
+ if get_parent_uri == 'null'
+ parsed_uri = context[:docset_uri] + '/' + self.urilized(get_name)
+ else
+ parsed_uri = get_parent_uri + '/' + self.urilized(get_name)
+ end
+ parsed_uri
+ end
+
+ def get_parsed_uri_by_name(name)
+ parsed_uri = context[:docset_uri] + '/' + self.urilized(name)
+ parsed_uri
+ end
+
+ def get_parent_uri
+ parent_uri = 'null'
+ parent_uri
+ end
+
+ def get_type
+ 'others'
+ end
+
+ def additional_entries
+ entry = type = nil
+ css('h3, h4, em:contains("Alias")').each_with_object [] do |node, entries|
+ case node.name
+ when 'h3'
+ type = node.content.strip
+ type.remove! %r{\(.+\)}
+ type.remove! ' Methods'
+ type.remove! ' API'
+ custom_parsed_uri = get_parsed_uri_by_name(type)
+ entries << [type, node['id'], REPLACE_TYPES[type] || type, custom_parsed_uri, get_parent_uri, get_docset] if type == 'Q.defer()'
+ when 'h4'
+ name = node.content.strip
+ name.sub! %r{\(.*?\).*}, '()'
+ id = node['id'] = name.parameterize
+ custom_parsed_uri = get_parsed_uri_by_name(name)
+ entry = [name, id, REPLACE_TYPES[type.strip] || type, custom_parsed_uri, get_parent_uri, get_docset]
+ entries << entry
+ when 'em'
+ name = node.parent.at_css('code').content
+ name << '()' if entry[0].end_with?('()')
+ dup = entry.dup
+ custom_parsed_uri = get_parsed_uri_by_name(name)
+ dup[0] = name
+ dup[3] = custom_parsed_uri
+ entries << dup
+ end
+ end
+ end
+ end
+ end
+end
diff --git a/lib/docs/filters/rails/clean_html.rb b/lib/docs/filters/rails/clean_html.rb
new file mode 100644
index 0000000000..9cc8144048
--- /dev/null
+++ b/lib/docs/filters/rails/clean_html.rb
@@ -0,0 +1,59 @@
+module Docs
+ class Rails
+ class CleanHtmlFilter < Docs::ReflyFilter
+ BROKEN_LINKS = [
+ 'rdoc-ref:httphelpers',
+ 'erb_'
+ ]
+ REPLACED_LINKS = {
+ }
+ def call
+ css('.box_info').remove
+ css('a[href]').each do |node|
+ node['href'] = CleanWrongCharacters(node['href'])
+ if REPLACED_LINKS[node['href'].downcase]
+ node['href'] = REPLACED_LINKS[node['href']]
+ elsif !node['href'].start_with? 'http://' and !node['href'].start_with? 'https://'
+ if node.content.strip.include? "\u{00B6}" or node['href'] == '#top'
+ node.remove
+ elsif node['href'].downcase.include? '/doc/syntax'
+ node['class'] = 'broken'
+ elsif BROKEN_LINKS.include? node['href'].downcase.remove! '../'
+ node['class'] = 'broken'
+ else
+ sluglist = slug.split('/')
+ nodelist = node['href'].split('/')
+ newhref = []
+ nodelist.each do |item|
+ if item == '..'
+ sluglist.pop
+ else
+ newhref << item
+ end
+ end
+ sluglist.pop
+ if sluglist.size>0
+ node['href'] = sluglist.join('/') + '/' + newhref.join('/')
+ else
+ node['href'] = newhref.join('/')
+ end
+ end
+ end
+ end
+
+ root_page? ? root : other
+
+ WrapPreContentWithCode 'hljs ruby'
+ WrapContentWithDivs '_page _rdoc'
+ doc
+
+ end
+
+ def root
+ end
+
+ def other
+ end
+ end
+ end
+end
\ No newline at end of file
diff --git a/lib/docs/filters/rails/entries.rb b/lib/docs/filters/rails/entries.rb
index 2bf4668504..d9c30fa52c 100644
--- a/lib/docs/filters/rails/entries.rb
+++ b/lib/docs/filters/rails/entries.rb
@@ -1,69 +1,78 @@
module Docs
class Rails
- class EntriesFilter < Docs::Rdoc::EntriesFilter
- TYPE_BY_NAME_MATCHES = {
- /Assertions|::Test|Fixture/ => 'Testing',
- /\AActiveRecord.+mysql/i => 'ActiveRecord/MySQL',
- /\AActiveRecord.+postgresql/i => 'ActiveRecord/PostgreSQL',
- /\AActiveRecord.+sqlite/i => 'ActiveRecord/SQLite',
- /\AActiveRecord.+Assoc/ => 'ActiveRecord/Associations',
- /\AActiveRecord.+Attribute/ => 'ActiveRecord/Attributes',
- /\AActiveRecord.+ConnectionAdapters/ => 'ActiveRecord/Connection',
- /\AActiveSupport.+(Subscriber|Notifications)/ => 'ActiveSupport/Instrumentation',
- /\A(False|Nil|True)Class/ => 'Boolean' }
+ class EntriesFilter < Docs::ReflyEntriesFilter
+ EXCLUDED_PATH = ['Libraries']
+ def get_name
+ if at_css('h1')
+ name = at_css('h1').content.strip
+ if name.index('::')
+ name = name.split('::').last
+ end
+ else
+ name = slug
+ end
+ name.remove! 'Module: '
+ name.remove! 'Class: '
+ name
+ end
- TYPE_BY_NAME_STARTS_WITH = {
- 'ActionDispatch::Integration' => 'Testing',
- 'ActionDispatch::Request' => 'ActionDispatch/Request',
- 'ActionDispatch::Response' => 'ActionDispatch/Response',
- 'ActionDispatch::Routing' => 'ActionDispatch/Routing',
- 'ActionView::Helpers' => 'ActionView/Helpers',
- 'ActiveModel::Errors' => 'ActiveModel/Validation',
- 'ActiveModel::Valid' => 'ActiveModel/Validation',
- 'ActiveRecord::Batches' => 'ActiveModel/Query',
- 'ActiveRecord::Calculations' => 'ActiveModel/Query',
- 'ActiveRecord::Connection' => 'ActiveModel/Connection',
- 'ActiveRecord::FinderMethods' => 'ActiveModel/Query',
- 'ActiveRecord::Query' => 'ActiveModel/Query',
- 'ActiveRecord::Relation' => 'ActiveModel/Relation',
- 'ActiveRecord::Result' => 'ActiveModel/Connection',
- 'ActiveRecord::Scoping' => 'ActiveModel/Query',
- 'ActiveRecord::SpawnMethods' => 'ActiveModel/Query',
- 'ActiveSupport::Cach' => 'ActiveSupport/Caching',
- 'ActiveSupport::Inflector' => 'ActiveSupport/Inflector',
- 'ActiveSupport::Time' => 'ActiveSupport/TimeZones',
- 'Rails::Application' => 'Rails/Application',
- 'Rails::Engine' => 'Rails/Engine',
- 'Rails::Railtie' => 'Rails/Railtie' }
+ def get_docset
+ docset = context[:root_title]
+ docset
+ end
- def get_type
- parent = at_css('.meta-parent').try(:content).to_s
+ def get_parsed_uri_by_name(name)
+ parsed_uri = context[:docset_uri] + '/' + self.urilized(name)
+ parsed_uri
+ end
- if [name, parent].any? { |str| str.end_with?('Error') || str.end_with?('Exception') }
- return 'Errors'
+ def get_parsed_uri
+ if get_parent_uri == 'null'
+ parsed_uri = context[:docset_uri] + '/' + self.urilized(get_name)
+ else
+ parsed_uri = get_parent_uri + '/' + self.urilized(get_name)
end
+ parsed_uri
+ end
- TYPE_BY_NAME_MATCHES.each_pair do |key, value|
- return value if name =~ key
+ def get_parent_uri
+ parent_uri = context[:docset_uri]
+ xpath('//div[@id="menu"]//a/text()').each do |node|
+ link = node.content.strip
+ if not EXCLUDED_PATH.include? link and !link.start_with? 'Index'
+ parent_uri += '/' + self.urilized(link)
+ end
end
-
- TYPE_BY_NAME_STARTS_WITH.each_pair do |key, value|
- return value if name.start_with?(key)
+ if parent_uri == context[:docset_uri]
+ parent_uri = 'null'
end
-
- super
+ parent_uri
end
- def include_default_entry?
- super && !skip?
+ def get_type
+ if at_css('h1')
+ name = at_css('h1').content.strip
+ else
+ name = 'others'
+ end
+ if name.start_with? 'Module'
+ type = 'module'
+ elsif name.start_with? 'Class'
+ type = 'class'
+ else
+ type = 'others'
+ end
+ type
end
def additional_entries
- skip? ? [] : super
- end
-
- def skip?
- @skip ||= !css('p').any? { |node| node.content.present? }
+ entries = []
+ css('h3.signature').each do |node|
+ name = node.content.strip
+ custom_parsed_uri = get_parsed_uri_by_name(name)
+ entries << [name, node['id'], 'method', custom_parsed_uri, get_parsed_uri, get_docset]
+ end
+ entries
end
end
end
diff --git a/lib/docs/filters/rdoc/clean_html.rb b/lib/docs/filters/rdoc/clean_html.rb
index 359b55b82a..deba4a3e75 100644
--- a/lib/docs/filters/rdoc/clean_html.rb
+++ b/lib/docs/filters/rdoc/clean_html.rb
@@ -1,6 +1,6 @@
module Docs
class Rdoc
- class CleanHtmlFilter < Filter
+ class CleanHtmlFilter < Docs::ReflyFilter
def call
root_page? ? root : other
doc
@@ -13,6 +13,20 @@ def root
css('li > span').each do |node|
node.parent.remove
end
+
+ #remove css title
+ css('title').each do |node|
+ node.remove
+ end
+ #remove css links
+ css('link').each do |node|
+ node.remove
+ end
+
+ #remove meta
+ css('meta').each do |node|
+ node.remove
+ end
end
def other
@@ -46,4 +60,4 @@ def other
end
end
end
-end
+end
\ No newline at end of file
diff --git a/lib/docs/filters/rdoc/container.rb b/lib/docs/filters/rdoc/container.rb
index fb6d3d2e8c..a97f2bc3cb 100644
--- a/lib/docs/filters/rdoc/container.rb
+++ b/lib/docs/filters/rdoc/container.rb
@@ -1,6 +1,6 @@
module Docs
class Rdoc
- class ContainerFilter < Filter
+ class ContainerFilter < Docs::ReflyFilter
def call
if root_page?
at_css 'main'
diff --git a/lib/docs/filters/rdoc/entries.rb b/lib/docs/filters/rdoc/entries.rb
index c62754bffb..a11756e3bc 100644
--- a/lib/docs/filters/rdoc/entries.rb
+++ b/lib/docs/filters/rdoc/entries.rb
@@ -1,6 +1,6 @@
module Docs
class Rdoc
- class EntriesFilter < Docs::EntriesFilter
+ class EntriesFilter < Docs::ReflyEntriesFilter
def get_name
name = at_css('h1, h2').content.strip
name.remove! "\u{00B6}" # remove pilcrow sign
@@ -10,8 +10,32 @@ def get_name
name
end
+ def get_docset
+ docset = context[:root_title]
+ docset
+ end
+
+ def get_parsed_uri
+ if get_parent_uri == 'null'
+ parsed_uri = context[:docset_uri] + '/' + self.urilized(get_name)
+ else
+ parsed_uri = get_parent_uri + '/' + self.urilized(get_name)
+ end
+ parsed_uri
+ end
+
+ def get_parent_uri
+ subpath = *path.split('/')
+ if subpath.length > 1
+ parent_uri = (context[:docset_uri]+ '/' + subpath[0,subpath.size-1].join('/')).downcase
+ else
+ parent_uri = 'null'
+ end
+ parent_uri
+ end
+
def get_type
- type = name.dup
+ type = get_name
unless type.gsub! %r{::.*\z}, ''
parent = at_css('.meta-parent').try(:content).to_s
@@ -22,7 +46,7 @@ def get_type
end
def include_default_entry?
- at_css('> .description p') || css('.documentation-section').any? { |node| node.content.present? }
+ true #at_css('> .description p') || css('.documentation-section').any? { |node| node.content.present? }
end
def additional_entries
@@ -38,7 +62,8 @@ def additional_entries
unless name.start_with? '_'
name.prepend self.name + (node['id'] =~ /\A\w+-c-/ ? '::' : '#')
- entries << [name, node['id']] unless entries.any? { |entry| entry[0] == name }
+ custom_parsed_uri = get_parsed_uri + '#' + node['id']
+ entries << [name, node['id'], get_type, custom_parsed_uri, get_parent_uri, get_docset] unless entries.any? { |entry| entry[0] == name }
end
entries
diff --git a/lib/docs/filters/react/clean_html.rb b/lib/docs/filters/react/clean_html.rb
index a9a7d82928..d6060d6011 100644
--- a/lib/docs/filters/react/clean_html.rb
+++ b/lib/docs/filters/react/clean_html.rb
@@ -1,6 +1,17 @@
module Docs
class React
- class CleanHtmlFilter < Filter
+ class CleanHtmlFilter < Docs::ReflyFilter
+ BROKEN_LINKS = [
+ 'nativemodulesandroid.md',
+ 'upgrading',
+ 'linux-windows-support',
+ 'javascript:void(0);'
+ ]
+ REPLACED_LINKS = {
+ 'react/docs/advanced-performance' => 'advanced-performance',
+ 'docs/docs/jsx-in-depth' => 'docs/jsx-in-depth',
+ 'docs/docs/tutorial' => 'docs/tutorial'
+ }
def call
@doc = at_css('.inner-content')
@@ -24,8 +35,44 @@ def call
node.remove if node.content.strip == 'Note:'
end
+ fixLinks
+ WrapPreContentWithCode 'hljs javascript'
+ WrapContentWithDivs '_page _react'
doc
end
+ def fixLinks
+ css('a[href]').each do |node|
+ node['href'] = CleanWrongCharacters(node['href']).downcase
+ if REPLACED_LINKS[node['href'].downcase.remove! '../']
+ node['href'] = REPLACED_LINKS[node['href'].remove '../']
+ elsif !node['href'].start_with? 'http://' and !node['href'].start_with? '#' and !node['href'].start_with? 'https://' and !node['href'].start_with? 'ftp://' and !node['href'].start_with? 'irc://' and !node['href'].start_with? 'news://' and !node['href'].start_with? 'mailto:'
+ if node['class'] == 'new'
+ node['class'] = 'broken'
+ node['title'] = ''
+ else
+ sluglist = slug.split('/')
+ if context[:url].to_s.include? '.html'
+ sluglist.pop
+ end
+ nodelist = sluglist + node['href'].split('/')
+ newhref = []
+ nodelist.each do |item|
+ if item == '..'
+ newhref.pop
+ elsif item != ''
+ newhref << item
+ end
+ end
+ node['href'] = newhref.join('/')
+ end
+ end
+ if BROKEN_LINKS.include? node['href'].downcase.remove! '../'
+ node['class'] = 'broken'
+ end
+ node['href'] = REPLACED_LINKS[node['href']] || node['href']
+ end
+
+ end
end
end
end
diff --git a/lib/docs/filters/react/entries.rb b/lib/docs/filters/react/entries.rb
index c6b707e272..c249ddcf77 100644
--- a/lib/docs/filters/react/entries.rb
+++ b/lib/docs/filters/react/entries.rb
@@ -1,32 +1,78 @@
module Docs
class React
- class EntriesFilter < Docs::EntriesFilter
+ class EntriesFilter < Docs::ReflyEntriesFilter
API_SLUGS = %w(
- top-level-api
- component-api
- component-specs
+ docs/top-level-api
+ docs/component-api
+ docs/component-specs
)
def get_name
- at_css('h1').child.content
+ at_css('h1').child.content.strip
+ end
+
+ def get_docset
+ docset = context[:root_title]
+ docset
+ end
+
+ def get_parsed_uri_by_name(name)
+ if get_parent_uri == 'null'
+ parsed_uri = context[:docset_uri] + '/' + self.urilized(name)
+ else
+ parsed_uri = get_parent_uri + '/' + self.urilized(name)
+ end
+ parsed_uri
+ end
+
+ def get_parsed_uri
+ parsed_uri = context[:docset_uri] + '/' + self.urilized(get_name)
+ parsed_uri
+ end
+
+ def get_parent_uri
+ 'null'
end
def get_type
- link = at_css('.nav-docs-section .active')
- section = link.ancestors('.nav-docs-section').first
- section.at_css('h3').content
+ if slug.downcase.include? 'component'
+ 'component'
+ elsif slug.downcase.include? 'thinking' or slug.include? 'tutorial' or slug.include? 'dom' or slug.include? 'performance'
+ 'guide'
+ elsif slug.downcase.include? 'event'
+ 'event'
+ elsif slug.downcase.include? 'api'
+ 'api'
+ elsif slug.downcase.include? 'jsx'
+ 'element'
+ else
+ 'others'
+ end
+
end
def additional_entries
- return [] unless API_SLUGS.include?(slug)
-
- css('.inner-content h3, .inner-content h4').map do |node|
- name = node.content
- name.remove! %r{[#\(\)]}
- name.remove! %r{\w+\:}
- id = node.at_css('.anchor')['name']
- type = slug.include?('component') ? 'Component' : 'React'
- [name, id, type]
+ if API_SLUGS.include?(slug)
+ css('.inner-content h3, .inner-content h4').map do |node|
+ name = node.content
+ name.remove! %r{[#\(\)]}
+ name.remove! %r{\w+\:}
+ id = node.at_css('.anchor')['name']
+ custom_parsed_uri = get_parsed_uri_by_name(name)
+ [name, id, get_type, custom_parsed_uri, get_parent_uri, get_docset]
+
+ end
+ else
+ css('.props > .prop > .propTitle').each_with_object([]) do |node, entries|
+ name = node.children.find(&:text?).try(:content)
+ next if name.blank?
+ sep = node.content.include?('static') ? '.' : '#'
+ name.prepend(self.name + sep)
+ name << '()' if node.css('.propType').last.content.start_with?('(')
+ id = node.at_css('.anchor')['name']
+ custom_parsed_uri = get_parsed_uri_by_name(name)
+ entries << [name, id, get_type, custom_parsed_uri, get_parent_uri, get_docset]
+ end
end
end
end
diff --git a/lib/docs/filters/react_router/clean_html.rb b/lib/docs/filters/react_router/clean_html.rb
new file mode 100644
index 0000000000..0b1c8ef770
--- /dev/null
+++ b/lib/docs/filters/react_router/clean_html.rb
@@ -0,0 +1,60 @@
+module Docs
+ class ReactRouter
+ class CleanHtmlFilter < Docs::ReflyFilter
+ BROKEN_LINKS = [
+ 'docs/redirect.md/index',
+ 'docs/changes.md/index'
+ ]
+ REPLACED_LINKS = {
+ 'examples/index' => 'https://github.com/rackt/react-router/tree/master/examples',
+ 'docs/index' => 'index',
+ 'docs/upgrade_guide.md/index' => 'upgrade_guide.md/index'
+ }
+ def call
+ css('p a img').remove
+ css('.highlight > pre').each do |node|
+ node.content = node.content.gsub(' ', ' ')
+ end
+ fixLinks
+ WrapPreContentWithCode 'hljs javascript'
+ WrapContentWithDivs '_page _react-router'
+ doc
+ end
+ def fixLinks
+ css('a[href]').each do |node|
+ node['href'] = CleanWrongCharacters(node['href']).downcase
+ if REPLACED_LINKS[node['href'].downcase.remove! '../']
+ node['href'] = REPLACED_LINKS[node['href'].remove '../']
+ elsif !node['href'].start_with? '#' and !node['href'].start_with? 'http://' and !node['href'].start_with? '#' and !node['href'].start_with? 'https://' and !node['href'].start_with? 'ftp://' and !node['href'].start_with? 'irc://' and !node['href'].start_with? 'news://' and !node['href'].start_with? 'mailto:'
+ if node['class'] == 'new'
+ node['class'] = 'broken'
+ node['title'] = ''
+ else
+ sluglist = slug.split('/')
+ if context[:url].to_s.include? '.html'
+ sluglist.pop
+ end
+ if slug == 'docs/README.md'
+ sluglist.pop
+ end
+ nodelist = sluglist + node['href'].split('/')
+ newhref = []
+ nodelist.each do |item|
+ if item == '..'
+ newhref.pop
+ elsif item != '' and !newhref.include? item
+ newhref << item
+ end
+ end
+ node['href'] = newhref.join('/')
+ end
+ end
+ if BROKEN_LINKS.include? node['href'].downcase.remove! '../'
+ node['class'] = 'broken'
+ end
+ node['href'] = REPLACED_LINKS[node['href']] || node['href']
+ end
+ end
+ end
+ end
+end
diff --git a/lib/docs/filters/react_router/entries.rb b/lib/docs/filters/react_router/entries.rb
new file mode 100644
index 0000000000..5da6dfbc74
--- /dev/null
+++ b/lib/docs/filters/react_router/entries.rb
@@ -0,0 +1,78 @@
+module Docs
+ class ReactRouter
+ class EntriesFilter < Docs::ReflyEntriesFilter
+ REPLACE_TYPES = {
+ 'Index' => 'others',
+ 'API' => 'api',
+ 'Upgrade guide' => 'guide',
+ 'Introduction' => 'guide',
+ 'Glossary' => 'glossary',
+ 'Route configuration' => 'routing',
+ 'Dynamic routing' => 'routing',
+ 'Route Matching' => 'routing',
+ 'Navigating outside of components' => 'navigation',
+ 'Confirming navigation' => 'navigation',
+ 'Component lifecycle' => 'guide',
+ 'Server rendering' => 'guide',
+ 'Index routes' => 'routing',
+ 'Troubleshooting' => 'others'
+ }
+ REPLACE_NAMES = {
+ 'README.md' => 'Index',
+ 'API.md' => 'API',
+ 'Introduction.md' => 'Introduction',
+ 'UPGRADE_GUIDE.md' => 'Upgrade guide',
+ 'Glossary.md' => 'Glossary',
+ 'RouteConfiguration.md' => 'Route configuration',
+ 'DynamicRouting.md' => 'Dynamic routing',
+ 'RouteMatching.md' => 'Route Matching',
+ 'NavigatingOutsideOfComponents.md' => 'Navigating outside of components',
+ 'ConfirmingNavigation.md' => 'Confirming navigation',
+ 'ComponentLifecycle.md' => 'Component lifecycle',
+ 'ServerRendering.md' => 'Server rendering',
+ 'IndexRoutes.md' => 'Index routes',
+ 'Troubleshooting.md' => 'Troubleshooting'
+ }
+ def get_name
+ REPLACE_NAMES[slug.split('/').last] || 'Otro Index'
+ end
+
+ def get_docset
+ docset = context[:root_title]
+ docset
+ end
+
+ def get_parsed_uri
+ if get_parent_uri == 'null'
+ parsed_uri = context[:docset_uri] + '/' + self.urilized(get_name)
+ else
+ parsed_uri = get_parent_uri + '/' + self.urilized(get_name)
+ end
+ parsed_uri
+ end
+
+ def get_parsed_uri_by_name(name)
+ parsed_uri = context[:docset_uri] + '/' + self.urilized(name)
+ parsed_uri
+ end
+
+ def get_parent_uri
+ 'null'
+ end
+
+ def get_type
+ REPLACE_TYPES[get_name] || 'others'
+ end
+
+ def additional_entries
+ entries = []
+ css('h1 a', 'h2 a', 'h3 a', 'h4 a').each do |node|
+ name = node.parent.content.strip
+ custom_parsed_uri = get_parsed_uri_by_name(name)
+ entries << [name, node['href'].remove('#'), get_type || 'others', custom_parsed_uri, get_parent_uri, get_docset]
+ end
+ entries
+ end
+ end
+ end
+end
diff --git a/lib/docs/filters/redis/clean_html.rb b/lib/docs/filters/redis/clean_html.rb
index 2a3f505964..7c8e2f05b2 100644
--- a/lib/docs/filters/redis/clean_html.rb
+++ b/lib/docs/filters/redis/clean_html.rb
@@ -1,6 +1,6 @@
module Docs
class Redis
- class CleanHtmlFilter < Filter
+ class CleanHtmlFilter < Docs::ReflyFilter
def call
at_css('ul')['class'] = 'commands' if root_page?
@@ -10,10 +10,8 @@ def call
node.before(node.children).remove
end
- css('.example > pre').each do |node|
- node.name = 'code'
- end
-
+ WrapPreContentWithCode 'hljs sql'
+ WrapContentWithDivs '_page _redis'
doc
end
end
diff --git a/lib/docs/filters/redis/entries.rb b/lib/docs/filters/redis/entries.rb
index 9c3668f59a..3906847b9c 100644
--- a/lib/docs/filters/redis/entries.rb
+++ b/lib/docs/filters/redis/entries.rb
@@ -1,25 +1,49 @@
module Docs
class Redis
- class EntriesFilter < Docs::EntriesFilter
+ class EntriesFilter < Docs::ReflyEntriesFilter
def get_name
- slug.gsub('-', ' ')
+ name = slug.gsub('-', ' ')
+ name = 'Index' if name == ''
+ name
+ end
+ def get_docset
+ docset = context[:root_title]
+ docset
+ end
+
+ def get_parsed_uri
+ parsed_uri = context[:docset_uri] + '/' + path
+ parsed_uri
+ end
+
+ def get_parent_uri
+ subpath = *path.split('/')
+ if subpath.length > 1
+ parent_uri = (context[:docset_uri]+ '/' + subpath[0,subpath.size-1].join('/')).downcase
+ else
+ parent_uri = 'null'
+ end
end
def get_type
- case at_css('aside > ul:last-child a').content.strip
- when 'DEL' then 'Keys'
- when 'APPEND' then 'Strings'
- when 'HDEL' then 'Hashes'
- when 'BLPOP' then 'Lists'
- when 'SADD' then 'Sets'
- when 'ZADD' then 'Sorted Sets'
- when 'PSUBSCRIBE' then 'Pub/Sub'
- when 'DISCARD' then 'Transactions'
- when 'EVAL' then 'Scripting'
- when 'AUTH' then 'Connection'
- when 'BGREWRITEAOF' then 'Server'
- when 'PFADD' then 'HyperLogLog'
- else 'Miscellaneous'
+ if at_css('aside > ul:last-child a')
+ case at_css('aside > ul:last-child a').content.strip
+ when 'DEL' then 'function'
+ when 'APPEND' then 'function'
+ when 'HDEL' then 'function'
+ when 'BLPOP' then 'function'
+ when 'SADD' then 'function'
+ when 'ZADD' then 'function'
+ when 'PSUBSCRIBE' then 'function'
+ when 'DISCARD' then 'function'
+ when 'EVAL' then 'function'
+ when 'AUTH' then 'network'
+ when 'BGREWRITEAOF' then 'network'
+ when 'PFADD' then 'others'
+ else 'others'
+ end
+ else
+ 'others'
end
end
end
diff --git a/lib/docs/filters/reflux/clean_html.rb b/lib/docs/filters/reflux/clean_html.rb
new file mode 100644
index 0000000000..ba395a337f
--- /dev/null
+++ b/lib/docs/filters/reflux/clean_html.rb
@@ -0,0 +1,52 @@
+module Docs
+ class Reflux
+ class CleanHtmlFilter < Docs::ReflyFilter
+ BROKEN_LINKS = [
+ 'blob/master/test/index.js/index'
+ ]
+ REPLACED_LINKS = {}
+ def call
+ css('p a img').remove
+ css('.highlight > pre').each do |node|
+ node.content = node.content.gsub(' ', ' ')
+ end
+ fixLinks
+ WrapPreContentWithCode 'hljs javascript'
+ WrapContentWithDivs '_page _reflux'
+ doc
+ end
+ def fixLinks
+ css('a[href]').each do |node|
+ node['href'] = CleanWrongCharacters(node['href']).downcase
+ if REPLACED_LINKS[node['href'].downcase.remove! '../']
+ node['href'] = REPLACED_LINKS[node['href'].remove '../']
+ elsif !node['href'].start_with? '#' and !node['href'].start_with? 'http://' and !node['href'].start_with? '#' and !node['href'].start_with? 'https://' and !node['href'].start_with? 'ftp://' and !node['href'].start_with? 'irc://' and !node['href'].start_with? 'news://' and !node['href'].start_with? 'mailto:'
+ if node['class'] == 'new'
+ node['class'] = 'broken'
+ node['title'] = ''
+ else
+ sluglist = slug.split('/')
+ if context[:url].to_s.include? '.html'
+ sluglist.pop
+ end
+ nodelist = sluglist + node['href'].split('/')
+ newhref = []
+ nodelist.each do |item|
+ if item == '..'
+ newhref.pop
+ elsif item != ''
+ newhref << item
+ end
+ end
+ node['href'] = newhref.join('/')
+ end
+ end
+ if BROKEN_LINKS.include? node['href'].downcase.remove! '../'
+ node['class'] = 'broken'
+ end
+ node['href'] = REPLACED_LINKS[node['href']] || node['href']
+ end
+ end
+ end
+ end
+end
diff --git a/lib/docs/filters/reflux/entries.rb b/lib/docs/filters/reflux/entries.rb
new file mode 100644
index 0000000000..c9205435fe
--- /dev/null
+++ b/lib/docs/filters/reflux/entries.rb
@@ -0,0 +1,90 @@
+module Docs
+ class Reflux
+ class EntriesFilter < Docs::ReflyEntriesFilter
+ REPLACE_TYPES = {
+ 'Content' => 'others',
+ 'Comparing RefluxJS with Facebook Flux' => 'guide',
+ 'Examples' => 'others',
+ 'Extensions and Plugins' => 'utils',
+ 'Installation' => 'guide',
+ 'Usage' => 'guide',
+ 'Advanced usage' => 'guide',
+ 'Similarities with Flux' => 'guide',
+ 'Differences with Flux' => 'guide',
+ 'NPM' => 'platforms',
+ 'Bower' => 'platforms',
+ 'CDN' => 'platforms',
+ 'ES5' => 'platforms',
+ 'Creating actions' => 'function',
+ 'Creating data stores' => 'function',
+ 'Listening to changes in data store' => 'function',
+ 'React component example' => 'others',
+ 'Listening to changes in other data stores (aggregate data stores)' => 'function',
+ 'Switching EventEmitter' => 'function',
+ 'Switching Promise library' => 'function',
+ 'Switching Promise factory' => 'function',
+ 'Switching nextTick' => 'function',
+ 'Joining parallel listeners with composed listenables' => 'function',
+ 'Sending initial state with the listenTo function' => 'function',
+ 'Asynchronous actions' => 'function',
+ 'Action hooks' => 'function',
+ 'Reflux.ActionMethods' => 'function',
+ 'Reflux.StoreMethods' => 'function',
+ 'Mixins in stores' => 'function',
+ 'Listening to many actions at once' => 'function',
+ 'The listenables shorthand' => 'function',
+ 'Listenables and asynchronous actions' => 'function',
+ 'Convenience mixin for React' => 'guide',
+ 'Using Reflux.listenTo' => 'method',
+ 'Using Reflux.connect' => 'method',
+ 'Using Reflux.connectFilter' => 'method',
+ 'Argument tracking' => 'method',
+ 'Using the listener instance methods' => 'method',
+ 'Using the static methods' => 'method',
+ }
+ def get_name
+ 'Index'
+ end
+
+ def get_docset
+ docset = context[:root_title]
+ docset
+ end
+
+ def get_parsed_uri
+ if get_parent_uri == 'null'
+ parsed_uri = context[:docset_uri] + '/' + self.urilized(get_name)
+ else
+ parsed_uri = get_parent_uri + '/' + self.urilized(get_name)
+ end
+ parsed_uri
+ end
+
+ def get_parsed_uri_by_name(name)
+ parsed_uri = context[:docset_uri] + '/' + self.urilized(name)
+ parsed_uri
+ end
+
+ def get_parent_uri
+ 'null'
+ end
+
+ def get_type
+ 'others'
+ end
+
+ def additional_entries
+ entries = []
+ count = 0
+ css('h1 a', 'h2 a', 'h3 a', 'h4 a').each do |node|
+ count+=1
+ name = node.parent.content.strip
+ next if name == 'Colophon' or name == 'RefluxJS'
+ custom_parsed_uri = get_parsed_uri_by_name(name)
+ entries << [name, node['href'].remove('#'), REPLACE_TYPES[name] || 'others', custom_parsed_uri, get_parent_uri, get_docset]
+ end
+ entries
+ end
+ end
+ end
+end
diff --git a/lib/docs/filters/requirejs/clean_html.rb b/lib/docs/filters/requirejs/clean_html.rb
index 56d551219c..808f2248b8 100644
--- a/lib/docs/filters/requirejs/clean_html.rb
+++ b/lib/docs/filters/requirejs/clean_html.rb
@@ -1,6 +1,6 @@
module Docs
class Requirejs
- class CleanHtmlFilter < Filter
+ class CleanHtmlFilter < Docs::ReflyFilter
def call
css('.sectionMark', '.hbox > .sect').remove
css('h1 + .note').remove if root_page?
@@ -15,6 +15,8 @@ def call
link.before(link.children).remove
end
+ WrapPreContentWithCode 'hljs javascript'
+ WrapContentWithDivs '_page _requirejs'
doc
end
end
diff --git a/lib/docs/filters/requirejs/entries.rb b/lib/docs/filters/requirejs/entries.rb
index f2e95d5faa..cbef3b3209 100644
--- a/lib/docs/filters/requirejs/entries.rb
+++ b/lib/docs/filters/requirejs/entries.rb
@@ -1,33 +1,103 @@
module Docs
class Requirejs
- class EntriesFilter < Docs::EntriesFilter
+ class EntriesFilter < Docs::ReflyEntriesFilter
+ SLUG_ENTRIES = %w(
+ api
+ optimization
+ jquery
+ node
+ dojo
+ commonjs
+ plugins
+ why
+ whyamd)
+
def get_name
- at_css('h1').content
+ if at_css('h1')
+ name = at_css('h1').content
+ else
+ name = 'Index'
+ end
+ name
end
+ def get_docset
+ docset = context[:root_title]
+ docset
+ end
+
+ def get_parsed_uri_by_name(name)
+ if get_parent_uri == 'null'
+ parsed_uri = context[:docset_uri] + '/' + self.urilized(name)
+ else
+ parsed_uri = get_parent_uri + '/' + self.urilized(name)
+ end
+ parsed_uri
+ end
+
+ def get_parsed_uri
+ if get_parent_uri == 'null'
+ parsed_uri = context[:docset_uri] + '/' + self.urilized(get_name)
+ else
+ parsed_uri = get_parent_uri + '/' + self.urilized(get_name)
+ end
+ parsed_uri
+ end
+
+ def get_parent_uri
+ subpath = *path.split('/')
+ if subpath.length > 1
+ parent_uri = (context[:docset_uri]+ '/' + subpath[0,subpath.size-1].join('/')).downcase
+ else
+ parent_uri = 'null'
+ end
+ end
+
def get_type
- 'Guides'
+ if slug.include? 'why' or slug.include? 'optimization'
+ 'guide'
+ elsif slug.include? 'api'
+ 'api'
+ elsif slug.include? 'jquery' or slug.include? 'commonjs' or slug.include? 'node'
+ 'guide'
+ elsif slug.include? 'plugins'
+ 'module'
+ else
+ 'others'
+ end
+ end
+
+ def include_default_entry?
+ return false if slug == ''
+ return true
end
def additional_entries
- return [] unless root_page?
-
+ return [] unless SLUG_ENTRIES.include? slug
entries = []
type = nil
+
css('*').each do |node|
if node.name == 'h2'
- type = node.content
- elsif node.name == 'h3' || node.name == 'h4'
- entries << [node.content, node['id'], type]
+ next if node == nil
+ name = node.content
+ custom_parsed_uri = get_parsed_uri_by_name(name)
+ id = node['id']
+ entries << [name, id, 'guide', custom_parsed_uri, get_parent_uri, get_docset]
+ elsif (node.name == 'h3' || node.name == 'h4') && node.content.strip !=''
+ name = node.content
+ custom_parsed_uri = get_parsed_uri_by_name(name)
+ entries << [name, node['id'], get_type, custom_parsed_uri, get_parent_uri, get_docset]
end
end
css('p[id^="config-"]').each do |node|
next if node['id'].include?('note')
- entries << [node.at_css('strong').content, node['id'], 'Configuration Options']
+ name = node.at_css('strong').content
+ custom_parsed_uri = get_parsed_uri_by_name(name)
+ entries << [name, node['id'], 'configuration', custom_parsed_uri, get_parent_uri, get_docset]
end
-
entries
end
end
diff --git a/lib/docs/filters/rethinkdb/clean_html.rb b/lib/docs/filters/rethinkdb/clean_html.rb
index ecaa27621a..989e652acf 100644
--- a/lib/docs/filters/rethinkdb/clean_html.rb
+++ b/lib/docs/filters/rethinkdb/clean_html.rb
@@ -1,6 +1,14 @@
module Docs
class Rethinkdb
- class CleanHtmlFilter < Filter
+ class CleanHtmlFilter < Docs::ReflyFilter
+
+ BROKEN_LINKS = [
+ 'table_status'
+ ]
+ REPLACED_LINKS = {
+
+ }
+
def call
if root_page?
doc.inner_html = 'ReQL command reference
'
@@ -31,6 +39,38 @@ def call
node.name = 'h2'
end
+ # fix links
+ css('a[href]').each do |node|
+ node['href'] = CleanWrongCharacters(node['href']).remove '_(event)'
+ if !node['href'].start_with? 'http://' and !node['href'].start_with? 'https://' and !node['href'].start_with? 'ftp://' and !node['href'].start_with? 'irc://'
+ if REPLACED_LINKS[node['href'].remove! '../']
+ node['href'] = REPLACED_LINKS[node['href'].remove! '../']
+ elsif BROKEN_LINKS.include?node['href'].downcase.remove! '../'
+ node['class'] = 'broken'
+ node['href'] = context[:domain] + '/help#brokenlink'
+ else
+ sluglist = slug.split('/')
+ nodelist = node['href'].split('/')
+ newhref = []
+ nodelist.each do |item|
+ if item == '..'
+ sluglist.pop
+ else
+ newhref << item
+ end
+ end
+ sluglist.pop
+ if sluglist.size>0
+ node['href'] = sluglist.join('/') + '/' + newhref.join('/')
+ else
+ node['href'] = newhref.join('/')
+ end
+ end
+ end
+ end
+
+ WrapPreContentWithCode 'hljs nimrod'
+ WrapContentWithDivs '_page _rethinkdb'
doc
end
end
diff --git a/lib/docs/filters/rethinkdb/entries.rb b/lib/docs/filters/rethinkdb/entries.rb
index 949cb891f8..040f9e1d01 100644
--- a/lib/docs/filters/rethinkdb/entries.rb
+++ b/lib/docs/filters/rethinkdb/entries.rb
@@ -1,8 +1,31 @@
module Docs
class Rethinkdb
- class EntriesFilter < Docs::EntriesFilter
+ class EntriesFilter < Docs::ReflyEntriesFilter
def get_name
- at_css('.title').content.remove('ReQL command:')
+ at_css('.title').content.remove('ReQL command:').split(', ').first
+ end
+
+ def get_docset
+ docset = context[:root_title]
+ docset
+ end
+
+ def get_parsed_uri_by_name(name)
+ context[:docset_uri] + '/' + self.urilized(name)
+ end
+
+ def get_parsed_uri
+ parsed_uri = context[:docset_uri] + '/' + path
+ parsed_uri
+ end
+
+ def get_parent_uri
+ subpath = *path.split('/')
+ if subpath.length > 1
+ parent_uri = (context[:docset_uri]+ '/' + subpath[0,subpath.size-1].join('/')).downcase
+ else
+ parent_uri = 'null'
+ end
end
def get_type
@@ -10,6 +33,26 @@ def get_type
dir = link['href'][/javascript\/([^\/]+)/, 1]
dir.titleize.gsub('Rql', 'ReQL').gsub('And', 'and')
end
+
+ def additional_entries
+ at_css('.title').content.split(', ')[1..-1].map do |name|
+ custom_parsed_uri = get_parsed_uri_by_name(name)
+ [name,'', get_type, custom_parsed_uri, get_parent_uri, get_docset]
+ end
+ end
+
+ # def get_type
+ # link = at_css('a[href^="https://github.com/rethinkdb/docs/blob/master/api/javascript/"]')
+ # dir = link['href'][/javascript\/([^\/]+)/, 1]
+ # dir = dir.titleize.gsub('Rql', 'ReQL').gsub('And', 'and')
+ # if dir.include? 'Joins' or dir.include? 'Data' or dir.include? 'Tables' or dir.include? 'Databases'
+ # 'databse'
+ # elsif dir.include? 'Manipulation' or dir.include? 'Math' or dir.include? 'String' or dir.include? 'Dates'
+ # 'function'
+ # else
+ # 'others'
+ # end
+ # end
end
end
end
diff --git a/lib/docs/filters/ruby/clean_html.rb b/lib/docs/filters/ruby/clean_html.rb
new file mode 100644
index 0000000000..343a3b3820
--- /dev/null
+++ b/lib/docs/filters/ruby/clean_html.rb
@@ -0,0 +1,114 @@
+module Docs
+ class Ruby
+ class CleanHtmlFilter < Docs::ReflyFilter
+ BROKEN_LINKS = [
+ 'i',
+ '*rows',
+ 'rdoc',
+ 'header',
+ 'text',
+ '123',
+ '0-3',
+ '0-2',
+ '4',
+ '3',
+ '2',
+ '1',
+ '0',
+ '',
+ 'bqn0',
+ 'uwm',
+ '@modifier',
+ '\'field_name\'',
+ '\'path\'',
+ 'position()=3',
+ 'widgetclassname',
+ 'ary',
+ '_territory',
+ 'status'
+ ]
+ REPLACED_LINKS = {
+ "www.ruby-lang.org" => "http://www.ruby-lang.org",
+ "../drb" => "libdoc/drb/rdoc/drb",
+ "../rexml" => "libdoc/rexml/rdoc/rexml",
+ "task" => "libdoc/rdoc/rdoc/rdoc/task",
+ "rdoc::markup@links" => "mailto:markup@links"
+ }
+ def call
+ css('#actionbar', '#metadata', '.title', '.link-list', 'form', '.info', '.dsq-brlink', '#footer').remove
+ css('#wrapper > p').each do |node|
+ node.remove if node['style']
+ end
+ root_page? ? root : other
+
+ #remove css title
+ css('title').each do |node|
+ node.remove
+ end
+ #remove css links
+ css('link').each do |node|
+ node.remove
+ end
+ #remove css links
+ css('.method-source-code').each do |node|
+ node['class'] = ''
+ end
+ #remove meta
+ css('meta').each do |node|
+ node.remove
+ end
+ WrapPreContentWithCode 'hljs ruby'
+ WrapContentWithDivs '_page _rdoc'
+ doc
+
+ end
+
+ def root
+ end
+
+ def other
+ css('hr').remove
+ # Move id attributes to headings
+ css('.method-detail').each do |node|
+ next unless heading = node.at_css('.method-heading')
+ heading['id'] = node['id']
+ node.remove_attribute 'id'
+ end
+
+ css('a[href]').each do |node|
+ node['href'] = CleanWrongCharacters(node['href'])
+ if REPLACED_LINKS[node['href'].downcase]
+ node['href'] = REPLACED_LINKS[node['href']]
+ elsif !node['href'].start_with? 'http://' and !node['href'].start_with? 'https://' and !node['href'].start_with? 'ftp://' and !node['href'].start_with? 'irc://' and !node['href'].start_with? 'mailto:'
+ if node.content.strip.include? "\u{00B6}" or node['href'] == '#top'
+ node.remove
+ elsif node['href'].downcase.include? '/doc/syntax'
+ node['class'] = 'broken'
+ node['href'] = context[:domain] + '/help#brokenlink'
+ elsif BROKEN_LINKS.include? node['href'].downcase.remove! '../'
+ node['class'] = 'broken'
+ node['href'] = context[:domain] + '/help#brokenlink'
+ else
+ sluglist = slug.split('/')
+ nodelist = node['href'].split('/')
+ newhref = []
+ nodelist.each do |item|
+ if item == '..'
+ sluglist.pop
+ else
+ newhref << item
+ end
+ end
+ sluglist.pop
+ if sluglist.size>0
+ node['href'] = sluglist.join('/') + '/' + newhref.join('/')
+ else
+ node['href'] = newhref.join('/')
+ end
+ end
+ end
+ end
+ end
+ end
+ end
+end
\ No newline at end of file
diff --git a/lib/docs/filters/ruby/entries.rb b/lib/docs/filters/ruby/entries.rb
index 23ea77650a..b3d1331402 100644
--- a/lib/docs/filters/ruby/entries.rb
+++ b/lib/docs/filters/ruby/entries.rb
@@ -1,78 +1,71 @@
module Docs
class Ruby
- class EntriesFilter < Docs::Rdoc::EntriesFilter
- REPLACE_TYPE = {
- 'ACL' => 'DRb',
- 'Addrinfo' => 'Socket',
- 'BigMath' => 'BigDecimal',
- 'CMath' => 'Math',
- 'ConditionVariable' => 'Mutex',
- 'DEBUGGER__' => 'Debug',
- 'Errno' => 'Errors',
- 'FileTest' => 'File',
- 'Jacobian' => 'BigDecimal',
- 'LUSolve' => 'BigDecimal',
- 'Newton' => 'BigDecimal',
- 'PP' => 'PrettyPrint',
- 'Profiler__' => 'Profiler',
- 'Psych' => 'YAML',
- 'Rinda' => 'DRb',
- 'SimpleDelegator' => 'Delegator',
- 'SingleForwardable' => 'Forwardable',
- 'SortedSet' => 'Set',
- 'TCPServer' => 'Socket',
- 'TempIO' => 'Tempfile',
- 'ThWait' => 'Thread',
- 'UNIXServer' => 'Socket' }
+ class EntriesFilter < Docs::ReflyEntriesFilter
- REPLACE_TYPE_STARTS_WITH = {
- 'Monitor' => 'Monitor',
- 'Mutex' => 'Mutex',
- 'Shell' => 'Shell',
- 'Sync' => 'Sync',
- 'Thread' => 'Thread' }
-
- REPLACE_TYPE_ENDS_WITH = {
- 'Queue' => 'Queue',
- 'Socket' => 'Socket' }
+ def get_name
+ if at_css('h1')
+ name = at_css('h1').content.strip
+ name.remove! "\u{00B6}" # remove pilcrow sign
+ name.remove! "\u{2191}" # remove up arrow sign
+ name.remove! 'class '
+ name.remove! 'module '
+ else
+ name = slug
+ end
+ name
+ end
- def get_type
- return 'Language' if guide?
- return $1 if name =~ /\A(Net\:\:(?:FTP|HTTP|IMAP|SMTP))/
+ def get_docset
+ docset = context[:root_title]
+ docset
+ end
- type = super
+ def get_parsed_uri_by_name(name)
+ parsed_uri = context[:docset_uri] + '/' + self.urilized(name)
+ parsed_uri
+ end
- REPLACE_TYPE_STARTS_WITH.each_pair do |key, value|
- return value if type.start_with?(key)
+ def get_parsed_uri
+ if get_parent_uri == 'null'
+ parsed_uri = context[:docset_uri] + '/' + self.urilized(get_name)
+ else
+ parsed_uri = get_parent_uri + '/' + self.urilized(get_name)
end
+ parsed_uri
+ end
- REPLACE_TYPE_ENDS_WITH.each_pair do |key, value|
- return value if type.end_with?(key)
- end
+ def get_parent_uri
+ parent_uri = 'null'
+ parent_uri
+ end
- REPLACE_TYPE[type] || type
+ def get_type
+ if get_name.include? 'Ruby Standard Library'
+ type = 'module'
+ elsif css('.parent-class-section')
+ type = 'class'
+ else
+ type = 'others'
+ end
+ type
end
def additional_entries
- return super unless guide?
-
- if slug == 'syntax/control_expressions_rdoc' || slug == 'syntax/miscellaneous_rdoc'
- css('h2 > code').each_with_object([]) do |node, entries|
- name = node.content.strip
- entries << [name, node.parent['id'], 'Syntax'] unless entries.any? { |e| e[0] == name }
- end
- elsif slug == 'globals_rdoc'
- css('dt').map do |node|
- name = node['id'] = node.content.strip
- [name, name, 'Globals']
- end
- else
- []
+ entries = []
+ css('h3').each do |node|
+ name = node.content.strip
+ custom_parsed_uri = get_parsed_uri_by_name(name)
+ entries << [name, node['id'], 'method', custom_parsed_uri, get_parsed_uri, get_docset]
end
+ entries
end
def include_default_entry?
- guide? || super
+ if !at_css('h1')
+ false
+ else
+ true
+ end
end
def guide?
@@ -80,4 +73,4 @@ def guide?
end
end
end
-end
+end
\ No newline at end of file
diff --git a/lib/docs/filters/rust/clean_html.rb b/lib/docs/filters/rust/clean_html.rb
new file mode 100644
index 0000000000..ed32c168b7
--- /dev/null
+++ b/lib/docs/filters/rust/clean_html.rb
@@ -0,0 +1,147 @@
+module Docs
+ class Rust
+ class CleanHtmlFilter < Docs::ReflyFilter
+
+ BROKEN_LINKS = [
+ # 'collections/vec/struct.partialveczerosized',
+ # 'collections/vec/struct.partialvecnonzerosized',
+ # 'collections/binary_heap/struct.hole',
+ # 'collections/btree/map/stack/struct.idref',
+ # 'collections/linked_list/struct.rawlink',
+ # 'collections/bit/struct.blockiter',
+ # 'collections/btree/node/struct.node',
+ # 'collections/btree/node/struct.handle',
+ # 'collections/btree/node/struct.abstraversal',
+ # 'collections/str/enum.decompositiontype',
+ # 'collections/str/enum.recompositionstate',
+ # 'collections/slice/enum.direction',
+ # 'collections/linked_list/struct.node',
+ # 'collections/btree/node/struct.movetraversalimpl',
+ # 'collections/btree/node/struct.rawitems',
+ # 'collections/slice/struct.sizedirection',
+ # 'collections/bit/struct.twobitpositions',
+ # 'collections/btree/map/struct.absiter',
+ # 'collections/btree/node/enum.traversalitem',
+ # 'collections/btree/node/struct.elemsandedges',
+ # 'collections/btree/node/trait.traversalimpl',
+ # 'collections/btree/map/trait.traverse',
+ # 'collections/primitive.i32'
+ ]
+ REPLACED_LINKS = {
+ 'collections/binary_heap/struct.binaryheap/struct.binaryheap' => 'collections/binary_heap/struct.binaryheap',
+ 'collections/binary_heap/vec/struct.vec' => 'collections/vec/struct.vec',
+ 'macro.try!' => 'std/macro.try!',
+ 'std/std/macro.write!' => 'std/macro.write!',
+ 'std/std/fs/struct.file' => 'std/fs/struct.file',
+ 'std/std/macro.format_args!' => 'std/macro.format_args!',
+ 'std/string/primitive.char' => 'std/primitive.char',
+ 'std/string/primitive.u8' => 'std/primitive.u8',
+ 'std/string/iter/trait.doubleendediterator' => 'std/iter/trait.doubleendediterator',
+ 'std/string/string/struct.string' => 'std/string/struct.string',
+ 'std/string/str/trait.fromstr' => 'std/str/trait.fromstr',
+ 'std/std/cell/struct.refcell' => 'std/cell/struct.refcell',
+ 'std/std/cell/struct.cell' => 'std/cell/struct.cell',
+ 'std/std/cmp/trait.ord' => 'std/cmp/trait.ord',
+ 'collections/btree_set/struct.btreemap' => 'std/collections/struct.btreemap',
+ 'std/collections/btree_set/struct.btreemap' => 'std/collections/struct.btreemap'
+ }
+ def call
+
+
+ if slug.start_with?('book')
+ book
+ elsif slug.start_with?('reference')
+ reference
+ else
+ api
+ end
+
+ css('.rusttest', 'hr').remove
+
+ css('.docblock > h1').each { |node| node.name = 'h4' }
+ css('h2.section-header').each { |node| node.name = 'h3' }
+ css('h1.section-header').each { |node| node.name = 'h2' }
+
+ css('> .impl-items', '> .docblock').each do |node|
+ node.before(node.children).remove
+ end
+
+ css('h1 > a', 'h2 > a', 'h3 > a', 'h4 > a', 'h5 > a').each do |node|
+ node.before(node.children).remove
+ end
+
+ css('pre > code').each do |node|
+ node.parent['class'] = node['class']
+ node.before(node.children).remove
+ end
+
+ css('pre').each do |node|
+ node.content = node.content
+ end
+ fixLinks
+ WrapPreContentWithCode 'hljs rust'
+ WrapContentWithDivs '_page _rust'
+ doc
+ end
+ def fixLinks
+ css('a[href]').each do |node|
+ node['href'] = CleanWrongCharacters(node['href']).downcase
+ if REPLACED_LINKS[node['href'].downcase.remove! '../']
+ node['href'] = REPLACED_LINKS[node['href'].remove '../']
+ elsif !node['href'].start_with? '#' and !node['href'].start_with? 'http://' and !node['href'].start_with? '#' and !node['href'].start_with? 'https://' and !node['href'].start_with? 'ftp://' and !node['href'].start_with? 'irc://' and !node['href'].start_with? 'news://' and !node['href'].start_with? 'mailto:'
+ if node['class'] == 'new'
+ node['class'] = 'broken'
+ node['title'] = ''
+ else
+ sluglist = slug.remove('struct.binaryheap/').split('/')
+ if context[:url].to_s.include? '.html'
+ sluglist.pop
+ end
+ if slug == 'book/index'
+ sluglist.pop
+ end
+ nodelist = sluglist + node['href'].split('/')
+ newhref = []
+ nodelist.each do |item|
+ if item == '..'
+ newhref.pop
+ elsif item != ''
+ newhref << item
+ end
+ end
+ node['href'] = newhref.join('/')
+ end
+ end
+ if BROKEN_LINKS.include? node['href'].downcase.remove! '../'
+ node['class'] = 'broken'
+ end
+ node['href'] = REPLACED_LINKS[node['href']] || node['href']
+ end
+
+ end
+
+ def book
+ @doc = at_css('#page')
+ end
+
+ def reference
+ css('#versioninfo').remove
+ end
+
+ def api
+ @doc = at_css('#main')
+
+ css('.toggle-wrapper').remove
+
+ css('h1.fqn').each do |node|
+ node.content = node.at_css('.in-band').content
+ end
+
+ css('.stability .stab').each do |node|
+ node.name = 'span'
+ node.content = node.content
+ end
+ end
+ end
+ end
+end
diff --git a/lib/docs/filters/rust/entries.rb b/lib/docs/filters/rust/entries.rb
new file mode 100644
index 0000000000..2b22bfa7d2
--- /dev/null
+++ b/lib/docs/filters/rust/entries.rb
@@ -0,0 +1,86 @@
+module Docs
+ class Rust
+ class EntriesFilter < Docs::ReflyEntriesFilter
+ def get_name
+ if slug == 'book/index'
+ 'Index'
+ elsif slug.start_with?('book')
+ at_css("#toc a[href='#{File.basename(slug)}']").content
+ elsif slug.start_with?('reference')
+ 'Reference'
+ else
+ name = at_css('h1.fqn .in-band').content.remove(/\A.+\s/)
+ mod = slug.split('/').first
+ name.prepend("#{mod}::") unless name.start_with?(mod)
+ name
+ end
+ end
+
+ PRIMITIVE_SLUG = /\A(\w+)\/(primitive)\./
+ def get_docset
+ docset = context[:root_title]
+ docset
+ end
+
+ def get_parsed_uri_by_name(name)
+ parsed_uri = context[:docset_uri] + '/' + self.urilized(name)
+ parsed_uri
+ end
+
+ def get_parsed_uri
+ if get_parent_uri == 'null'
+ parsed_uri = context[:docset_uri] + '/' + self.urilized(get_name)
+ else
+ parsed_uri = get_parent_uri + '/' + self.urilized(get_name)
+ end
+ parsed_uri
+ end
+
+ def get_parent_uri
+ parent_uri = 'null'
+ end
+
+ def get_type
+ if slug.start_with?('book')
+ 'guide'
+ elsif slug.start_with?('reference')
+ 'guide'
+ else
+ path = name.split('::')
+ heading = at_css('h1.fqn .in-band').content.strip
+ if path[0] == 'collections'
+ 'collection'
+ elsif path[0] == 'std'
+ 'language'
+ elsif path.length > 2 || (path.length == 2 && (heading.start_with?('Module') || heading.start_with?('Primitive')))
+ path[0..1].join('::')
+ else
+ path[0]
+ end
+ end
+ end
+
+ def additional_entries
+ if slug.start_with?('book')
+ []
+ elsif slug.start_with?('reference')
+ css('#TOC > ul > li > a', '#TOC > ul > li > ul > li > a').map do |node|
+ name = node.content
+ name.sub! %r{(\d)\ }, '\1. '
+ name.sub! '10.0.', '10.'
+ id = node['href'].remove('#')
+ custom_parsed_uri = get_parsed_uri_by_name(name)
+ [name, id, get_type, custom_parsed_uri, get_parent_uri, get_docset]
+ end
+ else
+ css('#methods + * + div > .method', '#required-methods + div > .method', '#provided-methods + div > .method').map do |node|
+ name = node.at_css('.fnname').content
+ name.prepend "#{self.name}::"
+ custom_parsed_uri = get_parsed_uri_by_name(name)
+ [name, node['id'], get_type, custom_parsed_uri, get_parent_uri, get_docset]
+ end
+ end
+ end
+ end
+ end
+end
diff --git a/lib/docs/filters/sass/clean_html.rb b/lib/docs/filters/sass/clean_html.rb
index ce19c6559d..dc8df155e2 100644
--- a/lib/docs/filters/sass/clean_html.rb
+++ b/lib/docs/filters/sass/clean_html.rb
@@ -1,6 +1,6 @@
module Docs
class Sass
- class CleanHtmlFilter < Filter
+ class CleanHtmlFilter < Docs::ReflyFilter
def call
css('tt').each do |node|
node.name = 'code'
@@ -8,11 +8,19 @@ def call
root_page? ? root : other
+ WrapPreContentWithCode 'hljs css'
+ WrapContentWithDivs '_page _yard'
doc
end
def root
at_css('.maruku_toc').remove
+ css('a[href]').each do |node|
+ node['href'] = node['href'].sub('../../','')
+ if node['href'].include? 'file.sass_reference'
+ node['href'] = node['href'].sub('file.sass_reference', 'index')
+ end
+ end
end
def other
@@ -42,6 +50,15 @@ def other
node.name = 'span'
end
+ css('a[href]').each do |node|
+ if node['href'].include? '../'
+ node['href'] = node['href'].sub('../../','')
+ end
+ if node['href'].include? 'file.sass_reference'
+ node['href'] = node['href'].sub('file.sass_reference', 'index')
+ end
+ end
+
# Remove links to type classes (e.g. Number)
css('.type > code').each do |node|
node.before(node.content.remove('Sass::Script::Value::').remove('Sass::Script::')).remove
@@ -49,4 +66,4 @@ def other
end
end
end
-end
+end
\ No newline at end of file
diff --git a/lib/docs/filters/sass/entries.rb b/lib/docs/filters/sass/entries.rb
index a20fd979a6..c9fb5b17b5 100644
--- a/lib/docs/filters/sass/entries.rb
+++ b/lib/docs/filters/sass/entries.rb
@@ -1,8 +1,8 @@
module Docs
class Sass
- class EntriesFilter < Docs::EntriesFilter
+ class EntriesFilter < Docs::ReflyEntriesFilter
TYPES = ['CSS Extensions', 'SassScript', '@-Rules and Directives',
- 'Output Styles']
+ 'Output Styles', 'Selector']
SKIP_NAMES = ['Interactive Shell', 'Data Types', 'Operations',
'Division and /', 'Keyword Arguments']
@@ -15,24 +15,68 @@ class EntriesFilter < Docs::EntriesFilter
'The !optional Flag' => '!optional'
}
+ def get_name
+ at_css('h1').content
+ end
+
+ def get_docset
+ docset = context[:root_title]
+ docset
+ end
+
+ def get_parsed_uri_by_name(name)
+ context[:docset_uri] + '/' + self.urilized(name)
+ end
+
+ def get_parsed_uri
+ subpath = *path.split('/')
+ parsed_uri = context[:docset_uri] + '/' + self.urilized(get_name)
+ parsed_uri
+ end
+
+ def get_parent_uri
+ parent_uri = 'null'
+ end
+
+ def get_type_by_name(typename)
+ if typename == 'SassScript'
+ 'language'
+ elsif typename == 'Functions'
+ 'function'
+ elsif typename == '@-Rules and Directives'
+ 'directives'
+ elsif typename == 'Output Styles' or typename == 'CSS Extensions' or typename == 'Selector'
+ 'styles'
+ else
+ 'others'
+ end
+ end
+
+ def get_type()
+ 'others'
+ end
+
def include_default_entry?
false
end
def additional_entries
- root_page? ? root_entries : function_entries
+ return root_entries if slug == 'file.SASS_REFERENCE'
+ return function_entries if slug == 'Sass/Script/Functions'
+ return []
end
def root_entries
entries = []
type = ''
- css('> [id]').each do |node|
+ css('dt[id]','> [id]').each do |node|
if node.name == 'h2'
type = node.content.strip
-
if type == 'Function Directives'
- entries << ['@function', node['id'], '@-Rules and Directives']
+ name = '@function'
+ custom_parsed_uri = get_parsed_uri_by_name(name)
+ entries << [name, node['id'], get_type_by_name('@-Rules and Directives'), custom_parsed_uri, get_parent_uri, get_docset]
end
if type.include? 'Directives'
@@ -42,6 +86,8 @@ def root_entries
end
next
+ elsif node.name == 'dt'
+ type = 'Selector'
end
next unless TYPES.include?(type)
@@ -57,21 +103,22 @@ def root_entries
if type == '@-Rules and Directives'
next unless name =~ /\A@[\w\-]+\z/ || name == '!optional'
end
-
- entries << [name, node['id'], type]
+ custom_parsed_uri = get_parsed_uri_by_name(name)
+ entries << [name, node['id'], get_type_by_name(type), custom_parsed_uri, get_parent_uri, get_docset]
end
entries
end
def function_entries
- css('.method_details > .signature').inject [] do |entries, node|
- name = node.at_css('strong').content.strip
-
- unless name == entries.last.try(:first)
- entries << [name, node['id'], 'Functions']
+ css('h2', '.method_details > .signature').inject [] do |entries, node|
+ if node.name == 'h2'
+ name = node.content
+ else
+ name = node.at_css('strong').content.strip
end
-
+ custom_parsed_uri = get_parsed_uri_by_name(name)
+ entries << [name, node['id'], get_type_by_name('Functions'), custom_parsed_uri, get_parent_uri, get_docset]
entries
end
end
diff --git a/lib/docs/filters/scala/clean_html.rb b/lib/docs/filters/scala/clean_html.rb
new file mode 100644
index 0000000000..f75535bd90
--- /dev/null
+++ b/lib/docs/filters/scala/clean_html.rb
@@ -0,0 +1,56 @@
+module Docs
+ class Scala
+ class CleanHtmlFilter < Docs::ReflyFilter
+
+ BROKEN_LINKS = ['concurrent/forkjoin','traversable']
+ REPLACED_LINKS = {
+ 'collection/immutable/mutable/setlike' => 'collection/mutable/setlike',
+ 'mutable/setlike' => 'collection/mutable/setlike'
+ }
+ def call
+ css('#comment', '#value', '#definition', '#mbrsel', '#inheritedMembers', '#groupedMembers', '#footer', '#tooltip', '.permalink').remove
+ xpath("//div[@class='toggleContainer block']","//div[@class='toggleContainer block diagram-container']").remove
+ xpath("//div[@class='toggleContainer block']","//div[@class='toggleContainer block diagram-container']").remove
+ WrapPreContentWithCode 'hljs scala'
+ WrapContentWithDivs '_page _scala'
+ fixLinks
+ doc
+ end
+ def fixLinks
+ css('a[href]').each do |node|
+ node['href'] = CleanWrongCharacters(node['href']).downcase
+ if REPLACED_LINKS[node['href'].downcase.remove! '../']
+ node['href'] = REPLACED_LINKS[node['href'].remove '../']
+ elsif !node['href'].start_with? 'http://' and !node['href'].start_with? '#' and !node['href'].start_with? 'https://' and !node['href'].start_with? 'ftp://' and !node['href'].start_with? 'irc://' and !node['href'].start_with? 'news://' and !node['href'].start_with? 'mailto:'
+ if node['class'] == 'new'
+ node['class'] = 'broken'
+ node['title'] = ''
+ else
+ # puts 'ini: ' + node['href']
+ sluglist = slug.split('/')
+ if context[:url].to_s.include? '.html'
+ sluglist.pop
+ end
+ nodelist = sluglist + node['href'].split('/')
+ newhref = []
+ nodelist.each do |item|
+ if item == '..'
+ newhref.pop
+ elsif item != ''
+ newhref << item
+ end
+ end
+ node['href'] = newhref.join('/')
+ end
+ end
+ if BROKEN_LINKS.include? node['href'].downcase.remove! '../'
+ node['class'] = 'broken'
+ end
+ node['href'] = REPLACED_LINKS[node['href']] || node['href']
+ end
+
+ end
+
+ end
+ end
+end
diff --git a/lib/docs/filters/scala/entries.rb b/lib/docs/filters/scala/entries.rb
new file mode 100644
index 0000000000..1f2931aaa0
--- /dev/null
+++ b/lib/docs/filters/scala/entries.rb
@@ -0,0 +1,49 @@
+module Docs
+ class Scala
+ class EntriesFilter < Docs::ReflyEntriesFilter
+ def get_name
+ if at_css('h1')
+ name = at_css('h1').content.strip
+ end
+ name
+ end
+
+ def get_docset
+ docset = context[:root_title]
+ docset
+ end
+
+ def get_parsed_uri_by_name(name)
+ parsed_uri = context[:docset_uri] + '/' + self.urilized(name)
+ parsed_uri
+ end
+
+ def get_parsed_uri
+ if get_parent_uri == 'null'
+ parsed_uri = context[:docset_uri] + '/' + self.urilized(get_name)
+ else
+ parsed_uri = get_parent_uri + '/' + self.urilized(get_name)
+ end
+ parsed_uri
+ end
+
+ def get_parent_uri
+ parent_uri = 'null'
+ parent_uri
+ end
+
+ def get_type
+ if css('#signature')
+ type = css('#signature .kind').first.content.remove 'case '
+ else
+ type = 'others'
+ end
+ type
+ end
+
+ def include_default_entry?
+ doc.at_css('h1') && !doc.at_css('#indextitle')
+ end
+ end
+ end
+end
diff --git a/lib/docs/filters/sinon/clean_html.rb b/lib/docs/filters/sinon/clean_html.rb
index a3a830fcc2..fa024c362d 100644
--- a/lib/docs/filters/sinon/clean_html.rb
+++ b/lib/docs/filters/sinon/clean_html.rb
@@ -1,8 +1,7 @@
module Docs
class Sinon
- class CleanHtmlFilter < Filter
+ class CleanHtmlFilter < Docs::ReflyFilter
def call
- css('> p:first-child', 'a.api', 'ul.nav').remove
css('.section', 'h2 code', 'h3 code').each do |node|
node.before(node.children).remove
@@ -13,6 +12,17 @@ def call
node.content = node.content
end
+ # fixing id in spy api
+ css('h3').each do |node|
+ if node.content == 'Spy API'
+ node['id'] = 'spyprops'
+ break
+ end
+ end
+ css('> p:first-child', 'a.api', 'ul.nav').remove
+
+ WrapPreContentWithCode 'hljs javascript'
+ WrapContentWithDivs '_page _sinon'
doc
end
end
diff --git a/lib/docs/filters/sinon/entries.rb b/lib/docs/filters/sinon/entries.rb
index 9096f87dde..161316b675 100644
--- a/lib/docs/filters/sinon/entries.rb
+++ b/lib/docs/filters/sinon/entries.rb
@@ -1,10 +1,61 @@
module Docs
class Sinon
- class EntriesFilter < Docs::EntriesFilter
+ class EntriesFilter < Docs::ReflyEntriesFilter
+
+ def get_docset
+ docset = context[:root_title]
+ docset
+ end
+
+ def get_parsed_uri_by_name(name)
+ if get_parent_uri == 'null'
+ parsed_uri = context[:docset_uri] + '/' + self.urilized(name)
+ else
+ parsed_uri = get_parent_uri + '/' + self.urilized(name)
+ end
+ parsed_uri
+ end
+
+ def get_parsed_uri
+ parsed_uri = context[:docset_uri] + '/' + path
+ parsed_uri
+ end
+
+ def get_parent_uri
+ subpath = *path.split('/')
+ if subpath.length > 1
+ parent_uri = (context[:docset_uri]+ '/' + subpath[0,subpath.size-1].join('/')).downcase
+ else
+ parent_uri = 'null'
+ end
+ end
+
+ def get_type
+ 'others'
+ end
+
+ def get_type_by_name(typename)
+ if typename.include? 'Fake timers' or typename.include? 'Fake XMLHttpRequest' or typename.include? 'Sandboxes' or typename.include? 'Spies'
+ 'function'
+ elsif typename.include? 'Assertions'
+ 'assertion'
+ elsif typename.include? 'Utilities'
+ 'utils'
+ elsif typename.include? 'Stubs'
+ 'stubs'
+ else
+ 'others'
+ end
+ end
+
+ def include_default_entry?
+ return false
+ end
+
def additional_entries
entries = []
type = config = nil
-
+ entries << ['Spi API','spyprops','others','/sinonjs/spiapi', 'null', 'SinonJS']
css('*').each do |node|
if node.name == 'h2'
config = false
@@ -12,11 +63,10 @@ def additional_entries
type.remove! 'Test '
type.remove! 'Sinon.JS '
type = type[0].upcase + type.from(1)
-
id = type.parameterize
node['id'] = id
-
- entries << [type, id, 'Sections']
+ custom_parsed_uri = get_parsed_uri_by_name(type)
+ entries << [type, id, 'others', custom_parsed_uri, get_parent_uri, get_docset]
elsif node.name == 'h3' && node.content.include?('sinon.config')
config = true
elsif node.name == 'dl'
@@ -28,14 +78,13 @@ def additional_entries
name.remove! %r{\A.+?\=\s+}
name.remove! %r{\A\w+?\s}
name.prepend 'sinon.config.' if config
-
next if name =~ /\s/
next if entries.any? { |entry| entry[0].casecmp(name) == 0 }
- id = name.parameterize
+ id = name.parameterize.remove 'sinon-'
code.parent['id'] = id
-
- entries << [name, id, type]
+ custom_parsed_uri = get_parsed_uri_by_name(name)
+ entries << [name, id, get_type_by_name(type), custom_parsed_uri, get_parent_uri, get_docset]
end
end
end
diff --git a/lib/docs/filters/socketio/clean_html.rb b/lib/docs/filters/socketio/clean_html.rb
index 40f02024ef..9bab4a333f 100644
--- a/lib/docs/filters/socketio/clean_html.rb
+++ b/lib/docs/filters/socketio/clean_html.rb
@@ -1,6 +1,6 @@
module Docs
class Socketio
- class CleanHtmlFilter < Filter
+ class CleanHtmlFilter < Docs::ReflyFilter
def call
@doc = at_css('.entry-content')
@@ -18,6 +18,8 @@ def call
node.content = node.content
end
+ WrapPreContentWithCode 'hljs javascript'
+ WrapContentWithDivs '_page _socketio'
doc
end
end
diff --git a/lib/docs/filters/socketio/entries.rb b/lib/docs/filters/socketio/entries.rb
index 656931a2b1..ffb7179c39 100644
--- a/lib/docs/filters/socketio/entries.rb
+++ b/lib/docs/filters/socketio/entries.rb
@@ -1,12 +1,53 @@
module Docs
class Socketio
- class EntriesFilter < Docs::EntriesFilter
+ class EntriesFilter < Docs::ReflyEntriesFilter
def get_name
at_css('h1').content
end
+ def get_docset
+ docset = context[:root_title]
+ docset
+ end
+
+ def get_parsed_uri_by_name(name)
+ parsed_uri = get_parsed_uri + '/' + self.urilized(name)
+ parsed_uri
+ end
+
+ def get_parsed_uri
+ parsed_uri = context[:docset_uri] + '/' + self.urilized(get_name)
+ parsed_uri
+ end
+ def get_parent_uri
+ 'null'
+ end
def get_type
- 'Guides'
+ 'guide'
+ end
+
+ def get_type_by_name(name)
+ type = 'others'
+ if name.start_with? 'IO'
+ type = 'io'
+ elsif name.start_with? 'Namespace'
+ type = 'namespace'
+ elsif name.start_with? 'Manager'
+ type = 'function'
+ elsif name.start_with? 'Server'
+ type = 'network'
+ elsif name.start_with? 'Socket'
+ type = 'network'
+ elsif name.include? 'Logging'
+ type = 'guide'
+ elsif name.include? 'Migration'
+ type = 'guide'
+ elsif name.include? 'Using'
+ type = 'guide'
+ else
+ type = 'others'
+ end
+ type
end
def additional_entries
@@ -16,9 +57,10 @@ def additional_entries
name = node.content
name.remove! %r{\(.*}
name.remove! %r{\:.*}
-
+ name.tr!('#','.')
unless entries.any? { |entry| entry[0] == name }
- entries << [name, node['id'], self.name.remove(' API')]
+ custom_parsed_uri = get_parsed_uri_by_name(name)
+ entries << [name, node['id'], get_type_by_name(name), custom_parsed_uri, get_parsed_uri, get_docset]
end
end
end
diff --git a/lib/docs/filters/sqlite/clean_html.rb b/lib/docs/filters/sqlite/clean_html.rb
new file mode 100644
index 0000000000..8642dd7b92
--- /dev/null
+++ b/lib/docs/filters/sqlite/clean_html.rb
@@ -0,0 +1,52 @@
+module Docs
+ class Sqlite
+ class CleanHtmlFilter < Docs::ReflyFilter
+ BROKEN_LINKS = []
+ REPLACED_LINKS = {}
+ def call
+ css('table.menubar','img.logo', '.tagline').remove
+ fixLinks
+ WrapPreContentWithCode 'hljs sql'
+ WrapContentWithDivs '_page _sqlite'
+ doc
+ end
+
+ def fixLinks
+ css('a[href]').each do |node|
+ node['href'] = CleanWrongCharacters(node['href']).downcase
+ node['href'] = node['href'].gsub /#\/\/.*/, ''
+ if REPLACED_LINKS[node['href'].downcase.remove! '../']
+ node['href'] = REPLACED_LINKS[node['href'].remove '../']
+ elsif !node['href'].start_with? '#' and !node['href'].start_with? 'http://' and !node['href'].start_with? '#' and !node['href'].start_with? 'https://' and !node['href'].start_with? 'ftp://' and !node['href'].start_with? 'irc://' and !node['href'].start_with? 'news://' and !node['href'].start_with? 'mailto:'
+ if node['class'] == 'new'
+ node['class'] = 'broken'
+ node['title'] = ''
+ else
+ sluglist = slug.split('/')
+ if context[:url].to_s.include? '.html'
+ sluglist.pop
+ end
+ if slug == 'docs/README.md'
+ sluglist.pop
+ end
+ nodelist = sluglist + node['href'].split('/')
+ newhref = []
+ nodelist.each do |item|
+ if item == '..'
+ newhref.pop
+ elsif item != '' and !newhref.include? item
+ newhref << item
+ end
+ end
+ node['href'] = newhref.join('/')
+ end
+ end
+ if BROKEN_LINKS.include? node['href'].downcase.remove! '../'
+ node['class'] = 'broken'
+ end
+ node['href'] = REPLACED_LINKS[node['href']] || node['href']
+ end
+ end
+ end
+ end
+end
diff --git a/lib/docs/filters/sqlite/entries.rb b/lib/docs/filters/sqlite/entries.rb
new file mode 100644
index 0000000000..5143bf4242
--- /dev/null
+++ b/lib/docs/filters/sqlite/entries.rb
@@ -0,0 +1,80 @@
+module Docs
+ class Sqlite
+ class EntriesFilter < Docs::ReflyEntriesFilter
+ TYPES_BY_SLUG = {
+ 'fts3' => 'command',
+ 'uri' => 'parameter',
+ 'compile' => 'configuration'
+ }
+ def get_name
+ if css('h1').to_s!= ''
+ name = css('h1').first.content.strip
+ else
+ name = css('h2').first.content.strip
+ end
+ name
+ end
+
+ def get_docset
+ docset = context[:root_title]
+ docset
+ end
+
+ def get_parsed_uri_by_name(name)
+ get_parsed_uri + '/' + self.urilized(name)
+ end
+
+ def get_parsed_uri
+ if get_parent_uri == 'null'
+ parsed_uri = context[:docset_uri] + '/' + self.urilized(get_name.remove '%')
+ else
+ parsed_uri = get_parent_uri + '/' + self.urilized(get_name.remove '%')
+ end
+ parsed_uri
+ end
+
+ def get_parent_uri
+ 'null'
+ end
+
+ def get_type
+ TYPES_BY_SLUG[slug] || 'guide'
+ end
+
+
+ def additional_entries
+ entries = []
+ if slug == 'compile'
+ css('p b').each do |node|
+ name = node.content
+ if !name.include? ':'
+ id = name
+ node['id'] = id
+ custom_parsed_uri = get_parsed_uri_by_name(name)
+ entries << [name, id, get_type, custom_parsed_uri, get_parsed_uri, get_docset]
+ end
+ end
+ end
+ if slug == 'uri'
+ css('dt b').each do |node|
+ name = node.inner_html.split('
').first
+ id = name
+ node['id'] = id
+ custom_parsed_uri = get_parsed_uri_by_name(name)
+ entries << [name, id, get_type, custom_parsed_uri, get_parsed_uri, get_docset]
+ end
+ end
+ if slug == 'fts3'
+ css('h1[id]', 'h2[id]').each do |node|
+ name = node.content.strip
+ id = name
+ node['id'] = id
+ custom_parsed_uri = get_parsed_uri_by_name(name)
+ entries << [name, id, get_type, custom_parsed_uri, get_parsed_uri, get_docset]
+ end
+ end
+ entries
+ end
+ end
+ end
+end
diff --git a/lib/docs/filters/svg/clean_html.rb b/lib/docs/filters/svg/clean_html.rb
index 4494e87518..7a6a0f876c 100644
--- a/lib/docs/filters/svg/clean_html.rb
+++ b/lib/docs/filters/svg/clean_html.rb
@@ -1,17 +1,57 @@
module Docs
class Svg
- class CleanHtmlFilter < Filter
+ class CleanHtmlFilter < Docs::ReflyFilter
+ BROKEN_LINKS = [
+ ]
+ REPLACED_LINKS = {
+ 'index' => 'element'
+ }
def call
root_page? ? root : other
+ WrapPreContentWithCode 'hljs javascript'
doc
end
def root
+ css('footer','div.article-meta', '.submenu', 'div.wiki-block', 'nav', '.toc', '#nav-access', '#main-header', '.title').remove
doc.inner_html = doc.at_css('#Documentation + dl').to_html
- end
+ end
def other
css('.prevnext').remove
+ css('footer','div.article-meta', '.submenu', 'div.wiki-block', 'nav', '.toc', '#nav-access', '#main-header', '.title').remove
+ css('a[href]').each do |node|
+ node['href'] = CleanWrongCharacters(node['href']).remove '_(event)'
+ if !node['href'].start_with? 'http://' and !node['href'].start_with? 'https://'
+ if node['class'] == 'new'
+ node['class'] = 'broken'
+ node['title'] = ''
+ # node['href'] = context[:domain] + '/help#brokenlink'
+ elsif BROKEN_LINKS.include?node['href'].downcase.remove! '../'
+ node['class'] = 'broken'
+ # node['href'] = context[:domain] + '/help#brokenlink'
+ elsif REPLACED_LINKS[node['href'].remove! '../']
+ node['href'] = REPLACED_LINKS[node['href'].remove! '../']
+ else
+ sluglist = slug.split('/')
+ nodelist = node['href'].split('/')
+ newhref = []
+ nodelist.each do |item|
+ if item == '..'
+ sluglist.pop
+ else
+ newhref << item
+ end
+ end
+ sluglist.pop
+ if sluglist.size>0
+ node['href'] = sluglist.join('/') + '/' + newhref.join('/')
+ else
+ node['href'] = newhref.join('/')
+ end
+ end
+ end
+ end
if at_css('p').content.include?("\u{00AB}")
at_css('p').remove
diff --git a/lib/docs/filters/svg/entries.rb b/lib/docs/filters/svg/entries.rb
index 64311a227c..c964ed729f 100644
--- a/lib/docs/filters/svg/entries.rb
+++ b/lib/docs/filters/svg/entries.rb
@@ -1,6 +1,6 @@
module Docs
class Svg
- class EntriesFilter < Docs::EntriesFilter
+ class EntriesFilter < Docs::ReflyEntriesFilter
def get_name
name = super
name.remove!('Element.').try(:downcase!)
@@ -11,21 +11,50 @@ def get_name
if name.in?(%w(Element Attribute Content\ type))
"#{name}s"
else
+ name = 'Index' if name == ''
name
end
end
+ def get_docset
+ docset = context[:root_title]
+ docset
+ end
+
+ def get_parsed_uri_by_name(name)
+ if get_parent_uri == 'null'
+ parsed_uri = context[:docset_uri] + '/' + self.urilized(name)
+ else
+ parsed_uri = get_parent_uri + '/' + self.urilized(name)
+ end
+ parsed_uri
+ end
+
+ def get_parsed_uri
+ parsed_uri = context[:docset_uri] + '/' + path
+ parsed_uri
+ end
+
+ def get_parent_uri
+ subpath = *path.split('/')
+ if subpath.length > 1
+ parent_uri = (context[:docset_uri]+ '/' + subpath[0,subpath.size-1].join('/')).downcase
+ else
+ parent_uri = 'null'
+ end
+ end
+
def get_type
if slug.start_with?('Element')
- 'Elements'
+ 'element'
elsif slug.start_with?('Attribute')
- 'Attributes'
+ 'attribute'
elsif slug.start_with?('Tutorial')
- 'Tutorial'
+ 'tutorial'
elsif slug == 'Content_type'
- 'Content types'
+ 'type'
else
- 'Miscellaneous'
+ 'others'
end
end
@@ -37,9 +66,9 @@ def additional_entries
dl = node.next_element
next unless dl.name == 'dl'
name = dl.at_css('dt').content.remove(/[<>]/)
- entries << [name, node['id']]
+ custom_parsed_uri = get_parsed_uri_by_name(name)
+ entries << [name, node['id'], get_type.downcase, custom_parsed_uri, get_parent_uri, get_docset]
end
-
entries
end
end
diff --git a/lib/docs/filters/swift/clean_html.rb b/lib/docs/filters/swift/clean_html.rb
new file mode 100644
index 0000000000..14ed9bfbd7
--- /dev/null
+++ b/lib/docs/filters/swift/clean_html.rb
@@ -0,0 +1,59 @@
+module Docs
+ class Swift
+ class CleanHtmlFilter < Docs::ReflyFilter
+ BROKEN_LINKS = []
+ REPLACED_LINKS = {
+ 'thebasics' => 'index'
+ }
+ def call
+ css('.copyright').remove
+ css('h3.section-name').each do |node|
+ node['id'] = node.content.downcase.tr ' ', '-'
+ end
+ css('div.Swift').each do |node|
+ node.name = 'pre'
+ end
+ fixLinks
+ WrapPreContentWithCode 'hljs swift'
+ WrapContentWithDivs '_page _swift'
+ doc
+ end
+ def fixLinks
+ css('a[href]').each do |node|
+ node['href'] = CleanWrongCharacters(node['href']).downcase
+ node['href'] = node['href'].gsub /#\/\/.*/, ''
+ if REPLACED_LINKS[node['href'].downcase.remove! '../']
+ node['href'] = REPLACED_LINKS[node['href'].remove '../']
+ elsif !node['href'].start_with? '#' and !node['href'].start_with? 'http://' and !node['href'].start_with? '#' and !node['href'].start_with? 'https://' and !node['href'].start_with? 'ftp://' and !node['href'].start_with? 'irc://' and !node['href'].start_with? 'news://' and !node['href'].start_with? 'mailto:'
+ if node['class'] == 'new'
+ node['class'] = 'broken'
+ node['title'] = ''
+ else
+ sluglist = slug.split('/')
+ if context[:url].to_s.include? '.html'
+ sluglist.pop
+ end
+ if slug == 'docs/README.md'
+ sluglist.pop
+ end
+ nodelist = sluglist + node['href'].split('/')
+ newhref = []
+ nodelist.each do |item|
+ if item == '..'
+ newhref.pop
+ elsif item != '' and !newhref.include? item
+ newhref << item
+ end
+ end
+ node['href'] = newhref.join('/')
+ end
+ end
+ if BROKEN_LINKS.include? node['href'].downcase.remove! '../'
+ node['class'] = 'broken'
+ end
+ node['href'] = REPLACED_LINKS[node['href']] || node['href']
+ end
+ end
+ end
+ end
+end
diff --git a/lib/docs/filters/swift/entries.rb b/lib/docs/filters/swift/entries.rb
new file mode 100644
index 0000000000..c64a03ebb2
--- /dev/null
+++ b/lib/docs/filters/swift/entries.rb
@@ -0,0 +1,76 @@
+module Docs
+ class Swift
+ class EntriesFilter < Docs::ReflyEntriesFilter
+
+ def get_name
+ node = css('h2.chapter-name')
+ name = node.first.content
+ name
+ end
+
+ def get_docset
+ docset = context[:root_title]
+ docset
+ end
+
+ def get_parsed_uri
+ if get_parent_uri == 'null'
+ parsed_uri = context[:docset_uri] + '/' + self.urilized(get_name)
+ else
+ parsed_uri = get_parent_uri + '/' + self.urilized(get_name)
+ end
+ parsed_uri
+ end
+
+ def get_parsed_uri_by_name(name)
+ parsed_uri = get_parsed_uri + '/' + self.urilized(name)
+ parsed_uri
+ end
+
+ def get_parent_uri
+ 'null'
+ end
+
+ def get_type
+ if get_name.include? 'Type' or get_name.include? 'Strings' or get_name.include? 'Enumerations'
+ type = 'type'
+ elsif get_name.include? 'Operators'
+ type = 'operator'
+ elsif get_name.include? 'Functions'
+ type = 'function'
+ elsif get_name.include? 'Methods'
+ type = 'method'
+ elsif get_name.include? 'Extensions'
+ type = 'utils'
+ elsif get_name.include? 'Expressions'
+ type = 'expression'
+ elsif get_name.include? 'Statements' or get_name.include? 'Lexical' or get_name.include? 'Patterns'
+ type = 'statement'
+ elsif get_name.include? 'Properties' or get_name.include? 'Attributes' or get_name.include? 'Parameters'
+ type = 'property'
+ elsif get_name.include? 'Basics' or get_name.include? 'Swift' or get_name.include? 'Generics' or get_name.include? 'Chaining' or get_name.include? 'Grammar'
+ type = 'guide'
+ elsif get_name.include? 'Closures' or get_name.include? 'Reference' or get_name.include? 'Control' or get_name.include? 'Declarations' or get_name.include? 'Protocols' or get_name.include? 'Handling'
+ type = 'language'
+ elsif get_name.include? 'Classes' or get_name.include? 'Subscripts' or get_name.include? 'Inheritance' or get_name.include? 'Initialization' or get_name.include? 'Deinitialization'
+ type = 'class'
+ else
+ type = get_name
+ end
+ type
+ end
+
+ def additional_entries
+ entries = []
+ css('h3.section-name').each do |node|
+ id = node['id']
+ name = node.content.strip
+ custom_parsed_uri = get_parsed_uri_by_name(name)
+ custom_parent_uri = get_parsed_uri
+ entries << [name, id, get_type || 'others', custom_parsed_uri, custom_parent_uri, get_docset]
+ end
+ entries
+ end
+ end
+ end
+end
diff --git a/lib/docs/filters/swiftreference/clean_html.rb b/lib/docs/filters/swiftreference/clean_html.rb
new file mode 100644
index 0000000000..25ee9d4027
--- /dev/null
+++ b/lib/docs/filters/swiftreference/clean_html.rb
@@ -0,0 +1,73 @@
+module Docs
+ class Swiftreference
+ class CleanHtmlFilter < Docs::ReflyFilter
+ BROKEN_LINKS = []
+ REPLACED_LINKS = {
+ 'thebasics' => 'index',
+ 'https:/developer.apple.com/library/watchos/documentation/cocoa/reference/foundation/classes/nsarray_class/index.html' => 'https://developer.apple.com/library/watchos/documentation/cocoa/reference/foundation/classes/nsarray_class/index.html'
+ }
+ def call
+ css('.copyright', '.metadata-table').remove
+ css('h3.section-name').each do |node|
+ node['id'] = node.content.downcase.tr ' ', '-'
+ end
+ css('code.code-voice').each do |node|
+ if node.parent.name != 'code'
+ node['class'] = ''
+ node.name = 'span'
+ end
+ end
+ css('div.Swift').each do |node|
+ node.name = 'pre'
+ end
+
+ fixLinks
+ WrapPreContentWithCode 'hljs swift'
+ WrapContentWithDivs '_page _swift'
+ doc
+ end
+ def fixLinks
+ css('a[href]').each do |node|
+ node['href'] = CleanWrongCharacters(node['href']).downcase
+ node['href'] = node['href'].gsub /#\/\/.*/, ''
+ if node.parent['class'] == 'n' or node.parent.parent['class'] == 'para'
+ node['href'] = '../' + node['href']
+ end
+ if node['href'] == ''
+ node.name = 'span'
+ next
+ end
+ # puts 'ini: ' + node['href']
+ if REPLACED_LINKS[node['href'].downcase.remove! '../']
+ node['href'] = REPLACED_LINKS[node['href'].remove '../']
+ elsif !node['href'].start_with? '#' and !node['href'].start_with? 'http://' and !node['href'].start_with? '#' and !node['href'].start_with? 'https://' and !node['href'].start_with? 'ftp://' and !node['href'].start_with? 'irc://' and !node['href'].start_with? 'news://' and !node['href'].start_with? 'mailto:'
+ if node['class'] == 'new'
+ node['class'] = 'broken'
+ node['title'] = ''
+ else
+ sluglist = slug.split('/')
+ if context[:url].to_s.include? '.html'
+ sluglist.pop
+ end
+ nodelist = sluglist + node['href'].split('/')
+ newhref = []
+ nodelist.each do |item|
+ if item == '..'
+ newhref.pop
+ elsif item != '' and !newhref.include? item
+ newhref << item
+ end
+ end
+ node['href'] = newhref.join('/')
+ end
+ end
+ if BROKEN_LINKS.include? node['href'].downcase.remove! '../'
+ node['class'] = 'broken'
+ end
+ node['href'] = REPLACED_LINKS[node['href']] || node['href']
+ # puts 'fin: ' + node['href']
+ end
+ end
+ end
+ end
+end
diff --git a/lib/docs/filters/swiftreference/entries.rb b/lib/docs/filters/swiftreference/entries.rb
new file mode 100644
index 0000000000..9c395c14c0
--- /dev/null
+++ b/lib/docs/filters/swiftreference/entries.rb
@@ -0,0 +1,129 @@
+module Docs
+ class Swiftreference
+ class EntriesFilter < Docs::ReflyEntriesFilter
+ NOT_VALID_REFERENCES = [
+ 'Subscripts',
+ 'Type Aliases',
+ 'Type Methods',
+ 'Type Properties',
+ 'Operator Functions',
+ 'Instance Properties',
+ 'Instance Methods',
+ 'Initializers',
+ 'Enumeration Cases',
+ 'Associated Types'
+ ]
+ TYPES_TYPE_NAMES = [
+ 'Float',
+ 'String',
+ 'Bit',
+ 'Bool',
+ 'Character',
+ 'UTF16',
+ 'UTF8',
+ 'UTF32',
+ 'Double',
+ 'BooleanLiteralConvertible',
+ 'Comparable',
+ 'String.UTF16View',
+ 'String.UTF8View',
+ 'AutoreleasingUnsafeMutablePointer',
+ 'CustomDebugStringConvertible',
+ 'Equatable'
+ ]
+ TYPES_TYPE_OBJECT = [
+ 'CustomDebugStringConvertible',
+ 'COpaquePointer',
+ 'CustomDebugStringConvertible',
+ 'Zip2Generator',
+ 'Zip2Sequence',
+ 'CustomStringConvertible',
+ 'CustomReflectable',
+ 'CustomStringConvertible',
+ 'CVaListPointer',
+ 'EmptyGenerator',
+ 'EnumerateGenerator',
+ 'ManagedBufferPointer',
+ 'CVaListPointer'
+ ]
+ def get_name
+ if css('.chapter-name')
+ name = css('.chapter-name').first.content.strip
+ else
+ name = slug.strip
+ end
+ name
+ end
+
+ def get_docset
+ docset = context[:root_title]
+ docset
+ end
+
+ def get_parsed_uri
+ if get_parent_uri == 'null'
+ parsed_uri = context[:docset_uri] + '/' + self.urilized(get_name)
+ else
+ parsed_uri = get_parent_uri + '/' + self.urilized(get_name)
+ end
+ parsed_uri
+ end
+
+ def get_parsed_uri_by_name(name)
+ parsed_uri = get_parsed_uri + '/' + self.urilized(name)
+ parsed_uri
+ end
+
+ def get_parent_uri
+ 'null'
+ end
+
+ def get_type
+ if get_name.include? 'Type' or get_name.include? 'Int' or get_name.include? 'Index' or TYPES_TYPE_NAMES.include? get_name
+ type = 'type'
+ elsif get_name.include? 'Array' or get_name.include? 'Collection' or get_name.include? 'Dictionary'
+ type = 'collection'
+ elsif get_name.include? 'Operators'
+ type = 'operator'
+ elsif get_name.include? 'Functions' or get_name.include? 'AbsoluteValuable'
+ type = 'function'
+ elsif get_name.include? 'Methods'
+ type = 'method'
+ elsif get_name.include? 'Extensions'
+ type = 'utils'
+ elsif get_name.include? 'Expressions'
+ type = 'expression'
+ elsif get_name.include? 'Statements' or get_name.include? 'Lexical' or get_name.include? 'Patterns'
+ type = 'statement'
+ elsif get_name.include? 'Properties' or get_name.include? 'Attributes' or get_name.include? 'Parameters'
+ type = 'property'
+ elsif get_name.include? 'Basics' or get_name.include? 'Swift' or get_name.include? 'Generics' or get_name.include? 'Chaining' or get_name.include? 'Grammar'
+ type = 'guide'
+ elsif get_name.include? 'Closures' or get_name.include? 'Reference' or get_name.include? 'Control' or get_name.include? 'Declarations' or get_name.include? 'Protocols' or get_name.include? 'Handling'
+ type = 'language'
+ elsif get_name.include? 'Classes' or get_name.include? 'Subscripts' or get_name.include? 'Inheritance' or get_name.include? 'Initialization' or get_name.include? 'Deinitialization' or get_name.include? 'Any'
+ type = 'class'
+ elsif TYPES_TYPE_OBJECT.include? get_name
+ type = 'object'
+ else
+ type = 'others'
+ end
+ type
+ end
+
+ def additional_entries
+ entries = []
+ css('h3.section-name').each do |node|
+ id = node['id']
+ name = node.content.strip
+ if id != '' and not NOT_VALID_REFERENCES.include? name
+ custom_parsed_uri = get_parsed_uri_by_name(name)
+ custom_parent_uri = get_parsed_uri
+ entries << [name, id, get_type || 'others', custom_parsed_uri, custom_parent_uri, get_docset]
+ end
+ end
+ entries
+ end
+ end
+ end
+end
diff --git a/lib/docs/filters/symfony/clean_html.rb b/lib/docs/filters/symfony/clean_html.rb
new file mode 100644
index 0000000000..b47715a9d5
--- /dev/null
+++ b/lib/docs/filters/symfony/clean_html.rb
@@ -0,0 +1,71 @@
+module Docs
+ class Symfony
+ class CleanHtmlFilter < Docs::ReflyFilter
+
+ BROKEN_LINKS = []
+ REPLACED_LINKS = {
+ 'classes' => 'symfony/component/browserkit',
+ 'index' => 'symfony/component/finder/adapter/abstractadapter'
+ }
+ def call
+ css('.location', '#footer').remove
+
+ css('.header > h1').each do |node|
+ node.content = 'Symfony' if root_page?
+ node.parent.before(node).remove
+ end
+
+ css('div.details').each do |node|
+ node.before(node.children).remove
+ end
+
+ css('a > abbr').each do |node|
+ node.parent['title'] = node['title']
+ node.before(node.children).remove
+ end
+
+ css('h1 > a', '.content', 'h3 > code', 'h3 strong', 'abbr').each do |node|
+ node.before(node.children).remove
+ end
+ fixLinks
+ WrapPreContentWithCode 'hljs php'
+ WrapContentWithDivs '_page _symfony'
+ doc
+ end
+ def fixLinks
+ css('a[href]').each do |node|
+ node['href'] = CleanWrongCharacters(node['href']).downcase
+ if REPLACED_LINKS[node['href'].downcase.remove! '../']
+ node['href'] = REPLACED_LINKS[node['href'].remove '../']
+ elsif !node['href'].start_with? 'http://' and !node['href'].start_with? '#' and !node['href'].start_with? 'https://' and !node['href'].start_with? 'ftp://' and !node['href'].start_with? 'irc://' and !node['href'].start_with? 'news://' and !node['href'].start_with? 'mailto:'
+ if node['class'] == 'new'
+ node['class'] = 'broken'
+ node['title'] = ''
+ else
+ sluglist = slug.split('/')
+ if context[:url].to_s.include? '.html'
+ sluglist.pop
+ end
+ nodelist = sluglist + node['href'].split('/')
+ newhref = []
+ nodelist.each do |item|
+ if item == '..'
+ newhref.pop
+ elsif item != ''
+ newhref << item
+ end
+ end
+ node['href'] = newhref.join('/')
+ end
+ end
+ if BROKEN_LINKS.include? node['href'].downcase.remove! '../'
+ node['class'] = 'broken'
+ end
+ node['href'] = REPLACED_LINKS[node['href']] || node['href']
+ end
+
+ end
+
+ end
+ end
+end
diff --git a/lib/docs/filters/symfony/entries.rb b/lib/docs/filters/symfony/entries.rb
new file mode 100644
index 0000000000..2114773cf1
--- /dev/null
+++ b/lib/docs/filters/symfony/entries.rb
@@ -0,0 +1,98 @@
+module Docs
+ class Symfony
+ class EntriesFilter < Docs::ReflyEntriesFilter
+ EXCLUDED_PATH = ['Symfony']
+ def get_name
+ name = at_css('h1').content
+ name = name.split("\\").last.gsub('deprecated', '')
+ name.strip
+ end
+
+ def get_docset
+ docset = context[:root_title]
+ docset
+ end
+
+ def get_parsed_uri_by_name(name)
+ parsed_uri = context[:docset_uri] + '/' + self.urilized(name)
+ parsed_uri
+ end
+
+ def get_parsed_uri
+ if get_parent_uri == 'null'
+ parsed_uri = context[:docset_uri] + '/' + self.urilized(get_name)
+ else
+ parsed_uri = get_parent_uri + '/' + self.urilized(get_name)
+ end
+ parsed_uri
+ end
+
+ def get_parent_uri
+ parent_uri = context[:docset_uri]
+ xpathnodes = xpath('//ol/li/a')
+ if get_type == 'namespace'
+ xpathnodes.pop
+ end
+ xpathnodes.each do |node|
+ link = node.content
+ if not EXCLUDED_PATH.include? link
+ parent_uri += '/' + self.urilized(link)
+ end
+ end
+ if parent_uri == context[:docset_uri]
+ parent_uri = 'null'
+ end
+ parent_uri
+ end
+
+ def get_type
+ if css('.label-default').to_s!= ''
+ type = css('.label-default').first.content.strip.downcase
+ type = 'others' if type == 'trait'
+ else
+ type = 'others'
+ end
+ type
+ end
+
+ def namespace
+ @namespace ||= begin
+ path = slug.remove('Symfony/').remove(/\/\w+?\z/).split('/')
+ upto = 1
+ upto = 2 if path[1] == 'Form' && path[2] == 'Extension'
+ upto = 2 if path[1] == 'HttpFoundation' && path[2] == 'Session'
+ path[0..upto].join('\\')
+ end
+ end
+
+ IGNORE_METHODS = %w(get set)
+
+ def additional_entries
+ return [] if initial_page?
+ return [] if type == 'Exceptions'
+ return [] if self.name.include?('Legacy') || self.name.include?('Loader')
+
+ entries = []
+ base_name = self.name.remove(/\(.+\)/).strip
+
+ css('h3[id^="method_"]').each do |node|
+ next if node.at_css('.location').content.start_with?('in')
+
+ name = node['id'].remove('method_')
+ next if name.start_with?('_') || IGNORE_METHODS.include?(name)
+
+ name.prepend "#{base_name}::"
+ name << "() (#{namespace})"
+ custom_parsed_uri = get_parsed_uri_by_name(name)
+ entries << [name, node['id'], get_type, custom_parsed_uri, get_parent_uri, get_docset]
+ end
+
+ entries.size > 1 ? entries : []
+ end
+
+ def include_default_entry?
+ !initial_page?
+ end
+ end
+ end
+end
diff --git a/lib/docs/filters/twig/clean_html.rb b/lib/docs/filters/twig/clean_html.rb
new file mode 100644
index 0000000000..7d00212403
--- /dev/null
+++ b/lib/docs/filters/twig/clean_html.rb
@@ -0,0 +1,18 @@
+module Docs
+ class Twig
+ class CleanHtmlFilter < Docs::ReflyFilter
+ def call
+ WrapPreContentWithCode 'hljs php'
+ WrapContentWithDivs '_page _twig'
+ css('.header', '#footer').remove
+ css('.content').each do |node|
+ node['class'] = ''
+ end
+ css('abbr').each do |node|
+ node.name = 'span'
+ end
+ doc
+ end
+ end
+ end
+end
diff --git a/lib/docs/filters/twig/entries.rb b/lib/docs/filters/twig/entries.rb
new file mode 100644
index 0000000000..d71a55b5e8
--- /dev/null
+++ b/lib/docs/filters/twig/entries.rb
@@ -0,0 +1,46 @@
+module Docs
+ class Twig
+ class EntriesFilter < Docs::ReflyEntriesFilter
+
+ EXCLUDED_PATH = ['MySQL 5.7 Reference Manual']
+
+ def get_name
+ if css('h1').to_s != ''
+ name = css('h1').first.content.strip
+ else
+ name = slug.capitalize
+ end
+ name
+ end
+
+ def get_docset
+ docset = context[:root_title]
+ docset
+ end
+
+ def get_parsed_uri
+ if get_parent_uri == 'null'
+ parsed_uri = context[:docset_uri] + '/' + self.urilized(get_name)
+ else
+ parsed_uri = get_parent_uri + '/' + self.urilized(get_name)
+ end
+ parsed_uri
+ end
+
+ def get_parent_uri
+ 'null'
+ end
+
+ def get_type
+ type = 'others'
+ if css('div.type').to_s != ''
+ type = css('div.type').first.content.downcase.strip
+ if type == 'index'
+ type = 'others'
+ end
+ end
+ type
+ end
+ end
+ end
+end
diff --git a/lib/docs/filters/underscore/clean_html.rb b/lib/docs/filters/underscore/clean_html.rb
index a2c0440171..135fb6979e 100644
--- a/lib/docs/filters/underscore/clean_html.rb
+++ b/lib/docs/filters/underscore/clean_html.rb
@@ -1,10 +1,35 @@
module Docs
class Underscore
- class CleanHtmlFilter < Filter
+ class CleanHtmlFilter < Docs::ReflyFilter
def call
# Remove Links, Changelog
css('#links ~ *', '#links').remove
+ css('tt').each do |node|
+ code = Nokogiri::XML::Node.new "code", doc
+ code.content = node.content
+ node.content = ''
+ node.name = 'pre'
+ node << code
+ end
+
+ css('code').each do |node|
+ code = Nokogiri::XML::Node.new "code", doc
+ code.content = node.content
+ node.content = ''
+ node.name = 'pre'
+ node << code
+ end
+
+ css('pre').each do |node|
+ code = Nokogiri::XML::Node.new "code", doc
+ code.content = node.content
+ node.content = ''
+ node << code
+ end
+
+ WrapPreContentWithCode 'hljs javascript'
+ WrapContentWithDivs '_page _underscore'
doc
end
end
diff --git a/lib/docs/filters/underscore/entries.rb b/lib/docs/filters/underscore/entries.rb
index fc33bda1b4..1d7d98e4ef 100644
--- a/lib/docs/filters/underscore/entries.rb
+++ b/lib/docs/filters/underscore/entries.rb
@@ -1,21 +1,72 @@
module Docs
class Underscore
- class EntriesFilter < Docs::EntriesFilter
+ class EntriesFilter < Docs::ReflyEntriesFilter
+
+ REPLACE_TYPE = {
+ 'Function' => 'function',
+ 'Chaining' => 'function',
+ 'utility' => 'function',
+ 'Collection' => 'collection',
+ 'Array' => 'collection',
+ 'Object' => 'object'
+ }
+ def get_docset
+ docset = context[:root_title]
+ docset
+ end
+
+ def get_parsed_uri_by_name(name)
+ if get_parent_uri == 'null'
+ parsed_uri = context[:docset_uri] + '/' + self.urilized(name)
+ else
+ parsed_uri = get_parent_uri + '/' + self.urilized(name)
+ end
+ parsed_uri
+ end
+
+ def get_parsed_uri
+ parsed_uri = context[:docset_uri] + '/' + path
+ parsed_uri
+ end
+
+ def get_type
+ 'others'
+ end
+
+ def get_parent_uri
+ subpath = *path.split('/')
+ if subpath.length > 1
+ parent_uri = (context[:docset_uri]+ '/' + subpath[0,subpath.size-1].join('/')).downcase
+ else
+ parent_uri = 'null'
+ end
+ end
+
+ def include_default_entry?
+ return false
+ end
+
def additional_entries
entries = []
type = nil
css('[id]').each do |node|
# Module
+ next if node['id'] == 'documentation'
if node.name == 'h2'
type = node.content.split.first
next
end
# Method
+ # type = 'others' if not type
node.css('.header', '.alias b').each do |header|
+ prefix = header.ancestors('p').first.at_css('code').content[/\A[^\.]+\./].strip
header.content.split(',').each do |name|
- entries << [name, node['id'], type]
+ name.strip!
+ name.prepend(prefix)
+ custom_parsed_uri = get_parsed_uri_by_name(name)
+ entries << [name, node['id'], REPLACE_TYPE[type] || 'others', custom_parsed_uri, get_parent_uri, get_docset]
end
end
end
diff --git a/lib/docs/filters/vagrant/clean_html.rb b/lib/docs/filters/vagrant/clean_html.rb
new file mode 100644
index 0000000000..cee475ea9c
--- /dev/null
+++ b/lib/docs/filters/vagrant/clean_html.rb
@@ -0,0 +1,64 @@
+module Docs
+ class Vagrant
+ class CleanHtmlFilter < Docs::ReflyFilter
+ BROKEN_LINKS = []
+ REPLACED_LINKS = {
+ 'multi-machine/vagrantfile/index' => 'vagrantfile/index',
+ 'multi-machine/networking/index' => 'networking/index',
+ 'multi-machine/networking/private_network' => 'networking/private_network'
+ }
+ def call
+ @doc = at_css('.page-contents .span8')
+
+ css('hr').remove
+
+ css('pre > code').each do |node|
+ node.parent['class'] = node['class']
+ node.before(node.children).remove
+ end
+ fixLinks
+ WrapPreContentWithCode 'hljs vagrant'
+ WrapContentWithDivs '_page _vagrant'
+ doc
+ end
+
+ def fixLinks
+ css('a[href]').each do |node|
+ node['href'] = CleanWrongCharacters(node['href']).downcase
+ puts 'ino: ' + node['href']
+ if REPLACED_LINKS[node['href'].downcase.remove! '../']
+ node['href'] = REPLACED_LINKS[node['href'].remove '../']
+ elsif !node['href'].start_with? '#' and !node['href'].start_with? 'http://' and !node['href'].start_with? '#' and !node['href'].start_with? 'https://' and !node['href'].start_with? 'ftp://' and !node['href'].start_with? 'irc://' and !node['href'].start_with? 'news://' and !node['href'].start_with? 'mailto:'
+ if node['class'] == 'new'
+ node['class'] = 'broken'
+ node['title'] = ''
+ else
+ sluglist = slug.split('/')
+ if context[:url].to_s.include? '.html'
+ sluglist.pop
+ end
+ if slug == 'docs/README.md'
+ sluglist.pop
+ end
+ nodelist = sluglist + node['href'].split('/')
+ newhref = []
+ nodelist.each do |item|
+ if item == '..'
+ newhref.pop
+ elsif item != '' and !newhref.include? item
+ newhref << item
+ end
+ end
+ node['href'] = newhref.join('/')
+ end
+ end
+ if BROKEN_LINKS.include? node['href'].downcase.remove! '../'
+ node['class'] = 'broken'
+ end
+ node['href'] = REPLACED_LINKS[node['href']] || node['href']
+ puts 'end: ' + node['href']
+ end
+ end
+ end
+ end
+end
diff --git a/lib/docs/filters/vagrant/entries.rb b/lib/docs/filters/vagrant/entries.rb
new file mode 100644
index 0000000000..64196eea68
--- /dev/null
+++ b/lib/docs/filters/vagrant/entries.rb
@@ -0,0 +1,101 @@
+module Docs
+ class Vagrant
+ class EntriesFilter < Docs::ReflyEntriesFilter
+
+ REPLACE_TYPES = {
+ 'Provisioning' => 'platform',
+ 'Push' => 'plugin',
+ 'Installation' => 'guide',
+ 'Providers' => 'platform',
+ 'Synced Folders' => 'network',
+ 'VMware' => 'platform',
+ 'VirtualBox' => 'platform',
+ 'Hyper-V' => 'platform',
+ 'Networking' => 'network',
+ 'Boxes' => 'module',
+ 'Docker' => 'platform',
+ 'Command-Line Interface' => 'guide',
+ 'Vagrantfile' => 'guide',
+ 'Vagrant Share' => 'network',
+ 'Getting Started' => 'guide',
+ 'Overview' => 'guide',
+ 'Other' => 'others',
+ 'Multi-Machine' => 'platform',
+ }
+ def get_name
+ if slug.start_with?('push/')
+ name = at_css('h2').try(:content)
+ elsif slug.start_with?('cli/')
+ name = at_css('h1 + p > strong > code').try(:content).try(:[], /\s*vagrant\s+[\w\-]+/)
+ end
+
+ name || at_css('h1').content
+ end
+
+ def get_docset
+ docset = context[:root_title]
+ docset
+ end
+
+ def get_parsed_uri
+ if get_parent_uri == 'null'
+ parsed_uri = context[:docset_uri] + '/' + self.urilized(get_name)
+ else
+ parsed_uri = get_parent_uri + '/' + self.urilized(get_name)
+ end
+ parsed_uri
+ end
+
+ def get_parsed_uri_by_name(name)
+ if get_parent_uri == 'null'
+ parsed_uri = context[:docset_uri] + '/' + self.urilized(name)
+ else
+ parsed_uri = get_parent_uri + '/' + self.urilized(name)
+ end
+ parsed_uri
+ end
+
+ def get_parent_uri
+ parent_uri = context[:docset_uri]
+ xpath('//nav[@class="crumbs"]//a/text()').each do |node|
+ link = node.content.strip
+ if not EXCLUDED_PATH.include? link
+ parent_uri += '/' + self.urilized(link)
+ end
+ end
+ if parent_uri == context[:docset_uri]
+ parent_uri = 'null'
+ end
+ parent_uri
+ end
+
+ def get_type
+ type = at_css('.docs-sidenav > li.active > a').content
+ node = at_css('.docs-sidenav > li.active > ul > li.active > a + ul')
+ type << ": #{node.previous_element.content}" if node
+ type
+ end
+ # def get_type
+ # REPLACE_TYPES[at_css('.sidebar-nav li.current').content] || 'others'
+ # end
+
+ def additional_entries
+ case at_css('h1 + p > strong > code').try(:content)
+ when /config\./
+ h2 = nil
+ css('.page-contents .span8 > *').each_with_object [] do |node, entries|
+ if node.name == 'h2'
+ h2 = node.content
+ elsif h2 == 'Available Settings' && (code = node.at_css('code')) && (name = code.content) && name.start_with?('config.')
+ id = code.parent['id'] = name.parameterize
+ custom_parsed_uri = get_parsed_uri_by_name(name)
+ entries << [name, id, 'configuration', custom_parsed_uri, get_parent_uri, get_docset]
+ end
+ end
+ else
+ []
+ end
+ end
+ end
+ end
+end
diff --git a/lib/docs/filters/vue/clean_html.rb b/lib/docs/filters/vue/clean_html.rb
new file mode 100644
index 0000000000..e877732124
--- /dev/null
+++ b/lib/docs/filters/vue/clean_html.rb
@@ -0,0 +1,67 @@
+module Docs
+ class Vue
+ class CleanHtmlFilter < Docs::ReflyFilter
+ BROKEN_LINKS = []
+ REPLACED_LINKS = {
+ 'guide/api/index' => 'api/index',
+ 'guide/guide/filters' => 'api/filters'
+ }
+ def call
+ @doc = at_css('.content')
+
+ at_css('h1').content = 'Vue.js' if root_page?
+
+ css('#demo').remove
+
+ # Remove code highlighting
+ css('figure').each do |node|
+ node.name = 'pre'
+ node.content = node.at_css('td.code pre').css('.line').map(&:content).join("\n")
+ end
+ fixLinks
+ WrapPreContentWithCode 'hljs javascript'
+ WrapContentWithDivs '_page _vue'
+ doc
+ end
+
+ def fixLinks
+ css('a[href]').each do |node|
+ node['href'] = CleanWrongCharacters(node['href']).downcase.gsub('guide\/guide','guide')
+ if REPLACED_LINKS[node['href'].downcase.remove! '../']
+ node['href'] = REPLACED_LINKS[node['href'].remove '../']
+ elsif !node['href'].start_with? '#' and !node['href'].start_with? 'http://' and !node['href'].start_with? '#' and !node['href'].start_with? 'https://' and !node['href'].start_with? 'ftp://' and !node['href'].start_with? 'irc://' and !node['href'].start_with? 'news://' and !node['href'].start_with? 'mailto:'
+ if node['class'] == 'new'
+ node['class'] = 'broken'
+ node['title'] = ''
+ else
+ sluglist = slug.split('/')
+ if context[:url].to_s.include? '.html'
+ sluglist.pop
+ end
+ # only for this docset
+ if node['href'].start_with? 'guide'
+ nodelist = node['href'].split('/')
+ else
+ nodelist = sluglist + node['href'].split('/')
+ end
+ newhref = []
+ nodelist.each do |item|
+ if item == '..'
+ newhref.pop
+ elsif item != ''
+ newhref << item
+ end
+ end
+ node['href'] = newhref.join('/')
+ end
+ end
+ if BROKEN_LINKS.include? node['href'].downcase.remove! '../'
+ node['class'] = 'broken'
+ end
+ node['href'] = REPLACED_LINKS[node['href']] || node['href']
+ end
+
+ end
+ end
+ end
+end
diff --git a/lib/docs/filters/vue/entries.rb b/lib/docs/filters/vue/entries.rb
new file mode 100644
index 0000000000..3dfbf8d20f
--- /dev/null
+++ b/lib/docs/filters/vue/entries.rb
@@ -0,0 +1,75 @@
+module Docs
+ class Vue
+ class EntriesFilter < Docs::ReflyEntriesFilter
+ REPLACE_TYPES = {
+ 'Component Options' => 'component',
+ 'Component System' => 'component',
+ 'Special Elements' => 'component',
+ 'Filters' => 'filter',
+ 'Custom Filters' => 'filter',
+ 'Common FAQs' => 'guide',
+ 'Getting Started' => 'guide',
+ 'Global API' => 'guide',
+ 'Installation' => 'guide',
+ 'Directives' => 'directive',
+ 'Custom Directives' => 'directive',
+ 'Displaying a List' => 'directive',
+ 'Handling Forms' => 'directive',
+ 'Computed Properties' => 'property',
+ }
+ def get_name
+ at_css('h1').content
+ end
+
+ def get_docset
+ docset = context[:root_title]
+ docset
+ end
+
+ def get_parsed_uri_by_name(name)
+ parsed_uri = context[:docset_uri] + '/' + self.urilized(name)
+ parsed_uri
+ end
+
+ def get_parsed_uri
+ if get_parent_uri == 'null'
+ parsed_uri = context[:docset_uri] + '/' + self.urilized(get_name)
+ else
+ parsed_uri = get_parent_uri + '/' + self.urilized(get_name)
+ end
+ parsed_uri
+ end
+
+ def get_parent_uri
+ 'null'
+ end
+
+ def get_type
+ REPLACE_TYPES[self.name] || 'others'
+ end
+ def get_custom_type(name)
+ if name.include? '()' or name.include? 'method'
+ type = 'method'
+ elsif name.include? 'vm.' or name.include? 'Properties'
+ type = 'property'
+ elsif name == 'Tips & Best Practices' or name == 'Building Larger Apps' or name == 'Extending Vue' or name == 'Overview'
+ type = 'guide'
+ else
+ type = self.name || 'others'
+ end
+ REPLACE_TYPES[type] || type
+ end
+
+ def additional_entries
+ return [] if slug.start_with?('guide')
+
+ css('h3').map do |node|
+ name = node.content.strip
+ name.sub! %r{\(.*\)}, '()'
+ custom_parsed_uri = get_parsed_uri_by_name(name)
+ [name, node['id'], get_custom_type(name), custom_parsed_uri, get_parent_uri, get_docset]
+ end
+ end
+ end
+ end
+end
diff --git a/lib/docs/filters/webpack/clean_html.rb b/lib/docs/filters/webpack/clean_html.rb
new file mode 100644
index 0000000000..f3238353fc
--- /dev/null
+++ b/lib/docs/filters/webpack/clean_html.rb
@@ -0,0 +1,34 @@
+module Docs
+ class Webpack
+ class CleanHtmlFilter < Docs::ReflyFilter
+ 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)
+ end
+
+
+ def other
+ # Re-create the header element
+ at_css("#wiki").child.before("#{at_css("#wikititle").content}
")
+
+ @doc = at_css("#wiki")
+
+ css('.contents', 'a.anchor', 'hr').remove
+
+ css('pre').each do |node|
+ node.content = node.content
+ end
+ end
+ end
+ end
+end
diff --git a/lib/docs/filters/webpack/entries.rb b/lib/docs/filters/webpack/entries.rb
new file mode 100644
index 0000000000..9211fbe1e4
--- /dev/null
+++ b/lib/docs/filters/webpack/entries.rb
@@ -0,0 +1,59 @@
+module Docs
+ class Webpack
+ class EntriesFilter < Docs::ReflyEntriesFilter
+
+ REPLACE_TYPES = {
+ 'guides' => 'guide',
+ 'getting started' => 'guide',
+ 'api' => 'api',
+ 'webpack with' => 'platforms',
+ 'dev tools' => 'tools',
+ 'home' => 'others',
+ 'lists' => 'lists'
+ }
+ def get_name
+ entry_link.content
+ end
+
+ def get_docset
+ docset = context[:root_title]
+ docset
+ end
+
+ def get_parsed_uri
+ if get_parent_uri == 'null'
+ parsed_uri = context[:docset_uri] + '/' + self.urilized(get_name)
+ else
+ parsed_uri = get_parent_uri + '/' + self.urilized(get_name)
+ end
+ parsed_uri
+ end
+
+ def get_parent_uri
+ 'null'
+ 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
+ # -
+ # TYPE
+ #
-
.. links ..
+ #
+ #
+ # Grab the first children (which is the text nodes whose contains the type)
+ REPLACE_TYPES[current_type.children.first.content.strip.downcase]
+ end
+
+ private
+
+ def entry_link
+ at_css("a[href='#{self.path}']")
+ end
+ end
+ end
+end
+
diff --git a/lib/docs/filters/xpath/clean_html.rb b/lib/docs/filters/xpath/clean_html.rb
index 6e3ee759ea..62b15774f4 100644
--- a/lib/docs/filters/xpath/clean_html.rb
+++ b/lib/docs/filters/xpath/clean_html.rb
@@ -1,8 +1,15 @@
module Docs
class Xpath
- class CleanHtmlFilter < Filter
+ class CleanHtmlFilter < Docs::ReflyFilter
+
+ BROKEN_LINKS = [
+ 'en/xslt/decimal-format',
+ 'en/xslt/key'
+ ]
+
def call
root_page? ? root : other
+ WrapPreContentWithCode 'hljs javascript'
doc
end
@@ -10,9 +17,47 @@ def root
if table = at_css('.topicpage-table')
table.after(table.css('td').children).remove
end
+ css('footer','div.article-meta', '.submenu', 'div.wiki-block', 'nav', '.toc', '#nav-access', '#main-header', '.title').remove
end
def other
+
+ #Cleaning content
+ css('footer','div.article-meta', '.submenu', 'div.wiki-block', 'nav', '.toc', '#nav-access', '#main-header', '.title').remove
+ css('a[href]').each do |node|
+ node['href'] = CleanWrongCharacters(node['href'])
+ if !node['href'].start_with? 'http://' and !node['href'].start_with? 'https://'
+ if node['class'] == 'new'
+ node['class'] = 'broken'
+ node['title'] = ''
+ # node['href'] = context[:domain] + '/help#brokenlink'
+ elsif BROKEN_LINKS.include?node['href'].downcase.remove!
+ node['class'] = 'broken'
+ # node['href'] = context[:domain] + '/help#brokenlink'
+ elsif !node['href'].start_with? '#'
+ sluglist = slug.split('/')
+ nodelist = node['href'].split('/')
+ newhref = []
+ nodelist.each do |item|
+ if item == '..'
+ sluglist.pop
+ elsif item == 'en'
+ sluglist.pop
+ elsif item == 'xpath'
+ sluglist.pop
+ else
+ newhref << item
+ end
+ end
+ sluglist.pop
+ if sluglist.size>0
+ node['href'] = sluglist.join('/') + '/' + newhref.join('/')
+ else
+ node['href'] = newhref.join('/')
+ end
+ end
+ end
+ end
css('div[style*="background: #f5f5f5;"]').remove
css('h3[id]').each do |node|
@@ -25,6 +70,9 @@ def other
child.remove if child.try(:name) == 'br'
end
end
+ def CleanWrongCharacters(href)
+ href.gsub('%23', '#').gsub('%28', '(').gsub('%29', ')').gsub('%21', '!').gsub('%7b', '{').gsub('%7e', '~').gsub('%2a', '*').gsub('%2b', '+').gsub('%3d', '=')
+ end
end
end
end
diff --git a/lib/docs/filters/xpath/entries.rb b/lib/docs/filters/xpath/entries.rb
index d07f2f865f..d369746f03 100644
--- a/lib/docs/filters/xpath/entries.rb
+++ b/lib/docs/filters/xpath/entries.rb
@@ -1,6 +1,7 @@
module Docs
class Xpath
- class EntriesFilter < Docs::EntriesFilter
+ class EntriesFilter < Docs::ReflyEntriesFilter
+ EXCLUDED_PATH = ['MDN','Web technology for developers', 'XPath']
def get_name
name = super
name.remove!('Axes.')
@@ -8,13 +9,41 @@ def get_name
name
end
+ def get_docset
+ docset = context[:root_title]
+ docset
+ end
+
+ def get_parsed_uri
+ if get_parent_uri == 'null'
+ parsed_uri = context[:docset_uri] + '/' + self.urilized(get_name)
+ else
+ parsed_uri = get_parent_uri + '/' + self.urilized(get_name)
+ end
+ parsed_uri
+ end
+
+ def get_parent_uri
+ parent_uri = context[:docset_uri]
+ css('.crumb a').each do |node|
+ link = node.content
+ if not EXCLUDED_PATH.include? link
+ parent_uri += '/' + self.urilized(link)
+ end
+ end
+ if parent_uri == context[:docset_uri]
+ parent_uri = 'null'
+ end
+ parent_uri
+ end
+
def get_type
if slug.start_with?('Axes')
- 'Axes'
+ 'axes'
elsif slug.start_with?('Functions')
- 'Functions'
+ 'function'
else
- 'Miscellaneous'
+ 'others'
end
end
end
diff --git a/lib/docs/filters/yii/clean_html.rb b/lib/docs/filters/yii/clean_html.rb
index 3249434f53..63bd8d27ba 100644
--- a/lib/docs/filters/yii/clean_html.rb
+++ b/lib/docs/filters/yii/clean_html.rb
@@ -1,6 +1,16 @@
module Docs
class Yii
- class CleanHtmlFilter < Filter
+ class CleanHtmlFilter < Docs::ReflyFilter
+ BROKEN_LINKS = [
+ 'input-file-upload',
+ 'license.md',
+ 'guide-tool-debugger',
+ 'guide-widget-jui',
+ 'guide-widget-bootstrap',
+ ]
+ REPLACED_LINKS = {
+ 'php.net/manual/en/book.pdo.php' => '/php/database_extensions/abstraction_layers/pdo'
+ }
def call
css('#nav', '.tool-link', '.toggle').remove
@@ -27,11 +37,41 @@ def call
css('.detail-table th').each do |node|
node.name = 'td'
end
+ #remove css links
+ css('link').each do |node|
+ node.remove
+ end
+ #remove meta
+ css('meta').each do |node|
+ node.remove
+ end
css('.detail-table td.signature').each do |node|
node.name = 'th'
end
+ css('a').each do |node|
+ if node.inner_html.include? '¶'
+ node.remove
+ end
+ end
+ css('a[href]').each do |node|
+ node['href'] = CleanWrongCharacters(node['href'])
+ if !node['href'].start_with? 'http://' and !node['href'].start_with? 'https://'
+ if node['class'] == 'new'
+ node['class'] = 'broken'
+ # node['href'] = context[:domain] + '/help#brokenlink'
+ elsif BROKEN_LINKS.include?node['href'].downcase.remove! '../'
+ node['class'] = 'broken'
+ # node['href'] = context[:domain] + '/help#brokenlink'
+ elsif REPLACED_LINKS[node['href'].remove! '../']
+ node['href'] = context[:domain] + REPLACED_LINKS[node['href'].remove! '../']
+ end
+ end
+ end
+
+ WrapPreContentWithCode 'hljs signature'
+ WrapContentWithDivs '_page _yii'
doc
end
end
diff --git a/lib/docs/filters/yii/entries.rb b/lib/docs/filters/yii/entries.rb
index b2cfdd3e32..dde0437714 100644
--- a/lib/docs/filters/yii/entries.rb
+++ b/lib/docs/filters/yii/entries.rb
@@ -1,31 +1,70 @@
module Docs
class Yii
- class EntriesFilter < Docs::EntriesFilter
+ class EntriesFilter < Docs::ReflyEntriesFilter
def get_name
name = at_css('h1').content.strip
name.remove! %r{\A.*?(Class|Trait|Interface)\s*}
name.remove!('yii\\')
+ name.remove! "\u{00B6}"
name
end
+ def get_docset
+ docset = context[:root_title]
+ docset
+ end
+
+ def get_parsed_uri_by_name(name)
+ if get_parent_uri == 'null'
+ parsed_uri = context[:docset_uri] + '/' + self.urilized(name)
+ else
+ parsed_uri = get_parent_uri + '/' + self.urilized(name)
+ end
+ parsed_uri
+ end
+
+ def get_parsed_uri
+ parsed_uri = context[:docset_uri] + '/' + self.urilized(get_name)
+ parsed_uri
+ end
+
+ def get_parent_uri
+ subpath = *path.split('/')
+ if subpath.length > 1
+ parent_uri = (context[:docset_uri]+ '/' + subpath[0,subpath.size-1].join('/')).downcase
+ else
+ parent_uri = 'null'
+ end
+ end
+
def get_type
- if slug.include?('guide')
- 'Guides'
+ if slug.include?'guide'
+ 'guide'
+ elsif slug.include? 'web' or slug.include? 'rest' or slug.include? 'mailer'
+ 'network'
+ elsif slug.include? 'mongodb' or slug.include? 'mutex' or slug.include? 'db' or slug.include? 'i18n' or slug.include? 'i18n' or slug.include? 'data'
+ 'data'
+ elsif slug.include? 'baseyii' or slug.include? 'gii' or slug.include? 'base' or slug.include? 'base'
+ 'core'
+ elsif slug.include? 'twig' or slug.include? 'smarty' or slug.include? 'widgets' or slug.include? 'bootstrap' or slug.include? 'jui'
+ 'view'
+ elsif slug.include? 'rbac' or slug.include? 'authclient' or slug.include? 'capcha'
+ 'security'
+ elsif slug.include? 'codeception' or slug.include? 'test' or slug.include? 'debug' or slug.include? 'log'
+ 'test'
else
- components = name.split('\\')
- type = components.first
- type << "\\#{components.second}" if (type == 'db' && components.second.in?(%w(cubrid mssql mysql oci pgsql sqlite))) ||
- (type == 'web' && components.second.in?(%w(Request Response)))
- type = 'yii' if type == 'BaseYii' || type == 'Yii'
- type
+ 'others'
end
end
def additional_entries
css('.detail-header').each_with_object [] do |node, entries|
- name = node.child.content.strip
+ name = node.child.content
+ name.remove! "\u{00B6}"
+ name.strip!
name.prepend "#{self.name} "
- entries << [name, node['id']]
+ custom_parsed_uri = get_parsed_uri_by_name(name.tr('\\\\', '.'))
+ entries << [name, node['id'], type, custom_parsed_uri, get_parent_uri, get_docset]
end
end
end
diff --git a/lib/docs/filters/yii1/clean_html.rb b/lib/docs/filters/yii1/clean_html.rb
new file mode 100644
index 0000000000..a0cc596a9e
--- /dev/null
+++ b/lib/docs/filters/yii1/clean_html.rb
@@ -0,0 +1,33 @@
+module Docs
+ class Yii1
+ class CleanHtmlFilter < Docs::ReflyFilter
+ def call
+ at_css('h1').content = 'Yii PHP Framework' if root_page?
+
+ css('.api-suggest', '.google-ad', '.g-plusone', '#nav', '#comments').remove
+
+ css('.summary > p > .toggle').each do |node|
+ node.parent.remove
+ end
+
+ css('.signature', '.signature2').each do |node|
+ node.name = 'pre'
+ node.inner_html = node.inner_html.strip
+ end
+
+ css('div.detailHeader').each do |node|
+ node.name = 'h3'
+ end
+
+ css('.sourceCode > .code > code').each do |node|
+ parent = node.parent
+ parent.name = 'pre'
+ node.remove
+ parent.inner_html = node.first_element_child.inner_html.strip
+ end
+
+ doc
+ end
+ end
+ end
+end
diff --git a/lib/docs/filters/yii1/entries.rb b/lib/docs/filters/yii1/entries.rb
new file mode 100644
index 0000000000..d9999a97ee
--- /dev/null
+++ b/lib/docs/filters/yii1/entries.rb
@@ -0,0 +1,93 @@
+module Docs
+ class Yii1
+ class EntriesFilter < Docs::ReflyEntriesFilter
+ REPLACE_TYPES = {
+ 'system.web.auth' => 'authentication',
+ 'system.web.actions' => 'web',
+ 'system.web' => 'web',
+ 'zii.widgets' => 'web',
+ 'system.web.widgets.pagers' => 'web',
+ 'system.web.widgets.captcha' => 'web',
+ 'system.web.filters' => 'web',
+ 'zii.widgets.jui' => 'web',
+ 'system.web.renderers' => 'web',
+ 'system.web.form' => 'web',
+ 'system.web.widgets' => 'web',
+ 'zii.widgets.grid' => 'web',
+ 'system.web.services' => 'web',
+ 'system.db.ar' => 'data',
+ 'system.db' => 'data',
+ 'system.db.schema.oci' => 'data',
+ 'system.db.schema.cubrid' => 'data',
+ 'system.db.schema' => 'data',
+ 'system.db.schema.mssql' => 'data',
+ 'system.db.schema.mysql' => 'data',
+ 'system.db.schema.pgsql' => 'data',
+ 'system.db.schema.sqlite' => 'data',
+ 'zii.behaviors' => 'data',
+ 'system.web.helpers' => 'helper',
+ 'system.collections' => 'collection',
+ 'system.base' => 'system',
+ 'system.caching' => 'system',
+ 'system.caching.dependencies' => 'system',
+ 'system.validators' => 'system',
+ 'system.logging' => 'system',
+ 'system.i18n' => 'system',
+ 'system.i18n.gettext' => 'system',
+ 'system.console' => 'system',
+ 'system.gii' => 'system',
+ 'system.utils' => 'utils',
+ 'system.test' => 'testing'
+ }
+ def get_name
+ at_css('h1').content.strip
+ end
+
+ def get_docset
+ docset = context[:root_title]
+ docset
+ end
+
+ def get_parsed_uri
+ if get_parent_uri == 'null'
+ parsed_uri = context[:docset_uri] + '/' + self.urilized(get_name)
+ else
+ parsed_uri = get_parent_uri + '/' + self.urilized(get_name)
+ end
+ parsed_uri
+ end
+
+ def get_parsed_uri_by_name(name)
+ if get_parent_uri == 'null'
+ parsed_uri = context[:docset_uri] + '/' + self.urilized(name)
+ else
+ parsed_uri = get_parent_uri + '/' + self.urilized(name)
+ end
+ parsed_uri
+ end
+
+ def get_parent_uri
+ subpath = *path.split('/')
+ if subpath.length > 1
+ parent_uri = (context[:docset_uri]+ '/' + subpath[0,subpath.size-1].join('/')).downcase
+ else
+ parent_uri = 'null'
+ end
+ end
+
+ def get_type
+ REPLACE_TYPES[css('.summaryTable td').first.content.strip] || css('.summaryTable td').first.content.strip
+ end
+
+
+ def additional_entries
+ css('.detailHeader').inject [] do |entries, node|
+ name = node.child.content.strip
+ name.prepend self.name + (node.next_element.content.include?('public static') ? '::' : '->')
+ custom_parsed_uri = get_parsed_uri_by_name(name)
+ entries << [name, node['id'], get_type, custom_parsed_uri, get_parent_uri, get_docset]
+ end
+ end
+ end
+ end
+end
diff --git a/lib/docs/scrapers/angular.rb b/lib/docs/scrapers/angular.rb
index 4f2d92adcb..7d6ec2f421 100644
--- a/lib/docs/scrapers/angular.rb
+++ b/lib/docs/scrapers/angular.rb
@@ -1,59 +1,32 @@
module Docs
class Angular < UrlScraper
- self.name = 'Angular.js'
+
+ self.name = 'AngularJS'
self.slug = 'angular'
self.type = 'angular'
- self.version = '1.3.8'
- self.base_url = "https://code.angularjs.org/#{version}/docs/partials/api/"
+ self.version = '1.4.5'
+ self.base_url = "https://code.angularjs.org/1.4.5/docs/partials/api/"
- html_filters.push 'angular/clean_html', 'angular/entries', 'title'
+ html_filters.push 'angular/entries', 'angular/clean_html', 'title'
text_filters.push 'angular/clean_urls'
options[:title] = false
- options[:root_title] = 'Angular.js'
-
+ options[:domain] = 'http://www.refly.xyz'
+ options[:root_title] = 'AngularJS'
+ options[:docset_uri] = '/angularjs'
+ options[:skip_patterns] = [
+ /\/misc\/misc\/.*/,
+ ]
options[:fix_urls] = ->(url) do
- url.sub! '/partials/api/api/', '/partials/api/'
- url.sub! %r{/api/(.+?)/api/}, '/api/'
- url.sub! %r{/partials/api/(.+?)(?
+ © 2010–2015 Google, Inc.
Licensed under the Creative Commons Attribution License 3.0.
HTML
- private
-
- def request_one(url)
- stub_root_page if url == root_url.to_s
- super
- end
-
- def request_all(urls, &block)
- stub_root_page
- super
- end
-
- def stub_root_page
- response = Typhoeus::Response.new(
- effective_url: root_url.to_s,
- code: 200,
- headers: { 'Content-Type' => 'text/html' },
- body: get_root_page_body)
- Typhoeus.stub(root_url.to_s).and_return(response)
- end
-
- def get_root_page_body
- require 'capybara'
- Capybara.current_driver = :selenium
- Capybara.visit("https://code.angularjs.org/#{self.class.version}/docs/api")
- Capybara.find('.side-navigation')['innerHTML']
- end
end
-end
+end
\ No newline at end of file
diff --git a/lib/docs/scrapers/apache.rb b/lib/docs/scrapers/apache.rb
new file mode 100644
index 0000000000..fb8ed88f7b
--- /dev/null
+++ b/lib/docs/scrapers/apache.rb
@@ -0,0 +1,36 @@
+module Docs
+ class Apache < UrlScraper
+ self.name = 'Apache HTTP Server'
+ self.slug = 'apache'
+ self.type = 'apache'
+ self.version = '2.4.12'
+ self.base_url = 'http://httpd.apache.org/docs/2.4/en/'
+
+ html_filters.push 'apache/clean_html', 'apache/entries'
+ options[:domain] = 'http://www.refly.xyz'
+ options[:root_title] = 'Apache'
+ options[:docset_uri] = '/apache'
+ options[:container] = '#page-content'
+
+ options[:skip] = %w(
+ upgrading.html
+ license.html
+ sitemap.html
+ glossary.html
+ mod/quickreference.html
+ mod/directive-dict.html
+ mod/directives.html
+ mod/module-dict.html
+ programs/other.html)
+
+ options[:skip_patterns] = [
+ /\A(da|de|en|es|fr|ja|ko|pt-br|tr|zh-cn)\//,
+ /\Anew_features/,
+ /\Adeveloper\// ]
+
+ options[:attribution] = <<-HTML
+ © The Apache Software Foundation
+ Licensed under the Apache License, Version 2.0.
+ HTML
+ end
+end
diff --git a/lib/docs/scrapers/backbone.rb b/lib/docs/scrapers/backbone.rb
index b092561697..4aeb02b5cc 100644
--- a/lib/docs/scrapers/backbone.rb
+++ b/lib/docs/scrapers/backbone.rb
@@ -3,12 +3,15 @@ class Backbone < UrlScraper
self.name = 'Backbone.js'
self.slug = 'backbone'
self.type = 'underscore'
- self.version = '1.1.2'
+ self.version = '1.2.3'
self.base_url = 'http://backbonejs.org'
html_filters.push 'backbone/clean_html', 'backbone/entries', 'title'
- options[:title] = 'Backbone.js'
+ options[:domain] = 'http://www.refly.xyz'
+ options[:title] = 'BackboneJS'
+ options[:root_title] = 'BackboneJS'
+ options[:docset_uri] = '/backbonejs'
options[:container] = '.container'
options[:skip_links] = true
diff --git a/lib/docs/scrapers/bootstrap.rb b/lib/docs/scrapers/bootstrap.rb
new file mode 100644
index 0000000000..674a824304
--- /dev/null
+++ b/lib/docs/scrapers/bootstrap.rb
@@ -0,0 +1,29 @@
+module Docs
+ class Bootstrap < UrlScraper
+ self.name = 'Bootstrap'
+ self.type = 'Bootstrap'
+ self.version = '3.3.35'
+ self.base_url = 'http://getbootstrap.com/'
+ self.root_path = '/getting-started/'
+
+ html_filters.push 'bootstrap/entries', 'bootstrap/clean_html'
+
+ options[:domain] = 'http://www.refly.xyz'
+ options[:container] = '.container.bs-docs-container'
+ options[:trailing_slash] = true
+ options[:root_title] = 'Bootstrap'
+ options[:docset_uri] = '/bootstrap'
+ options[:only] = [
+ 'javascript/',
+ 'css/',
+ 'components/',
+ 'getting-started/'
+ ]
+
+ options[:attribution] = <<-HTML
+ © 2015 Rackt
+ Licensed under the MIT License.
+ HTML
+
+ end
+end
diff --git a/lib/docs/scrapers/bower.rb b/lib/docs/scrapers/bower.rb
index f545274376..e739d49c3d 100644
--- a/lib/docs/scrapers/bower.rb
+++ b/lib/docs/scrapers/bower.rb
@@ -2,12 +2,15 @@ module Docs
class Bower < UrlScraper
self.name = 'Bower'
self.type = 'bower'
- self.version = '1.3.12'
+ self.version = '1.4.1'
self.base_url = 'http://bower.io/docs/'
- self.root_path = 'api'
+ self.root_path = 'api/'
html_filters.push 'bower/clean_html', 'bower/entries'
+ options[:domain] = 'http://www.refly.xyz'
+ options[:root_title] = 'Bower'
+ options[:docset_uri] = '/bower'
options[:trailing_slash] = false
options[:skip] = %w(tools about)
@@ -15,5 +18,6 @@ class Bower < UrlScraper
© 2014 Bower contributors
Licensed under the Creative Commons Attribution License.
HTML
+
end
end
diff --git a/lib/docs/scrapers/browserify.rb b/lib/docs/scrapers/browserify.rb
new file mode 100644
index 0000000000..8a057c41ba
--- /dev/null
+++ b/lib/docs/scrapers/browserify.rb
@@ -0,0 +1,25 @@
+module Docs
+ class Browserify < UrlScraper
+ self.name = 'Browserify'
+ self.type = 'Browserify'
+ self.version = '11.0.1'
+ self.base_url = 'https://github.com/substack/node-browserify/blob/master/'
+ self.root_path = 'readme.markdown'
+
+ html_filters.push 'browserify/entries', 'browserify/clean_html'
+
+ options[:domain] = 'http://www.refly.xyz'
+ options[:container] = 'article'
+ options[:trailing_slash] = true
+ options[:root_title] = 'Browserify'
+ options[:docset_uri] = '/browserify'
+
+ options[:skip] = %w(changelog.markdown/)
+ options[:skip_patterns] = [/bin/]
+ options[:attribution] = <<-HTML
+ © 2015 Joyent, Inc. and other Node contributors
+ Licensed under the MIT License.
+ HTML
+
+ end
+end
diff --git a/lib/docs/scrapers/c.rb b/lib/docs/scrapers/c.rb
index a4af5910fe..8752fdfb2a 100644
--- a/lib/docs/scrapers/c.rb
+++ b/lib/docs/scrapers/c.rb
@@ -1,17 +1,22 @@
module Docs
class C < FileScraper
self.type = 'c'
- self.dir = '/Users/Thibaut/DevDocs/Docs/C/en/c'
+ self.dir = './file_scraper_docs/c/reference/en/c'
self.base_url = 'http://en.cppreference.com/w/c/'
self.root_path = 'header.html'
+ self.initial_paths = %w(
+ /program.html
+ )
html_filters.insert_before 'clean_html', 'c/fix_code'
html_filters.push 'c/entries', 'c/clean_html', 'title'
text_filters.push 'c/fix_urls'
+ options[:domain] = 'http://www.refly.xyz'
options[:container] = '#content'
options[:title] = false
- options[:root_title] = 'C Programming Language'
+ options[:root_title] = 'C'
+ options[:docset_uri] = '/c'
options[:skip] = %w(language/history.html)
options[:fix_urls] = ->(url) do
diff --git a/lib/docs/scrapers/chai.rb b/lib/docs/scrapers/chai.rb
index 3178cda5dc..6d93b9145c 100644
--- a/lib/docs/scrapers/chai.rb
+++ b/lib/docs/scrapers/chai.rb
@@ -2,15 +2,21 @@ module Docs
class Chai < UrlScraper
self.name = 'Chai'
self.type = 'chai'
- self.version = '1.10.0'
+ self.version = '2.3.0'
self.base_url = 'http://chaijs.com'
self.root_path = '/api/'
self.initial_paths = %w(/guide/installation/)
-
+ self.links = {
+ home: 'http://chaijs.com/',
+ code: 'https://github.com/chaijs/chai'
+ }
html_filters.push 'chai/entries', 'chai/clean_html'
+ options[:domain] = 'http://www.refly.xyz'
options[:container] = '#content'
options[:trailing_slash] = true
+ options[:root_title] = 'Chai'
+ options[:docset_uri] = '/chai'
options[:only_patterns] = [/\A\/guide/, /\A\/api/]
options[:skip] = %w(/api/test/ /guide/ /guide/resources/)
@@ -19,5 +25,6 @@ class Chai < UrlScraper
© 2011–2014 Jake Luer
Licensed under the MIT License.
HTML
+
end
end
diff --git a/lib/docs/scrapers/chef.rb b/lib/docs/scrapers/chef.rb
new file mode 100644
index 0000000000..581fb0e6b7
--- /dev/null
+++ b/lib/docs/scrapers/chef.rb
@@ -0,0 +1,29 @@
+module Docs
+ class Chef < UrlScraper
+ self.type = 'chef'
+ self.version = '12.4'
+ self.base_url = 'https://docs.chef.io/'
+ self.root_path = 'index.html'
+ self.initial_paths = %w(
+ resources.html
+ )
+
+ html_filters.push 'chef/clean_html', 'chef/entries'
+
+ options[:domain] = 'http://www.refly.xyz'
+ options[:root_title] = 'Chef'
+ options[:docset_uri] = '/chef'
+ options[:container] = '.body'
+ options[:skip_patterns] = [/\Adecks\//, /.*\.svg/]
+ options[:skip] = %w(
+ lwrp.html
+ signup
+ )
+
+ options[:attribution] = <<-HTML
+ © 2015 The Chef Project Developers
+ Licensed under the Creative Common, Version 3.0.
+ HTML
+
+ end
+end
diff --git a/lib/docs/scrapers/clojure.rb b/lib/docs/scrapers/clojure.rb
new file mode 100644
index 0000000000..11a2880cd8
--- /dev/null
+++ b/lib/docs/scrapers/clojure.rb
@@ -0,0 +1,20 @@
+module Docs
+ class Clojure < UrlScraper
+ self.type = 'clojure'
+ self.version = '1.7'
+ self.base_url = 'http://clojure.github.io/clojure/'
+ self.root_path = 'api-index.html'
+
+ html_filters.push 'clojure/entries', 'clojure/clean_html'
+ options[:domain] = 'http://www.refly.xyz'
+ options[:root_title] = 'Clojure'
+ options[:docset_uri] = '/clojure'
+ options[:container] = '#content_view'
+ options[:only_patterns] = [/\Aclojure\./]
+
+ options[:attribution] = <<-HTML
+ © Rich Hickey
+ Licensed under the Eclipse Public License 1.0.
+ HTML
+ end
+end
diff --git a/lib/docs/scrapers/coffeescript.rb b/lib/docs/scrapers/coffeescript.rb
index a1f016d2a1..242990c164 100644
--- a/lib/docs/scrapers/coffeescript.rb
+++ b/lib/docs/scrapers/coffeescript.rb
@@ -2,13 +2,17 @@ module Docs
class Coffeescript < UrlScraper
self.name = 'CoffeeScript'
self.type = 'coffeescript'
- self.version = '1.8.0'
+ self.version = '1.10.0'
self.base_url = 'http://coffeescript.org'
+ self.root_path = 'index.html'
html_filters.push 'coffeescript/clean_html', 'coffeescript/entries', 'title'
+ options[:domain] = 'http://www.refly.xyz'
options[:title] = 'CoffeeScript'
options[:container] = '.container'
+ options[:root_title] = 'CoffeeScript'
+ options[:docset_uri] = '/coffeescript'
options[:skip_links] = true
options[:attribution] = <<-HTML
diff --git a/lib/docs/scrapers/cordova.rb b/lib/docs/scrapers/cordova.rb
index e7ee72f67a..9134193b5b 100644
--- a/lib/docs/scrapers/cordova.rb
+++ b/lib/docs/scrapers/cordova.rb
@@ -2,19 +2,24 @@ module Docs
class Cordova < UrlScraper
self.name = 'Cordova'
self.type = 'cordova'
- self.version = '4.0.0'
- self.base_url = 'http://cordova.apache.org/docs/en/4.0.0/'
+ self.version = '5.1.1'
+ self.base_url = "http://cordova.apache.org/docs/en/#{version}/"
self.root_path = 'index.html'
+ self.links = {
+ home: 'http://cordova.apache.org/'
+ }
html_filters.push 'cordova/clean_html', 'cordova/entries', 'title'
- options[:container] = ->(filter) { filter.root_page? ? '#home' : '#content' }
+ options[:container] = '#page-toc-source'
options[:title] = false
options[:root_title] = 'Apache Cordova'
+ options[:docset_uri] = '/apache_cordova'
+ options[:root_title] = 'Apache Cordova'
options[:skip] = %w(_index.html guide_support_index.md.html)
options[:attribution] = <<-HTML
- © 2012-2014 The Apache Software Foundation
+ © 2012-2015 The Apache Software Foundation
Licensed under the Apache License 2.0.
HTML
end
diff --git a/lib/docs/scrapers/cpp.rb b/lib/docs/scrapers/cpp.rb
index 8066966b2a..875caca404 100644
--- a/lib/docs/scrapers/cpp.rb
+++ b/lib/docs/scrapers/cpp.rb
@@ -3,22 +3,27 @@ class Cpp < FileScraper
self.name = 'C++'
self.slug = 'cpp'
self.type = 'c'
- self.dir = '/Users/Thibaut/DevDocs/Docs/C/en/cpp'
+ self.dir = './file_scraper_docs/c/reference/en/cpp'
self.base_url = 'http://en.cppreference.com/w/cpp/'
self.root_path = 'header.html'
-
+ self.initial_paths = %w(
+ /experimental.html
+ )
html_filters.insert_before 'clean_html', 'c/fix_code'
html_filters.push 'cpp/entries', 'c/clean_html', 'title'
text_filters.push 'cpp/fix_urls'
+ options[:domain] = 'http://www.refly.xyz'
+ options[:root_title] = 'Cpp'
+ options[:docset_uri] = '/cpp'
options[:container] = '#content'
options[:title] = false
- options[:root_title] = 'C++ Programming Language'
options[:skip] = %w(
language/extending_std.html
language/history.html
regex/ecmascript.html
regex/regex_token_iterator/operator_cmp.html
+
)
options[:only_patterns] = [/\.html\z/]
@@ -32,4 +37,4 @@ class Cpp < FileScraper
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
HTML
end
-end
+end
\ No newline at end of file
diff --git a/lib/docs/scrapers/d3.rb b/lib/docs/scrapers/d3.rb
index 52109d2db7..10e135e113 100644
--- a/lib/docs/scrapers/d3.rb
+++ b/lib/docs/scrapers/d3.rb
@@ -3,13 +3,16 @@ class D3 < UrlScraper
self.name = 'D3.js'
self.slug = 'd3'
self.type = 'd3'
- self.version = '3.5.2'
+ self.version = '3.5.6'
self.base_url = 'https://github.com/mbostock/d3/wiki/'
self.root_path = 'API-Reference'
html_filters.push 'd3/clean_html', 'd3/entries'
+ options[:domain] = 'http://www.refly.xyz'
options[:container] = '#wiki-wrapper'
+ options[:root_title] = 'D3'
+ options[:docset_uri] = '/d3'
options[:only] = %w(
Selections
diff --git a/lib/docs/scrapers/django.rb b/lib/docs/scrapers/django.rb
index b72419e30f..b925a24f01 100644
--- a/lib/docs/scrapers/django.rb
+++ b/lib/docs/scrapers/django.rb
@@ -2,23 +2,27 @@ module Docs
class Django < FileScraper
self.name = 'Django'
self.type = 'sphinx'
- self.version = '1.7.1'
- self.dir = '/Users/Thibaut/DevDocs/Docs/Django'
- self.base_url = 'https://docs.djangoproject.com/en/1.7/'
+ self.version = '1.8.4'
+ self.dir = './file_scraper_docs/django'
+ self.base_url = 'https://docs.djangoproject.com/en/1.8/'
self.root_path = 'index.html'
html_filters.push 'django/entries', 'django/clean_html'
text_filters.push 'django/fix_urls'
+ options[:domain] = 'http://www.refly.xyz'
+ options[:title] = false
+ options[:root_title] = 'Django'
+ options[:docset_uri] = '/django'
options[:container] = '#bd'
- options[:skip] = %w(
- contents.html
- genindex.html
- py-modindex.html
- glossary.html
- search.html
- intro/whatsnext.html)
+ # options[:skip] = %w(
+ # contents.html
+ # genindex.html
+ # py-modindex.html
+ # glossary.html
+ # search.html
+ # intro/whatsnext.html)
options[:skip_patterns] = [
/\Afaq\//,
diff --git a/lib/docs/scrapers/dojo.rb b/lib/docs/scrapers/dojo.rb
new file mode 100644
index 0000000000..331949970e
--- /dev/null
+++ b/lib/docs/scrapers/dojo.rb
@@ -0,0 +1,51 @@
+require 'yajl/json_gem'
+
+module Docs
+ class Dojo < UrlScraper
+ # include StubRootPage
+ self.type = 'dojo'
+ self.version = '1.10'
+ # self.base_url = "http://dojotoolkit.org//api/?qs=#{version}/"
+ self.base_url = "http://dojotoolkit.org/reference-guide/1.10/"
+ # self.root_path = 'dojo/_base/kernel'
+
+ # Dojo expects all the requests to be xhrs or it redirects you back to the docs home page
+ # where it uses js to call the backend based on the URL so you get the appropriate documentation
+ self.links = {
+ home: 'http://dojotoolkit.org',
+ code: 'https://github.com/dojo/dojo'
+ }
+
+ html_filters.push 'dojo/entries', 'dojo/clean_html', 'title'
+ text_filters.push 'dojo/clean_urls'
+
+ options[:container] = false
+ options[:title] = false
+ options[:root_title] = 'Dojo'
+ options[:domain] = 'http://www.refly.xyz'
+ options[:docset_uri] = '/dojo'
+ options[:only_patterns] = [/\Adojo\//]
+ options[:skip_patterns] = [/dijit/, /dojox/]
+
+ options[:attribution] = <<-HTML
+ © 2005–2015 The Dojo Foundation
+ Licensed under the AFL 2.1 and BSD 3-Clause licenses.
+ HTML
+
+ # private
+
+ # def root_page_body
+ # response = request_one("http://dojotoolkit.org/api/1.10/tree.json")
+ # puts "#{self.base_url}tree.json"
+ # json = JSON.parse(response.body)
+ # urls = get_url_list(json)
+ # urls.map { |url| "#{url}" }.join
+ # end
+
+ # def get_url_list(json, set = Set.new)
+ # set.add("#{self.class.base_url}#{json['fullname']}.html?xhr=true")
+ # json['children'].each { |child| get_url_list(child, set) } if json['children']
+ # set
+ # end
+ end
+end
diff --git a/lib/docs/scrapers/drupal.rb b/lib/docs/scrapers/drupal.rb
new file mode 100644
index 0000000000..c62b1f1077
--- /dev/null
+++ b/lib/docs/scrapers/drupal.rb
@@ -0,0 +1,53 @@
+module Docs
+ class Drupal < UrlScraper
+ self.type = 'drupal'
+ self.version = '7.38'
+ self.base_url = 'https://api.drupal.org/api/drupal/'
+ self.initial_paths = %w(groups groups?page=1)
+
+ html_filters.push 'drupal/entries', 'drupal/clean_html', 'title'
+
+ options[:decode_and_clean_paths] = true
+ options[:container] = '#page-inner'
+ options[:domain] = 'http://www.refly.xyz'
+ options[:root_title] = 'Drupal'
+ options[:docset_uri] = '/drupal'
+ options[:title] = false
+ options[:root_title] = 'Drupal'
+
+ options[:only_patterns] = [
+ /\/class\/[^\/]+/,
+ /\/group\/[^\/]+/,
+ /\/modules\/[^\/]+/,
+ /\/function\/[^\/]+/]
+
+ options[:skip_link] = ->(link) { link['href'] =~ /[\?&]order/ }
+
+ options[:skip_patterns] = [
+ /\/group\/updates\-7/,
+ /\/group\/updates\-6/,
+ /_update_[0-9]{4}/, # Skip update functions
+ /\/[4-6](\.[0-9])*$/, # Skip previous versions
+ /\/[8-9](\.[0-9])*$/, # Skip future versions
+ /\/class\/hierarchy\//, # Skip class hierarchy listings
+ /\/function\/calls\//, # Skip function calls listings
+ /\/function\/invokes\//, # Skip function invokations listings
+ /\/function\/overrides\//, # Skip function overrides listings
+ /\/function\/references\//, # Skip function references listings
+ /\/function\/implementations\//, # Skip hook implementation listings
+ /\/function\/theme_references\//, # Skip hook references listings
+ /\.test\/function\// # Skip test files
+ ]
+
+ options[:fix_urls] = ->(url) do
+ url.remove! %r{/7$}
+ url
+ end
+
+ options[:attribution] = <<-HTML
+ © 2001–2015 by the original authors
+ Licensed under the GNU General Public License, version 2 and later.
+ Drupal is a registered trademark of Dries Buytaert.
+ HTML
+ end
+end
diff --git a/lib/docs/scrapers/elixir.rb b/lib/docs/scrapers/elixir.rb
new file mode 100644
index 0000000000..2b5e2d9dfc
--- /dev/null
+++ b/lib/docs/scrapers/elixir.rb
@@ -0,0 +1,33 @@
+module Docs
+ class Elixir < UrlScraper
+ self.name = 'Elixir'
+ self.type = 'elixir'
+ self.version = '1.1.1'
+ self.base_url = 'http://elixir-lang.org/docs/stable/'
+ self.root_path = 'elixir/extra-api-reference.html'
+ self.initial_paths = %w(
+ eex/EEx.html
+ ex_unit/ExUnit.html
+ iex/IEx.html
+ logger/Logger.html
+ mix/Mix.html
+ )
+ self.links = {
+ home: 'http://elixir-lang.org/',
+ code: 'https://github.com/elixir-lang/elixir'
+ }
+
+ html_filters.push 'elixir/clean_html', 'elixir/entries', 'title'
+
+ options[:domain] = 'http://www.refly.xyz'
+ options[:root_title] = 'Elixir'
+ options[:docset_uri] = '/elixir'
+ options[:container] = "#content"
+ options[:title] = false
+
+ options[:attribution] = <<-HTML
+ © 2012 Plataformatec
+ Licensed under the Apache License, Version 2.0.
+ HTML
+ end
+end
diff --git a/lib/docs/scrapers/ember.rb b/lib/docs/scrapers/ember.rb
index fccf6d362f..c90e41b5de 100644
--- a/lib/docs/scrapers/ember.rb
+++ b/lib/docs/scrapers/ember.rb
@@ -1,15 +1,17 @@
module Docs
class Ember < UrlScraper
- self.name = 'Ember.js'
+ self.name = 'EmberJS'
self.slug = 'ember'
self.type = 'ember'
- self.version = '1.9.0'
+ self.version = '2.0.1'
self.base_url = 'http://emberjs.com/api/'
html_filters.push 'ember/clean_html', 'ember/entries', 'title'
+ options[:domain] = 'http://www.refly.xyz'
options[:title] = false
- options[:root_title] = 'Ember.js'
+ options[:root_title] = 'EmberJS'
+ options[:docset_uri] = '/emberjs'
options[:container] = ->(filter) do
filter.root_page? ? '#toc-list' : '#content'
@@ -17,8 +19,7 @@ class Ember < UrlScraper
# Duplicates
options[:skip] = %w(
- classes/String.html
- data/classes/DS.html)
+ classes/String.html)
# Empty
options[:skip].concat %w(
diff --git a/lib/docs/scrapers/express.rb b/lib/docs/scrapers/express.rb
index bfb7621ced..70e3e7e7d5 100644
--- a/lib/docs/scrapers/express.rb
+++ b/lib/docs/scrapers/express.rb
@@ -2,18 +2,33 @@ module Docs
class Express < UrlScraper
self.name = 'Express'
self.type = 'express'
- self.version = '4.10.0'
- self.base_url = 'http://expressjs.com/4x/api.html'
+ self.release = '4.13.4'
+ self.base_url = 'http://expressjs.com/en/'
+ self.root_path = '4x/api.html'
+ self.initial_paths = %w(
+ starter/installing.html
+ guide/routing.html
+ advanced/developing-template-engines.html )
+ self.links = {
+ home: 'http://expressjs.com/',
+ code: 'https://github.com/strongloop/express/'
+ }
html_filters.push 'express/clean_html', 'express/entries', 'title'
+ options[:domain] = 'http://www.refly.xyz'
options[:title] = 'Express'
- options[:container] = '#api-doc'
- options[:skip_links] = true
+ options[:root_title] = 'Express'
+ options[:docset_uri] = '/express'
+ options[:container] = '.content'
+
+ options[:only_patterns] = [
+ /\Astarter/,
+ /\Aguide/,
+ /\Aadvanced/ ]
options[:attribution] = <<-HTML
- © 2009–2014 TJ Holowaychuk
- Licensed under the MIT License.
+ © 2016 StrongLoop, IBM, and other expressjs.com contributors.
HTML
end
end
diff --git a/lib/docs/scrapers/flow.rb b/lib/docs/scrapers/flow.rb
new file mode 100644
index 0000000000..4dc88a9801
--- /dev/null
+++ b/lib/docs/scrapers/flow.rb
@@ -0,0 +1,24 @@
+module Docs
+ class Flow < React
+ self.type = 'react'
+ self.version = '0.18'
+ self.base_url = 'http://flowtype.org/docs/'
+ self.root_path = 'getting-started.html'
+ self.links = {
+ home: 'http://flowtype.org/',
+ code: 'https://github.com/facebook/flow'
+ }
+
+ options[:container] = '.content'
+ options[:domain] = 'http://www.refly.xyz'
+ options[:root_title] = 'Flow'
+ options[:docset_uri] = '/flow'
+ options[:only_patterns] = nil
+ options[:skip] = %w(coming-soon.html)
+
+ options[:attribution] = <<-HTML
+ © 2013–2015 Facebook Inc.
+ Licensed under the BSD License.
+ HTML
+ end
+end
diff --git a/lib/docs/scrapers/git.rb b/lib/docs/scrapers/git.rb
index b6acc2cc7d..6bf8664d5c 100644
--- a/lib/docs/scrapers/git.rb
+++ b/lib/docs/scrapers/git.rb
@@ -1,15 +1,34 @@
module Docs
class Git < UrlScraper
self.type = 'git'
- self.version = '2.2.0'
+ self.version = '2.5.1'
self.base_url = 'http://git-scm.com/docs'
- self.initial_paths = %w(/git.html)
+ self.initial_paths = %w(
+ /git.html
+ /git-upload-archive
+ /git-annotate
+ /git-blame
+ /gitcli
+ /line-range-format.txt
+ /giteveryday
+ /gittutorial
+ /gittutorial-2
+ /user-manual
+ /gitcore-tutorial
+ /gitglossary
+ /gitcvs-migration
+ /gitattributes
+ /gitworkflows
+ /gitignore
+ )
html_filters.push 'git/clean_html', 'git/entries'
-
+ options[:domain] = 'http://www.refly.xyz'
+ options[:root_title] = 'Git'
+ options[:title] = false
+ options[:docset_uri] = '/git'
options[:container] = ->(filter) { filter.root_page? ? '#main' : '.man-page, #main' }
- options[:follow_links] = ->(filter) { filter.root_page? }
- options[:only_patterns] = [/\A\/git\-/]
+ #options[:follow_links] = ->(filter) { filter.root_page? }
options[:attribution] = <<-HTML
© 2005–2014 Linus Torvalds and others
diff --git a/lib/docs/scrapers/go.rb b/lib/docs/scrapers/go.rb
index 9fb80505f7..166d42d948 100644
--- a/lib/docs/scrapers/go.rb
+++ b/lib/docs/scrapers/go.rb
@@ -1,11 +1,18 @@
module Docs
class Go < UrlScraper
self.type = 'go'
- self.version = '1.4.0'
- self.base_url = 'http://golang.org/pkg/'
+ self.version = '1.5.0'
+ self.base_url = 'https://golang.org/pkg/'
+ self.links = {
+ home: 'https://golang.org/',
+ code: 'https://go.googlesource.com/go'
+ }
html_filters.push 'go/clean_html', 'go/entries'
-
+ options[:domain] = 'http://www.refly.xyz'
+ options[:container] = '#page .container'
+ options[:root_title] = 'Go'
+ options[:docset_uri] = '/go'
options[:container] = '#page .container'
options[:attribution] = <<-HTML
diff --git a/lib/docs/scrapers/grunt.rb b/lib/docs/scrapers/grunt.rb
index 11ca52efb5..6f1c265c7e 100644
--- a/lib/docs/scrapers/grunt.rb
+++ b/lib/docs/scrapers/grunt.rb
@@ -4,24 +4,29 @@ class Grunt < UrlScraper
self.type = 'grunt'
self.version = '0.4.5'
self.base_url = 'http://gruntjs.com/'
- self.root_path = 'getting-started'
- self.initial_paths = %w(api/grunt)
+ self.initial_paths = %w(api/grunt getting-started)
html_filters.push 'grunt/clean_html', 'grunt/entries'
options[:only] = %w(
+ getting-started
configuring-tasks
sample-gruntfile
creating-tasks
using-the-cli
)
+ options[:domain] = 'http://www.refly.xyz'
options[:only_patterns] = [/\Aapi\//]
-
+ options[:root_title] = 'Grunt'
+ options[:docset_uri] = '/grunt'
options[:container] = '.container > .row-fluid'
options[:attribution] = <<-HTML
© 2014 Grunt Team
Licensed under the MIT License.
HTML
+
+
end
+
end
diff --git a/lib/docs/scrapers/haskell.rb b/lib/docs/scrapers/haskell.rb
index eec02b3ba6..bdcd34d3fb 100755
--- a/lib/docs/scrapers/haskell.rb
+++ b/lib/docs/scrapers/haskell.rb
@@ -2,25 +2,16 @@ module Docs
class Haskell < UrlScraper
self.name = 'Haskell'
self.type = 'haskell'
- self.version = '7.8.2'
- self.base_url = 'http://www.haskell.org/ghc/docs/7.8.2/html/libraries/'
+ self.version = '7.10.2'
+ self.base_url = 'https://downloads.haskell.org/~ghc/7.8.2/docs/html/libraries/'
self.root_path = 'index.html'
html_filters.push 'haskell/entries', 'haskell/clean_html'
+ options[:domain] = 'http://www.refly.xyz'
options[:container] = '#content'
-
- options[:skip] = %w(
- hoopl-3.10.0.1/Compiler-Hoopl-Internals.html
- base-4.7.0.0/Control-Exception-Base.html
- binary-0.7.1.0/Data-Binary-Get-Internal.html
- template-haskell-2.9.0.0/Language-Haskell-TH-Lib.html
- haskell98-2.0.0.3/Prelude.html
- pretty-1.1.1.1/Text-PrettyPrint.html
- base-4.7.0.0/Data-OldTypeable-Internal.html
- base-4.7.0.0/Data-Typeable-Internal.html
- base-4.7.0.0/GHC-IO-Encoding-Types.html
- unix-2.7.0.1/System-Posix-Process-Internals.html)
+ options[:root_title] = 'Haskell'
+ options[:docset_uri] = '/haskell'
options[:skip_patterns] = [/src\//, /doc-index/, /haskell2010/, /ghc-/, /Cabal-/]
diff --git a/lib/docs/scrapers/http.rb b/lib/docs/scrapers/http.rb
index 2f517c757e..d1a2fcb704 100644
--- a/lib/docs/scrapers/http.rb
+++ b/lib/docs/scrapers/http.rb
@@ -2,13 +2,17 @@ module Docs
class Http < UrlScraper
self.name = 'HTTP'
self.type = 'rfc'
- self.base_url = 'http://www.w3.org/Protocols/rfc2616/'
- self.root_path = 'rfc2616.html'
+ self.base_url = 'https://tools.ietf.org/html/'
+ self.initial_paths = %w(rfc2616 rfc7230 rfc7231
+ rfc7232 rfc7233 rfc7234 rfc7235)
html_filters.push 'http/clean_html', 'http/entries'
-
- options[:only] = %w(rfc2616-sec10.html rfc2616-sec14.html)
- options[:container] = ->(filter) { '.toc' if filter.root_page? }
- options[:attribution] = "© 1999 The Internet Society"
+ options[:domain] = 'http://www.refly.xyz'
+ options[:root_title] = 'Http'
+ options[:docset_uri] = '/http'
+ options[:skip_links] = true
+ options[:attribution] = <<-HTML
+ © document authors. All rights reserved.
+ HTML
end
end
diff --git a/lib/docs/scrapers/iojs.rb b/lib/docs/scrapers/iojs.rb
new file mode 100644
index 0000000000..ed7779f713
--- /dev/null
+++ b/lib/docs/scrapers/iojs.rb
@@ -0,0 +1,23 @@
+module Docs
+ class Iojs < UrlScraper
+ self.name = 'io.js'
+ self.slug = 'iojs'
+ self.type = 'node'
+ self.version = '3.2.0'
+ self.base_url = 'https://iojs.org/api/'
+
+ html_filters.push 'node/clean_html', 'node/entries', 'title'
+
+ options[:title] = false
+ options[:domain] = 'http://www.refly.xyz'
+ options[:root_title] = 'ioJS'
+ options[:docset_uri] = '/iojs'
+ options[:container] = '#apicontent'
+ options[:skip] = %w(index.html all.html documentation.html synopsis.html)
+
+ options[:attribution] = <<-HTML
+ © io.js contributors
+ Licensed under the MIT License.
+ HTML
+ end
+end
diff --git a/lib/docs/scrapers/jasmine.rb b/lib/docs/scrapers/jasmine.rb
new file mode 100644
index 0000000000..929fcc3d8e
--- /dev/null
+++ b/lib/docs/scrapers/jasmine.rb
@@ -0,0 +1,24 @@
+module Docs
+ class Jasmine < UrlScraper
+ self.name = 'jasmine'
+ self.type = 'jasmine'
+ self.version = 'edge'
+ self.base_url = 'http://jasmine.github.io/edge/'
+ self.root_path = 'introduction.html'
+
+ html_filters.push 'jasmine/clean_html', 'jasmine/entries'
+
+ options[:domain] = 'http://www.refly.xyz'
+ options[:container] = '#container'
+ options[:root_title] = 'Jasmine'
+ options[:docset_uri] = '/jasmine'
+
+ # options[:skip] = %w()
+ # options[:skip_patterns] = [/bin/]
+ options[:attribution] = <<-HTML
+ © 2015 Joyent, Inc. and other Node contributors
+ Licensed under the MIT License.
+ HTML
+
+ end
+end
diff --git a/lib/docs/scrapers/java7se.rb b/lib/docs/scrapers/java7se.rb
new file mode 100644
index 0000000000..0946593727
--- /dev/null
+++ b/lib/docs/scrapers/java7se.rb
@@ -0,0 +1,27 @@
+module Docs
+ class Java7se < UrlScraper
+ self.name = 'Java7SE'
+ self.type = 'java7se'
+ self.version = '7 SE'
+ self.base_url = 'http://docs.oracle.com/javase/7/docs/api/'
+ self.root_path = 'index-files/index-1.html'
+ self.initial_paths = %w(
+ allclasses-noframe.html)
+
+ html_filters.push 'java7se/entries', 'java7se/clean_html'
+
+ options[:domain] = 'http://www.refly.xyz'
+ options[:root_title] = 'Java 7 SE'
+ options[:docset_uri] = '/java_7_se'
+ options[:skip] = %w()
+ options[:skip_patterns] = [
+ /index\.html\.*/i,
+ /index-files*/i
+ ]
+ options[:attribution] = <<-HTML
+ © 2015 Oracle Corporation
+ Licensed under the Oracle Binary Code License.
+ HTML
+
+ end
+end
diff --git a/lib/docs/scrapers/jest.rb b/lib/docs/scrapers/jest.rb
new file mode 100644
index 0000000000..71aedca458
--- /dev/null
+++ b/lib/docs/scrapers/jest.rb
@@ -0,0 +1,22 @@
+module Docs
+ class Jest < UrlScraper
+ self.name = 'Jest'
+ self.type = 'jest'
+ self.version = '0.5.6'
+ self.base_url = 'https://facebook.github.io/jest/'
+ self.root_path = 'docs/getting-started.html'
+ html_filters.push 'jest/entries', 'jest/clean_html'
+
+ options[:domain] = 'http://www.refly.xyz'
+ options[:container] = '.documentationContent'
+ options[:root_title] = 'Jest'
+ options[:docset_uri] = '/jest'
+ options[:only_patterns] = [/\Adocs\//, /\Atips\//]
+ options[:skip] = %w()
+
+ options[:attribution] = <<-HTML
+ © 2013–2014 Facebook Inc.
+ Licensed under BSD License.
+ HTML
+ end
+end
diff --git a/lib/docs/scrapers/jquery/jquery.rb b/lib/docs/scrapers/jquery/jquery.rb
index b01228cdf7..933064c95b 100644
--- a/lib/docs/scrapers/jquery/jquery.rb
+++ b/lib/docs/scrapers/jquery/jquery.rb
@@ -6,6 +6,7 @@ class Jquery < UrlScraper
html_filters.push 'jquery/clean_html', 'title'
text_filters.push 'jquery/clean_urls'
+ options[:domain] = 'http://www.refly.xyz'
options[:title] = false
options[:container] = '#content'
options[:trailing_slash] = false
diff --git a/lib/docs/scrapers/jquery/jquery_core.rb b/lib/docs/scrapers/jquery/jquery_core.rb
index ea4e9a54eb..c5319f51a4 100644
--- a/lib/docs/scrapers/jquery/jquery_core.rb
+++ b/lib/docs/scrapers/jquery/jquery_core.rb
@@ -2,12 +2,12 @@ module Docs
class JqueryCore < Jquery
self.name = 'jQuery'
self.version = 'up to 2.1.0'
- self.base_url = 'http://local.api.jquery.com'
+ self.base_url = 'http://api.jquery.com'
html_filters.insert_before 'jquery/clean_html', 'jquery_core/entries'
- options[:root_title] = 'jQuery'
-
+ options[:root_title] = 'JQuery'
+ options[:docset_uri] = '/jquery'
# Duplicates
options[:skip] = %w(/selectors/odd /selectors/even /selectors/event
/selected /checked)
diff --git a/lib/docs/scrapers/jquery/jquery_mobile.rb b/lib/docs/scrapers/jquery/jquery_mobile.rb
index 26e6329db1..c79454a020 100644
--- a/lib/docs/scrapers/jquery/jquery_mobile.rb
+++ b/lib/docs/scrapers/jquery/jquery_mobile.rb
@@ -3,14 +3,16 @@ class JqueryMobile < Jquery
self.name = 'jQuery Mobile'
self.slug = 'jquerymobile'
self.version = '1.4.0'
- self.base_url = 'http://local.api.jquerymobile.com'
+ self.base_url = 'http://api.jquerymobile.com'
self.root_path = '/category/all'
html_filters.insert_before 'jquery/clean_html', 'jquery_mobile/entries'
- options[:root_title] = 'jQuery Mobile'
- options[:skip] = %w(/tabs /theme)
+ options[:root_title] = 'JQuery Mobile'
+ options[:docset_uri] = '/jquery_mobile'
+ #options[:skip] = %w(/tabs /theme)
options[:skip_patterns].concat [/\A\/icons/]
+ options[:skip] = %w(/cdn-cgi/l/email-protection)
options[:replace_paths] = { '/select/' => '/selectmenu' }
end
end
diff --git a/lib/docs/scrapers/jquery/jquery_ui.rb b/lib/docs/scrapers/jquery/jquery_ui.rb
index d7f4158358..e4baf92aa6 100644
--- a/lib/docs/scrapers/jquery/jquery_ui.rb
+++ b/lib/docs/scrapers/jquery/jquery_ui.rb
@@ -3,13 +3,14 @@ class JqueryUi < Jquery
self.name = 'jQuery UI'
self.slug = 'jqueryui'
self.version = '1.10.4'
- self.base_url = 'http://local.api.jqueryui.com'
+ self.base_url = 'http://api.jqueryui.com'
self.root_path = '/category/all'
html_filters.insert_before 'jquery/clean_html', 'jquery_ui/entries'
- options[:root_title] = 'jQuery UI'
- options[:skip] = %w(/theming)
+ options[:root_title] = 'JQuery UI'
+ options[:docset_uri] = '/jquery_ui'
+ #options[:skip] = %w(/theming)
options[:skip_patterns].concat [/\A\/1\./]
end
end
diff --git a/lib/docs/scrapers/knex.rb b/lib/docs/scrapers/knex.rb
new file mode 100644
index 0000000000..d218a01c30
--- /dev/null
+++ b/lib/docs/scrapers/knex.rb
@@ -0,0 +1,18 @@
+module Docs
+ class Knex < UrlScraper
+ self.name = 'Knex'
+ self.type = 'Knex'
+ self.version = '0.8.6'
+ self.base_url = 'http://knexjs.org/'
+ html_filters.push 'knex/entries', 'knex/clean_html'
+
+ options[:domain] = 'http://www.refly.xyz'
+ options[:container] = '.container'
+ options[:root_title] = 'Knex'
+ options[:docset_uri] = '/knex'
+ options[:attribution] = <<-HTML
+ © 2013–2014 Facebook Inc.
+ Licensed under BSD License.
+ HTML
+ end
+end
diff --git a/lib/docs/scrapers/knockout.rb b/lib/docs/scrapers/knockout.rb
index fc01bd00a0..0195831b1d 100644
--- a/lib/docs/scrapers/knockout.rb
+++ b/lib/docs/scrapers/knockout.rb
@@ -3,12 +3,15 @@ class Knockout < UrlScraper
self.name = 'Knockout.js'
self.slug = 'knockout'
self.type = 'knockout'
- self.version = '3.2.0'
+ self.version = '3.3.0'
self.base_url = 'http://knockoutjs.com/documentation/'
self.root_path = 'introduction.html'
html_filters.push 'knockout/clean_html', 'knockout/entries'
+ options[:domain] = 'http://www.refly.xyz'
+ options[:root_title] = 'KnockOut'
+ options[:docset_uri] = '/knockout'
options[:follow_links] = ->(filter) { filter.root_page? }
options[:container] = ->(filter) { filter.root_page? ? '#wrapper' : '.content' }
diff --git a/lib/docs/scrapers/laravel.rb b/lib/docs/scrapers/laravel.rb
index c5a317a593..a734d34c1d 100644
--- a/lib/docs/scrapers/laravel.rb
+++ b/lib/docs/scrapers/laravel.rb
@@ -3,36 +3,40 @@ class Laravel < UrlScraper
self.name = 'Laravel'
self.slug = 'laravel'
self.type = 'laravel'
- self.version = '4.2.11'
+ self.version = '5.1.1'
self.base_url = 'http://laravel.com'
- self.root_path = '/docs/4.2/introduction'
- self.initial_paths = %w(/api/4.2/classes.html)
+ self.root_path = '/api/5.0/index.html'
+ self.initial_paths = %w(/api/5.0/classes.html api/5.0/Illuminate.html)
html_filters.push 'laravel/entries', 'laravel/clean_html'
options[:container] = ->(filter) {
- filter.subpath.start_with?('/api') ? nil : '#documentation > article'
+ filter.subpath.start_with?('/api') ? '#content' : '.docs-wrapper'
}
+ options[:root_title] = 'Laravel'
+ options[:docset_uri] = '/laravel'
+ options[:domain] = 'http://www.refly.xyz'
options[:only_patterns] = [
- /\A\/api\/4\.2\//,
- /\A\/docs\/4\.2\//]
+ /\A\/api\/5\.0\//,
+ /\A\/docs\/5\.0\//]
options[:skip] = %w(
- /docs/4.2/quick
- /docs/4.2/releases
- /docs/4.2/upgrade
- /docs/4.2/artisan
- /docs/4.2/commands
- /api/4.2/panel.html
- /api/4.2/namespaces.html
- /api/4.2/interfaces.html
- /api/4.2/traits.html
- /api/4.2/doc-index.html
- /api/4.2/Illuminate.html)
+ /docs/5.0/installation
+ /docs/5.0/quick
+ /docs/5.0/releases
+ /docs/5.0/artisan
+ /docs/5.0/commands
+ /api/5.0/panel.html
+ /api/5.0/namespaces.html
+ /api/5.0/interfaces.html
+ /api/5.0/traits.html
+ /api/5.0/doc-index.html
+ /api/5.0/Illuminate.html
+ /api/5.0/search.html)
options[:fix_urls] = ->(url) do
- url.sub! %r{#{Regexp.escape(Laravel.base_url)}/docs\/(?!\d)}, "#{Laravel.base_url}/docs/4.2/"
+ url.sub! %r{#{Regexp.escape(Laravel.base_url)}/docs\/(?!\d)}, "#{Laravel.base_url}/docs/5.0/"
url
end
@@ -41,4 +45,4 @@ class Laravel < UrlScraper
Licensed under the MIT License.
HTML
end
-end
+end
\ No newline at end of file
diff --git a/lib/docs/scrapers/less.rb b/lib/docs/scrapers/less.rb
index fda76c3322..e409a96ee6 100644
--- a/lib/docs/scrapers/less.rb
+++ b/lib/docs/scrapers/less.rb
@@ -1,14 +1,17 @@
module Docs
class Less < UrlScraper
self.type = 'less'
- self.version = '2.1.0'
+ self.version = '2.5.0'
self.base_url = 'http://lesscss.org'
self.root_path = '/features'
self.initial_paths = %w(/functions)
html_filters.push 'less/clean_html', 'less/entries', 'title'
+ options[:domain] = 'http://www.refly.xyz'
options[:title] = 'Less'
+ options[:root_title] = 'Less'
+ options[:docset_uri] = '/less'
options[:container] = 'div[role=main]'
options[:follow_links] = false
options[:trailing_slash] = false
diff --git a/lib/docs/scrapers/lodash.rb b/lib/docs/scrapers/lodash.rb
index 130e906247..9ad58d5786 100644
--- a/lib/docs/scrapers/lodash.rb
+++ b/lib/docs/scrapers/lodash.rb
@@ -3,11 +3,13 @@ class Lodash < UrlScraper
self.name = 'Lo-Dash'
self.slug = 'lodash'
self.type = 'lodash'
- self.version = '2.4.1'
+ self.version = '3.10.0'
self.base_url = 'https://lodash.com/docs'
html_filters.push 'lodash/clean_html', 'lodash/entries', 'title'
-
+ options[:domain] = 'http://www.refly.xyz'
+ options[:root_title] = 'Lo-Dash'
+ options[:docset_uri] = '/lo-dash'
options[:title] = 'Lo-Dash'
options[:container] = 'h1+div+div'
options[:skip_links] = true
diff --git a/lib/docs/scrapers/lua.rb b/lib/docs/scrapers/lua.rb
new file mode 100644
index 0000000000..4a0efe8e40
--- /dev/null
+++ b/lib/docs/scrapers/lua.rb
@@ -0,0 +1,19 @@
+module Docs
+ class Lua < UrlScraper
+ self.type = 'lua'
+ self.version = '5.3'
+ self.base_url = 'http://www.lua.org/manual/5.3/'
+ self.root_path = 'manual.html'
+
+ html_filters.push 'lua/clean_html', 'lua/entries'
+
+ options[:skip_links] = true
+ options[:domain] = 'http://www.refly.xyz'
+ options[:root_title] = 'Lua'
+ options[:docset_uri] = '/lua'
+ options[:attribution] = <<-HTML
+ © 1994–2015 Lua.org, PUC-Rio.
+ Licensed under the MIT License.
+ HTML
+ end
+end
diff --git a/lib/docs/scrapers/marionette.rb b/lib/docs/scrapers/marionette.rb
index b89d4287c1..1b923a6b60 100644
--- a/lib/docs/scrapers/marionette.rb
+++ b/lib/docs/scrapers/marionette.rb
@@ -3,25 +3,19 @@ class Marionette < UrlScraper
self.name = 'Marionette.js'
self.slug = 'marionette'
self.type = 'marionette'
- self.version = '2.3.0'
- self.base_url = 'http://marionettejs.com/docs/'
- self.root_path = 'current'
+ self.version = '2.4.3'
+ self.base_url = "http://marionettejs.com/docs/v#{version}/"
+ self.root_path = 'index'
html_filters.push 'marionette/clean_html', 'marionette/entries'
- options[:container] = '#content'
-
- options[:skip] = %w(/readme.html)
- options[:skip_patterns] = [/\A\/v\d/]
-
- options[:fix_urls] = ->(url) do
- url.sub! %r{marionette([^\/#\?]*)\.md}, 'marionette\1'
- url
- end
-
+ options[:domain] = 'http://www.refly.xyz'
+ options[:root_title] = 'Marionette'
+ options[:docset_uri] = '/marionette'
+ options[:container] = '.docs__content'
options[:attribution] = <<-HTML
- © 2014 Muted Solutions, LLC
+ © 2015 Muted Solutions, LLC
Licensed under the MIT License.
HTML
end
-end
+end
\ No newline at end of file
diff --git a/lib/docs/scrapers/markdown.rb b/lib/docs/scrapers/markdown.rb
index 6dc7b02085..14de86a428 100644
--- a/lib/docs/scrapers/markdown.rb
+++ b/lib/docs/scrapers/markdown.rb
@@ -6,8 +6,11 @@ class Markdown < UrlScraper
html_filters.push 'markdown/clean_html', 'markdown/entries'
+ options[:domain] = 'http://www.refly.xyz'
options[:container] = '.article'
options[:skip_links] = true
+ options[:root_title] = 'MarkDown'
+ options[:docset_uri] = '/markdown'
options[:attribution] = <<-HTML
© 2004 John Gruber
diff --git a/lib/docs/scrapers/maxcdn.rb b/lib/docs/scrapers/maxcdn.rb
index 5d371fac78..45682741d8 100644
--- a/lib/docs/scrapers/maxcdn.rb
+++ b/lib/docs/scrapers/maxcdn.rb
@@ -6,6 +6,9 @@ class Maxcdn < UrlScraper
html_filters.push 'maxcdn/clean_html', 'maxcdn/entries'
+ options[:domain] = 'http://www.refly.xyz'
+ options[:root_title] = 'MaxCDN'
+ options[:docset_uri] = '/maxcdn'
options[:container] = '#readme-docs'
options[:skip_links] = true
diff --git a/lib/docs/scrapers/mdn/css.rb b/lib/docs/scrapers/mdn/css.rb
index 454a7c18b8..5c890756fd 100644
--- a/lib/docs/scrapers/mdn/css.rb
+++ b/lib/docs/scrapers/mdn/css.rb
@@ -2,47 +2,44 @@ module Docs
class Css < Mdn
self.name = 'CSS'
self.base_url = 'https://developer.mozilla.org/en-US/docs/Web/CSS'
- self.root_path = '/Reference'
-
- html_filters.push 'css/clean_html', 'css/entries', 'title'
+ self.initial_paths = %w(
+ /Reference
+ )
+ html_filters.push 'css/entries', 'css/clean_html'
options[:root_title] = 'CSS'
-
+ options[:docset_uri] = '/css'
options[:skip] = %w(
/Syntax
/At-rule
+ /auto
/Comments
/Specificity
- /actual_value
- /initial_value
/inheritance
/specified_value
- /computed_value
/used_value actual_value
/box_model
/Replaced_element
/Value_definition_syntax
- /Pseudo-elements
/Layout_mode
/Visual_formatting_model
/Shorthand_properties
/margin_collapsing
/CSS3
- /Pseudo-classes
/CSS_values_syntax
/Media/Visual
/block_formatting_context
/image()
/paged_media)
- options[:skip_patterns] = [/\-webkit/, /\-moz/, /Extensions/, /Tools/]
+ options[:skip_patterns] = [/\-webkit/, /\-moz/, /Extensions/, /Tools/, /\w*\$\w+/i,]
options[:replace_paths] = {
'/%3Cbasic-shape%3E' => '/basic-shape'
}
options[:fix_urls] = ->(url) do
- url.sub! %r{https://developer\.mozilla\.org/en\-US/docs/CSS/([a-z@:])}, "#{Css.base_url}/\\1"
+ url.sub! %r{https://developer\.mozilla\.org/en\-US/docs/CSS/([_a-z@:])}, "#{Css.base_url}/\\1"
url
end
end
diff --git a/lib/docs/scrapers/mdn/dom.rb b/lib/docs/scrapers/mdn/dom.rb
index e308335a77..be0b7e38bf 100644
--- a/lib/docs/scrapers/mdn/dom.rb
+++ b/lib/docs/scrapers/mdn/dom.rb
@@ -3,9 +3,18 @@ class Dom < Mdn
self.name = 'DOM'
self.base_url = 'https://developer.mozilla.org/en-US/docs/Web/API'
- html_filters.push 'dom/clean_html', 'dom/entries', 'title'
+ html_filters.push 'dom/entries', 'dom/clean_html', 'title'
options[:root_title] = 'DOM'
+ options[:docset_uri] = '/dom'
+ self.initial_paths = %w(
+ /identitymanager
+ /WindowEventHandlers
+ /css_object_model
+ /Event
+ /web_crypto_api
+ /CSSStyleDeclaration
+ /canvas_api/tutorial)
# Don't want
options[:skip] = %w(
@@ -30,7 +39,6 @@ class Dom < Mdn
/Node.nodePrincipal
/Notation
/PowerManager
- /PushManager
/ProcessingInstruction
/TCPServerSocket
/TCPSocket
@@ -49,7 +57,6 @@ class Dom < Mdn
/window.navigator.requestWakeLock
/window.updateCommands
/window.pkcs11)
-
options[:skip_patterns] = [
/NS/,
/XPC/,
@@ -58,6 +65,7 @@ class Dom < Mdn
/webkit/i,
/gamepad/i,
/UserData/,
+ /\w*\$\w+/i,
/\A\/Camera/,
/\A\/Data_Store_API/,
/\A\/DataStore/,
@@ -76,8 +84,26 @@ class Dom < Mdn
/\A\/Window\.\w+bar/i,
/\A\/Apps/,
/\A\/Contact/,
- /\A\/L10n/,
- /\A\/Permission/]
+ /\A\/\w*\.\w*/i,
+ /\A\/L10n/]
+ # /\A\/AnalyserNode\//,
+ # /\A\/Audio\w*\//,
+ # /\A\/Animation\w*\//,
+ # /\A\/Battery\w*\//i,
+ # /\A\/Biquad\w*\//i,
+ # /\A\/Blob\w*\//i,
+ # /\A\/body\w*\//i,
+ # /\A\/broadcast\w*\//i,
+ # /\A\/cache\w*\//i,
+ # /\A\/Canvas\w*\//i,
+ # /\A\/childnode\w*\//i,
+ # /\A\/subtlecrypto\w*\//i,
+ # /\A\/crypto\w*\//i,
+ # /\A\/DelayNode\w*\//i,
+ # /\A\/Device\w*\//i,
+ # /\A\/DOM\w*\//i,
+ # /\A\/document\w*\//i,
+ # /\A\/Permission/]
# Broken / Empty
options[:skip].concat %w(
@@ -101,6 +127,9 @@ class Dom < Mdn
/table.rows
/XMLHttpRequest/FormData
/Performance.now
+ /element.scrollTop
+ /element.scrollTopMax
+ /
/Document_Object_Model)
options[:fix_urls] = ->(url) do
@@ -116,8 +145,8 @@ class Dom < Mdn
url.sub! "#{Dom.base_url}/Window", "#{Dom.base_url}/window"
url.sub! "#{Dom.base_url}/window.navigator", "#{Dom.base_url}/navigator"
url.sub! "#{Dom.base_url}/Selection/", "#{Dom.base_url}/Selection."
- url.sub! "#{Dom.base_url}/windowTimers", "#{Dom.base_url}/window"
- url.sub! "#{Dom.base_url}/windowEventHandlers", "#{Dom.base_url}/window"
+ # url.sub! "#{Dom.base_url}/windowTimers", "#{Dom.base_url}/window"
+ # url.sub! "#{Dom.base_url}/windowEventHandlers", "#{Dom.base_url}/window"
url.sub! %r{\/windowLocalStorage(\.localStorage)?}i, "/window.localStorage"
url.sub! %r{\/windowSessionStorage(\.sessionStorage)?}i, "/window.sessionStorage"
url.sub! "#{Dom.base_url}/Screen.", "#{Dom.base_url}/window.screen"
diff --git a/lib/docs/scrapers/mdn/dom_events.rb b/lib/docs/scrapers/mdn/dom_events.rb
index ddc2b1c7b7..6ced93badc 100644
--- a/lib/docs/scrapers/mdn/dom_events.rb
+++ b/lib/docs/scrapers/mdn/dom_events.rb
@@ -4,10 +4,13 @@ class DomEvents < Mdn
self.slug = 'dom_events'
self.base_url = 'https://developer.mozilla.org/en-US/docs/Web/Events'
- html_filters.insert_after 'clean_html', 'dom_events/clean_html'
- html_filters.push 'dom_events/entries', 'title'
-
+ html_filters.insert_after 'clean_html'
+ html_filters.push 'dom_events/entries', 'dom_events/clean_html', 'title'
+ self.initial_paths = %w(
+ /Events)
+ options[:skip_patterns] = [/\w*\$\w+/i]
options[:root_title] = 'DOM Events'
+ options[:docset_uri] = '/dom_events'
options[:fix_urls] = ->(url) do
url.sub! 'https://developer.mozilla.org/en-US/Mozilla_event_reference', DomEvents.base_url
url.sub! 'https://developer.mozilla.org/en-US/docs/Mozilla_event_reference', DomEvents.base_url
diff --git a/lib/docs/scrapers/mdn/html.rb b/lib/docs/scrapers/mdn/html.rb
index 7acc106831..eb8129ad59 100644
--- a/lib/docs/scrapers/mdn/html.rb
+++ b/lib/docs/scrapers/mdn/html.rb
@@ -3,33 +3,20 @@ class Html < Mdn
self.name = 'HTML'
self.base_url = 'https://developer.mozilla.org/en-US/docs/Web/HTML'
self.root_path = '/Element'
- self.initial_paths = %w(/Attributes /Link_types)
+ self.initial_paths = %w(/Attributes /Link_types /element /Global_elements)
- html_filters.push 'html/clean_html', 'html/entries', 'title'
+ html_filters.push 'html/entries', 'html/clean_html', 'title'
options[:root_title] = 'HTML'
+ options[:docset_uri] = '/html'
- options[:title] = ->(filter) do
- if filter.slug == 'Element/Heading_Elements'
- 'Heading Elements'
- elsif filter.slug == 'Attributes'
- 'Attributes'
- elsif filter.slug == 'Link_types'
- 'Link types'
- else
- "<#{filter.default_title}>"
- end
- end
-
- options[:skip] = ['/Element/shadow']
- options[:only_patterns] = [/\A\/Element/]
+ options[:title] = false
+ options[:skip_patterns] = [/\w*\$\w+/i]
- options[:replace_paths] = {
- '/Element/h1' => '/Element/Heading_Elements',
- '/Element/h2' => '/Element/Heading_Elements',
- '/Element/h3' => '/Element/Heading_Elements',
- '/Element/h4' => '/Element/Heading_Elements',
- '/Element/h5' => '/Element/Heading_Elements',
- '/Element/h6' => '/Element/Heading_Elements' }
+ options[:fix_urls] = ->(url) do
+ url.sub! %r{https://developer\.mozilla\.org/en\-US/docs/Web/HTML/([_a-z@:])}, "#{Javascript.base_url}/\\1"
+ url.sub! 'https://developer.mozilla.org/en-US/docs/Web/HTML/Content_categories', 'https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Content_categories'
+ url
+ end
end
end
diff --git a/lib/docs/scrapers/mdn/javascript.rb b/lib/docs/scrapers/mdn/javascript.rb
index 3ba4f8b134..f55fadfddb 100644
--- a/lib/docs/scrapers/mdn/javascript.rb
+++ b/lib/docs/scrapers/mdn/javascript.rb
@@ -3,23 +3,22 @@ class Javascript < Mdn
self.name = 'JavaScript'
self.base_url = 'https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference'
- html_filters.push 'javascript/clean_html', 'javascript/entries', 'title'
+ html_filters.push 'javascript/entries', 'javascript/clean_html'
options[:root_title] = 'JavaScript'
+ options[:docset_uri] = '/javascript'
+
+ options[:skip_patterns] = [/\w*\$\w+/i]
# Don't want
options[:skip] = %w(
/About
/Code_comments
/Deprecated_Features
- /Deprecated_and_obsolete_features
/Functions_and_function_scope
/Global_Objects/Iterator
- /Global_Objects/Proxy
/Reserved_Words
- /Functions/arguments
/arrow_functions
- /rest_parameters
/default_parameters
/Strict_mode
/Functions/rest_parameters
@@ -28,20 +27,23 @@ class Javascript < Mdn
/Strict_mode/Transitioning_to_strict_mode
/Operators/Legacy_generator_function
/Statements/Legacy_generator_function)
-
- # Duplicates
- options[:skip].concat %w(
- /Global_Objects
- /Operators
- /Statements)
-
+ # Duplicates 301
+ options[:skip] = %w(
+ /Global_Objects/object/__proto__
+ /Global_Objects/object/__definegetter__
+ /Global_Objects/object/__definesetter__
+ /Global_Objects/object/__lookupgetter__
+ /Global_Objects/function/constructor)
options[:fix_urls] = ->(url) do
url.sub! 'https://developer.mozilla.org/en-US/docs/JavaScript/Reference', Javascript.base_url
url.sub! 'https://developer.mozilla.org/en/JavaScript/Reference', Javascript.base_url
url.sub! 'https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference', Javascript.base_url
url.sub! 'https://developer.mozilla.org/En/Core_JavaScript_1.5_Reference', Javascript.base_url
url.sub! '/Operators/Special/', '/Operators/'
- url.sub! 'Destructing_assignment', 'Destructuring_assignment'
+ url.sub! '/Operators/Special/', '/Operators/'
+ url.sub! '%40%40', '@@'
+
+ url.sub! 'Functions_and_function_scope', 'Functions'
url.sub! 'Array.prototype.values()', 'values'
url
end
diff --git a/lib/docs/scrapers/mdn/mdn.rb b/lib/docs/scrapers/mdn/mdn.rb
index 99cebbec52..aac7011349 100644
--- a/lib/docs/scrapers/mdn/mdn.rb
+++ b/lib/docs/scrapers/mdn/mdn.rb
@@ -3,13 +3,15 @@ class Mdn < UrlScraper
self.abstract = true
self.type = 'mdn'
- params[:raw] = 1
- params[:macros] = 1
+ # params[:raw] = 1
+ # params[:macros] = 1
html_filters.push 'mdn/clean_html'
text_filters.insert_before 'attribution', 'mdn/contribute_link'
+ options[:domain] = 'http://www.refly.xyz'
options[:trailing_slash] = false
+ options[:title] = false
options[:skip_link] = ->(link) { link['title'].try(:include?, 'hasn\'t been written yet'.freeze) }
@@ -20,8 +22,8 @@ class Mdn < UrlScraper
private
- def process_response?(response)
- super && response.effective_url.query == 'raw=1¯os=1'
- end
+ # def process_response?(response)
+ # super && response.effective_url.query == 'raw=1¯os=1'
+ # end
end
end
diff --git a/lib/docs/scrapers/mdn/svg.rb b/lib/docs/scrapers/mdn/svg.rb
index 4120941859..528fb16b62 100644
--- a/lib/docs/scrapers/mdn/svg.rb
+++ b/lib/docs/scrapers/mdn/svg.rb
@@ -3,10 +3,9 @@ class Svg < Mdn
self.name = 'SVG'
self.base_url = 'https://developer.mozilla.org/en-US/docs/Web/SVG'
- html_filters.push 'svg/clean_html', 'svg/entries', 'title'
-
+ html_filters.push 'svg/entries', 'svg/clean_html', 'title'
options[:root_title] = 'SVG'
-
+ options[:docset_uri] = '/svg'
options[:title] = ->(filter) do
if filter.slug.starts_with?('Element/')
"<#{filter.default_title}>"
@@ -16,7 +15,7 @@ class Svg < Mdn
false
end
end
-
+ options[:skip_patterns] = [/\w*\$\w+/i]
options[:skip] = %w(
/Compatibility_sources
/FAQ
diff --git a/lib/docs/scrapers/mdn/xpath.rb b/lib/docs/scrapers/mdn/xpath.rb
index fd2d486cd9..a4fea35dd4 100644
--- a/lib/docs/scrapers/mdn/xpath.rb
+++ b/lib/docs/scrapers/mdn/xpath.rb
@@ -2,10 +2,15 @@ module Docs
class Xpath < Mdn
self.name = 'XPath'
self.base_url = 'https://developer.mozilla.org/en-US/docs/Web/XPath'
+ self.root_path = '/index'
- html_filters.push 'xpath/clean_html', 'xpath/entries', 'title'
+ html_filters.push 'xpath/entries', 'xpath/clean_html', 'title'
options[:root_title] = 'XPath'
+ options[:docset_uri] = '/xpath'
+ options[:skip_patterns] = [/\w*\$\w+/i]
+
+
options[:fix_urls] = ->(url) do
url.sub! 'https://developer.mozilla.org/en/XPath', Xpath.base_url
diff --git a/lib/docs/scrapers/meteor.rb b/lib/docs/scrapers/meteor.rb
new file mode 100644
index 0000000000..c5d1707976
--- /dev/null
+++ b/lib/docs/scrapers/meteor.rb
@@ -0,0 +1,30 @@
+module Docs
+ class Meteor < UrlScraper
+
+ self.type = 'meteor'
+ self.version = '1.1.0'
+ self.base_url = 'http://docs.meteor.com'
+ self.root_path = '/#/full/'
+
+ html_filters.push 'meteor/entries', 'meteor/clean_html', 'title'
+
+ options[:title] = 'Meteor'
+ options[:skip_links] = true
+ options[:domain] = 'http://www.refly.xyz'
+ options[:root_title] = 'Meteor'
+ options[:docset_uri] = '/meteor'
+ options[:attribution] = <<-HTML
+ © 2011–2015 Meteor Development Group
+ Licensed under the MIT License.
+ HTML
+
+ private
+
+ def root_page_body
+ require 'capybara'
+ Capybara.current_driver = :selenium
+ Capybara.visit(root_url.to_s)
+ Capybara.find('.body')['innerHTML']
+ end
+ end
+end
diff --git a/lib/docs/scrapers/mocha.rb b/lib/docs/scrapers/mocha.rb
new file mode 100644
index 0000000000..b003783b6f
--- /dev/null
+++ b/lib/docs/scrapers/mocha.rb
@@ -0,0 +1,22 @@
+module Docs
+ class Mocha < UrlScraper
+ self.name = 'mocha'
+ self.type = 'mocha'
+ self.version = '2.2.1'
+ self.base_url = 'http://mochajs.org/'
+
+ html_filters.push 'mocha/entries', 'mocha/clean_html', 'title'
+
+ options[:container] = '#content'
+ options[:title] = 'mocha'
+ options[:domain] = 'http://www.refly.xyz'
+ options[:docset_uri] = '/mocha'
+ options[:root_title] = 'Mocha'
+ options[:skip_links] = true
+
+ options[:attribution] = <<-HTML
+ © 2011–2015 TJ Holowaychuk
+ Licensed under the MIT License.
+ HTML
+ end
+end
diff --git a/lib/docs/scrapers/modernizr.rb b/lib/docs/scrapers/modernizr.rb
index 9299ed919c..1b31ddc869 100644
--- a/lib/docs/scrapers/modernizr.rb
+++ b/lib/docs/scrapers/modernizr.rb
@@ -3,12 +3,15 @@ class Modernizr < UrlScraper
self.name = 'Modernizr'
self.type = 'modernizr'
self.version = '2.8.3'
- self.base_url = 'http://modernizr.com/docs/'
+ self.base_url = 'https://modernizr.com/docs/'
html_filters.push 'modernizr/entries', 'modernizr/clean_html', 'title'
+ options[:domain] = 'http://www.refly.xyz'
+ options[:root_title] = 'Modernizr'
+ options[:docset_uri] = '/modernizr'
options[:title] = 'Modernizr'
- options[:container] = '#documentation'
+ options[:container] = '#main'
options[:skip_links] = true
options[:attribution] = <<-HTML
diff --git a/lib/docs/scrapers/moment.rb b/lib/docs/scrapers/moment.rb
index 04d7e3433d..b2284f59f9 100644
--- a/lib/docs/scrapers/moment.rb
+++ b/lib/docs/scrapers/moment.rb
@@ -3,14 +3,18 @@ class Moment < UrlScraper
self.name = 'Moment.js'
self.slug = 'moment'
self.type = 'moment'
- self.version = '2.8.3'
+ self.version = '2.10.2'
self.base_url = 'http://momentjs.com/docs/'
html_filters.push 'moment/clean_html', 'moment/entries', 'title'
+ options[:domain] = 'http://www.refly.xyz'
options[:title] = 'Moment.js'
options[:container] = '.docs-content'
options[:skip_links] = true
+ options[:root_title] = 'Moment'
+ options[:docset_uri] = '/moment'
+
options[:attribution] = <<-HTML
© 2011–2014 Tim Wood, Iskren Chernev, Moment.js contributors
diff --git a/lib/docs/scrapers/mongoose.rb b/lib/docs/scrapers/mongoose.rb
index 54e7a6e3ad..f1b879ef05 100644
--- a/lib/docs/scrapers/mongoose.rb
+++ b/lib/docs/scrapers/mongoose.rb
@@ -1,16 +1,18 @@
module Docs
class Mongoose < UrlScraper
- self.name = 'Mongoose'
+ self.name = 'MongooseJS'
self.type = 'mongoose'
- self.version = '3.8.19'
+ self.version = '4.1.6'
self.base_url = 'http://mongoosejs.com/docs/'
self.root_path = 'index.html'
self.initial_paths = %w(guide.html api.html)
html_filters.push 'mongoose/clean_html', 'mongoose/entries'
+ options[:domain] = 'http://www.refly.xyz'
options[:container] = '#content'
-
+ options[:root_title] = 'MongooseJS'
+ options[:docset_uri] = '/mongoosejs'
options[:skip] = %w(
faq.html
prior.html
diff --git a/lib/docs/scrapers/mysql.rb b/lib/docs/scrapers/mysql.rb
new file mode 100644
index 0000000000..8be050f5f0
--- /dev/null
+++ b/lib/docs/scrapers/mysql.rb
@@ -0,0 +1,23 @@
+module Docs
+ class Mysql < UrlScraper
+ self.name = 'Mysql'
+ self.type = 'mysql'
+ self.version = '5.7'
+ self.base_url = 'http://dev.mysql.com/doc/refman/5.7/en/'
+ self.root_path = 'index.html'
+ html_filters.push 'mysql/entries', 'mysql/clean_html'
+
+ options[:domain] = 'http://www.refly.xyz'
+ options[:container] = '#page'
+ options[:root_title] = 'Mysql'
+ options[:docset_uri] = '/mysql'
+ options[:skip] = %w(
+ manual-info.html
+ )
+ options[:attribution] = <<-HTML
+ © 2015 Oracle Corporation
+ Licensed under the GPL License.
+ HTML
+
+ end
+end
diff --git a/lib/docs/scrapers/nginx.rb b/lib/docs/scrapers/nginx.rb
index 301bb66c3e..3caec935d0 100644
--- a/lib/docs/scrapers/nginx.rb
+++ b/lib/docs/scrapers/nginx.rb
@@ -2,17 +2,24 @@ module Docs
class Nginx < UrlScraper
self.name = 'nginx'
self.type = 'nginx'
- self.version = '1.7.9'
+ self.version = '1.9.4'
self.base_url = 'http://nginx.org/en/docs/'
+ self.root_path = 'index.html'
+ self.initial_paths = %w(
+ varindex.html
+ dirindex.html
+ )
+
html_filters.push 'nginx/clean_html', 'nginx/entries'
+ options[:domain] = 'http://www.refly.xyz'
options[:container] = '#content'
-
+ options[:root_title] = 'Nginx'
+ options[:docset_uri] = '/nginx'
options[:skip] = %w(
contributing_changes.html
- dirindex.html
- varindex.html)
+ dirindex.html)
options[:skip_patterns] = [/\/faq\//]
diff --git a/lib/docs/scrapers/node.rb b/lib/docs/scrapers/node.rb
index ee5c08f4fc..85db8976c2 100644
--- a/lib/docs/scrapers/node.rb
+++ b/lib/docs/scrapers/node.rb
@@ -3,15 +3,17 @@ class Node < UrlScraper
self.name = 'Node.js'
self.slug = 'node'
self.type = 'node'
- self.version = '0.10.35'
- self.base_url = 'http://nodejs.org/api/'
+ self.version = '4.0.0'
+ self.base_url = 'https://nodejs.org/api/'
html_filters.push 'node/clean_html', 'node/entries', 'title'
+ options[:domain] = 'http://www.refly.xyz'
options[:title] = false
- options[:root_title] = 'Node.js'
+ options[:root_title] = 'NodeJS'
+ options[:docset_uri] = '/nodejs'
options[:container] = '#apicontent'
- options[:skip] = %w(index.html all.html documentation.html synopsis.html)
+ options[:skip] = %w(all.html)
options[:attribution] = <<-HTML
© Joyent, Inc. and other Node contributors
diff --git a/lib/docs/scrapers/node_lts.rb b/lib/docs/scrapers/node_lts.rb
new file mode 100644
index 0000000000..0b3f563104
--- /dev/null
+++ b/lib/docs/scrapers/node_lts.rb
@@ -0,0 +1,12 @@
+module Docs
+ class NodeLts < Node
+ self.name = 'Node.js (LTS)'
+ self.slug = 'node_lts'
+ self.type = 'node'
+ self.version = '4.2.1'
+ self.base_url = 'https://nodejs.org/dist/v4.2.1/docs/api/'
+ options[:domain] = 'http://www.refly.xyz'
+ options[:root_title] = 'NodeJS LTS'
+ options[:docset_uri] = '/nodejs_lts'
+ end
+end
diff --git a/lib/docs/scrapers/nokogiri2.rb b/lib/docs/scrapers/nokogiri2.rb
index 21f1f8fe61..5b5b124c34 100644
--- a/lib/docs/scrapers/nokogiri2.rb
+++ b/lib/docs/scrapers/nokogiri2.rb
@@ -1,14 +1,21 @@
module Docs
- class Nokogiri2 < Rdoc
+ class Nokogiri2 < UrlScraper
self.name = 'Nokogiri'
self.slug = 'nokogiri'
- self.version = '1.6.4'
- self.dir = '/Users/Thibaut/DevDocs/Docs/RDoc/Nokogiri'
-
- html_filters.replace 'rdoc/entries', 'nokogiri2/entries'
+ self.version = '1.6.6.2'
+ self.base_url = 'http://www.rubydoc.info/gems/nokogiri/1.6.6.2/'
+ self.root_path = 'index'
+ self.initial_paths = %w(
+ toplevel
+ Nokogiri/XML
+ Nokogiri/XSLT
+ )
+ html_filters.push 'nokogiri2/entries', 'nokogiri2/clean_html'
+ options[:domain] = 'http://www.refly.xyz'
options[:root_title] = 'Nokogiri'
- options[:only_patterns] = [/\ANokogiri/]
+ options[:docset_uri] = '/nokogiri'
+ options[:container] = '#content'
options[:attribution] = <<-HTML
© 2008–2014 Aaron Patterson, Mike Dalessio, Charles Nutter,
diff --git a/lib/docs/scrapers/npm.rb b/lib/docs/scrapers/npm.rb
new file mode 100644
index 0000000000..115f16ffda
--- /dev/null
+++ b/lib/docs/scrapers/npm.rb
@@ -0,0 +1,31 @@
+module Docs
+ class Npm < UrlScraper
+ self.name = 'npm'
+ self.type = 'npm'
+ self.version = '2.13.0'
+ self.base_url = 'https://docs.npmjs.com/'
+ self.links = {
+ home: 'https://www.npmjs.com/',
+ code: 'https://github.com/npm/npm'
+ }
+ html_filters.push 'npm/entries', 'npm/clean_html', 'title'
+
+ options[:container] = ->(filter) { filter.root_page? ? '.toc' : nil }
+ options[:title] = false
+ options[:domain] = 'http://www.refly.xyz'
+ options[:root_title] = 'npm'
+ options[:docset_uri] = '/npm'
+ options[:skip] = %w(all misc/index)
+ options[:skip_patterns] = [
+ /\Aenterprise/,
+ /\Acompany/,
+ /\Apolicies/
+ ]
+
+ options[:attribution] = <<-HTML
+ © npm, Inc. and Contributors
+ Licensed under the npm License.
+ npm is a trademark of npm, Inc.
+ HTML
+ end
+end
\ No newline at end of file
diff --git a/lib/docs/scrapers/opentsdb.rb b/lib/docs/scrapers/opentsdb.rb
new file mode 100644
index 0000000000..e6bccda33d
--- /dev/null
+++ b/lib/docs/scrapers/opentsdb.rb
@@ -0,0 +1,20 @@
+module Docs
+ class Opentsdb < UrlScraper
+ self.name = 'OpenTSDB'
+ self.type = 'opentsdb'
+ self.version = '2.1.0'
+ self.base_url = 'http://opentsdb.net/docs/build/html/'
+ self.root_path = 'index.html'
+
+ html_filters.push 'opentsdb/entries', 'opentsdb/clean_html'
+ options[:domain] = 'http://www.refly.xyz'
+ options[:docset_uri] = '/opentsdb'
+ options[:root_title] = 'OpenTSDB'
+ options[:skip] = %w(genindex.html search.html)
+
+ options[:attribution] = <<-HTML
+ © 2010–2015 The OpenTSDB Authors
+ Licensed under the GNU LGPLv2.1+ and GPLv3+ licenses.
+ HTML
+ end
+end
diff --git a/lib/docs/scrapers/perl.rb b/lib/docs/scrapers/perl.rb
new file mode 100644
index 0000000000..83c2972b63
--- /dev/null
+++ b/lib/docs/scrapers/perl.rb
@@ -0,0 +1,38 @@
+module Docs
+ class Perl < FileScraper
+ self.version = '5.22'
+ self.type = 'sphinx'
+ self.dir = './file_scraper_docs/perl/perldoc-html' # downloaded from docs.python.org/3/download.html
+ self.base_url = 'http://perldoc.perl.org/'
+ self.root_path = 'index.html'
+ self.initial_paths = %w(
+ index-language.html
+ index-overview.html
+ index-tutorials.html
+ index-faq.html
+ index-language.html
+ index-functions.html
+ index-operators.html
+ perlvar.html
+ index-pragmas.html
+ index-utilities.html
+ index-platforms.html
+ index-internals.html
+ )
+
+ html_filters.push 'perl/entries', 'perl/clean_html'
+
+ options[:domain] = 'http://www.refly.xyz'
+ options[:root_title] = 'Perl'
+ options[:docset_uri] = '/perl'
+ options[:container] = '#content_body'
+ options[:skip_patterns] = [
+ /perl\d*delta\.html/,
+ /index-modules-\w\.html/
+ ]
+ options[:attribution] = <<-HTML
+ © 1989– Free Software Foundation, Inc.
+ Licensed under the GNU General Public License.
+ HTML
+ end
+end
diff --git a/lib/docs/scrapers/phalcon.rb b/lib/docs/scrapers/phalcon.rb
new file mode 100644
index 0000000000..c81bda6e00
--- /dev/null
+++ b/lib/docs/scrapers/phalcon.rb
@@ -0,0 +1,23 @@
+module Docs
+ class Phalcon < UrlScraper
+ self.type = 'phalcon'
+ self.version = '2.0.6'
+ self.base_url = 'https://docs.phalconphp.com/en/latest/'
+ self.root_path = 'index.html'
+
+ html_filters.push 'phalcon/clean_html', 'phalcon/entries'
+
+ options[:domain] = 'http://www.refly.xyz'
+ options[:root_title] = 'Phalcon'
+ options[:docset_uri] = '/phalcon'
+ options[:only_patterns] = [/reference\//, /api\//]
+ options[:skip] = %w(
+ api/index.html
+ reference/license.html)
+
+ options[:attribution] = <<-HTML
+ © 2011–2015 Phalcon Framework Team
+ Licensed under the Creative Commons Attribution License 3.0.
+ HTML
+ end
+end
diff --git a/lib/docs/scrapers/phaser.rb b/lib/docs/scrapers/phaser.rb
new file mode 100644
index 0000000000..7af6b20ce4
--- /dev/null
+++ b/lib/docs/scrapers/phaser.rb
@@ -0,0 +1,32 @@
+module Docs
+ class Phaser < UrlScraper
+ self.type = 'phaser'
+ self.version = '2.4.1'
+ self.base_url = "http://phaser.io/docs/#{version}"
+ self.root_path = 'Phaser.Input.html'
+ self.links = {
+ home: 'http://phaser.io/',
+ code: 'https://github.com/photonstorm/phaser'
+ }
+
+ html_filters.push 'phaser/entries', 'phaser/clean_html'
+ options[:domain] = 'http://www.refly.xyz'
+ options[:root_title] = 'Phaser'
+ options[:docset_uri] = '/phaser'
+ options[:skip] = %w(
+ /docs_pixi-jsdoc.js.html
+ /p2.Body.html
+ /Phaser.html
+ /PIXI.html
+ /index
+ /PIXI.WebGLMaskManager.html
+ /PIXI.WebGLShaderManager.html
+ /PIXI.WebGLSpriteBatch.html
+ /PIXI.WebGLStencilManager.html)
+
+ options[:attribution] = <<-HTML
+ © 2015 Richard Davey, Photon Storm Ltd.
+ Licensed under the MIT License.
+ HTML
+ end
+end
diff --git a/lib/docs/scrapers/phoenix.rb b/lib/docs/scrapers/phoenix.rb
new file mode 100644
index 0000000000..e920a36b0a
--- /dev/null
+++ b/lib/docs/scrapers/phoenix.rb
@@ -0,0 +1,48 @@
+module Docs
+ class Phoenix < Elixir
+ self.type = 'elixir'
+ self.version = '1.0.3'
+ self.base_url = 'http://hexdocs.pm/'
+ self.root_path = 'phoenix/Phoenix.html'
+ self.initial_paths = %w(
+ phoenix/extra-api-reference.html
+ ecto/extra-api-reference.html
+ phoenix_html/extra-api-reference.html
+ plug/extra-api-reference.html)
+ self.links = {
+ home: 'http://www.phoenixframework.org',
+ code: 'https://github.com/phoenixframework/phoenix'
+ }
+
+ options[:root_title] = false
+ options[:root_title] = 'Phoenix'
+ options[:domain] = 'http://www.refly.xyz'
+ options[:docset_uri] = '/phoenix'
+ options[:skip_patterns] = [/extra-api-reference/]
+ options[:only_patterns] = [
+ /\Aphoenix\//,
+ /\Aecto\//,
+ /\Aphoenix_html\//,
+ /\Aplug\//
+ ]
+
+ options[:attribution] = -> (filter) {
+ if filter.slug.start_with?('ecto')
+ <<-HTML
+ © 2012 Plataformatec
+ Licensed under the Apache License, Version 2.0.
+ HTML
+ elsif filter.slug.start_with?('plug')
+ <<-HTML
+ © 2013 Plataformatec
+ Licensed under the Apache License, Version 2.0.
+ HTML
+ else
+ <<-HTML
+ © 2014 Chris McCord
+ Licensed under the MIT License.
+ HTML
+ end
+ }
+ end
+end
diff --git a/lib/docs/scrapers/php.rb b/lib/docs/scrapers/php.rb
index dc3a29545c..3e00b092ff 100644
--- a/lib/docs/scrapers/php.rb
+++ b/lib/docs/scrapers/php.rb
@@ -15,13 +15,14 @@ class Php < FileScraper
reserved.variables.html)
# Downloaded from php.net/download-docs.php
- self.dir = '/Users/Thibaut/DevDocs/Docs/PHP'
+ self.dir = '/home/desarrollo/Descargas/docs/php'
html_filters.push 'php/internal_urls', 'php/entries', 'php/clean_html', 'title'
text_filters.push 'php/fix_urls'
options[:title] = false
- options[:root_title] = 'PHP: Hypertext Preprocessor'
+ options[:root_title] = 'PHP'
+ options[:docset_uri] = '/php'
options[:skip_links] = ->(filter) { !filter.initial_page? }
options[:only_patterns] = [
diff --git a/lib/docs/scrapers/php2.rb b/lib/docs/scrapers/php2.rb
new file mode 100644
index 0000000000..ee387812da
--- /dev/null
+++ b/lib/docs/scrapers/php2.rb
@@ -0,0 +1,58 @@
+module Docs
+ class Php2 < UrlScraper
+ self.name = 'PHP'
+ self.type = 'php'
+ self.version = 'up to 5.6.2'
+ self.base_url = 'http://php.net/manual/en/'
+ self.root_path = 'index.php'
+ self.initial_paths = %w(
+ reserved.variables.php
+ spl.iterators.php
+ funcref.php
+ langref.php
+ ref.bbcode.php
+ ref.filesystem.php
+ ref.url.php
+ ref.info.php
+ ref.fann.php
+ refs.database.php
+ refs.math.php
+ ref.apache.php
+ ref.strings.php
+ ref.apc.php
+ ref.apd.php
+ ref.array.php
+ function.pdf-add-textflow.php
+ function.pdf-begin-document.php
+ eventbufferevent.construct.php
+ eventbufferevent.setcallbacks.php
+ set.mysqlinfo.php
+ language.control-structures.php
+ reserved.exceptions.php
+ reserved.interfaces.php)
+
+ html_filters.push 'php2/entries', 'php2/clean_html', 'title'
+ text_filters.push 'php2/fix_urls'
+
+ options[:domain] = 'http://www.refly.xyz'
+ options[:title] = false
+ options[:root_title] = 'PHP'
+ options[:docset_uri] = '/php'
+
+ #options[:skip_links] = ->(filter) { !filter.initial_page? }
+
+ options[:skip_patterns] = [/mysqlnd/]
+ options[:skip] = ['php_manual.php','indexes.examples.php', 'url.mongodb.dochub.maxWriteBatchSize', 'url.imagemagick.usage.color_mods.sigmoidal','url.mongodb.dochub.maxbsonobjectsize']
+
+ options[:attribution] = <<-HTML
+ © 1997–2014 The PHP Documentation Group
+ Licensed under the Creative Commons Attribution License v3.0 or later.
+ HTML
+
+ options[:fix_urls] = ->(url) do
+ url.sub! 'http://php.net/manual/en/language.types.string.php#language.types.string.parsing.complex', 'http://php.net/manual/en/language.types.string.php'
+ url.sub! 'http://php.net/manual/en/language.pseudo-types.php#language.types.mixed', 'http://php.net/manual/en/language.pseudo-types.php#language.types.mixed'
+ url
+ end
+ end
+end
diff --git a/lib/docs/scrapers/phpunit.rb b/lib/docs/scrapers/phpunit.rb
index 9c999fb8a2..fc0e177bce 100644
--- a/lib/docs/scrapers/phpunit.rb
+++ b/lib/docs/scrapers/phpunit.rb
@@ -2,13 +2,15 @@ module Docs
class Phpunit < UrlScraper
self.name = 'PHPUnit'
self.type = 'phpunit'
- self.version = '4.4'
+ self.version = '4.8'
self.base_url = "https://phpunit.de/manual/#{version}/en/"
self.root_path = 'index.html'
html_filters.push 'phpunit/clean_html', 'phpunit/entries', 'title'
+ options[:domain] = 'http://www.refly.xyz'
options[:root_title] = 'PHPUnit'
+ options[:docset_uri] = '/phpunit'
options[:title] = false
options[:skip] = %w(
diff --git a/lib/docs/scrapers/postgresql.rb b/lib/docs/scrapers/postgresql.rb
index fdfe07b8ea..9431e691a3 100644
--- a/lib/docs/scrapers/postgresql.rb
+++ b/lib/docs/scrapers/postgresql.rb
@@ -5,13 +5,15 @@ class Postgresql < UrlScraper
self.version = '9.4'
self.base_url = "http://www.postgresql.org/docs/#{version}/static/"
self.root_path = 'reference.html'
- self.initial_paths = %w(sql.html admin.html)
+ self.initial_paths = %w(sql.html admin.html sql-keywords-appendix.html)
html_filters.insert_before 'normalize_urls', 'postgresql/extract_metadata'
html_filters.push 'postgresql/clean_html', 'postgresql/entries', 'title'
+ options[:domain] = 'http://www.refly.xyz'
options[:title] = false
options[:root_title] = 'PostgreSQL'
+ options[:docset_uri] = '/postgresql'
options[:follow_links] = ->(filter) { filter.initial_page? }
options[:only] = %w(
@@ -33,6 +35,7 @@ class Postgresql < UrlScraper
non-durability.html
logfile-maintenance.html
continuous-archiving.html
+ sql-keywords-appendix.html
dynamic-trace.html)
options[:only_patterns] = [
@@ -40,7 +43,9 @@ class Postgresql < UrlScraper
/\Aapp\-/,
/\Addl\-/,
/\Adml\-/,
+ /\Aruntime\-/,
/\Aqueries\-/,
+ /\Apattern\-/,
/\Adatatype\-/,
/\Afunctions\-/,
/\Atypeconv\-/,
@@ -56,6 +61,8 @@ class Postgresql < UrlScraper
/\Amonitoring\-/,
/\Awal\-/,
/\Adisk/,
+ /functions/,
+ /bitstring_operators/,
/role/,
/recovery/,
/standby/]
diff --git a/lib/docs/scrapers/python.rb b/lib/docs/scrapers/python.rb
index 80d1da9c2d..913bcd2cb1 100644
--- a/lib/docs/scrapers/python.rb
+++ b/lib/docs/scrapers/python.rb
@@ -1,13 +1,17 @@
module Docs
class Python < FileScraper
- self.version = '3.4.2'
+ self.version = '3.5.0'
self.type = 'sphinx'
- self.dir = '/Users/Thibaut/DevDocs/Docs/Python' # downloaded from docs.python.org/3/download.html
+ self.dir = './file_scraper_docs/python/python-3.5.0-docs-html' # downloaded from docs.python.org/3/download.html
self.base_url = 'http://docs.python.org/3/'
self.root_path = 'library/index.html'
html_filters.push 'python/entries', 'python/clean_html'
+ options[:domain] = 'http://www.refly.xyz'
+ options[:root_title] = 'Python3'
+ options[:docset_uri] = '/python3'
+
options[:only_patterns] = [/\Alibrary\//]
options[:skip] = %w(
diff --git a/lib/docs/scrapers/python2.rb b/lib/docs/scrapers/python2.rb
index a9f730b953..2cae3c0369 100644
--- a/lib/docs/scrapers/python2.rb
+++ b/lib/docs/scrapers/python2.rb
@@ -2,20 +2,23 @@ module Docs
class Python2 < FileScraper
self.name = 'Python 2'
self.slug = 'python2'
- self.version = '2.7.8'
+ self.version = '2.7.10'
self.type = 'sphinx'
- self.dir = '/Users/Thibaut/DevDocs/Docs/Python2' # downloaded from docs.python.org/2.7/download.html
+ self.dir = './file_scraper_docs/python2/python-2.7.8-docs-html' # downloaded from docs.python.org/2.7/download.html
self.base_url = 'http://docs.python.org/2.7/'
self.root_path = 'library/index.html'
html_filters.push 'python2/entries', 'python/clean_html'
+ options[:domain] = 'http://www.refly.co'
+ options[:root_title] = 'Python2'
+ options[:docset_uri] = '/python2'
+
options[:only_patterns] = [/\Alibrary\//]
options[:skip] = %w(
library/2to3.html
library/formatter.html
- library/index.html
library/intro.html
library/undoc.html
library/unittest.mock-examples.html
diff --git a/lib/docs/scrapers/q.rb b/lib/docs/scrapers/q.rb
new file mode 100644
index 0000000000..80e7171f04
--- /dev/null
+++ b/lib/docs/scrapers/q.rb
@@ -0,0 +1,23 @@
+module Docs
+ class Q < UrlScraper
+ self.name = 'Q'
+ self.type = 'q'
+ self.version = '1.4.1'
+ self.base_url = 'https://github.com/kriskowal/q/wiki/'
+ self.root_path = 'API-Reference'
+
+ html_filters.push 'q/clean_html', 'q/entries', 'title'
+
+ options[:container] = '.markdown-body'
+ options[:domain] = 'http://www.refly.xyz'
+ options[:root_title] = 'q'
+ options[:docset_uri] = '/q'
+ options[:title] = 'Q'
+ options[:skip_links] = true
+
+ options[:attribution] = <<-HTML
+ © 2009–2015 Kristopher Michael Kowal and contributors
+ Licensed under the MIT License.
+ HTML
+ end
+end
diff --git a/lib/docs/scrapers/rdoc/rails.rb b/lib/docs/scrapers/rdoc/rails.rb
index 678a18aa08..449f97a28b 100644
--- a/lib/docs/scrapers/rdoc/rails.rb
+++ b/lib/docs/scrapers/rdoc/rails.rb
@@ -1,72 +1,17 @@
module Docs
- class Rails < Rdoc
- # Generated with:
- # find \
- # actionmailer \
- # actionpack \
- # actionview \
- # activemodel \
- # activejob \
- # activerecord \
- # activesupport \
- # railties \
- # -name '*.rb' \
- # -not -name 'version.rb' \
- # -not -wholename '*generators/*' \
- # -not -wholename '*test/*' \
- # -not -wholename '*examples/*' \
- # | xargs \
- # rdoc --format=darkfish --no-line-numbers --op=rdoc --visibility=public
-
+ class Rails < UrlScraper
self.name = 'Ruby on Rails'
self.slug = 'rails'
self.version = '4.2.0'
- self.dir = '/Users/Thibaut/DevDocs/Docs/RDoc/Rails'
-
- html_filters.replace 'rdoc/entries', 'rails/entries'
-
- options[:root_title] = 'Ruby on Rails'
+ self.base_url = 'http://www.rubydoc.info/docs/rails/'
+ self.root_path = 'index'
- options[:skip] += %w(
- AbstractController/Callbacks.html
- AbstractController/UrlFor.html
- ActionController/Instrumentation.html
- ActionController/Rendering.html
- ActionDispatch/DebugExceptions.html
- ActionDispatch/Http/URL.html
- ActionDispatch/Journey/Parser.html
- ActionDispatch/Reloader.html
- ActionDispatch/RequestId.html
- ActionDispatch/Routing/HtmlTableFormatter.html
- ActionDispatch/Routing/Mapper.html
- ActionDispatch/Routing/RouteSet.html
- ActionDispatch/ShowExceptions.html
- ActionView/FileSystemResolver.html
- ActionView/FixtureResolver.html
- ActionView/LogSubscriber.html
- ActionView/Template/Handlers/Erubis.html
- ActionView/TestCase/Behavior/RenderedViewsCollection.html
- ActiveRecord/DynamicMatchers/Finder.html
- ActiveRecord/Sanitization.html
- ActiveRecord/Tasks/DatabaseTasks.html
- ActiveSupport/Configurable/Configuration.html
- ActiveSupport/Dependencies/WatchStack.html
- ActiveSupport/DescendantsTracker.html
- ActiveSupport/FileUpdateChecker.html
- ActiveSupport/Notifications/Fanout.html
- ActiveSupport/Testing/Isolation/Subprocess.html
- Rails/API/Task.html)
+ html_filters.push 'rails/entries', 'rails/clean_html'
- options[:skip_patterns] += [
- /\AActionController\/Caching(?!\/Fragments|\.)/,
- /\AActionController\/RequestForgeryProtection\/ProtectionMethods/,
- /\AActionController\/Testing/,
- /\AActionDispatch\/RemoteIp/,
- /\AActionView\/LookupContext/,
- /\AActionView\/Resolver/,
- /\AActiveSupport\/Multibyte\/Unicode\//,
- /\AActiveSupport\/XML/i,
- /\ASourceAnnotationExtractor/]
+ options[:domain] = 'http://www.refly.xyz'
+ options[:root_title] = 'Rails'
+ options[:docset_uri] = '/rails'
+ options[:container] = '#content'
options[:attribution] = <<-HTML
© 2004–2014 David Heinemeier Hansson
diff --git a/lib/docs/scrapers/rdoc/rdoc.rb b/lib/docs/scrapers/rdoc/rdoc.rb
index 0110d5138c..c4f8aee109 100644
--- a/lib/docs/scrapers/rdoc/rdoc.rb
+++ b/lib/docs/scrapers/rdoc/rdoc.rb
@@ -5,11 +5,13 @@ class Rdoc < FileScraper
self.root_path = 'table_of_contents.html'
html_filters.replace 'container', 'rdoc/container'
- html_filters.push 'title', 'rdoc/entries', 'rdoc/clean_html'
+ html_filters.push 'rdoc/entries', 'rdoc/clean_html', 'title'
options[:title] = false
options[:skip] = %w(index.html)
options[:skip_patterns] = [
+ /history/i,
+ /rakefile/i,
/changelog/i,
/readme/i,
/news/i,
diff --git a/lib/docs/scrapers/rdoc/ruby.rb b/lib/docs/scrapers/rdoc/ruby.rb
index 64357d6e8e..6aac2352b7 100644
--- a/lib/docs/scrapers/rdoc/ruby.rb
+++ b/lib/docs/scrapers/rdoc/ruby.rb
@@ -1,24 +1,17 @@
module Docs
- class Ruby < Rdoc
- # Generated with:
- # rdoc \
- # --root . \
- # --page-dir doc \
- # --encoding=UTF-8 \
- # --visibility=public \
- # --format=darkfish \
- # --no-line-numbers \
- # --op html .
+ class Ruby < UrlScraper
+ self.name = 'Ruby'
+ self.type = 'Ruby'
+ self.version = '2.2.2'
+ self.base_url = 'http://ruby-doc.org/stdlib-2.2.2/'
+ self.root_path = 'toc.html'
- self.version = '2.2.0'
- self.dir = '/Users/Thibaut/DevDocs/Docs/RDoc/Ruby'
+ html_filters.push 'ruby/clean_html', 'ruby/entries'
+ options[:domain] = 'http://www.refly.xyz'
+ options[:root_title] = 'Ruby'
+ options[:docset_uri] = '/ruby'
- html_filters.replace 'rdoc/entries', 'ruby/entries'
-
- options[:root_title] = 'Ruby Programming Language'
- options[:title] = ->(filter) { filter.slug == 'globals_rdoc' ? 'Globals' : false }
-
- options[:skip] += %w(
+ options[:skip] = %w(
contributing_rdoc.html
contributors_rdoc.html
dtrace_probes_rdoc.html
@@ -35,42 +28,13 @@ class Ruby < Rdoc
OptParse.html
UnicodeNormalize.html)
- options[:skip_patterns] += [
- /\Alib\//,
- /\ADEBUGGER__/,
- /\AException2MessageMapper/,
- /\AJSON\/Ext/,
- /\AGem/,
- /\AHTTP/i,
- /\AIRB/,
- /\AMakeMakefile/i,
- /\AMiniTest/i,
- /\ANQXML/,
- /\AOpenSSL/,
- /\AOptionParser\//,
- /\APrettyPrint/,
- /\APride/,
- /\AProfiler__/,
- /\APsych\//,
- /\ARacc/,
- /\ARake/,
- /\ARbConfig/,
- /\ARDoc/,
- /\AREXML/,
- /\ARSS/,
- /\AShell\//,
- /\ASocket\//,
- /\ATest/,
- /\AWEBrick/,
- /win32/i,
- /\AXML/,
- /\AXMP/]
+ options[:skip_patterns] = []
options[:attribution] = <<-HTML
- Ruby Core © 1993–2014 Yukihiro Matsumoto
+ Ruby Core © 1993–2015 Yukihiro Matsumoto
Licensed under the Ruby License.
Ruby Standard Library © contributors
Licensed under their own licenses.
HTML
end
-end
+end
\ No newline at end of file
diff --git a/lib/docs/scrapers/react.rb b/lib/docs/scrapers/react.rb
index 80879542ea..23cbcd4adc 100644
--- a/lib/docs/scrapers/react.rb
+++ b/lib/docs/scrapers/react.rb
@@ -2,18 +2,23 @@ module Docs
class React < UrlScraper
self.name = 'React'
self.type = 'react'
- self.version = '0.12.2'
- self.base_url = 'http://facebook.github.io/react/docs/'
- self.root_path = 'getting-started.html'
-
+ self.version = '0.13.3'
+ self.base_url = 'http://facebook.github.io/react/'
+ self.root_path = 'docs/getting-started.html'
html_filters.push 'react/entries', 'react/clean_html'
+ options[:domain] = 'http://www.refly.xyz'
options[:container] = '.documentationContent'
-
+ options[:root_title] = 'React'
+ options[:docset_uri] = '/react'
+ options[:only_patterns] = [/\Adocs\//, /\Atips\//]
options[:skip] = %w(
- videos.html
- complementary-tools.html
- examples.html)
+ docs/
+ docs/videos.html
+ docs/complementary-tools.html
+ docs/examples.html
+ docs/conferences.html
+ tips/introduction.html)
options[:attribution] = <<-HTML
© 2013–2014 Facebook Inc.
diff --git a/lib/docs/scrapers/react_native.rb b/lib/docs/scrapers/react_native.rb
new file mode 100644
index 0000000000..641761927d
--- /dev/null
+++ b/lib/docs/scrapers/react_native.rb
@@ -0,0 +1,24 @@
+module Docs
+ class ReactNative < React
+ self.name = 'React Native'
+ self.slug = 'react_native'
+ self.type = 'react'
+ self.version = '0.10.0'
+ self.base_url = 'https://facebook.github.io/react-native/docs/'
+ self.root_path = 'getting-started.html'
+
+ options[:domain] = 'http://www.refly.xyz'
+ options[:root_title] = 'React native'
+ options[:docset_uri] = '/react_native'
+ options[:only_patterns] = nil
+ options[:skip] = %w(
+ videos.html
+ transforms.html
+ troubleshooting.html)
+
+ options[:attribution] = <<-HTML
+ © 2015 Facebook Inc.
+ Licensed under the Creative Commons Attribution 4.0 International Public License.
+ HTML
+ end
+end
diff --git a/lib/docs/scrapers/react_router.rb b/lib/docs/scrapers/react_router.rb
new file mode 100644
index 0000000000..e00680b676
--- /dev/null
+++ b/lib/docs/scrapers/react_router.rb
@@ -0,0 +1,24 @@
+module Docs
+ class ReactRouter < UrlScraper
+ self.name = 'React_Router'
+ self.type = 'React_Router'
+ self.version = '1.0.0-rc1'
+ self.base_url = 'https://github.com/rackt/react-router/blob/master/docs/'
+ self.root_path = 'README.md'
+
+ html_filters.push 'react_router/entries', 'react_router/clean_html'
+
+ options[:domain] = 'http://www.refly.xyz'
+ options[:container] = 'article'
+ options[:trailing_slash] = true
+ options[:root_title] = 'React Router'
+ options[:docset_uri] = '/react_router'
+
+ options[:skip] = %w(CHANGELOG.md/)
+ options[:attribution] = <<-HTML
+ © 2015 Rackt
+ Licensed under the MIT License.
+ HTML
+
+ end
+end
diff --git a/lib/docs/scrapers/redis.rb b/lib/docs/scrapers/redis.rb
index 6d7b0a44ec..022b021d08 100644
--- a/lib/docs/scrapers/redis.rb
+++ b/lib/docs/scrapers/redis.rb
@@ -1,14 +1,17 @@
module Docs
class Redis < UrlScraper
self.type = 'redis'
- self.version = 'up to 2.8.18'
+ self.version = 'up to 3.0.4'
self.base_url = 'http://redis.io/commands'
html_filters.push 'redis/entries', 'redis/clean_html', 'title'
+ options[:domain] = 'http://www.refly.xyz'
options[:container] = ->(filter) { filter.root_page? ? '#commands' : '.text' }
options[:title] = false
options[:root_title] = 'Redis'
+ options[:docset_uri] = '/redis'
+
options[:follow_links] = ->(filter) { filter.root_page? }
options[:attribution] = <<-HTML
diff --git a/lib/docs/scrapers/reflux.rb b/lib/docs/scrapers/reflux.rb
new file mode 100644
index 0000000000..00ab2d5780
--- /dev/null
+++ b/lib/docs/scrapers/reflux.rb
@@ -0,0 +1,23 @@
+module Docs
+ class Reflux < UrlScraper
+ self.name = 'Reflux'
+ self.type = 'reflux'
+ self.version = '0.2.12'
+ self.base_url = 'https://github.com/reflux/refluxjs/blob/master/README.md'
+
+ html_filters.push 'reflux/entries', 'reflux/clean_html'
+
+ options[:domain] = 'http://www.refly.xyz'
+ options[:container] = 'article'
+ options[:trailing_slash] = true
+ options[:root_title] = 'Reflux'
+ options[:docset_uri] = '/reflux'
+
+ options[:skip] = %w(/graphs/contributors/ /blob/master/LICENSE.md/)
+ options[:attribution] = <<-HTML
+ © 2014 Arnout Kazemier
+ Licensed under the MIT License.
+ HTML
+
+ end
+end
diff --git a/lib/docs/scrapers/relay.rb b/lib/docs/scrapers/relay.rb
new file mode 100644
index 0000000000..c2ad87ea60
--- /dev/null
+++ b/lib/docs/scrapers/relay.rb
@@ -0,0 +1,23 @@
+module Docs
+ class Relay < React
+ self.type = 'react'
+ self.version = '0.5'
+ self.base_url = 'https://facebook.github.io/relay/docs/'
+ self.root_path = 'getting-started.html'
+ self.links = {
+ home: 'https://facebook.github.io/relay/',
+ code: 'https://github.com/facebook/relay'
+ }
+
+ options[:domain] = 'http://www.refly.xyz'
+ options[:root_title] = 'Relay'
+ options[:docset_uri] = '/relay'
+ options[:only_patterns] = nil
+ options[:skip] = %w(videos.html graphql-further-reading.html)
+
+ options[:attribution] = <<-HTML
+ © 2013–2015 Facebook Inc.
+ Licensed under the BSD License.
+ HTML
+ end
+end
diff --git a/lib/docs/scrapers/requirejs.rb b/lib/docs/scrapers/requirejs.rb
index 0ec7fabb2b..2773d4e5e5 100644
--- a/lib/docs/scrapers/requirejs.rb
+++ b/lib/docs/scrapers/requirejs.rb
@@ -2,10 +2,10 @@ module Docs
class Requirejs < UrlScraper
self.name = 'RequireJS'
self.type = 'requirejs'
- self.version = '2.1.15'
+ self.version = '2.1.18'
self.base_url = 'http://requirejs.org/docs/'
- self.root_path = 'api.html'
self.initial_paths = %w(
+ api.html
optimization.html
jquery.html
node.html
@@ -14,10 +14,12 @@ class Requirejs < UrlScraper
plugins.html
why.html
whyamd.html)
-
html_filters.push 'requirejs/clean_html', 'requirejs/entries'
+ options[:domain] = 'http://www.refly.xyz'
options[:container] = '#content'
+ options[:root_title] = 'RequireJS'
+ options[:docset_uri] = '/requirejs'
options[:follow_links] = false
options[:only] = self.initial_paths
diff --git a/lib/docs/scrapers/rethinkdb.rb b/lib/docs/scrapers/rethinkdb.rb
index 36213bb494..ae01e06b7b 100644
--- a/lib/docs/scrapers/rethinkdb.rb
+++ b/lib/docs/scrapers/rethinkdb.rb
@@ -2,21 +2,24 @@ module Docs
class Rethinkdb < UrlScraper
self.name = 'RethinkDB'
self.type = 'rethinkdb'
- self.version = '1.15.2'
+ self.version = '2.1.2'
self.base_url = 'http://rethinkdb.com/api/javascript/'
html_filters.push 'rethinkdb/entries', 'rethinkdb/clean_html'
+ options[:domain] = 'http://www.refly.xyz'
+ options[:root_title] = 'RethinkDB'
+ options[:docset_uri] = '/rethinkdb'
options[:trailing_slash] = false
- options[:container] = '.container .section'
-
- options[:fix_urls] = ->(url) do
- url.sub! %r{rethinkdb.com/api/(?!javascript|ruby|python)}, 'rethinkdb.com/api/javascript/'
- end
+ options[:container] = '.docs-article'
+ # options[:fix_urls] = ->(url) do
+ # url.sub! %r{rethinkdb.com/api/(?!javascript|ruby|python)}, 'rethinkdb.com/api/javascript/'
+ # url
+ # end
options[:attribution] = <<-HTML
© RethinkDB contributors
Licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported License.
HTML
end
-end
+end
\ No newline at end of file
diff --git a/lib/docs/scrapers/rust.rb b/lib/docs/scrapers/rust.rb
new file mode 100644
index 0000000000..377543064a
--- /dev/null
+++ b/lib/docs/scrapers/rust.rb
@@ -0,0 +1,45 @@
+module Docs
+ class Rust < UrlScraper
+ self.type = 'rust'
+ self.version = '1.2.0'
+ self.base_url = 'http://doc.rust-lang.org/'
+ self.root_path = 'book/index.html'
+ self.initial_paths = %w(
+ reference.html
+ collections/index.html
+ std/index.html)
+
+ html_filters.push 'rust/entries', 'rust/clean_html'
+
+ options[:only_patterns] = [
+ /\Abook\//,
+ /\Acollections\//,
+ /\Astd\// ]
+
+ options[:domain] = 'http://www.refly.xyz'
+ options[:root_title] = 'Rust'
+ options[:docset_uri] = '/rust'
+ options[:skip] = %w(book/README.html)
+ # options[:skip_patterns] = [/(?(url) do
+ url.sub! %r{(#{Rust.base_url}.+/)\z}, '\1index.html'
+ url.sub! '/unicode/u_str', '/unicode/str/'
+ url
+ end
+
+ options[:attribution] = <<-HTML
+ © 2011-2015 The Rust Project Developers
+ Licensed under the Apache License, Version 2.0 or the MIT license, at your option.
+ HTML
+
+ private
+
+ REDIRECT_RGX = /http-equiv="refresh"/i
+ NOT_FOUND_RGX = /Not Found<\/title>/
+
+ def process_response?(response)
+ !(response.body =~ REDIRECT_RGX || response.body =~ NOT_FOUND_RGX || response.body.blank?)
+ end
+ end
+end
diff --git a/lib/docs/scrapers/sass.rb b/lib/docs/scrapers/sass.rb
index e253a23d26..f009c3c138 100644
--- a/lib/docs/scrapers/sass.rb
+++ b/lib/docs/scrapers/sass.rb
@@ -7,12 +7,14 @@ class Sass < UrlScraper
html_filters.push 'sass/clean_html', 'sass/entries', 'title'
+ options[:domain] = 'http://www.refly.xyz'
options[:only] = %w(Sass/Script/Functions.html)
- options[:root_title] = false
+ options[:root_title] = 'Sass'
options[:title] = 'Sass Functions'
+ options[:docset_uri] = '/sass'
options[:container] = ->(filter) do
- filter.root_page? ? '#filecontents' : '#instance_method_details'
+ filter.root_page? ? '#filecontents' : '#content'
end
options[:attribution] = <<-HTML
diff --git a/lib/docs/scrapers/scala.rb b/lib/docs/scrapers/scala.rb
new file mode 100644
index 0000000000..3f751b813a
--- /dev/null
+++ b/lib/docs/scrapers/scala.rb
@@ -0,0 +1,25 @@
+module Docs
+ class Scala < UrlScraper
+ self.type = 'scala'
+ self.version = '2.11'
+ self.base_url = "http://www.scala-lang.org/api/current/scala/"
+
+ html_filters.push 'scala/entries', 'scala/clean_html'
+ options[:domain] = 'http://www.refly.xyz'
+ options[:root_title] = 'Scala'
+ options[:docset_uri] = '/scala'
+ options[:skip] = %w(
+ package.html
+ )
+ options[:skip_patterns] = [/.*\?.*/]
+ options[:fix_urls] = ->(url) do
+ url.sub! '%24%24', '$$'
+ url.sub! '%24', '$'
+ url
+ end
+ options[:attribution] = <<-HTML
+ © 2003-2013 EPFL
+ All rights reserved.
+ HTML
+ end
+end
diff --git a/lib/docs/scrapers/sinon.rb b/lib/docs/scrapers/sinon.rb
index 1fa633ef1b..2b94bf41f0 100644
--- a/lib/docs/scrapers/sinon.rb
+++ b/lib/docs/scrapers/sinon.rb
@@ -2,13 +2,15 @@ module Docs
class Sinon < UrlScraper
self.name = 'Sinon'
self.type = 'sinon'
- self.version = '1.12.1'
+ self.version = '1.16.1'
self.base_url = 'http://sinonjs.org/docs/'
-
html_filters.push 'sinon/clean_html', 'sinon/entries', 'title'
+ options[:domain] = 'http://www.refly.xyz'
options[:title] = 'Sinon.JS'
options[:container] = '.docs'
+ options[:root_title] = 'SinonJS'
+ options[:docset_uri] = '/sinonjs'
options[:skip_links] = true
options[:attribution] = <<-HTML
diff --git a/lib/docs/scrapers/socketio.rb b/lib/docs/scrapers/socketio.rb
index 2863c57b51..17a78070e2 100644
--- a/lib/docs/scrapers/socketio.rb
+++ b/lib/docs/scrapers/socketio.rb
@@ -3,12 +3,15 @@ class Socketio < UrlScraper
self.name = 'Socket.IO'
self.slug = 'socketio'
self.type = 'socketio'
- self.version = '1.2.1'
+ self.version = '1.3.6'
self.base_url = 'http://socket.io/docs/'
html_filters.push 'socketio/clean_html', 'socketio/entries'
+ options[:domain] = 'http://www.refly.xyz'
options[:container] = '#content'
+ options[:root_title] = 'SocketIO'
+ options[:docset_uri] = '/socketio'
options[:trailing_slash] = false
options[:skip] = %w(faq)
diff --git a/lib/docs/scrapers/sqlite.rb b/lib/docs/scrapers/sqlite.rb
new file mode 100644
index 0000000000..559ae9ede1
--- /dev/null
+++ b/lib/docs/scrapers/sqlite.rb
@@ -0,0 +1,42 @@
+module Docs
+ class Sqlite < FileScraper
+ self.type = 'sqlite'
+ self.version = '3.9.1'
+ self.dir = 'file_scraper_docs/sqlite/sqlite-doc-3090100'
+ self.base_url = "https://www.sqlite.org/"
+ self.root_path = 'docs.html'
+ self.initial_paths = %w(
+ /c3ref/
+ /syntax/
+ )
+
+ html_filters.push 'sqlite/clean_html', 'sqlite/entries'
+ options[:domain] = 'http://www.refly.xyz'
+ options[:root_title] = 'SQLite'
+ options[:follow_links] = false
+ options[:docset_uri] = '/sqlite'
+ options[:only_patterns] = [
+ /\A\w*\.html\Z/
+ ]
+ options[:skip_patterns] = [
+ /\A\/matrix\/.*l\Z/,
+ /\A\/releaselog\/.*l\Z/,
+ /\A\/session\/.*l\Z/
+ ]
+ options[:skip] = %w(
+ about.html
+ sitemap.html
+ download.html
+ copyright.html
+ news.html
+ support.html
+ index.html
+ hp1.html
+ oldnews.html
+ )
+ options[:attribution] = <<-HTML
+ Without ©
+ SQLite is Public domain.
+ HTML
+ end
+end
diff --git a/lib/docs/scrapers/swift.rb b/lib/docs/scrapers/swift.rb
new file mode 100644
index 0000000000..423079cdad
--- /dev/null
+++ b/lib/docs/scrapers/swift.rb
@@ -0,0 +1,29 @@
+module Docs
+ class Swift < UrlScraper
+ self.type = 'swift'
+ self.version = '12.4'
+ self.base_url = 'https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/'
+ self.root_path = 'TheBasics.html'
+ self.initial_paths = %w(
+ AboutTheLanguageReference.html
+ )
+
+ html_filters.push 'swift/clean_html', 'swift/entries'
+
+ options[:domain] = 'http://www.refly.xyz'
+ options[:root_title] = 'Swift'
+ options[:docset_uri] = '/swift'
+ options[:container] = '.chapter'
+ options[:skip] = [
+ 'RevisionHistory.html',
+ 'GuidedTour.playground.zip',
+ 'GuidedTour.html'
+ ]
+
+ options[:attribution] = <<-HTML
+ © 2015 Apple Inc.
+ Licensed under Open Source.
+ HTML
+
+ end
+end
diff --git a/lib/docs/scrapers/swiftreference.rb b/lib/docs/scrapers/swiftreference.rb
new file mode 100644
index 0000000000..ed8fcb9003
--- /dev/null
+++ b/lib/docs/scrapers/swiftreference.rb
@@ -0,0 +1,24 @@
+module Docs
+ class Swiftreference < UrlScraper
+ self.type = 'Swiftreference'
+ self.version = '1.0'
+ self.base_url = 'https://developer.apple.com/library/watchos/documentation/Swift/Reference'
+ self.root_path = 'Swift_Int_Structure/index.html'
+
+ html_filters.push 'swiftreference/clean_html', 'swiftreference/entries'
+
+ options[:domain] = 'http://www.refly.xyz'
+ options[:root_title] = 'Swift'
+ options[:docset_uri] = '/swift/reference'
+ options[:container] = 'article'
+ options[:skip_patterns] = [
+ /.*RevisionHistory.html.*/
+ ]
+
+ options[:attribution] = <<-HTML
+ © 2015 Apple Inc.
+ Licensed under Open Source.
+ HTML
+
+ end
+end
diff --git a/lib/docs/scrapers/symfony.rb b/lib/docs/scrapers/symfony.rb
new file mode 100644
index 0000000000..36566f0976
--- /dev/null
+++ b/lib/docs/scrapers/symfony.rb
@@ -0,0 +1,30 @@
+module Docs
+ class Symfony < UrlScraper
+ self.name = 'Symfony'
+ self.slug = 'symfony'
+ self.type = 'laravel'
+ self.version = '2.7'
+ self.base_url = "http://api.symfony.com/#{version}/"
+ self.root_path = 'namespaces.html'
+ self.initial_paths = %w(classes.html)
+
+ html_filters.push 'symfony/entries', 'symfony/clean_html'
+
+ options[:domain] = 'http://www.refly.xyz'
+ options[:root_title] = 'Symfony'
+ options[:docset_uri] = '/symfony'
+ options[:skip] = %w(
+ panel.html
+ namespaces.html
+ interfaces.html
+ traits.html
+ doc-index.html
+ search.html
+ Symfony.html)
+
+ options[:attribution] = <<-HTML
+ © 2004–2015 Fabien Potencier
+ Licensed under the MIT License.
+ HTML
+ end
+end
diff --git a/lib/docs/scrapers/twig.rb b/lib/docs/scrapers/twig.rb
new file mode 100644
index 0000000000..d2b0648f0a
--- /dev/null
+++ b/lib/docs/scrapers/twig.rb
@@ -0,0 +1,20 @@
+module Docs
+ class Twig < UrlScraper
+ self.name = 'Twig'
+ self.type = 'twig'
+ self.version = '5.7'
+ self.base_url = 'http://twig.sensiolabs.org/api/master/'
+ self.root_path = 'classes.html'
+ html_filters.push 'twig/entries', 'twig/clean_html'
+
+ options[:domain] = 'http://www.refly.xyz'
+ options[:root_title] = 'Twig'
+ options[:docset_uri] = '/twig'
+ options[:skips]= %w(/traits.html)
+ options[:attribution] = <<-HTML
+ © 2009-2015 Twig Team
+ Licensed under the Creative Commons License.
+ HTML
+
+ end
+end
diff --git a/lib/docs/scrapers/underscore.rb b/lib/docs/scrapers/underscore.rb
index d11d633b6f..871eabe5cd 100644
--- a/lib/docs/scrapers/underscore.rb
+++ b/lib/docs/scrapers/underscore.rb
@@ -3,12 +3,16 @@ class Underscore < UrlScraper
self.name = 'Underscore.js'
self.slug = 'underscore'
self.type = 'underscore'
- self.version = '1.7.0'
+ self.version = '1.8.3'
self.base_url = 'http://underscorejs.org'
html_filters.push 'underscore/clean_html', 'underscore/entries', 'title'
- options[:title] = 'Underscore.js'
+ options[:domain] = 'http://www.refly.xyz'
+ options[:title] = 'UnderscoreJS'
+ options[:root_title] = 'UnderscoreJS'
+ options[:docset_uri] = '/underscorejs'
+
options[:container] = '#documentation'
options[:skip_links] = true
diff --git a/lib/docs/scrapers/vagrant.rb b/lib/docs/scrapers/vagrant.rb
new file mode 100644
index 0000000000..c05e172dd1
--- /dev/null
+++ b/lib/docs/scrapers/vagrant.rb
@@ -0,0 +1,23 @@
+module Docs
+ class Vagrant < UrlScraper
+ self.name = 'Vagrant'
+ self.type = 'vagrant'
+ self.release = '1.8.3'
+ self.base_url = 'https://www.vagrantup.com/docs/'
+ self.root_path = 'index.html'
+ self.links = {
+ home: 'https://www.vagrantup.com/',
+ code: 'https://github.com/mitchellh/vagrant'
+ }
+
+ html_filters.push 'vagrant/entries', 'vagrant/clean_html'
+ options[:domain] = 'http://www.refly.xyz'
+ options[:root_title] = 'Vagrant'
+ options[:docset_uri] = '/vagrant'
+
+ options[:attribution] = <<-HTML
+ © 2010–2016 Mitchell Hashimoto
+ Licensed under the MIT License.
+ HTML
+ end
+end
diff --git a/lib/docs/scrapers/vue.rb b/lib/docs/scrapers/vue.rb
new file mode 100644
index 0000000000..b2319260da
--- /dev/null
+++ b/lib/docs/scrapers/vue.rb
@@ -0,0 +1,22 @@
+module Docs
+ class Vue < UrlScraper
+ self.name = 'Vue.js'
+ self.slug = 'vue'
+ self.type = 'vue'
+ self.version = '0.12.9'
+ self.base_url = 'http://vuejs.org'
+ self.root_path = '/guide/index.html'
+ self.initial_paths = %w(/api/index.html)
+
+ html_filters.push 'vue/clean_html', 'vue/entries'
+
+ options[:only_patterns] = [/\/guide\//, /\/api\//]
+ options[:domain] = 'http://www.refly.xyz'
+ options[:root_title] = 'Vue'
+ options[:docset_uri] = '/vue'
+ options[:attribution] = <<-HTML
+ © 2013–2015 Evan You, Vue.js contributors
+ Licensed under the MIT License.
+ HTML
+ end
+end
diff --git a/lib/docs/scrapers/webpack.rb b/lib/docs/scrapers/webpack.rb
new file mode 100644
index 0000000000..f40388f8b8
--- /dev/null
+++ b/lib/docs/scrapers/webpack.rb
@@ -0,0 +1,23 @@
+module Docs
+ class Webpack < UrlScraper
+ self.name = 'webpack'
+ self.type = 'webpack'
+ self.version = '1.12'
+ self.base_url = 'https://webpack.github.io/docs/'
+
+
+ html_filters.push 'webpack/entries', 'webpack/clean_html', 'title'
+
+ options[:title] = false
+ options[:domain] = 'http://www.refly.xyz'
+ options[:title] = false
+ options[:root_title] = 'Webpack'
+ options[:docset_uri] = '/webpack'
+ options[:skip] = %w(list-of-tutorials.html examples.html changelog.html ideas.html roadmap.html)
+
+ options[:attribution] = <<-HTML
+ © 2012–2015 Tobias Koppers
+ Licensed under the MIT License.
+ HTML
+ end
+end
diff --git a/lib/docs/scrapers/yii.rb b/lib/docs/scrapers/yii.rb
index b667dc481b..80d9e8b32d 100755
--- a/lib/docs/scrapers/yii.rb
+++ b/lib/docs/scrapers/yii.rb
@@ -1,13 +1,16 @@
module Docs
class Yii < UrlScraper
self.type = 'yii'
- self.version = '2.0.1'
+ self.version = '2.0.2'
self.base_url = 'http://www.yiiframework.com/doc-2.0/'
self.root_path = 'index.html'
html_filters.push 'yii/clean_html', 'yii/entries'
+ options[:domain] = 'http://www.refly.xyz'
options[:container] = 'div[role=main]'
+ options[:root_title] = 'Yii'
+ options[:docset_uri] = '/yii'
options[:skip_patterns] = [/\Ayii-apidoc/]
options[:attribution] = <<-HTML
diff --git a/lib/docs/scrapers/yii1.rb b/lib/docs/scrapers/yii1.rb
new file mode 100644
index 0000000000..59ddff4c7c
--- /dev/null
+++ b/lib/docs/scrapers/yii1.rb
@@ -0,0 +1,19 @@
+module Docs
+ class Yii1 < UrlScraper
+ self.name = 'Yii 1'
+ self.slug = 'yii1'
+ self.type = 'yii'
+ self.version = '1.1.16'
+ self.base_url = 'http://www.yiiframework.com/doc/api/1.1/'
+
+ html_filters.push 'yii1/clean_html', 'yii1/entries'
+ options[:domain] = 'http://www.refly.xyz'
+ options[:root_title] = 'Yii1'
+ options[:docset_uri] = '/yii1'
+ options[:container] = '.grid_9'
+ options[:attribution] = <<-HTML
+ © 2008–2015 by Yii Software LLC
+ Licensed under the three clause BSD license.
+ HTML
+ end
+end
diff --git a/lib/docs/subscribers/doc_subscriber.rb b/lib/docs/subscribers/doc_subscriber.rb
new file mode 100644
index 0000000000..7c1fa5508b
--- /dev/null
+++ b/lib/docs/subscribers/doc_subscriber.rb
@@ -0,0 +1,47 @@
+module Docs
+ class DocSubscriber < Subscriber
+ self.namespace = 'doc'
+
+ def index(event)
+ before, after = parse_payload(event)
+ log "Entries:"
+ log_diff before['entries'], after['entries'], 'name'
+ log "Types:"
+ log_diff before['types'], after['types'], 'name'
+ end
+
+ def db(event)
+ before, after = parse_payload(event)
+ log "Files:"
+ log_diff before.keys, after.keys
+ end
+
+ def info(event)
+ log event.payload[:msg]
+ end
+
+ private
+
+ def parse_payload(event)
+ [JSON.parse(event.payload[:before]), JSON.parse(event.payload[:after])]
+ end
+
+ def log_diff(before, after, prop = nil)
+ before ||= []
+ after ||= []
+
+ if prop
+ before = before.map { |obj| obj[prop] }
+ after = after.map { |obj| obj[prop] }
+ end
+
+ created, updated, deleted = (after - before), (before & after), (before - after)
+
+ log " Updated: #{updated.length}"
+ log " Created: #{created.length}"
+ created.each { |str| log " + #{str}" }
+ log " Deleted: #{deleted.length}"
+ deleted.each { |str| log " - #{str}" }
+ end
+ end
+end
diff --git a/lib/tasks/docs.thor b/lib/tasks/docs.thor
index d44f7efcdc..8a8beb0d9e 100644
--- a/lib/tasks/docs.thor
+++ b/lib/tasks/docs.thor
@@ -43,14 +43,15 @@ class DocsCLI < Thor
invalid_doc(name)
end
- desc 'generate [--verbose] [--debug] [--force]', 'Generate a documentation'
+ desc 'generate [--verbose] [--debug] [--force] [--package]', 'Generate a documentation'
option :verbose, type: :boolean
option :debug, type: :boolean
option :force, type: :boolean
+ option :package, type: :boolean
def generate(name)
Docs.install_report :store if options[:verbose]
Docs.install_report :scraper if options[:debug]
- Docs.install_report :progress_bar if $stdout.tty?
+ Docs.install_report :progress_bar, :doc if $stdout.tty?
unless options[:force]
puts <<-TEXT.strip_heredoc
@@ -67,6 +68,10 @@ class DocsCLI < Thor
if Docs.generate(name)
generate_manifest
+ if options[:package]
+ require 'unix_utils'
+ package_doc(Docs.find(name))
+ end
puts 'Done'
else
puts "Failed!#{' (try running with --debug for more information)' unless options[:debug]}"
diff --git a/public/docs/docs.json b/public/docs/docs.json
index 0637a088a0..cdffde8801 100644
--- a/public/docs/docs.json
+++ b/public/docs/docs.json
@@ -1 +1 @@
-[]
\ No newline at end of file
+[{"name":"Angular.js","slug":"angular","type":"angular","parsed_uri":null,"anchor":null,"parent_uri":null,"docset":null,"version":"1.3.8","index_path":"angular/index.json","db_path":"angular/db.json","mtime":1425223535,"db_size":891254},{"name":"Backbone.js","slug":"backbone","type":"underscore","parsed_uri":null,"anchor":null,"parent_uri":null,"docset":null,"version":"1.1.2","index_path":"backbone/index.json","db_path":"backbone/db.json","mtime":1429988927,"db_size":94458},{"name":"Bower","slug":"bower","type":"bower","parsed_uri":null,"anchor":null,"parent_uri":null,"docset":null,"version":"1.3.12","index_path":"bower/index.json","db_path":"bower/db.json","mtime":1429989319,"db_size":48973},{"name":"C","slug":"c","type":"c","parsed_uri":null,"anchor":null,"parent_uri":null,"docset":null,"version":null,"index_path":"c/index.json","db_path":"c/db.json","mtime":1429789512,"db_size":2943179},{"name":"Chai","slug":"chai","type":"chai","parsed_uri":null,"anchor":null,"parent_uri":null,"docset":null,"version":"1.10.0","index_path":"chai/index.json","db_path":"chai/db.json","mtime":1430121242,"db_size":135231},{"name":"CoffeeScript","slug":"coffeescript","type":"coffeescript","parsed_uri":null,"anchor":null,"parent_uri":null,"docset":null,"version":"1.8.0","index_path":"coffeescript/index.json","db_path":"coffeescript/db.json","mtime":1422831060,"db_size":53032},{"name":"Cordova","slug":"cordova","type":"cordova","parsed_uri":null,"anchor":null,"parent_uri":null,"docset":null,"version":"4.0.0","index_path":"cordova/index.json","db_path":"cordova/db.json","mtime":1430152366,"db_size":528103},{"name":"C++","slug":"cpp","type":"c","parsed_uri":null,"anchor":null,"parent_uri":null,"docset":null,"version":null,"index_path":"cpp/index.json","db_path":"cpp/db.json","mtime":1429910519,"db_size":17655436},{"name":"CSS","slug":"css","type":"mdn","parsed_uri":null,"anchor":null,"parent_uri":null,"docset":null,"version":null,"index_path":"css/index.json","db_path":"css/db.json","mtime":1430295435,"db_size":572584},{"name":"D3.js","slug":"d3","type":"d3","parsed_uri":null,"anchor":null,"parent_uri":null,"docset":null,"version":"3.5.2","index_path":"d3/index.json","db_path":"d3/db.json","mtime":1430213630,"db_size":618304},{"name":"Django","slug":"django","type":"sphinx","parsed_uri":null,"anchor":null,"parent_uri":null,"docset":null,"version":"1.7.1","index_path":"django/index.json","db_path":"django/db.json","mtime":1426424870,"db_size":4543071},{"name":"DOM","slug":"dom","type":"mdn","parsed_uri":null,"anchor":null,"parent_uri":null,"docset":null,"version":null,"index_path":"dom/index.json","db_path":"dom/db.json","mtime":1430292716,"db_size":3555886},{"name":"DOM Events","slug":"dom_events","type":"mdn","parsed_uri":null,"anchor":null,"parent_uri":null,"docset":null,"version":null,"index_path":"dom_events/index.json","db_path":"dom_events/db.json","mtime":1430305859,"db_size":1292493},{"name":"EmberJS","slug":"ember","type":"ember","parsed_uri":null,"anchor":null,"parent_uri":null,"docset":null,"version":"1.9.0","index_path":"ember/index.json","db_path":"ember/db.json","mtime":1430202838,"db_size":1278312},{"name":"Express","slug":"express","type":"express","parsed_uri":null,"anchor":null,"parent_uri":null,"docset":null,"version":"4.10.0","index_path":"express/index.json","db_path":"express/db.json","mtime":1427985286,"db_size":88391},{"name":"Git","slug":"git","type":"git","parsed_uri":null,"anchor":null,"parent_uri":null,"docset":null,"version":"2.2.0","index_path":"git/index.json","db_path":"git/db.json","mtime":1430327500,"db_size":2565405},{"name":"Go","slug":"go","type":"go","parsed_uri":null,"anchor":null,"parent_uri":null,"docset":null,"version":"1.4.0","index_path":"go/index.json","db_path":"go/db.json","mtime":1430386949,"db_size":2471770},{"name":"Grunt","slug":"grunt","type":"grunt","parsed_uri":null,"anchor":null,"parent_uri":null,"docset":null,"version":"0.4.5","index_path":"grunt/index.json","db_path":"grunt/db.json","mtime":1430390720,"db_size":125642},{"name":"Haskell","slug":"haskell","type":"haskell","parsed_uri":null,"anchor":null,"parent_uri":null,"docset":null,"version":"7.8.2","index_path":"haskell/index.json","db_path":"haskell/db.json","mtime":1428492682,"db_size":6954072},{"name":"HTML","slug":"html","type":"mdn","parsed_uri":null,"anchor":null,"parent_uri":null,"docset":null,"version":null,"index_path":"html/index.json","db_path":"html/db.json","mtime":1430323761,"db_size":259097},{"name":"HTTP","slug":"http","type":"rfc","parsed_uri":null,"anchor":null,"parent_uri":null,"docset":null,"version":null,"index_path":"http/index.json","db_path":"http/db.json","mtime":1429694638,"db_size":182984},{"name":"JavaScript","slug":"javascript","type":"mdn","parsed_uri":null,"anchor":null,"parent_uri":null,"docset":null,"version":null,"index_path":"javascript/index.json","db_path":"javascript/db.json","mtime":1430325771,"db_size":954363},{"name":"jQuery","slug":"jquery","type":"jquery","parsed_uri":null,"anchor":null,"parent_uri":null,"docset":null,"version":"up to 2.1.0","index_path":"jquery/index.json","db_path":"jquery/db.json","mtime":1427452908,"db_size":1829863},{"name":"jQuery Mobile","slug":"jquerymobile","type":"jquery","parsed_uri":null,"anchor":null,"parent_uri":null,"docset":null,"version":"1.4.0","index_path":"jquerymobile/index.json","db_path":"jquerymobile/db.json","mtime":1430390892,"db_size":1064905},{"name":"jQuery UI","slug":"jqueryui","type":"jquery","parsed_uri":null,"anchor":null,"parent_uri":null,"docset":null,"version":"1.10.4","index_path":"jqueryui/index.json","db_path":"jqueryui/db.json","mtime":1430391986,"db_size":896461},{"name":"Knockout.js","slug":"knockout","type":"knockout","parsed_uri":null,"anchor":null,"parent_uri":null,"docset":null,"version":"3.2.0","index_path":"knockout/index.json","db_path":"knockout/db.json","mtime":1424535229,"db_size":394621},{"name":"Laravel","slug":"laravel","type":"laravel","parsed_uri":null,"anchor":null,"parent_uri":null,"docset":null,"version":"4.2.11","index_path":"laravel/index.json","db_path":"laravel/db.json","mtime":1423421754,"db_size":6771984},{"name":"Less","slug":"less","type":"less","parsed_uri":null,"anchor":null,"parent_uri":null,"docset":null,"version":"2.1.0","index_path":"less/index.json","db_path":"less/db.json","mtime":1429040410,"db_size":146985},{"name":"Lo-Dash","slug":"lodash","type":"lodash","parsed_uri":null,"anchor":null,"parent_uri":null,"docset":null,"version":"2.4.1","index_path":"lodash/index.json","db_path":"lodash/db.json","mtime":1428936005,"db_size":234348},{"name":"Marionette.js","slug":"marionette","type":"marionette","parsed_uri":null,"anchor":null,"parent_uri":null,"docset":null,"version":"2.3.0","index_path":"marionette/index.json","db_path":"marionette/db.json","mtime":1425224881,"db_size":302115},{"name":"Markdown","slug":"markdown","type":"markdown","parsed_uri":null,"anchor":null,"parent_uri":null,"docset":null,"version":null,"index_path":"markdown/index.json","db_path":"markdown/db.json","mtime":1429040426,"db_size":31338},{"name":"MaxCDN","slug":"maxcdn","type":"maxcdn","parsed_uri":null,"anchor":null,"parent_uri":null,"docset":null,"version":null,"index_path":"maxcdn/index.json","db_path":"maxcdn/db.json","mtime":1422825159,"db_size":318676},{"name":"Modernizr","slug":"modernizr","type":"modernizr","parsed_uri":null,"anchor":null,"parent_uri":null,"docset":null,"version":"2.8.3","index_path":"modernizr/index.json","db_path":"modernizr/db.json","mtime":1429868911,"db_size":35933},{"name":"Moment.js","slug":"moment","type":"moment","parsed_uri":null,"anchor":null,"parent_uri":null,"docset":null,"version":"2.8.3","index_path":"moment/index.json","db_path":"moment/db.json","mtime":1422825261,"db_size":153984},{"name":"MongooseJS","slug":"mongoosejs","type":"mongoose","parsed_uri":null,"anchor":null,"parent_uri":null,"docset":null,"version":"3.8.19","index_path":"mongoosejs/index.json","db_path":"mongoosejs/db.json","mtime":1429993361,"db_size":415455},{"name":"nginx","slug":"nginx","type":"nginx","parsed_uri":null,"anchor":null,"parent_uri":null,"docset":null,"version":"1.7.9","index_path":"nginx/index.json","db_path":"nginx/db.json","mtime":1428490075,"db_size":892805},{"name":"Node.js","slug":"node","type":"node","parsed_uri":null,"anchor":null,"parent_uri":null,"docset":null,"version":"0.12.0","index_path":"node/index.json","db_path":"node/db.json","mtime":1429121754,"db_size":596416},{"name":"Nokogiri","slug":"nokogiri","type":"rdoc","parsed_uri":null,"anchor":null,"parent_uri":null,"docset":null,"version":"1.6.4","index_path":"nokogiri/index.json","db_path":"nokogiri/db.json","mtime":1420139792,"db_size":463492},{"name":"PHP","slug":"php","type":"php","parsed_uri":null,"anchor":null,"parent_uri":null,"docset":null,"version":"up to 5.6.2","index_path":"php/index.json","db_path":"php/db.json","mtime":1430480320,"db_size":60930579},{"name":"PHP","slug":"php","type":"php","parsed_uri":null,"anchor":null,"parent_uri":null,"docset":null,"version":"up to 5.6.2","index_path":"php/index.json","db_path":"php/db.json","mtime":1430480320,"db_size":60930579},{"name":"PHPUnit","slug":"phpunit","type":"phpunit","parsed_uri":null,"anchor":null,"parent_uri":null,"docset":null,"version":"4.4","index_path":"phpunit/index.json","db_path":"phpunit/db.json","mtime":1429269437,"db_size":416212},{"name":"PostgreSQL","slug":"postgresql","type":"postgres","parsed_uri":null,"anchor":null,"parent_uri":null,"docset":null,"version":"9.4","index_path":"postgresql/index.json","db_path":"postgresql/db.json","mtime":1427453682,"db_size":3831704},{"name":"Python","slug":"python","type":"sphinx","parsed_uri":null,"anchor":null,"parent_uri":null,"docset":null,"version":"3.4.2","index_path":"python/index.json","db_path":"python/db.json","mtime":1430474488,"db_size":7617490},{"name":"Python 2","slug":"python2","type":"sphinx","parsed_uri":null,"anchor":null,"parent_uri":null,"docset":null,"version":"2.7.8","index_path":"python2/index.json","db_path":"python2/db.json","mtime":1429517513,"db_size":9157360},{"name":"Ruby on Rails","slug":"rails","type":"rdoc","parsed_uri":null,"anchor":null,"parent_uri":null,"docset":null,"version":"4.2.0","index_path":"rails/index.json","db_path":"rails/db.json","mtime":1427036547,"db_size":3699249},{"name":"React","slug":"react","type":"react","parsed_uri":null,"anchor":null,"parent_uri":null,"docset":null,"version":"0.12.2","index_path":"react/index.json","db_path":"react/db.json","mtime":1430462573,"db_size":248532},{"name":"Redis","slug":"redis","type":"redis","parsed_uri":null,"anchor":null,"parent_uri":null,"docset":null,"version":"up to 2.8.18","index_path":"redis/index.json","db_path":"redis/db.json","mtime":1429695684,"db_size":590950},{"name":"RequireJS","slug":"requirejs","type":"requirejs","parsed_uri":null,"anchor":null,"parent_uri":null,"docset":null,"version":"2.1.15","index_path":"requirejs/index.json","db_path":"requirejs/db.json","mtime":1429041012,"db_size":170653},{"name":"RethinkDB","slug":"rethinkdb","type":"rethinkdb","parsed_uri":null,"anchor":null,"parent_uri":null,"docset":null,"version":"1.15.2","index_path":"rethinkdb/index.json","db_path":"rethinkdb/db.json","mtime":1422825943,"db_size":425658},{"name":"Sass","slug":"sass","type":"yard","parsed_uri":null,"anchor":null,"parent_uri":null,"docset":null,"version":"3.4.7","index_path":"sass/index.json","db_path":"sass/db.json","mtime":1428658530,"db_size":265470},{"name":"Sinon","slug":"sinon","type":"sinon","parsed_uri":null,"anchor":null,"parent_uri":null,"docset":null,"version":"1.12.1","index_path":"sinon/index.json","db_path":"sinon/db.json","mtime":1429117520,"db_size":72687},{"name":"Socket.IO","slug":"socketio","type":"socketio","parsed_uri":null,"anchor":null,"parent_uri":null,"docset":null,"version":"1.2.1","index_path":"socketio/index.json","db_path":"socketio/db.json","mtime":1429287286,"db_size":42561},{"name":"SVG","slug":"svg","type":"mdn","parsed_uri":null,"anchor":null,"parent_uri":null,"docset":null,"version":null,"index_path":"svg/index.json","db_path":"svg/db.json","mtime":1430406419,"db_size":4436300},{"name":"Underscore.js","slug":"underscore","type":"underscore","parsed_uri":null,"anchor":null,"parent_uri":null,"docset":null,"version":"1.7.0","index_path":"underscore/index.json","db_path":"underscore/db.json","mtime":1428396863,"db_size":56667},{"name":"XPath","slug":"xpath","type":"mdn","parsed_uri":null,"anchor":null,"parent_uri":null,"docset":null,"version":null,"index_path":"xpath/index.json","db_path":"xpath/db.json","mtime":1430397213,"db_size":282290},{"name":"Yii","slug":"yii","type":"yii","parsed_uri":null,"anchor":null,"parent_uri":null,"docset":null,"version":"2.0.1","index_path":"yii/index.json","db_path":"yii/db.json","mtime":1430469785,"db_size":14587283}]
\ No newline at end of file
diff --git a/scrapper.sh b/scrapper.sh
new file mode 100755
index 0000000000..db4b7d3da7
--- /dev/null
+++ b/scrapper.sh
@@ -0,0 +1,4 @@
+#!/bin/bash
+export DYLD_FALLBACK_LIBRARY _PATH=/Library/PostgreSQL/9.4/lib/
+cd lib/docs/db_storage/
+python import_docset.py -aall -mall -cs$2
\ No newline at end of file