Merge branch 'master' into wikimatze-master

pull/1007/head
Jasper van Merle 6 years ago
commit 7d89878ab1

@ -55,13 +55,12 @@ In addition to the [guidelines for contributing code](#contributing-code-and-fea
* Remove as much content and HTML markup as possible, particularly content not associated with any entry (e.g. introduction, changelog, etc.). * Remove as much content and HTML markup as possible, particularly content not associated with any entry (e.g. introduction, changelog, etc.).
* Names must be as short as possible and unique across the documentation. * Names must be as short as possible and unique across the documentation.
* The number of types (categories) should ideally be less than 100. * The number of types (categories) should ideally be less than 100.
* Don't modify the icon sprite. I'll do it after your pull request is merged.
## Updating existing documentations ## Updating existing documentations
Please don't submit a pull request updating the version number of a documentation, unless a change is required in the scraper and you've verified that it works. Please don't submit a pull request updating the version number of a documentation, unless a change is required in the scraper and you've verified that it works.
To ask that an existing documentation be updated, please use the [Trello board](https://trello.com/c/2B0hmW7M/52-request-updates-here). To ask that an existing documentation be updated, first check the last two [documentation versions reports](https://github.com/freeCodeCamp/devdocs/issues?utf8=%E2%9C%93&q=Documentation+versions+report+is%3Aissue+author%3Adevdocs-bot+sort%3Acreated-desc). Only create an issue if the documentation has been wrongly marked as up-to-date.
## Coding conventions ## Coding conventions

@ -2,6 +2,6 @@
Please read the contributing guidelines before opening an issue: Please read the contributing guidelines before opening an issue:
https://github.com/freeCodeCamp/devdocs/blob/master/.github/CONTRIBUTING.md https://github.com/freeCodeCamp/devdocs/blob/master/.github/CONTRIBUTING.md
To request a new documentation, or an update of an existing documentation, go here: Go here to request a new documentation:
https://trello.com/b/6BmTulfx/devdocs-documentation https://trello.com/b/6BmTulfx/devdocs-documentation
--> -->

1
.gitignore vendored

@ -1,5 +1,6 @@
.DS_Store .DS_Store
.bundle .bundle
log
tmp tmp
public/assets public/assets
public/fonts public/fonts

@ -1 +1 @@
2.6.0 2.6.3

@ -1,2 +1 @@
public/icons test
test

@ -1,7 +1,26 @@
language: ruby language: ruby
addons:
apt:
packages:
- libcurl4-openssl-dev
cache: bundler cache: bundler
before_script: before_install:
- "echo 'gem: --no-document' > ~/.gemrc"
- gem update --system - gem update --system
- gem install bundler - gem install bundler
script:
- if [ "$TRAVIS_EVENT_TYPE" != "cron" ]; then bundle exec rake; fi
- if [ "$TRAVIS_EVENT_TYPE" = "cron" ]; then bundle exec thor updates:check --github-token $GH_TOKEN --upload; fi
deploy:
provider: heroku
app: devdocs
on:
branch: master
condition: $TRAVIS_EVENT_TYPE != cron
api_key:
secure: "4p1klvWJZSOImzFcKOduILjP93hlOlAhceWlYMKS4tU+TCFE8qTBzdKdFPSCsCgjB+YR9pBss+L0lJpVVMjSwFHXqpKe6EeUSltO2k7DFHfW7kXLUM/L0AfqXz+YXk76XUyZMhvOEbldPfaMaj10e8vgDOQCSHABDyK/4CU+hnI="

@ -1,11 +1,12 @@
FROM ruby:2.6.0 FROM ruby:2.6.3
ENV LANG=C.UTF-8 ENV LANG=C.UTF-8
ENV ENABLE_SERVICE_WORKER=true
WORKDIR /devdocs WORKDIR /devdocs
RUN apt-get update && \ RUN apt-get update && \
apt-get -y install git nodejs && \ apt-get -y install git nodejs libcurl4 && \
gem install bundler && \ gem install bundler && \
rm -rf /var/lib/apt/lists/* rm -rf /var/lib/apt/lists/*

@ -1,12 +1,13 @@
FROM ruby:2.6.0-alpine FROM ruby:2.6.3-alpine
ENV LANG=C.UTF-8 ENV LANG=C.UTF-8
ENV ENABLE_SERVICE_WORKER=true
WORKDIR /devdocs WORKDIR /devdocs
COPY . /devdocs COPY . /devdocs
RUN apk --update add nodejs build-base libstdc++ gzip git zlib-dev && \ RUN apk --update add nodejs build-base libstdc++ gzip git zlib-dev libcurl && \
gem install bundler && \ gem install bundler && \
bundle install --system --without test && \ bundle install --system --without test && \
thor docs:download --all && \ thor docs:download --all && \

@ -1,5 +1,5 @@
source 'https://rubygems.org' source 'https://rubygems.org'
ruby '2.6.0' ruby '2.6.3'
gem 'rake' gem 'rake'
gem 'thor' gem 'thor'
@ -22,6 +22,8 @@ group :app do
gem 'browser' gem 'browser'
gem 'sass' gem 'sass'
gem 'coffee-script' gem 'coffee-script'
gem 'chunky_png'
gem 'sprockets-sass'
end end
group :production do group :production do
@ -40,6 +42,7 @@ group :docs do
gem 'unix_utils', require: false gem 'unix_utils', require: false
gem 'tty-pager', require: false gem 'tty-pager', require: false
gem 'net-sftp', '>= 2.1.3.rc2', require: false gem 'net-sftp', '>= 2.1.3.rc2', require: false
gem 'terminal-table', require: false
end end
group :test do group :test do

@ -1,49 +1,50 @@
GEM GEM
remote: https://rubygems.org/ remote: https://rubygems.org/
specs: specs:
activesupport (5.2.2) activesupport (5.2.3)
concurrent-ruby (~> 1.0, >= 1.0.2) concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 0.7, < 2) i18n (>= 0.7, < 2)
minitest (~> 5.1) minitest (~> 5.1)
tzinfo (~> 1.1) tzinfo (~> 1.1)
backports (3.11.4) backports (3.15.0)
better_errors (2.5.0) better_errors (2.5.1)
coderay (>= 1.0.0) coderay (>= 1.0.0)
erubi (>= 1.0.0) erubi (>= 1.0.0)
rack (>= 0.9.0) rack (>= 0.9.0)
browser (2.5.3) browser (2.6.1)
chunky_png (1.3.11)
coderay (1.1.2) coderay (1.1.2)
coffee-script (2.4.1) coffee-script (2.4.1)
coffee-script-source coffee-script-source
execjs execjs
coffee-script-source (1.12.2) coffee-script-source (1.12.2)
concurrent-ruby (1.1.4) concurrent-ruby (1.1.5)
daemons (1.3.1) daemons (1.3.1)
erubi (1.8.0) erubi (1.8.0)
ethon (0.12.0) ethon (0.12.0)
ffi (>= 1.3.0) ffi (>= 1.3.0)
eventmachine (1.2.7) eventmachine (1.2.7)
execjs (2.7.0) execjs (2.7.0)
exifr (1.3.5) exifr (1.3.6)
ffi (1.10.0) ffi (1.11.1)
fspath (3.1.0) fspath (3.1.2)
highline (2.0.0) highline (2.0.2)
html-pipeline (2.10.0) html-pipeline (2.11.1)
activesupport (>= 2) activesupport (>= 2)
nokogiri (>= 1.4) nokogiri (>= 1.4)
i18n (1.5.2) i18n (1.6.0)
concurrent-ruby (~> 1.0) concurrent-ruby (~> 1.0)
image_optim (0.26.3) image_optim (0.26.5)
exifr (~> 1.2, >= 1.2.2) exifr (~> 1.2, >= 1.2.2)
fspath (~> 3.0) fspath (~> 3.0)
image_size (>= 1.5, < 3) image_size (>= 1.5, < 3)
in_threads (~> 1.3) in_threads (~> 1.3)
progress (~> 3.0, >= 3.0.1) progress (~> 3.0, >= 3.0.1)
image_optim_pack (0.5.1.20190105) image_optim_pack (0.5.6)
fspath (>= 2.1, < 4) fspath (>= 2.1, < 4)
image_optim (~> 0.19) image_optim (~> 0.19)
image_size (2.0.0) image_size (2.0.2)
in_threads (1.5.1) in_threads (1.5.3)
method_source (0.9.2) method_source (0.9.2)
mini_portile2 (2.4.0) mini_portile2 (2.4.0)
minitest (5.11.3) minitest (5.11.3)
@ -51,19 +52,19 @@ GEM
mustermann (1.0.3) mustermann (1.0.3)
net-sftp (3.0.0.beta1) net-sftp (3.0.0.beta1)
net-ssh (>= 5.0.0, < 6.0.0) net-ssh (>= 5.0.0, < 6.0.0)
net-ssh (5.1.0) net-ssh (5.2.0)
newrelic_rpm (5.7.0.350) newrelic_rpm (6.5.0.357)
nokogiri (1.10.1) nokogiri (1.10.3)
mini_portile2 (~> 2.4.0) mini_portile2 (~> 2.4.0)
options (2.3.2) options (2.3.2)
progress (3.5.0) progress (3.5.2)
progress_bar (1.3.0) progress_bar (1.3.0)
highline (>= 1.6, < 3) highline (>= 1.6, < 3)
options (~> 2.3.0) options (~> 2.3.0)
pry (0.12.2) pry (0.12.2)
coderay (~> 1.1.0) coderay (~> 1.1.0)
method_source (~> 0.9.0) method_source (~> 0.9.0)
rack (2.0.6) rack (2.0.7)
rack-protection (2.0.5) rack-protection (2.0.5)
rack rack
rack-ssl-enforcer (0.2.9) rack-ssl-enforcer (0.2.9)
@ -74,7 +75,7 @@ GEM
rb-inotify (0.10.0) rb-inotify (0.10.0)
ffi (~> 1.0) ffi (~> 1.0)
rr (1.2.1) rr (1.2.1)
sass (3.7.3) sass (3.7.4)
sass-listen (~> 4.0.0) sass-listen (~> 4.0.0)
sass-listen (4.0.0) sass-listen (4.0.0)
rb-fsevent (~> 0.9, >= 0.9.4) rb-fsevent (~> 0.9, >= 0.9.4)
@ -96,11 +97,15 @@ GEM
rack (> 1, < 3) rack (> 1, < 3)
sprockets-helpers (1.2.1) sprockets-helpers (1.2.1)
sprockets (>= 2.2) sprockets (>= 2.2)
strings (0.1.4) sprockets-sass (2.0.0.beta2)
strings-ansi (~> 0.1.0) sprockets (>= 2.0, < 4.0)
unicode-display_width (~> 1.4.0) strings (0.1.5)
unicode_utils (~> 1.4.0) strings-ansi (~> 0.1)
unicode-display_width (~> 1.5)
unicode_utils (~> 1.4)
strings-ansi (0.1.0) strings-ansi (0.1.0)
terminal-table (1.8.0)
unicode-display_width (~> 1.1, >= 1.1.1)
thin (1.7.2) thin (1.7.2)
daemons (~> 1.0, >= 1.0.9) daemons (~> 1.0, >= 1.0.9)
eventmachine (~> 1.0, >= 1.0.4) eventmachine (~> 1.0, >= 1.0.4)
@ -108,19 +113,19 @@ GEM
thor (0.20.3) thor (0.20.3)
thread_safe (0.3.6) thread_safe (0.3.6)
tilt (2.0.9) tilt (2.0.9)
tty-pager (0.12.0) tty-pager (0.12.1)
strings (~> 0.1.4) strings (~> 0.1.4)
tty-screen (~> 0.6) tty-screen (~> 0.6)
tty-which (~> 0.4) tty-which (~> 0.4)
tty-screen (0.6.5) tty-screen (0.7.0)
tty-which (0.4.0) tty-which (0.4.1)
typhoeus (1.3.1) typhoeus (1.3.1)
ethon (>= 0.9.0) ethon (>= 0.9.0)
tzinfo (1.2.5) tzinfo (1.2.5)
thread_safe (~> 0.1) thread_safe (~> 0.1)
uglifier (4.1.20) uglifier (4.1.20)
execjs (>= 0.3.0, < 3) execjs (>= 0.3.0, < 3)
unicode-display_width (1.4.1) unicode-display_width (1.6.0)
unicode_utils (1.4.0) unicode_utils (1.4.0)
unix_utils (0.0.15) unix_utils (0.0.15)
yajl-ruby (1.4.1) yajl-ruby (1.4.1)
@ -132,6 +137,7 @@ DEPENDENCIES
activesupport (~> 5.2) activesupport (~> 5.2)
better_errors better_errors
browser browser
chunky_png
coffee-script coffee-script
erubi erubi
html-pipeline html-pipeline
@ -153,6 +159,8 @@ DEPENDENCIES
sinatra-contrib sinatra-contrib
sprockets sprockets
sprockets-helpers sprockets-helpers
sprockets-sass
terminal-table
thin thin
thor thor
tty-pager tty-pager
@ -162,7 +170,7 @@ DEPENDENCIES
yajl-ruby yajl-ruby
RUBY VERSION RUBY VERSION
ruby 2.6.0p0 ruby 2.6.3p62
BUNDLED WITH BUNDLED WITH
1.17.2 2.0.2

@ -59,14 +59,14 @@ The web app is all client-side JavaScript, written in [CoffeeScript](http://coff
Many of the code's design decisions were driven by the fact that the app uses XHR to load content directly into the main frame. This includes stripping the original documents of most of their HTML markup (e.g. scripts and stylesheets) to avoid polluting the main frame, and prefixing all CSS class names with an underscore to prevent conflicts. Many of the code's design decisions were driven by the fact that the app uses XHR to load content directly into the main frame. This includes stripping the original documents of most of their HTML markup (e.g. scripts and stylesheets) to avoid polluting the main frame, and prefixing all CSS class names with an underscore to prevent conflicts.
Another driving factor is performance and the fact that everything happens in the browser. `applicationCache` (which comes with its own set of constraints) and `localStorage` are used to speed up the boot time, while memory consumption is kept in check by allowing the user to pick his/her own set of documentations. The search algorithm is kept simple because it needs to be fast even searching through 100,000 strings. Another driving factor is performance and the fact that everything happens in the browser. A service worker (which comes with its own set of constraints) and `localStorage` are used to speed up the boot time, while memory consumption is kept in check by allowing the user to pick his/her own set of documentations. The search algorithm is kept simple because it needs to be fast even searching through 100,000 strings.
DevDocs being a developer tool, the browser requirements are high: DevDocs being a developer tool, the browser requirements are high:
* Recent versions of Firefox, Chrome, or Opera * Recent versions of Firefox, Chrome, or Opera
* Safari 9.1+ * Safari 11.1+
* Edge 16+ * Edge 17+
* iOS 10+ * iOS 11.3+
This allows the code to take advantage of the latest DOM and HTML5 APIs and make developing DevDocs a lot more fun! This allows the code to take advantage of the latest DOM and HTML5 APIs and make developing DevDocs a lot more fun!
@ -156,7 +156,7 @@ Contributions are welcome. Please read the [contributing guidelines](./.github/C
* [Doc Browser](https://github.com/qwfy/doc-browser) is a native Linux app that supports DevDocs docsets * [Doc Browser](https://github.com/qwfy/doc-browser) is a native Linux app that supports DevDocs docsets
* [GNOME Application](https://github.com/hardpixel/devdocs-desktop) GTK3 application with search integrated in headerbar * [GNOME Application](https://github.com/hardpixel/devdocs-desktop) GTK3 application with search integrated in headerbar
* [macOS Application](https://github.com/dteoh/devdocs-macos) * [macOS Application](https://github.com/dteoh/devdocs-macos)
* [Android Application](https://github.com/Merith-TK/devdocs_webapp_kotlin) is a fully working, advanced WebView with AppCache enabled * [Android Application](https://github.com/Merith-TK/devdocs_webapp_kotlin) is a fully working, advanced WebView
## Copyright / License ## Copyright / License

@ -0,0 +1 @@
sprites/**/*

Binary file not shown.

Before

Width:  |  Height:  |  Size: 45 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 119 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 48 KiB

@ -13,10 +13,12 @@
@el = $('._app') @el = $('._app')
@localStorage = new LocalStorageStore @localStorage = new LocalStorageStore
@appCache = new app.AppCache if app.AppCache.isEnabled() @serviceWorker = new app.ServiceWorker if app.ServiceWorker.isEnabled()
@settings = new app.Settings @settings = new app.Settings
@db = new app.DB() @db = new app.DB()
@settings.initLayout()
@docs = new app.collections.Docs @docs = new app.collections.Docs
@disabledDocs = new app.collections.Docs @disabledDocs = new app.collections.Docs
@entries = new app.collections.Entries @entries = new app.collections.Entries
@ -76,7 +78,7 @@
.install() .install()
@previousErrorHandler = onerror @previousErrorHandler = onerror
window.onerror = @onWindowError.bind(@) window.onerror = @onWindowError.bind(@)
CookieStore.onBlocked = @onCookieBlocked CookiesStore.onBlocked = @onCookieBlocked
return return
bootOne: -> bootOne: ->
@ -138,7 +140,10 @@
@docs.sort() @docs.sort()
@initDoc(doc) @initDoc(doc)
@saveDocs() @saveDocs()
_onSuccess() if app.settings.get('autoInstall')
doc.install(_onSuccess, onError)
else
_onSuccess()
return return
doc.load onSuccess, onError, writeCache: true doc.load onSuccess, onError, writeCache: true
@ -147,7 +152,7 @@
saveDocs: -> saveDocs: ->
@settings.setDocs(doc.slug for doc in @docs.all()) @settings.setDocs(doc.slug for doc in @docs.all())
@db.migrate() @db.migrate()
@appCache?.updateInBackground() @serviceWorker?.updateInBackground()
welcomeBack: -> welcomeBack: ->
visitCount = @settings.get('count') visitCount = @settings.get('count')
@ -167,14 +172,14 @@
reload: -> reload: ->
@docs.clearCache() @docs.clearCache()
@disabledDocs.clearCache() @disabledDocs.clearCache()
if @appCache then @appCache.reload() else @reboot() if @serviceWorker then @serviceWorker.reload() else @reboot()
return return
reset: -> reset: ->
@localStorage.reset() @localStorage.reset()
@settings.reset() @settings.reset()
@db?.reset() @db?.reset()
@appCache?.update() @serviceWorker?.update()
window.location = '/' window.location = '/'
return return
@ -193,9 +198,9 @@
return return
indexHost: -> indexHost: ->
# Can't load the index files from the host/CDN when applicationCache is # Can't load the index files from the host/CDN when service worker is
# enabled because it doesn't support caching URLs that use CORS. # enabled because it doesn't support caching URLs that use CORS.
@config[if @appCache and @settings.hasDocs() then 'index_path' else 'docs_origin'] @config[if @serviceWorker and @settings.hasDocs() then 'index_path' else 'docs_origin']
onBootError: (args...) -> onBootError: (args...) ->
@trigger 'bootError' @trigger 'bootError'
@ -252,7 +257,7 @@
matchMedia: !!window.matchMedia matchMedia: !!window.matchMedia
insertAdjacentHTML: !!document.body.insertAdjacentHTML insertAdjacentHTML: !!document.body.insertAdjacentHTML
defaultPrevented: document.createEvent('CustomEvent').defaultPrevented is false defaultPrevented: document.createEvent('CustomEvent').defaultPrevented is false
cssVariables: CSS.supports and CSS.supports('(--t: 0)') cssVariables: !!CSS?.supports?('(--t: 0)')
for key, value of features when not value for key, value of features when not value
Raven.captureMessage "unsupported/#{key}", level: 'info' Raven.captureMessage "unsupported/#{key}", level: 'info'

@ -1,42 +0,0 @@
class app.AppCache
$.extend @prototype, Events
@isEnabled: ->
try
applicationCache and applicationCache.status isnt applicationCache.UNCACHED
catch
constructor: ->
@cache = applicationCache
@notifyUpdate = true
@onUpdateReady() if @cache.status is @cache.UPDATEREADY
$.on @cache, 'progress', @onProgress
$.on @cache, 'updateready', @onUpdateReady
update: ->
@notifyUpdate = true
@notifyProgress = true
try @cache.update() catch
return
updateInBackground: ->
@notifyUpdate = false
@notifyProgress = false
try @cache.update() catch
return
reload: ->
$.on @cache, 'updateready noupdate error', -> app.reboot()
@notifyUpdate = false
@notifyProgress = true
try @cache.update() catch
return
onProgress: (event) =>
@trigger 'progress', event if @notifyProgress
return
onUpdateReady: =>
@trigger 'updateready' if @notifyUpdate
return

@ -13,3 +13,6 @@ app.config =
version: <%= Time.now.to_i %> version: <%= Time.now.to_i %>
release: <%= Time.now.utc.httpdate.to_json %> release: <%= Time.now.utc.httpdate.to_json %>
mathml_stylesheet: '<%= App.cdn_origin %>/mathml.css' mathml_stylesheet: '<%= App.cdn_origin %>/mathml.css'
favicon_spritesheet: '<%= image_path('sprites/docs.png') %>'
service_worker_path: '/service-worker.js'
service_worker_enabled: <%= App.environment == :production || ENV['ENABLE_SERVICE_WORKER'] == 'true' %>

@ -0,0 +1,49 @@
class app.ServiceWorker
$.extend @prototype, Events
@isEnabled: ->
!!navigator.serviceWorker and app.config.service_worker_enabled
constructor: ->
@registration = null
@notifyUpdate = true
navigator.serviceWorker.register(app.config.service_worker_path, {scope: '/'})
.then(
(registration) => @updateRegistration(registration),
(error) -> console.error('Could not register service worker:', error)
)
update: ->
return unless @registration
@notifyUpdate = true
return @registration.update().catch(->)
updateInBackground: ->
return unless @registration
@notifyUpdate = false
return @registration.update().catch(->)
reload: ->
return @updateInBackground().then(() -> app.reboot())
updateRegistration: (registration) ->
@registration = registration
$.on @registration, 'updatefound', @onUpdateFound
return
onUpdateFound: =>
$.off @installingRegistration, 'statechange', @onStateChange() if @installingRegistration
@installingRegistration = @registration.installing
$.on @installingRegistration, 'statechange', @onStateChange
return
onStateChange: =>
if @installingRegistration and @installingRegistration.state == 'installed' and navigator.serviceWorker.controller
@installingRegistration = null
@onUpdateReady()
return
onUpdateReady: ->
@trigger 'updateready' if @notifyUpdate
return

@ -5,11 +5,13 @@ class app.Settings
'manualUpdate' 'manualUpdate'
'fastScroll' 'fastScroll'
'arrowScroll' 'arrowScroll'
'analyticsConsent'
'docs' 'docs'
'dark' 'dark'
'layout' 'layout'
'size' 'size'
'tips' 'tips'
'autoInstall'
] ]
INTERNAL_KEYS = [ INTERNAL_KEYS = [
@ -19,6 +21,8 @@ class app.Settings
'news' 'news'
] ]
LAYOUTS: ['_max-width', '_sidebar-hidden', '_native-scrollbars']
@defaults: @defaults:
count: 0 count: 0
hideDisabled: false hideDisabled: false
@ -26,9 +30,10 @@ class app.Settings
news: 0 news: 0
manualUpdate: false manualUpdate: false
schema: 1 schema: 1
analyticsConsent: false
constructor: -> constructor: ->
@store = new CookieStore @store = new CookiesStore
@cache = {} @cache = {}
get: (key) -> get: (key) ->
@ -38,6 +43,7 @@ class app.Settings
set: (key, value) -> set: (key, value) ->
@store.set(key, value) @store.set(key, value)
delete @cache[key] delete @cache[key]
@toggleDark(value) if key == 'dark'
return return
del: (key) -> del: (key) ->
@ -63,6 +69,8 @@ class app.Settings
return return
setLayout: (name, enable) -> setLayout: (name, enable) ->
@toggleLayout(name, enable)
layout = (@store.get('layout') || '').split(' ') layout = (@store.get('layout') || '').split(' ')
$.arrayDelete(layout, '') $.arrayDelete(layout, '')
@ -104,3 +112,28 @@ class app.Settings
@store.reset() @store.reset()
@cache = {} @cache = {}
return return
initLayout: ->
@toggleDark(@get('dark') is 1)
@toggleLayout(layout, @hasLayout(layout)) for layout in @LAYOUTS
@initSidebarWidth()
return
toggleDark: (enable) ->
classList = document.documentElement.classList
classList.toggle('_theme-default', !enable)
classList.toggle('_theme-dark', enable)
color = getComputedStyle(document.documentElement).getPropertyValue('--headerBackground').trim()
$('meta[name=theme-color]').setAttribute('content', color)
return
toggleLayout: (layout, enable) ->
classList = document.body.classList
classList.toggle(layout, enable) unless layout is '_sidebar-hidden'
classList.toggle('_overlay-scrollbars', $.overlayScrollbarsEnabled())
return
initSidebarWidth: ->
size = @get('size')
document.documentElement.style.setProperty('--sidebarWidth', size + 'px') if size
return

@ -3,13 +3,13 @@ class app.UpdateChecker
@lastCheck = Date.now() @lastCheck = Date.now()
$.on window, 'focus', @onFocus $.on window, 'focus', @onFocus
app.appCache.on 'updateready', @onUpdateReady if app.appCache app.serviceWorker?.on 'updateready', @onUpdateReady
setTimeout @checkDocs, 0 setTimeout @checkDocs, 0
check: -> check: ->
if app.appCache if app.serviceWorker
app.appCache.update() app.serviceWorker.update()
else else
ajax ajax
url: $('script[src*="application"]').getAttribute('src') url: $('script[src*="application"]').getAttribute('src')

@ -1,4 +1,8 @@
class @CookieStore class @CookiesStore
# Intentionally called CookiesStore instead of CookieStore
# Calling it CookieStore causes issues when the Experimental Web Platform features flag is enabled in Chrome
# Related issue: https://github.com/freeCodeCamp/devdocs/issues/932
INT = /^\d+$/ INT = /^\d+$/
@onBlocked: -> @onBlocked: ->

@ -0,0 +1,64 @@
defaultUrl = null
currentSlug = null
imageCache = {}
urlCache = {}
withImage = (url, action) ->
if imageCache[url]
action(imageCache[url])
else
img = new Image()
img.crossOrigin = 'anonymous'
img.src = url
img.onload = () =>
imageCache[url] = img
action(img)
@setFaviconForDoc = (doc) ->
return if currentSlug == doc.slug
favicon = $('link[rel="icon"]')
if defaultUrl == null
defaultUrl = favicon.href
if urlCache[doc.slug]
favicon.href = urlCache[doc.slug]
currentSlug = doc.slug
return
styles = window.getComputedStyle($("._icon-#{doc.slug.split('~')[0]}"), ':before')
bgUrl = app.config.favicon_spritesheet
sourceSize = 16
sourceX = Math.abs(parseInt(styles['background-position-x'].slice(0, -2)))
sourceY = Math.abs(parseInt(styles['background-position-y'].slice(0, -2)))
withImage(bgUrl, (docImg) ->
withImage(defaultUrl, (defaultImg) ->
size = defaultImg.width
canvas = document.createElement('canvas')
ctx = canvas.getContext('2d')
canvas.width = size
canvas.height = size
ctx.drawImage(defaultImg, 0, 0)
docIconPercentage = 65
destinationCoords = size / 100 * (100 - docIconPercentage)
destinationSize = size / 100 * docIconPercentage
ctx.drawImage(docImg, sourceX, sourceY, sourceSize, sourceSize, destinationCoords, destinationCoords, destinationSize, destinationSize)
urlCache[doc.slug] = canvas.toDataURL()
favicon.href = urlCache[doc.slug]
currentSlug = doc.slug
)
)
@resetFavicon = () ->
if defaultUrl != null and currentSlug != null
$('link[rel="icon"]').href = defaultUrl
currentSlug = null

@ -199,5 +199,21 @@ page.track = (fn) ->
return return
track = -> track = ->
tracker.call() for tracker in trackers consentGiven = Cookies.get('analyticsConsent')
consentAsked = Cookies.get('analyticsConsentAsked')
if consentGiven == '1'
tracker.call() for tracker in trackers
else if consentGiven == undefined and consentAsked == undefined
# Only ask for consent once per browser session
Cookies.set('analyticsConsentAsked', '1')
new app.views.Notif 'AnalyticsConsent', autoHide: null
return
@resetAnalytics = ->
for cookie in document.cookie.split(/;\s?/)
name = cookie.split('=')[0]
if name[0] == '_'
Cookies.expire(name)
return return

@ -352,6 +352,10 @@ isIE = null
$.isIE = -> $.isIE = ->
isIE ?= navigator.userAgent?.indexOf('MSIE') >= 0 || navigator.userAgent?.indexOf('rv:11.0') >= 0 isIE ?= navigator.userAgent?.indexOf('MSIE') >= 0 || navigator.userAgent?.indexOf('rv:11.0') >= 0
isChromeForAndroid = null
$.isChromeForAndroid = ->
isChromeForAndroid ?= navigator.userAgent?.indexOf('Android') >= 0 && /Chrome\/([.0-9])+ Mobile/.test(navigator.userAgent)
isAndroid = null isAndroid = null
$.isAndroid = -> $.isAndroid = ->
isAndroid ?= navigator.userAgent?.indexOf('Android') >= 0 isAndroid ?= navigator.userAgent?.indexOf('Android') >= 0

@ -142,4 +142,6 @@ class app.models.Doc extends app.Model
return return
isOutdated: (status) -> isOutdated: (status) ->
status and status.installed and @mtime isnt status.mtime return false if not status
isInstalled = status.installed or app.settings.get('autoInstall')
isInstalled and @mtime isnt status.mtime

@ -1,4 +1,12 @@
[ [
[
"2019-07-21",
"Fixed several bugs, added an option to automatically download documentation and <a href=\"https://github.com/freeCodeCamp/devdocs/pulls?utf8=%E2%9C%93&q=is%3Apr+is%3Aclosed+sort%3Aupdated-desc+closed%3A%3E2019-07-18+977+988+986+870+886+1024+979+975+941+831+1005+848+942\" target=\"_blank\">more</a>."
],
[
"2019-07-19",
"Replaced the AppCache with a Service Worker (which makes DevDocs an installable PWA) and fixed layout preferences on Firefox."
],
[ [
"2018-09-23", "2018-09-23",
"New documentations: <a href=\"/puppeteer/\">Puppeteer</a> and <a href=\"/handlebars/\">Handlebars.js</a>" "New documentations: <a href=\"/puppeteer/\">Puppeteer</a> and <a href=\"/handlebars/\">Handlebars.js</a>"

@ -12,8 +12,8 @@ app.templates.notFoundPage = ->
app.templates.pageLoadError = -> app.templates.pageLoadError = ->
error """ The page failed to load. """, error """ The page failed to load. """,
""" It may be missing from the server (try reloading the app) or you could be offline.<br> """ It may be missing from the server (try reloading the app) or you could be offline (try <a href="/offline">installing the documentation for offline usage</a> when online again).<br>
If you keep seeing this, you're likely behind a proxy or firewall that blocks cross-domain requests. """, If you're online and you keep seeing this, you're likely behind a proxy or firewall that blocks cross-domain requests. """,
""" #{back} &middot; <a href="/##{location.pathname}" target="_top" class="_error-link">Reload</a> """ #{back} &middot; <a href="/##{location.pathname}" target="_top" class="_error-link">Reload</a>
&middot; <a href="#" class="_error-link" data-retry>Retry</a> """ &middot; <a href="#" class="_error-link" data-retry>Retry</a> """
@ -57,9 +57,9 @@ app.templates.unsupportedBrowser = """
<p class="_fail-text">DevDocs is an API documentation browser which supports the following browsers: <p class="_fail-text">DevDocs is an API documentation browser which supports the following browsers:
<ul class="_fail-list"> <ul class="_fail-list">
<li>Recent versions of Firefox, Chrome, or Opera <li>Recent versions of Firefox, Chrome, or Opera
<li>Safari 9.1+ <li>Safari 11.1+
<li>Edge 16+ <li>Edge 17+
<li>iOS 10+ <li>iOS 11.3+
</ul> </ul>
<p class="_fail-text"> <p class="_fail-text">
If you're unable to upgrade, we apologize. If you're unable to upgrade, we apologize.

@ -68,3 +68,9 @@ app.templates.notifShare = ->
app.templates.notifUpdateDocs = -> app.templates.notifUpdateDocs = ->
textNotif """ Documentation updates available. """, textNotif """ Documentation updates available. """,
""" <a href="/offline">Install them</a> as soon as possible to avoid broken pages. """ """ <a href="/offline">Install them</a> as soon as possible to avoid broken pages. """
app.templates.notifAnalyticsConsent = ->
textNotif """ Tracking cookies """,
""" We would like to gather usage data about how DevDocs is used through Google Analytics and Gauges. We only collect anonymous traffic information.
Please confirm if you accept our tracking cookies. You can always change your decision in the settings.
<br><span class="_notif-right"><a href="#" data-behavior="accept-analytics">Accept</a> or <a href="#" data-behavior="decline-analytics">Decline</a></span> """

@ -73,7 +73,8 @@ app.templates.aboutPage = -> """
<ul> <ul>
<li><a href="https://devdocs.io">devdocs.io</a> ("App") is operated by <a href="https://www.freecodecamp.org/">freeCodeCamp</a> ("We"). <li><a href="https://devdocs.io">devdocs.io</a> ("App") is operated by <a href="https://www.freecodecamp.org/">freeCodeCamp</a> ("We").
<li>We do not collect personal information through the app. <li>We do not collect personal information through the app.
<li>We use Google Analytics, Gauges and Sentry to collect anonymous traffic information and improve the app. <li>We use Google Analytics and Gauges to collect anonymous traffic information if you have given consent to this. You can change your decision in the <a href="/settings">settings</a>.
<li>We use Sentry to collect crash data and improve the app.
<li>The app uses cookies to store user preferences. <li>The app uses cookies to store user preferences.
<li>By using the app, you signify your acceptance of this policy. If you do not agree to this policy, please do not use the app. <li>By using the app, you signify your acceptance of this policy. If you do not agree to this policy, please do not use the app.
<li>If you have any questions regarding privacy, please email <a href="mailto:privacy@freecodecamp.org">privacy@freecodecamp.org</a>. <li>If you have any questions regarding privacy, please email <a href="mailto:privacy@freecodecamp.org">privacy@freecodecamp.org</a>.

@ -25,8 +25,8 @@ app.templates.offlinePage = (docs) -> """
<h2 class="_block-heading">Questions & Answers</h2> <h2 class="_block-heading">Questions & Answers</h2>
<dl> <dl>
<dt>How does this work? <dt>How does this work?
<dd>Each page is cached as a key-value pair in <a href="https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API">IndexedDB</a> (downloaded from a single file).<br> <dd>Each page is cached as a key-value pair in <a href="https://devdocs.io/dom/indexeddb_api">IndexedDB</a> (downloaded from a single file).<br>
The app also uses <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Using_the_application_cache">AppCache</a> and <a href="https://developer.mozilla.org/en-US/docs/Web/API/Web_Storage_API">localStorage</a> to cache the assets and index files. The app also uses <a href="https://devdocs.io/dom/service_worker_api/using_service_workers">Service Workers</a> and <a href="https://devdocs.io/dom/web_storage_api">localStorage</a> to cache the assets and index files.
<dt>Can I close the tab/browser? <dt>Can I close the tab/browser?
<dd>#{canICloseTheTab()} <dd>#{canICloseTheTab()}
<dt>What if I don't update a documentation? <dt>What if I don't update a documentation?
@ -41,10 +41,15 @@ app.templates.offlinePage = (docs) -> """
""" """
canICloseTheTab = -> canICloseTheTab = ->
if app.AppCache.isEnabled() if app.ServiceWorker.isEnabled()
""" Yes! Even offline, you can open a new tab, go to <a href="//devdocs.io">devdocs.io</a>, and everything will work as if you were online (provided you installed all the documentations you want to use beforehand). """ """ Yes! Even offline, you can open a new tab, go to <a href="//devdocs.io">devdocs.io</a>, and everything will work as if you were online (provided you installed all the documentations you want to use beforehand). """
else else
""" No. AppCache isn't available in your browser (or is disabled), so loading <a href="//devdocs.io">devdocs.io</a> offline won't work.<br> reason = "aren't available in your browser (or are disabled)"
if app.config.env != 'production'
reason = "are disabled in your development instance of DevDocs (enable them by setting the <code>ENABLE_SERVICE_WORKER</code> environment variable to <code>true</code>)"
""" No. Service Workers #{reason}, so loading <a href="//devdocs.io">devdocs.io</a> offline won't work.<br>
The current tab will continue to function even when you go offline (provided you installed all the documentations beforehand). """ The current tab will continue to function even when you go offline (provided you installed all the documentations beforehand). """
app.templates.offlineDoc = (doc, status) -> app.templates.offlineDoc = (doc, status) ->

@ -8,7 +8,7 @@ app.templates.intro = """
<p>Thanks for downloading DevDocs. Here are a few things you should know: <p>Thanks for downloading DevDocs. Here are a few things you should know:
<ol class="_intro-list"> <ol class="_intro-list">
<li>Your local version of DevDocs won't self-update. Unless you're modifying the code, <li>Your local version of DevDocs won't self-update. Unless you're modifying the code,
I&nbsp;recommend using the hosted version at <a href="https://devdocs.io">devdocs.io</a>. we&nbsp;recommend using the hosted version at <a href="https://devdocs.io">devdocs.io</a>.
<li>Run <code>thor docs:list</code> to see all available documentations. <li>Run <code>thor docs:list</code> to see all available documentations.
<li>Run <code>thor docs:download &lt;name&gt;</code> to download documentations. <li>Run <code>thor docs:download &lt;name&gt;</code> to download documentations.
<li>Run <code>thor docs:download --installed</code> to update all downloaded documentations. <li>Run <code>thor docs:download --installed</code> to update all downloaded documentations.
@ -39,7 +39,7 @@ app.templates.intro = """
<li>DevDocs works <a href="/offline">offline</a>, on mobile, and can be installed on <a href="https://chrome.google.com/webstore/detail/devdocs/mnfehgbmkapmjnhcnbodoamcioleeooe">Chrome</a>. <li>DevDocs works <a href="/offline">offline</a>, on mobile, and can be installed on <a href="https://chrome.google.com/webstore/detail/devdocs/mnfehgbmkapmjnhcnbodoamcioleeooe">Chrome</a>.
<li>For the latest news, follow <a href="https://twitter.com/DevDocs">@DevDocs</a>. <li>For the latest news, follow <a href="https://twitter.com/DevDocs">@DevDocs</a>.
<li>DevDocs is free and <a href="https://github.com/freeCodeCamp/devdocs">open source</a>. <li>DevDocs is free and <a href="https://github.com/freeCodeCamp/devdocs">open source</a>.
<iframe class="_github-btn" src="//ghbtns.com/github-btn.html?user=freeCodeCamp&repo=devdocs&type=watch&count=true" allowtransparency="true" frameborder="0" scrolling="0" width="100" height="20"></iframe> <object data="https://img.shields.io/github/stars/freeCodeCamp/devdocs.svg?style=social" type="image/svg+xml" aria-hidden="true"></object>
<li>And if you're new to coding, check out <a href="https://www.freecodecamp.org/">freeCodeCamp's open source curriculum</a>. <li>And if you're new to coding, check out <a href="https://www.freecodecamp.org/">freeCodeCamp's open source curriculum</a>.
</ol> </ol>
<p>Happy coding! <p>Happy coding!

@ -15,6 +15,14 @@ app.templates.settingsPage = (settings) -> """
<input type="checkbox" form="settings" name="layout" value="_sidebar-hidden"#{if settings['_sidebar-hidden'] then ' checked' else ''}>Automatically hide and show the sidebar <input type="checkbox" form="settings" name="layout" value="_sidebar-hidden"#{if settings['_sidebar-hidden'] then ' checked' else ''}>Automatically hide and show the sidebar
<small>Tip: drag the edge of the sidebar to resize it.</small> <small>Tip: drag the edge of the sidebar to resize it.</small>
</label> </label>
<label class="_settings-label">
<input type="checkbox" form="settings" name="autoInstall" value="_auto-install"#{if settings.autoInstall then ' checked' else ''}>Automatically download documentation for offline use
<small>Only enable this when bandwidth isn't a concern to you.</small>
</label>
<label class="_settings-label">
<input type="checkbox" form="settings" name="analyticsConsent"#{if settings.analyticsConsent then ' checked' else ''}>Enable tracking cookies
<small>With this checked, we enable Google Analytics and Gauges to collect anonymous traffic information.</small>
</label>
</div> </div>
</div> </div>

@ -1,28 +1,32 @@
try { try {
if (app.config.env == 'production') { if (app.config.env === 'production') {
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ if (Cookies.get('analyticsConsent') === '1') {
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga'); m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
ga('create', 'UA-5544833-12', 'devdocs.io'); })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
page.track(function() { ga('create', 'UA-5544833-12', 'devdocs.io');
ga('send', 'pageview', { page.track(function() {
page: location.pathname + location.search + location.hash, ga('send', 'pageview', {
dimension1: app.router.context && app.router.context.doc && app.router.context.doc.slug_without_version page: location.pathname + location.search + location.hash,
dimension1: app.router.context && app.router.context.doc && app.router.context.doc.slug_without_version
});
}); });
});
page.track(function() { page.track(function() {
if (window._gauges) if (window._gauges)
_gauges.push(['track']); _gauges.push(['track']);
else else
(function() { (function() {
var _gauges=_gauges||[];!function(){var a=document.createElement("script"); var _gauges=_gauges||[];!function(){var a=document.createElement("script");
a.type="text/javascript",a.async=!0,a.id="gauges-tracker", a.type="text/javascript",a.async=!0,a.id="gauges-tracker",
a.setAttribute("data-site-id","51c15f82613f5d7819000067"), a.setAttribute("data-site-id","51c15f82613f5d7819000067"),
a.src="https://secure.gaug.es/track.js";var b=document.getElementsByTagName("script")[0]; a.src="https://secure.gaug.es/track.js";var b=document.getElementsByTagName("script")[0];
b.parentNode.insertBefore(a,b)}(); b.parentNode.insertBefore(a,b)}();
})(); })();
}); });
} else {
resetAnalytics();
}
} }
} catch(e) { } } catch(e) { }

@ -153,6 +153,9 @@ class app.views.Content extends app.View
return return
afterRoute: (route, context) => afterRoute: (route, context) =>
if route != 'entry' and route != 'type'
resetFavicon()
switch route switch route
when 'root' when 'root'
@show @rootPage @show @rootPage

@ -40,6 +40,7 @@ class app.views.EntryPage extends app.View
if app.disabledDocs.findBy 'slug', @entry.doc.slug if app.disabledDocs.findBy 'slug', @entry.doc.slug
@hiddenView = new app.views.HiddenPage @el, @entry @hiddenView = new app.views.HiddenPage @el, @entry
setFaviconForDoc(@entry.doc)
@delay @polyfillMathML @delay @polyfillMathML
@trigger 'loaded' @trigger 'loaded'
return return
@ -123,7 +124,7 @@ class app.views.EntryPage extends app.View
@render @tmpl('pageLoadError') @render @tmpl('pageLoadError')
@resetClass() @resetClass()
@addClass @constructor.errorClass @addClass @constructor.errorClass
app.appCache?.update() app.serviceWorker?.update()
return return
cache: -> cache: ->

@ -1,7 +1,4 @@
class app.views.SettingsPage extends app.View class app.views.SettingsPage extends app.View
LAYOUTS = ['_max-width', '_sidebar-hidden', '_native-scrollbars']
SIDEBAR_HIDDEN_LAYOUT = '_sidebar-hidden'
@className: '_static' @className: '_static'
@events: @events:
@ -17,31 +14,31 @@ class app.views.SettingsPage extends app.View
settings.dark = app.settings.get('dark') settings.dark = app.settings.get('dark')
settings.smoothScroll = !app.settings.get('fastScroll') settings.smoothScroll = !app.settings.get('fastScroll')
settings.arrowScroll = app.settings.get('arrowScroll') settings.arrowScroll = app.settings.get('arrowScroll')
settings[layout] = app.settings.hasLayout(layout) for layout in LAYOUTS settings.autoInstall = app.settings.get('autoInstall')
settings.analyticsConsent = app.settings.get('analyticsConsent')
settings[layout] = app.settings.hasLayout(layout) for layout in app.settings.LAYOUTS
settings settings
getTitle: -> getTitle: ->
'Preferences' 'Preferences'
toggleDark: (enable) -> toggleDark: (enable) ->
html = document.documentElement
html.classList.toggle('_theme-default')
html.classList.toggle('_theme-dark')
app.settings.set('dark', !!enable) app.settings.set('dark', !!enable)
app.appCache?.updateInBackground()
return return
toggleLayout: (layout, enable) -> toggleLayout: (layout, enable) ->
document.body.classList[if enable then 'add' else 'remove'](layout) unless layout is SIDEBAR_HIDDEN_LAYOUT
document.body.classList[if $.overlayScrollbarsEnabled() then 'add' else 'remove']('_overlay-scrollbars')
app.settings.setLayout(layout, enable) app.settings.setLayout(layout, enable)
app.appCache?.updateInBackground()
return return
toggleSmoothScroll: (enable) -> toggleSmoothScroll: (enable) ->
app.settings.set('fastScroll', !enable) app.settings.set('fastScroll', !enable)
return return
toggleAnalyticsConsent: (enable) ->
app.settings.set('analyticsConsent', if enable then '1' else '0')
resetAnalytics() unless enable
return
toggle: (name, enable) -> toggle: (name, enable) ->
app.settings.set(name, enable) app.settings.set(name, enable)
return return
@ -85,6 +82,8 @@ class app.views.SettingsPage extends app.View
@toggleSmoothScroll input.checked @toggleSmoothScroll input.checked
when 'import' when 'import'
@import input.files[0], input @import input.files[0], input
when 'analyticsConsent'
@toggleAnalyticsConsent input.checked
else else
@toggle input.name, input.checked @toggle input.name, input.checked
return return

@ -9,6 +9,7 @@ class app.views.TypePage extends app.View
render: (@type) -> render: (@type) ->
@html @tmpl('typePage', @type) @html @tmpl('typePage', @type)
setFaviconForDoc(@type.doc)
return return
getTitle: -> getTitle: ->

@ -75,9 +75,11 @@ class app.views.Document extends app.View
return unless target.hasAttribute('data-behavior') return unless target.hasAttribute('data-behavior')
$.stopEvent(event) $.stopEvent(event)
switch target.getAttribute('data-behavior') switch target.getAttribute('data-behavior')
when 'back' then history.back() when 'back' then history.back()
when 'reload' then window.location.reload() when 'reload' then window.location.reload()
when 'reboot' then app.reboot() when 'reboot' then app.reboot()
when 'hard-reload' then app.reload() when 'hard-reload' then app.reload()
when 'reset' then app.reset() if confirm('Are you sure you want to reset DevDocs?') when 'reset' then app.reset() if confirm('Are you sure you want to reset DevDocs?')
when 'accept-analytics' then Cookies.set('analyticsConsent', '1') && app.reboot()
when 'decline-analytics' then Cookies.set('analyticsConsent', '0') && app.reboot()
return return

@ -11,9 +11,6 @@ class app.views.Resizer extends app.View
init: -> init: ->
@el.setAttribute('draggable', 'true') @el.setAttribute('draggable', 'true')
@appendTo $('._app') @appendTo $('._app')
@style = $('style[data-resizer]')
@size = @style.getAttribute('data-size')
return return
MIN = 260 MIN = 260
@ -24,15 +21,11 @@ class app.views.Resizer extends app.View
return unless value > 0 return unless value > 0
value = Math.min(Math.max(Math.round(value), MIN), MAX) value = Math.min(Math.max(Math.round(value), MIN), MAX)
newSize = "#{value}px" newSize = "#{value}px"
@style.innerHTML = @style.innerHTML.replace(new RegExp(@size, 'g'), newSize) document.documentElement.style.setProperty('--sidebarWidth', newSize)
@size = newSize app.settings.setSize(value) if save
if save
app.settings.setSize(value)
app.appCache?.updateInBackground()
return return
onDragStart: (event) => onDragStart: (event) =>
@style.removeAttribute('disabled')
event.dataTransfer.effectAllowed = 'link' event.dataTransfer.effectAllowed = 'link'
event.dataTransfer.setData('Text', '') event.dataTransfer.setData('Text', '')
$.on(window, 'dragover', @onDrag) $.on(window, 'dragover', @onDrag)

@ -25,7 +25,6 @@ class app.views.Settings extends app.View
if super if super
@render() @render()
document.body.classList.remove(SIDEBAR_HIDDEN_LAYOUT) document.body.classList.remove(SIDEBAR_HIDDEN_LAYOUT)
app.appCache?.on 'progress', @onAppCacheProgress
return return
deactivate: -> deactivate: ->
@ -33,7 +32,6 @@ class app.views.Settings extends app.View
@resetClass() @resetClass()
@docPicker.detach() @docPicker.detach()
document.body.classList.add(SIDEBAR_HIDDEN_LAYOUT) if app.settings.hasLayout(SIDEBAR_HIDDEN_LAYOUT) document.body.classList.add(SIDEBAR_HIDDEN_LAYOUT) if app.settings.hasLayout(SIDEBAR_HIDDEN_LAYOUT)
app.appCache?.off 'progress', @onAppCacheProgress
return return
render: -> render: ->
@ -52,7 +50,7 @@ class app.views.Settings extends app.View
docs = @docPicker.getSelectedDocs() docs = @docPicker.getSelectedDocs()
app.settings.setDocs(docs) app.settings.setDocs(docs)
@saveBtn.textContent = if app.appCache then 'Downloading\u2026' else 'Saving\u2026' @saveBtn.textContent = 'Saving\u2026'
disabledDocs = new app.collections.Docs(doc for doc in app.docs.all() when docs.indexOf(doc.slug) is -1) disabledDocs = new app.collections.Docs(doc for doc in app.docs.all() when docs.indexOf(doc.slug) is -1)
disabledDocs.uninstall -> disabledDocs.uninstall ->
app.db.migrate() app.db.migrate()
@ -83,9 +81,3 @@ class app.views.Settings extends app.View
$.stopEvent(event) $.stopEvent(event)
app.router.show '/' app.router.show '/'
return return
onAppCacheProgress: (event) =>
if event.lengthComputable
percentage = Math.round event.loaded * 100 / event.total
@saveBtn.textContent = "Downloading\u2026 (#{percentage}%)"
return

@ -30,6 +30,9 @@ class app.views.Search extends app.View
.on 'results', @onResults .on 'results', @onResults
.on 'end', @onEnd .on 'end', @onEnd
@scope
.on 'change', @onScopeChange
app.on 'ready', @onReady app.on 'ready', @onReady
$.on window, 'hashchange', @searchUrl $.on window, 'hashchange', @searchUrl
$.on window, 'focus', @onWindowFocus $.on window, 'focus', @onWindowFocus
@ -138,6 +141,11 @@ class app.views.Search extends app.View
$.stopEvent(event) $.stopEvent(event)
return return
onScopeChange: =>
@value = ''
@onInput()
return
afterRoute: (name, context) => afterRoute: (name, context) =>
return if app.shortcuts.eventInProgress?.name is 'escape' return if app.shortcuts.eventInProgress?.name is 'escape'
@reset(true) if not context.init and app.router.isIndex() @reset(true) if not context.init and app.router.isIndex()

@ -6,7 +6,9 @@ class app.views.SearchScope extends app.View
tag: '._search-tag' tag: '._search-tag'
@events: @events:
click: 'onClick'
keydown: 'onKeydown' keydown: 'onKeydown'
textInput: 'onTextInput'
@routes: @routes:
after: 'afterRoute' after: 'afterRoute'
@ -87,17 +89,33 @@ class app.views.SearchScope extends app.View
@trigger 'change', null, previousDoc @trigger 'change', null, previousDoc
return return
doScopeSearch: (event) =>
@search @input.value[0...@input.selectionStart]
$.stopEvent(event) if @doc
return
onClick: (event) =>
if event.target is @tag
@reset()
$.stopEvent(event)
return
onKeydown: (event) => onKeydown: (event) =>
if event.which is 8 # backspace if event.which is 8 # backspace
if @doc and not @input.value if @doc and @input.selectionEnd is 0
$.stopEvent(event)
@reset() @reset()
else if not @doc and @input.value $.stopEvent(event)
else if not @doc and @input.value and not $.isChromeForAndroid()
return if event.ctrlKey or event.metaKey or event.altKey or event.shiftKey return if event.ctrlKey or event.metaKey or event.altKey or event.shiftKey
if event.which is 9 or # tab if event.which is 9 or # tab
(event.which is 32 and app.isMobile()) # space (event.which is 32 and app.isMobile()) # space
@search @input.value[0...@input.selectionStart] @doScopeSearch(event)
$.stopEvent(event) if @doc return
onTextInput: (event) =>
return unless $.isChromeForAndroid()
if not @doc and @input.value and event.data == ' '
@doScopeSearch(event)
return return
extractHashValue: -> extractHashValue: ->

@ -28,7 +28,7 @@ class app.views.Sidebar extends app.View
app.on 'ready', @onReady app.on 'ready', @onReady
$.on document.documentElement, 'mouseleave', (event) => @display() if event.clientX < 10 $.on document.documentElement, 'mouseleave', (event) => @display() unless event.clientX <= 0
$.on document.documentElement, 'mouseenter', => @resetDisplay(forceNoHover: false) $.on document.documentElement, 'mouseenter', => @resetDisplay(forceNoHover: false)
return return

@ -1,7 +1,6 @@
//= depend_on docs-1.png //= depend_on sprites/docs.png
//= depend_on docs-1@2x.png //= depend_on sprites/docs@2x.png
//= depend_on docs-2.png //= depend_on sprites/docs.json
//= depend_on docs-2@2x.png
/*! /*!
* Copyright 2013-2019 Thibaut Courouble and other contributors * Copyright 2013-2019 Thibaut Courouble and other contributors

@ -215,5 +215,6 @@
color: var(--textColorLight); color: var(--textColorLight);
background: var(--searchTagBackground); background: var(--searchTagBackground);
border-radius: 2px; border-radius: 2px;
cursor: pointer;
@extend %truncate-text; @extend %truncate-text;
} }

@ -134,3 +134,7 @@
._notif-info { color: var(--textColorLight); } ._notif-info { color: var(--textColorLight); }
} }
._notif-right {
float: right;
}

@ -1,182 +0,0 @@
%svg-icon {
display: inline-block;
vertical-align: top;
width: 1rem;
height: 1rem;
pointer-events: none;
fill: currentColor;
}
%doc-icon {
content: '';
display: block;
width: 1rem;
height: 1rem;
background-image: image-url('docs-1.png');
background-size: 10rem 10rem;
}
%doc-icon-2 { background-image: image-url('docs-2.png') !important; }
@media (-webkit-min-device-pixel-ratio: 1.5), (min-resolution: 144dpi) {
%doc-icon { background-image: image-url('docs-1@2x.png'); }
%doc-icon-2 { background-image: image-url('docs-2@2x.png') !important; }
}
html._theme-dark {
%darkIconFix {
filter: invert(100%) grayscale(100%);
-webkit-filter: invert(100%) grayscale(100%);
}
}
._icon-jest:before { background-position: 0 0; }
._icon-liquid:before { background-position: -1rem 0; }
._icon-openjdk:before { background-position: -2rem 0; }
._icon-codeceptjs:before { background-position: -3rem 0; }
._icon-codeception:before { background-position: -4rem 0; }
._icon-sqlite:before { background-position: -5rem 0; @extend %darkIconFix !optional; }
._icon-async:before { background-position: -6rem 0; @extend %darkIconFix !optional; }
._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,
._icon-node_lts:before { background-position: -6rem -1rem; }
._icon-sass:before { background-position: -7rem -1rem; }
._icon-less:before { background-position: -8rem -1rem; }
._icon-angularjs:before { background-position: -9rem -1rem; }
._icon-coffeescript:before { background-position: 0 -2rem; @extend %darkIconFix !optional; }
._icon-ember:before { background-position: -1rem -2rem; }
._icon-yarn:before { background-position: -2rem -2rem; }
._icon-immutable:before { background-position: -3rem -2rem; @extend %darkIconFix !optional; }
._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-statsmodels:before { 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-rust:before { background-position: -4rem -4rem; @extend %darkIconFix !optional; }
._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; }
._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-xslt_xpath:before { background-position: -3rem -5rem; }
._icon-nginx:before,
._icon-nginx_lua_module:before { background-position: -4rem -5rem; }
._icon-svg:before { background-position: -5rem -5rem; }
._icon-marionette:before { background-position: -6rem -5rem; }
._icon-jsdoc:before,
._icon-koa:before,
._icon-graphite:before,
._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-fish:before { background-position: -5rem -6rem; @extend %darkIconFix !optional; }
._icon-scikit_image:before { background-position: -6rem -6rem; }
._icon-twig:before { background-position: -7rem -6rem; }
._icon-pandas:before { background-position: -8rem -6rem; }
._icon-scikit_learn:before { background-position: -9rem -6rem; }
._icon-bottle:before { background-position: 0 -7rem; }
._icon-docker:before { background-position: -1rem -7rem; }
._icon-cakephp:before { background-position: -2rem -7rem; }
._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; }
._icon-drupal:before { background-position: 0 -8rem; }
._icon-webpack:before { background-position: -1rem -8rem; }
._icon-phaser:before { background-position: -2rem -8rem; }
._icon-vue:before { background-position: -3rem -8rem; }
._icon-opentsdb:before { background-position: -4rem -8rem; }
._icon-q:before { background-position: -5rem -8rem; }
._icon-crystal:before { background-position: -6rem -8rem; @extend %darkIconFix !optional; }
._icon-julia:before { background-position: -7rem -8rem; @extend %darkIconFix !optional; }
._icon-redux:before { background-position: -8rem -8rem; @extend %darkIconFix !optional; }
._icon-bootstrap:before { background-position: -9rem -8rem; }
._icon-react_native:before { background-position: 0 -9rem; }
._icon-phalcon:before { background-position: -1rem -9rem; }
._icon-matplotlib:before { background-position: -2rem -9rem; }
._icon-cmake:before { background-position: -3rem -9rem; }
._icon-elixir:before { background-position: -4rem -9rem; @extend %darkIconFix !optional; }
._icon-vagrant:before { background-position: -5rem -9rem; }
._icon-dojo:before { background-position: -6rem -9rem; }
._icon-flow:before { background-position: -7rem -9rem; }
._icon-relay:before { background-position: -8rem -9rem; }
._icon-phoenix:before { background-position: -9rem -9rem; }
._icon-tcl_tk:before { background-position: 0 0; @extend %doc-icon-2; }
._icon-erlang:before { background-position: -1rem 0; @extend %doc-icon-2; }
._icon-chef:before { background-position: -2rem 0; @extend %doc-icon-2; }
._icon-ramda:before { background-position: -3rem 0; @extend %doc-icon-2; @extend %darkIconFix !optional; }
._icon-codeigniter:before { background-position: -4rem 0; @extend %doc-icon-2; @extend %darkIconFix !optional; }
._icon-influxdata:before { background-position: -5rem 0; @extend %doc-icon-2; @extend %darkIconFix !optional; }
._icon-tensorflow:before { background-position: -6rem 0; @extend %doc-icon-2; }
._icon-haxe:before { background-position: -7rem 0; @extend %doc-icon-2; }
._icon-ansible:before { background-position: -8rem 0; @extend %doc-icon-2; @extend %darkIconFix !optional; }
._icon-typescript:before { background-position: -9rem 0; @extend %doc-icon-2; }
._icon-browser_support_tables:before { background-position: 0rem -1rem; @extend %doc-icon-2; }
._icon-gnu_fortran:before { background-position: -1rem -1rem; @extend %doc-icon-2; }
._icon-gcc:before { background-position: -2rem -1rem; @extend %doc-icon-2; }
._icon-perl:before { background-position: -3rem -1rem; @extend %doc-icon-2; }
._icon-apache_pig:before { background-position: -4rem -1rem; @extend %doc-icon-2; }
._icon-numpy:before { background-position: -5rem -1rem; @extend %doc-icon-2; }
._icon-kotlin:before { background-position: -6rem -1rem; @extend %doc-icon-2; }
._icon-padrino:before { background-position: -7rem -1rem; @extend %doc-icon-2; }
._icon-angular:before { background-position: -8rem -1rem; @extend %doc-icon-2; }
._icon-love:before { background-position: -9rem -1rem; @extend %doc-icon-2; }
._icon-jasmine:before { background-position: 0 -2rem; @extend %doc-icon-2; }
._icon-pug:before { background-position: -1rem -2rem; @extend %doc-icon-2; }
._icon-electron:before { background-position: -2rem -2rem; @extend %doc-icon-2; }
._icon-falcon:before { background-position: -3rem -2rem; @extend %doc-icon-2; }
._icon-godot:before { background-position: -4rem -2rem; @extend %doc-icon-2; }
._icon-nim:before { background-position: -5rem -2rem; @extend %doc-icon-2; @extend %darkIconFix !optional; }
._icon-vulkan:before { background-position: -6rem -2rem; @extend %doc-icon-2; @extend %darkIconFix !optional; }
._icon-d:before { background-position: -7rem -2rem; @extend %doc-icon-2; }
._icon-bluebird:before { background-position: -8rem -2rem; @extend %doc-icon-2; }
._icon-eslint:before { background-position: -9rem -2rem; @extend %doc-icon-2; }
._icon-homebrew:before { background-position: 0 -3rem; @extend %doc-icon-2; }
._icon-jekyll:before { background-position: -1rem -3rem; @extend %doc-icon-2; }
._icon-babel:before { background-position: -2rem -3rem; @extend %doc-icon-2; }
._icon-leaflet:before { background-position: -3rem -3rem; @extend %doc-icon-2; }
._icon-terraform:before { background-position: -4rem -3rem; @extend %doc-icon-2; }
._icon-pygame:before { background-position: -5rem -3rem; @extend %doc-icon-2; }
._icon-bash:before { background-position: -6rem -3rem; @extend %doc-icon-2; }
._icon-dart:before { background-position: -7rem -3rem; @extend %doc-icon-2; }
._icon-qt:before { background-position: -8rem -3rem; @extend %doc-icon-2; }
._icon-puppeteer:before { background-position: -9rem -3rem; @extend %doc-icon-2; }
._icon-handlebars:before { background-position: 0 -4rem; @extend %doc-icon-2; @extend %darkIconFix !optional; }

@ -0,0 +1,43 @@
<% manifest = JSON.parse(File.read('assets/images/sprites/docs.json')) %>
%svg-icon {
display: inline-block;
vertical-align: top;
width: 1rem;
height: 1rem;
pointer-events: none;
fill: currentColor;
}
%doc-icon {
content: '';
display: block;
width: 1rem;
height: 1rem;
background-image: image-url('sprites/docs.png');
background-size: <%= manifest['icons_per_row'] %>rem <%= manifest['icons_per_row'] %>rem;
}
@media (-webkit-min-device-pixel-ratio: 1.5), (min-resolution: 144dpi) {
%doc-icon { background-image: image-url('sprites/docs@2x.png'); }
}
html._theme-dark {
%darkIconFix {
filter: invert(100%) grayscale(100%);
-webkit-filter: invert(100%) grayscale(100%);
}
}
<%=
items = []
manifest['items'].each do |item|
rules = []
rules << "background-position: -#{item['col']}rem -#{item['row']}rem;"
rules << "@extend %darkIconFix !optional;" if item['dark_icon_fix']
items << "._icon-#{item['type']}:before { #{rules.join(' ')} }"
end
items.join('')
%>

@ -15,8 +15,9 @@ Adding a documentation may look like a daunting task but once you get the hang o
8. Tweak the scraper/filters and repeat 5) and 6) until the pages and metadata are ok. 8. Tweak the scraper/filters and repeat 5) and 6) until the pages and metadata are ok.
9. To customize the pages' styling, create an SCSS file in the `assets/stylesheets/pages/` directory and import it in both `application.css.scss` AND `application-dark.css.scss`. Both the file and CSS class should be named `_[type]` where [type] is equal to the scraper's `type` attribute (documentations with the same type share the same custom CSS and JS). Setting the type to `simple` will apply the general styling rules in `assets/stylesheets/pages/_simple.scss`, which can be used for documentations where little to no CSS changes are needed. 9. To customize the pages' styling, create an SCSS file in the `assets/stylesheets/pages/` directory and import it in both `application.css.scss` AND `application-dark.css.scss`. Both the file and CSS class should be named `_[type]` where [type] is equal to the scraper's `type` attribute (documentations with the same type share the same custom CSS and JS). Setting the type to `simple` will apply the general styling rules in `assets/stylesheets/pages/_simple.scss`, which can be used for documentations where little to no CSS changes are needed.
10. To add syntax highlighting or execute custom JavaScript on the pages, create a file in the `assets/javascripts/views/pages/` directory (take a look at the other files to see how it works). 10. To add syntax highlighting or execute custom JavaScript on the pages, create a file in the `assets/javascripts/views/pages/` directory (take a look at the other files to see how it works).
11. Add the documentation's icon in the `public/icons/docs/[my_doc]/` directory, in both 16x16 and 32x32-pixels formats. It'll be added to the icon spritesheet after your pull request is merged. 11. Add the documentation's icon in the `public/icons/docs/[my_doc]/` directory, in both 16x16 and 32x32-pixels formats. The icon spritesheet is automatically generated when you (re)start your local DevDocs instance.
12. Add the documentation's copyright details to the list in `assets/javascripts/templates/pages/about_tmpl.coffee`. This is the data shown in the table on the [about](https://devdocs.io/about) page, and is ordered alphabetically. Simply copying an existing item, placing it in the right slot and updating the values to match the new scraper will do the job. 12. Add the documentation's copyright details to the list in `assets/javascripts/templates/pages/about_tmpl.coffee`. This is the data shown in the table on the [about](https://devdocs.io/about) page, and is ordered alphabetically. Simply copying an existing item, placing it in the right slot and updating the values to match the new scraper will do the job.
13. Ensure `thor updates:check [my_doc]` shows the correct latest version.
If the documentation includes more than a few hundreds pages and is available for download, try to scrape it locally (e.g. using `FileScraper`). It'll make the development process much faster and avoids putting too much load on the source site. (It's not a problem if your scraper is coupled to your local setup, just explain how it works in your pull request.) If the documentation includes more than a few hundreds pages and is available for download, try to scrape it locally (e.g. using `FileScraper`). It'll make the development process much faster and avoids putting too much load on the source site. (It's not a problem if your scraper is coupled to your local setup, just explain how it works in your pull request.)

@ -21,8 +21,7 @@ The process for updating docs is as follow:
- Commit the changes (protip: use the `thor docs:commit` command documented below). - Commit the changes (protip: use the `thor docs:commit` command documented below).
- Optional: do more updates. - Optional: do more updates.
- Run `thor docs:upload` (documented below). - Run `thor docs:upload` (documented below).
- [Deploy the app](#deploying-devdocs) and verify that everything works in production. - Push to GitHub to [deploy the app](#deploying-devdocs) and verify that everything works in production.
- Push to GitHub.
- Run `thor docs:clean` (documented below). - Run `thor docs:clean` (documented below).
Note: changes to `public/docs/docs.json` should never be committed. This file reflects which documentations have been downloaded or generated locally, which is always none on a fresh `git clone`. Note: changes to `public/docs/docs.json` should never be committed. This file reflects which documentations have been downloaded or generated locally, which is always none on a fresh `git clone`.
@ -82,13 +81,13 @@ In addition to the [publicly-documented commands](https://github.com/freeCodeCam
## Deploying DevDocs ## Deploying DevDocs
Once docs have been uploaded via `thor docs:upload` (if applicable), deploying DevDocs is as simple as running `git push heroku master`. See [Heroku's documentation](https://devcenter.heroku.com/articles/git) for more information. Once docs have been uploaded via `thor docs:upload` (if applicable), you can push to the DevDocs master branch (or merge the PR containing the updates). If the Travis build succeeds, the Heroku application will be deployed automatically.
- If you're deploying documentation updates, verify that the documentations work properly once the deploy is done (you will need to reload [devdocs.io](https://devdocs.io/) a couple times for the application cache to update and the new version to load). - If you're deploying documentation updates, verify that the documentations work properly once the deploy is done. Keep in mind that you'll need to wait a few seconds for the service worker to finish caching the new assets. You should see a "DevDocs has been updated" notification appear when the caching is done, after which you need to refresh the page to see the changes.
- If you're deploying frontend changes, monitor [Sentry](https://sentry.io/devdocs/devdocs-js/) for new JS errors once the deploy is done. - If you're deploying frontend changes, monitor [Sentry](https://sentry.io/devdocs/devdocs-js/) for new JS errors once the deploy is done.
- If you're deploying server changes, monitor New Relic (accessible through [the Heroku dashboard](https://dashboard.heroku.com/apps/devdocs)) for Ruby exceptions and throughput or response time changes once the deploy is done. - If you're deploying server changes, monitor New Relic (accessible through [the Heroku dashboard](https://dashboard.heroku.com/apps/devdocs)) for Ruby exceptions and throughput or response time changes once the deploy is done.
If any issue arises, run `heroku rollback` to rollback to the previous of the app (this can also be done via Heroku's UI). Note that this will not revert changes made to documentation files that were uploaded via `thor docs:upload`. Try and fix the issue as quickly as possible, then re-deploy the app. Reach out to other maintainers if you need help. If any issue arises, run `heroku rollback` to rollback to the previous version of the app (this can also be done via Heroku's UI). Note that this will not revert changes made to documentation files that were uploaded via `thor docs:upload`. Try and fix the issue as quickly as possible, then re-deploy the app. Reach out to other maintainers if you need help.
If this is your first deploy, make sure another maintainer is around to assist. If this is your first deploy, make sure another maintainer is around to assist.

@ -184,3 +184,44 @@ More information about how filters work is available on the [Filter Reference](.
Overrides the `:title` option for the root page only. Overrides the `:title` option for the root page only.
_Note: this filter is disabled by default._ _Note: this filter is disabled by default._
## Keeping scrapers up-to-date
In order to keep scrapers up-to-date the `get_latest_version(opts)` method should be overridden. If `self.release` is defined, this should return the latest version of the documentation. If `self.release` is not defined, it should return the Epoch time when the documentation was last modified. If the documentation will never change, simply return `1.0.0`. The result of this method is periodically reported in a "Documentation versions report" issue which helps maintainers keep track of outdated documentations.
To make life easier, there are a few utility methods that you can use in `get_latest_version`:
* `fetch(url, opts)`
Makes a GET request to the url and returns the response body.
Example: [lib/docs/scrapers/bash.rb](../lib/docs/scrapers/bash.rb)
* `fetch_doc(url, opts)`
Makes a GET request to the url and returns the HTML body converted to a Nokogiri document.
Example: [lib/docs/scrapers/git.rb](../lib/docs/scrapers/git.rb)
* `fetch_json(url, opts)`
Makes a GET request to the url and returns the JSON body converted to a dictionary.
Example: [lib/docs/scrapers/mdn/mdn.rb](../lib/docs/scrapers/mdn/mdn.rb)
* `get_npm_version(package, opts)`
Returns the latest version of the given npm package.
Example: [lib/docs/scrapers/bower.rb](../lib/docs/scrapers/bower.rb)
* `get_latest_github_release(owner, repo, opts)`
Returns the tag name of the latest GitHub release of the given repository. If the tag name is preceded by a "v", the "v" will be removed.
Example: [lib/docs/scrapers/jsdoc.rb](../lib/docs/scrapers/jsdoc.rb)
* `get_github_tags(owner, repo, opts)`
Returns the list of tags on the given repository ([format](https://developer.github.com/v3/repos/#list-tags)).
Example: [lib/docs/scrapers/liquid.rb](../lib/docs/scrapers/liquid.rb)
* `get_github_file_contents(owner, repo, path, opts)`
Returns the contents of the requested file in the default branch of the given repository.
Example: [lib/docs/scrapers/minitest.rb](../lib/docs/scrapers/minitest.rb)

@ -37,6 +37,9 @@ class App < Sinatra::Application
set :csp, false set :csp, false
require 'docs'
Docs.generate_manifest
Dir[docs_path, root.join(assets_prefix, '*/')].each do |path| Dir[docs_path, root.join(assets_prefix, '*/')].each do |path|
sprockets.append_path(path) sprockets.append_path(path)
end end
@ -50,6 +53,11 @@ class App < Sinatra::Application
end end
configure :test, :development do configure :test, :development do
require 'thor'
load 'tasks/sprites.thor'
SpritesCLI.new.invoke(:generate)
require 'active_support/per_thread_registry' require 'active_support/per_thread_registry'
require 'active_support/cache' require 'active_support/cache'
sprockets.cache = ActiveSupport::Cache.lookup_store :file_store, root.join('tmp', 'cache', 'assets', environment.to_s) sprockets.cache = ActiveSupport::Cache.lookup_store :file_store, root.join('tmp', 'cache', 'assets', environment.to_s)
@ -192,35 +200,45 @@ class App < Sinatra::Application
request.query_string.empty? ? nil : "?#{request.query_string}" request.query_string.empty? ? nil : "?#{request.query_string}"
end end
def manifest_asset_urls def service_worker_asset_urls
@@manifest_asset_urls ||= [ @@service_worker_asset_urls ||= [
javascript_path('application', asset_host: false), javascript_path('application', asset_host: false),
stylesheet_path('application'), stylesheet_path('application'),
image_path('docs-1.png'), image_path('sprites/docs.png'),
image_path('docs-1@2x.png'), image_path('sprites/docs@2x.png'),
image_path('docs-2.png'), asset_path('docs.js'),
image_path('docs-2@2x.png'), App.production? ? nil : javascript_path('debug'),
asset_path('docs.js') ].compact
]
end end
def app_size # Returns a cache name for the service worker to use which changes if any of the assets changes
@app_size ||= memoized_cookies['size'].nil? ? '20rem' : "#{memoized_cookies['size']}px" # When a manifest exist, this name is only created once based on the asset manifest because it never changes without a server restart
end # If a manifest does not exist, it is created every time this method is called because the assets can change while the server is running
def service_worker_cache_name
if File.exist?(App.assets_manifest_path)
if defined?(@@service_worker_cache_name)
return @@service_worker_cache_name
end
def app_layout digest = Sprockets::Manifest
memoized_cookies['layout'] .new(nil, App.assets_manifest_path)
end .files
.values
.map {|file| file["digest"]}
.join
def app_theme return @@service_worker_cache_name ||= Digest::MD5.hexdigest(digest)
@app_theme ||= memoized_cookies['dark'].nil? ? 'default' : 'dark' else
end paths = App.sprockets
.each_file
.to_a
.reject {|file| file.start_with?(App.docs_path)}
def dark_theme? return App.sprockets.pack_hexdigest(App.sprockets.files_digest(paths))
app_theme == 'dark' end
end end
def redirect_via_js(path) # courtesy of HTML5 App Cache def redirect_via_js(path)
response.set_cookie :initial_path, value: path, expires: Time.now + 15, path: '/' response.set_cookie :initial_path, value: path, expires: Time.now + 15, path: '/'
redirect '/', 302 redirect '/', 302
end end
@ -243,15 +261,15 @@ class App < Sinatra::Application
end end
end end
get '/manifest.appcache' do get '/service-worker.js' do
content_type 'text/cache-manifest' content_type 'application/javascript'
expires 0, :'no-cache' expires 0, :'no-cache'
erb :manifest erb :'service-worker.js'
end end
get '/' do get '/' do
return redirect "/#q=#{params[:q]}" if params[:q] return redirect "/#q=#{params[:q]}" if params[:q]
return redirect '/' unless request.query_string.empty? # courtesy of HTML5 App Cache return redirect '/' unless request.query_string.empty?
response.headers['Content-Security-Policy'] = settings.csp if settings.csp response.headers['Content-Security-Policy'] = settings.csp if settings.csp
erb :index erb :index
end end

@ -152,7 +152,6 @@ module Docs
end end
end end
def initialize def initialize
raise NotImplementedError, "#{self.class} is an abstract class and cannot be instantiated." if self.class.abstract raise NotImplementedError, "#{self.class} is an abstract class and cannot be instantiated." if self.class.abstract
end end
@ -164,5 +163,104 @@ module Docs
def build_pages(&block) def build_pages(&block)
raise NotImplementedError raise NotImplementedError
end end
def get_scraper_version(opts)
if self.class.method_defined?(:options) and !options[:release].nil?
options[:release]
else
# If options[:release] does not exist, we return the Epoch timestamp of when the doc was last modified in DevDocs production
json = fetch_json('https://devdocs.io/docs.json', opts)
items = json.select {|item| item['name'] == self.class.name}
items = items.map {|item| item['mtime']}
items.max
end
end
# Should return the latest version of this documentation
# If options[:release] is defined, it should be in the same format
# If options[:release] is not defined, it should return the Epoch timestamp of when the documentation was last updated
# If the docs will never change, simply return '1.0.0'
def get_latest_version(opts)
raise NotImplementedError
end
# Returns whether or not this scraper is outdated.
#
# The default implementation assumes the documentation uses a semver(-like) approach when it comes to versions.
# Patch updates are ignored because there are usually little to no documentation changes in bug-fix-only releases.
#
# Scrapers of documentations that do not use this versioning approach should override this method.
#
# Examples of the default implementation:
# 1 -> 2 = outdated
# 1.1 -> 1.2 = outdated
# 1.1.1 -> 1.1.2 = not outdated
def is_outdated(scraper_version, latest_version)
scraper_parts = scraper_version.to_s.split(/\./).map(&:to_i)
latest_parts = latest_version.to_s.split(/\./).map(&:to_i)
# Only check the first two parts, the third part is for patch updates
[0, 1].each do |i|
break if i >= scraper_parts.length or i >= latest_parts.length
return true if latest_parts[i] > scraper_parts[i]
return false if latest_parts[i] < scraper_parts[i]
end
false
end
private
#
# Utility methods for get_latest_version
#
def fetch(url, opts)
headers = {}
if opts.key?(:github_token) and url.start_with?('https://api.github.com/')
headers['Authorization'] = "token #{opts[:github_token]}"
end
opts[:logger].debug("Fetching #{url}")
response = Request.run(url, { connecttimeout: 15, headers: headers })
if response.success?
response.body
else
reason = response.timed_out? ? "Timed out while connecting to #{url}" : "Couldn't fetch #{url} (response code #{response.code})"
opts[:logger].error(reason)
raise reason
end
end
def fetch_doc(url, opts)
body = fetch(url, opts)
Nokogiri::HTML.parse(body, nil, 'UTF-8')
end
def fetch_json(url, opts)
JSON.parse fetch(url, opts)
end
def get_npm_version(package, opts)
json = fetch_json("https://registry.npmjs.com/#{package}", opts)
json['dist-tags']['latest']
end
def get_latest_github_release(owner, repo, opts)
release = fetch_json("https://api.github.com/repos/#{owner}/#{repo}/releases/latest", opts)
tag_name = release['tag_name']
tag_name.start_with?('v') ? tag_name[1..-1] : tag_name
end
def get_github_tags(owner, repo, opts)
fetch_json("https://api.github.com/repos/#{owner}/#{repo}/tags", opts)
end
def get_github_file_contents(owner, repo, path, opts)
json = fetch_json("https://api.github.com/repos/#{owner}/#{repo}/contents/#{path}", opts)
Base64.decode64(json['content'])
end
end end
end end

@ -29,7 +29,7 @@ module Docs
def request_one(url) def request_one(url)
assert_source_directory_exists assert_source_directory_exists
Response.new read_file(url_to_path(url)), URL.parse(url) Response.new read_file(File.join(source_directory, url_to_path(url))), URL.parse(url)
end end
def request_all(urls) def request_all(urls)
@ -50,7 +50,7 @@ module Docs
end end
def read_file(path) def read_file(path)
File.read(File.join(source_directory, path)) File.read(path)
rescue rescue
instrument 'warn.doc', msg: "Failed to open file: #{path}" instrument 'warn.doc', msg: "Failed to open file: #{path}"
nil nil

@ -57,6 +57,11 @@ module Docs
node.parent.after(node) node.parent.after(node)
end end
css('.signature').each do |node|
non_text_children = node.xpath('node()[not(self::text())]')
non_text_children.to_a.reverse.each { |child| node.parent.add_next_sibling(child) }
end
css('pre').each do |node| css('pre').each do |node|
node['data-language'] = 'elixir' node['data-language'] = 'elixir'
node.content = node.content node.content = node.content

@ -4,6 +4,11 @@ module Docs
def call def call
css('hr') css('hr')
if at_css('h1').nil?
title = current_url.normalized_path[1..-1].gsub(/-/, ' ')
doc.children.before("<h1>#{title}</h1>")
end
css('div.highlighter-rouge').each do |node| css('div.highlighter-rouge').each do |node|
lang = node['class'][/language-(\w+)/, 1] lang = node['class'][/language-(\w+)/, 1]
node['data-language'] = lang if lang node['data-language'] = lang if lang

@ -2,7 +2,8 @@ module Docs
class Homebrew class Homebrew
class EntriesFilter < Docs::EntriesFilter class EntriesFilter < Docs::EntriesFilter
def get_name def get_name
name = at_css('h1').content.strip header = at_css('h1')
name = header.nil? ? current_url.normalized_path[1..-1].gsub(/-/, ' ') : header.content.strip
name.remove! %r{\(.*} name.remove! %r{\(.*}
name name
end end
@ -16,6 +17,7 @@ module Docs
Python-for-Formula-Authors Python-for-Formula-Authors
Migrating-A-Formula-To-A-Tap Migrating-A-Formula-To-A-Tap
Rename-A-Formula Rename-A-Formula
Building-Against-Non-Homebrew-Dependencies
How-to-Create-and-Maintain-a-Tap How-to-Create-and-Maintain-a-Tap
Brew-Test-Bot Brew-Test-Bot
Prose-Style-Guidelines) Prose-Style-Guidelines)

@ -8,6 +8,7 @@ module Docs
# QML property/method header # QML property/method header
css('.qmlproto').each do |node| css('.qmlproto').each do |node|
id = node.at_css('tr')['id'] id = node.at_css('tr')['id']
id = node.at_css('a')['name'] if id.blank?
node.inner_html = node.at_css('td').inner_html node.inner_html = node.at_css('td').inner_html
node.name = 'h3' node.name = 'h3'
node['id'] = id node['id'] = id

@ -111,6 +111,7 @@ module Docs
css('.qmlproto').each do |node| css('.qmlproto').each do |node|
title = node.content.strip title = node.content.strip
id = node.at_css('tr')['id'] id = node.at_css('tr')['id']
id = node.at_css('a')['name'] if id.blank?
# Remove options # Remove options
title.remove!(%r{^\[.*\] }) title.remove!(%r{^\[.*\] })

@ -155,6 +155,10 @@ module Docs
end end
end end
def get_latest_version(opts)
get_npm_version('@angular/core', opts)
end
private private
def parse(response) def parse(response)

@ -69,5 +69,9 @@ module Docs
self.release = '1.2.32' self.release = '1.2.32'
self.base_url = "https://code.angularjs.org/#{release}/docs/partials/" self.base_url = "https://code.angularjs.org/#{release}/docs/partials/"
end end
def get_latest_version(opts)
get_npm_version('angular', opts)
end
end end
end end

@ -87,5 +87,10 @@ module Docs
quickstart.html quickstart.html
list_of_all_modules.html) list_of_all_modules.html)
end end
def get_latest_version(opts)
doc = fetch_doc('https://docs.ansible.com/ansible/latest/index.html', opts)
doc.at_css('.DocSiteProduct-CurrentVersion').content.strip
end
end end
end end

@ -33,5 +33,10 @@ module Docs
&copy; 2018 The Apache Software Foundation<br> &copy; 2018 The Apache Software Foundation<br>
Licensed under the Apache License, Version 2.0. Licensed under the Apache License, Version 2.0.
HTML HTML
def get_latest_version(opts)
doc = fetch_doc('http://httpd.apache.org/docs/', opts)
doc.at_css('#apcontents > ul a')['href'][0...-1]
end
end end
end end

@ -43,5 +43,10 @@ module Docs
self.base_url = "https://pig.apache.org/docs/r#{release}/" self.base_url = "https://pig.apache.org/docs/r#{release}/"
end end
def get_latest_version(opts)
doc = fetch_doc('https://pig.apache.org/', opts)
item = doc.at_css('div[id="menu_1.2"] > .menuitem:last-child')
item.content.strip.sub(/Release /, '')
end
end end
end end

@ -17,5 +17,10 @@ module Docs
&copy; 2010&ndash;2018 Caolan McMahon<br> &copy; 2010&ndash;2018 Caolan McMahon<br>
Licensed under the MIT License. Licensed under the MIT License.
HTML HTML
def get_latest_version(opts)
doc = fetch_doc('https://caolan.github.io/async/v3/', opts)
doc.at_css('#version-dropdown > a').content.strip[1..-1]
end
end end
end end

@ -22,5 +22,10 @@ module Docs
stub '' do stub '' do
'<div></div>' '<div></div>'
end end
def get_latest_version(opts)
doc = fetch_doc('https://babeljs.io/docs/en/', opts)
doc.at_css('a[href="/versions"] > h3').content
end
end end
end end

@ -20,5 +20,10 @@ module Docs
&copy; 2010&ndash;2016 Jeremy Ashkenas, DocumentCloud<br> &copy; 2010&ndash;2016 Jeremy Ashkenas, DocumentCloud<br>
Licensed under the MIT License. Licensed under the MIT License.
HTML HTML
def get_latest_version(opts)
doc = fetch_doc('https://backbonejs.org/', opts)
doc.at_css('.version').content[1...-1]
end
end end
end end

@ -1,7 +1,7 @@
module Docs module Docs
class Bash < UrlScraper class Bash < UrlScraper
self.type = 'bash' self.type = 'bash'
self.release = '4.4' self.release = '5.0'
self.base_url = 'https://www.gnu.org/software/bash/manual' self.base_url = 'https://www.gnu.org/software/bash/manual'
self.root_path = '/html_node/index.html' self.root_path = '/html_node/index.html'
self.links = { self.links = {
@ -17,5 +17,10 @@ module Docs
Copyright &copy; 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc.<br> Copyright &copy; 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc.<br>
Licensed under the GNU Free Documentation License. Licensed under the GNU Free Documentation License.
HTML HTML
def get_latest_version(opts)
body = fetch('https://www.gnu.org/software/bash/manual/html_node/index.html', opts)
body.scan(/, Version ([0-9.]+)/)[0][0][0...-1]
end
end end
end end

@ -18,5 +18,9 @@ module Docs
&copy; 2013&ndash;2017 Petka Antonov<br> &copy; 2013&ndash;2017 Petka Antonov<br>
Licensed under the MIT License. Licensed under the MIT License.
HTML HTML
def get_latest_version(opts)
get_npm_version('bluebird', opts)
end
end end
end end

@ -34,5 +34,10 @@ module Docs
options[:only] = %w(getting-started/ css/ components/ javascript/) options[:only] = %w(getting-started/ css/ components/ javascript/)
end end
def get_latest_version(opts)
doc = fetch_doc('https://getbootstrap.com/', opts)
doc.at_css('#bd-versions').content.strip[1..-1]
end
end end
end end

@ -27,5 +27,11 @@ module Docs
self.release = '0.11.7' self.release = '0.11.7'
self.base_url = "https://bottlepy.org/docs/#{self.version}/" self.base_url = "https://bottlepy.org/docs/#{self.version}/"
end end
def get_latest_version(opts)
doc = fetch_doc('https://bottlepy.org/docs/stable/', opts)
label = doc.at_css('.sphinxsidebarwrapper > ul > li > b')
label.content.sub(/Bottle /, '')
end
end end
end end

@ -19,5 +19,9 @@ module Docs
&copy; 2018 Bower contributors<br> &copy; 2018 Bower contributors<br>
Licensed under the MIT License. Licensed under the MIT License.
HTML HTML
def get_latest_version(opts)
get_npm_version('bower', opts)
end
end end
end end

@ -26,6 +26,13 @@ module Docs
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0. Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
HTML HTML
def get_latest_version(opts)
doc = fetch_doc('https://en.cppreference.com/w/Cppreference:Archives', opts)
link = doc.at_css('a[title^="File:"]')
date = link.content.scan(/(\d+)\./)[0][0]
DateTime.strptime(date, '%Y%m%d').to_time.to_i
end
private private
def file_path_for(*) def file_path_for(*)

@ -71,6 +71,11 @@ module Docs
self.base_url = 'https://api.cakephp.org/2.7/' self.base_url = 'https://api.cakephp.org/2.7/'
end end
def get_latest_version(opts)
doc = fetch_doc('https://api.cakephp.org/3.7/', opts)
doc.at_css('.version-picker .dropdown-toggle').content.strip
end
private private
def parse(response) def parse(response)

@ -23,5 +23,9 @@ module Docs
&copy; 2016 Chai.js Assertion Library<br> &copy; 2016 Chai.js Assertion Library<br>
Licensed under the MIT License. Licensed under the MIT License.
HTML HTML
def get_latest_version(opts)
get_npm_version('chai', opts)
end
end end
end end

@ -47,5 +47,10 @@ module Docs
options[:only_patterns] = [/\A#{client_path}\//, /\A#{server_path}\//] options[:only_patterns] = [/\A#{client_path}\//, /\A#{server_path}\//]
end end
def get_latest_version(opts)
doc = fetch_doc('https://downloads.chef.io/chef', opts)
doc.at_css('h1.product-heading > span').content.strip
end
end end
end end

@ -13,19 +13,29 @@ module Docs
Licensed under the Eclipse Public License 1.0. Licensed under the Eclipse Public License 1.0.
HTML HTML
version '1.9' do version '1.10' do
self.release = '1.9' self.release = '1.10 (stable)'
self.base_url = 'https://clojure.github.io/clojure/' self.base_url = 'https://clojure.github.io/clojure/'
end end
version '1.9' do
self.release = '1.9 (legacy)'
self.base_url = 'https://clojure.github.io/clojure/branch-clojure-1.9.0/'
end
version '1.8' do version '1.8' do
self.release = '1.8' self.release = '1.8 (legacy)'
self.base_url = 'https://clojure.github.io/clojure/branch-clojure-1.8.0/' self.base_url = 'https://clojure.github.io/clojure/branch-clojure-1.8.0/'
end end
version '1.7' do version '1.7' do
self.release = '1.7' self.release = '1.7 (legacy)'
self.base_url = 'https://clojure.github.io/clojure/branch-clojure-1.7.0/' self.base_url = 'https://clojure.github.io/clojure/branch-clojure-1.7.0/'
end end
def get_latest_version(opts)
doc = fetch_doc('http://clojure.github.io/clojure/index.html', opts)
doc.at_css('#header-version').content[1..-1]
end
end end
end end

@ -59,5 +59,11 @@ module Docs
self.release = '3.5.2' self.release = '3.5.2'
self.base_url = 'https://cmake.org/cmake/help/v3.5/' self.base_url = 'https://cmake.org/cmake/help/v3.5/'
end end
def get_latest_version(opts)
doc = fetch_doc('https://cmake.org/documentation/', opts)
link = doc.at_css('.entry-content ul > li > strong > a > big')
link.content.scan(/([0-9.]+)/)[0][0]
end
end end
end end

@ -18,5 +18,10 @@ module Docs
&copy; 2011 Michael Bodnarchuk and contributors<br> &copy; 2011 Michael Bodnarchuk and contributors<br>
Licensed under the MIT License. Licensed under the MIT License.
HTML HTML
def get_latest_version(opts)
doc = fetch_doc('https://codeception.com/changelog', opts)
doc.at_css('#page > h4').content
end
end end
end end

@ -21,5 +21,9 @@ module Docs
&copy; 2015 DavertMik &lt;davert@codegyre.com&gt; (http://codegyre.com)<br> &copy; 2015 DavertMik &lt;davert@codegyre.com&gt; (http://codegyre.com)<br>
Licensed under the MIT License. Licensed under the MIT License.
HTML HTML
def get_latest_version(opts)
get_npm_version('codeceptjs', opts)
end
end end
end end

@ -38,5 +38,11 @@ module Docs
version '3' do version '3' do
self.release = '3.1.8' self.release = '3.1.8'
end end
def get_latest_version(opts)
doc = fetch_doc('https://codeigniter.com/user_guide/changelog.html', opts)
header = doc.at_css('#change-log h2')
header.content.scan(/([0-9.]+)/)[0][0]
end
end end
end end

@ -30,5 +30,9 @@ module Docs
options[:container] = '.container' options[:container] = '.container'
end end
def get_latest_version(opts)
get_npm_version('coffeescript', opts)
end
end end
end end

@ -42,5 +42,15 @@ module Docs
self.release = '6.5.0' self.release = '6.5.0'
self.base_url = 'https://cordova.apache.org/docs/en/6.x/' self.base_url = 'https://cordova.apache.org/docs/en/6.x/'
end end
def get_latest_version(opts)
doc = fetch_doc('https://cordova.apache.org/docs/en/latest/', opts)
label = doc.at_css('#versionDropdown').content.strip
version = label.scan(/([0-9.]+)/)[0][0]
version = version[0...-1] if version.end_with?('.')
version
end
end end
end end

@ -34,6 +34,14 @@ module Docs
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0. Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
HTML HTML
# Same as get_latest_version in lib/docs/scrapers/c.rb
def get_latest_version(opts)
doc = fetch_doc('https://en.cppreference.com/w/Cppreference:Archives', opts)
link = doc.at_css('a[title^="File:"]')
date = link.content.scan(/(\d+)\./)[0][0]
DateTime.strptime(date, '%Y%m%d').to_time.to_i
end
private private
def file_path_for(*) def file_path_for(*)

@ -34,5 +34,10 @@ module Docs
HTML HTML
end end
} }
def get_latest_version(opts)
body = fetch('https://crystal-lang.org/api', opts)
body.scan(/Crystal Docs ([0-9.]+)/)[0][0]
end
end end
end end

@ -26,5 +26,10 @@ module Docs
def initial_urls def initial_urls
%w(https://dlang.org/phobos/index.html https://dlang.org/spec/intro.html) %w(https://dlang.org/phobos/index.html https://dlang.org/spec/intro.html)
end end
def get_latest_version(opts)
doc = fetch_doc('https://dlang.org/changelog/', opts)
doc.at_css('#content > ul > li:nth-child(2) > a')['id']
end
end end
end end

@ -58,5 +58,9 @@ module Docs
options[:root_title] = 'D3.js' options[:root_title] = 'D3.js'
options[:only_patterns] = [/\.md\z/] options[:only_patterns] = [/\.md\z/]
end end
def get_latest_version(opts)
get_npm_version('d3', opts)
end
end end
end end

@ -31,5 +31,11 @@ module Docs
self.release = '1.24.3' self.release = '1.24.3'
self.base_url = "https://api.dartlang.org/stable/#{release}/" self.base_url = "https://api.dartlang.org/stable/#{release}/"
end end
def get_latest_version(opts)
doc = fetch_doc('https://api.dartlang.org/', opts)
label = doc.at_css('footer > span').content.strip
label.sub(/Dart /, '')
end
end end
end end

@ -63,5 +63,10 @@ module Docs
self.release = '1.8.18' self.release = '1.8.18'
self.base_url = 'https://docs.djangoproject.com/en/1.8/' self.base_url = 'https://docs.djangoproject.com/en/1.8/'
end end
def get_latest_version(opts)
doc = fetch_doc('https://docs.djangoproject.com/', opts)
doc.at_css('#doc-versions > li.current > span > strong').content
end
end end
end end

@ -15,15 +15,15 @@ module Docs
end end
options[:attribution] = <<-HTML options[:attribution] = <<-HTML
&copy; 2017 Docker, Inc.<br> &copy; 2019 Docker, Inc.<br>
Licensed under the Apache License, Version 2.0.<br> Licensed under the Apache License, Version 2.0.<br>
Docker and the Docker logo are trademarks or registered trademarks of Docker, Inc. in the United States and/or other countries.<br> Docker and the Docker logo are trademarks or registered trademarks of Docker, Inc. in the United States and/or other countries.<br>
Docker, Inc. and other parties may also have trademark rights in other terms used herein. Docker, Inc. and other parties may also have trademark rights in other terms used herein.
HTML HTML
version '17' do version '19' do
self.release = '17.06' self.release = '19.03'
self.base_url = 'https://docs.docker.com/' self.base_url = "https://docs.docker.com/"
html_filters.push 'docker/entries', 'docker/clean_html' html_filters.push 'docker/entries', 'docker/clean_html'
@ -33,29 +33,150 @@ module Docs
options[:skip_patterns] = [/\Aengine\/api\/v/, /glossary/, /docker-ee/] options[:skip_patterns] = [/\Aengine\/api\/v/, /glossary/, /docker-ee/]
options[:replace_paths] = { options[:replace_paths] = {
'engine/installation/linux/docker-ee/linux-postinstall/' => 'engine/installation/linux/linux-postinstall/', 'install/linux/ubuntu/' => 'install/linux/docker-ce',
'engine/installation/linux/docker-ee/' => 'engine/installation/', 'get-started/part1' => 'get-started',
'engine/installation/linux/docker-ce/' => 'engine/installation/', 'engine/installation/' => 'install',
'engine/installation/linux/' => 'engine/installation/', 'engine/installation/linux/linux-postinstall/' => 'install/linux',
'engine/installation/windows/' => 'engine/installation/', 'compose/overview/' => 'compose',
'engine/userguide/intro/' => 'engine/userguide/', 'docker-cloud/' => 'docker-hub',
'engine/tutorials/dockervolumes/' => 'engine/admin/volumes/volumes/', 'datacenter/install/linux/' => 'ee',
'engine/getstarted/' => 'get-started/', 'engine/userguide/' => 'config/daemon',
'engine/tutorials/dockerimages/' => 'get-started/', 'engine/admin/' => 'config/daemon',
'engine/tutorials/dockerrepos/' => 'get-started/', 'opensource/get-help/' => 'opensource',
'engine/admin/host_integration/' => 'engine/admin/start-containers-automatically/', 'engine/tutorials/dockerimages/' => 'get-started',
'engine/installation/linux/rhel/' => 'engine/installation/linux/docker-ee/rhel/', 'engine/admin/volumes/bind-mounts/' => 'storage',
'engine/installation/linux/ubuntulinux/' => 'engine/installation/linux/docker-ee/ubuntu/', 'engine/tutorials/dockervolumes/' => 'storage',
'engine/installation/linux/suse/' => 'engine/installation/linux/docker-ee/suse/', 'engine/admin/volumes/volumes/' => 'storage',
'engine/admin/logging/' => 'engine/admin/logging/view_container_logs/', 'engine/userguide/labels-custom-metadata/' => 'config',
'engine/swarm/how-swarm-mode-works/' => 'engine/swarm/how-swarm-mode-works/nodes/', 'engine/userguide/eng-image/multistage-build/' => 'develop/develop-images',
'engine/installation/binaries/' => 'engine/installation/linux/docker-ce/binaries/', 'engine/swarm/networking/' => 'network',
'engine/admin/resource_constraints/' => 'config/containers',
'engine/admin/logging/overview/' => 'config/containers/logging',
'engine/userguide/eng-image/dockerfile_best-practices/' => 'develop/develop-images',
'engine/tutorials/dockerrepos/' => 'get-started',
'engine/userguide/networking/' => 'network',
'engine/userguide/networking/get-started-overlay/' => 'network',
'engine/reference/commandline/swarm_join_token/' => 'engine/reference/commandline',
'engine/understanding-docker/' => 'engine',
'engine/userguide/dockervolumes/' => 'storage',
'engine/installation/binaries/' => 'install/linux/docker-ce',
'engine/userguide/networking/default_network/dockerlinks/' => 'network',
'engine/reference/api/' => 'develop/sdk',
'engine/admin/systemd/' => 'config/daemon',
'engine/userguide/storagedriver/imagesandcontainers/' => 'storage/storagedriver',
'engine/api/' => 'develop/sdk',
'engine/userguide/networking/get-started-overlay' => 'network',
'engine/userguide/networking/overlay-security-model/' => 'network',
'engine/installation/linux/docker-ce/binaries/' => 'install/linux/docker-ce',
'engine/admin/volumes/' => 'storage/volumes/',
'engine/userguide/networking//' => 'network',
'engine/reference/commandline' => 'engine/reference/commandline/docker',
'engine/reference/commandline/' => 'engine/reference/commandline/docker/', 'engine/reference/commandline/' => 'engine/reference/commandline/docker/',
'engine/reference/api/' => 'engine/api/', }
'engine/userguide/dockervolumes/' => 'engine/admin/volumes/volumes/', end
'engine/understanding-docker/' => 'engine/docker-overview/',
'engine/reference/commandline/swarm_join_token/' => 'engine/reference/commandline/swarm_join-token/', version '18' do
'engine/api/getting-started/' => 'engine/api/get-started/', self.release = '18.09'
self.base_url = "https://docs.docker.com/v#{release}/"
html_filters.push 'docker/entries', 'docker/clean_html'
options[:container] = '.wrapper .container-fluid .row'
options[:only_patterns] = [/\Aget-started\//, /\Aengine\//, /\Acompose\//, /\Amachine\//, /\Anotary\//]
options[:skip_patterns] = [/\Aengine\/api\/v/, /glossary/, /docker-ee/]
options[:replace_paths] = {
'install/linux/ubuntu/' => 'install/linux/docker-ce',
'get-started/part1' => 'get-started',
'engine/installation/' => 'install',
'engine/installation/linux/linux-postinstall/' => 'install/linux',
'compose/overview/' => 'compose',
'datacenter/install/linux/' => 'ee',
'engine/userguide/' => 'config/daemon',
'engine/admin/' => 'config/daemon',
'opensource/get-help/' => 'opensource',
'engine/tutorials/dockerimages/' => 'get-started',
'engine/admin/volumes/bind-mounts/' => 'storage',
'engine/tutorials/dockervolumes/' => 'storage',
'engine/admin/volumes/volumes/' => 'storage',
'engine/userguide/labels-custom-metadata/' => 'config',
'engine/reference/api/' => 'develop/sdk',
'engine/userguide/eng-image/multistage-build/' => 'develop/develop-images',
'engine/swarm/networking/' => 'network',
'engine/admin/resource_constraints/' => 'config/containers',
'engine/admin/logging/overview/' => 'config/containers/logging',
'engine/userguide/eng-image/dockerfile_best-practices/' => 'develop/develop-images',
'engine/tutorials/dockerrepos/' => 'get-started',
'engine/userguide/networking/' => 'network',
'engine/userguide/networking/get-started-overlay/' => 'network',
'engine/understanding-docker/' => 'engine',
'engine/reference/commandline/swarm_join_token/' => 'engine/reference/commandline',
'engine/userguide/dockervolumes/' => 'storage',
'engine/admin/systemd/' => 'config/daemon',
'engine/userguide/storagedriver/imagesandcontainers/' => 'storage/storagedriver',
'engine/installation/binaries/' => 'install/linux/docker-ce',
'engine/userguide/networking/default_network/dockerlinks/' => 'network',
'engine/userguide/networking/overlay-security-model/' => 'network',
'engine/userguide/networking/get-started-overlay' => 'network',
'engine/api/' => 'develop/sdk',
'engine/installation/linux/docker-ce/binaries/' => 'install/linux/docker-ce',
'engine/admin/volumes/' => 'storage/volumes/',
'engine/userguide/networking//' => 'network',
'engine/reference/commandline' => 'engine/reference/commandline/docker',
'engine/reference/commandline/' => 'engine/reference/commandline/docker/',
}
end
version '17' do
self.release = '17.12'
self.base_url = "https://docs.docker.com/v#{release}/"
html_filters.push 'docker/entries', 'docker/clean_html'
options[:container] = '.wrapper .container-fluid .row'
options[:only_patterns] = [/\Aget-started\//, /\Aengine\//, /\Acompose\//, /\Amachine\//, /\Anotary\//]
options[:skip_patterns] = [/\Aengine\/api\/v/, /glossary/, /docker-ee/]
options[:replace_paths] = {
'get-started/part1' => 'get-started',
'engine/installation/' => 'install',
'engine/installation/linux/linux-postinstall/' => 'install/linux',
'opensource/get-help/' => 'opensource',
'engine/admin/volumes/volumes/' => 'storage',
'engine/tutorials/dockerimages/' => 'get-started',
'engine/admin/volumes/bind-mounts/' => 'storage',
'engine/tutorials/dockervolumes/' => 'storage',
'datacenter/install/aws/' => 'docker-for-aws',
'engine/userguide/' => 'config/daemon',
'engine/admin/' => 'config/daemon',
'engine/userguide/labels-custom-metadata/' => 'config',
'engine/userguide/eng-image/multistage-build/' => 'develop/develop-images',
'engine/swarm/networking/' => 'network',
'engine/admin/resource_constraints/' => 'config/containers',
'engine/admin/logging/overview/' => 'config/containers/logging',
'engine/understanding-docker/' => 'engine',
'engine/userguide/eng-image/dockerfile_best-practices/' => 'develop/develop-images',
'engine/tutorials/dockerrepos/' => 'get-started',
'engine/userguide/networking/' => 'network',
'engine/reference/commandline/swarm_join_token/' => 'edge/engine/reference/commandline',
'engine/userguide/networking/get-started-overlay/' => 'network',
'engine/userguide/dockervolumes/' => 'storage',
'engine/installation/binaries/' => 'install/linux/docker-ce',
'engine/userguide/networking/default_network/dockerlinks/' => 'network',
'engine/reference/api/' => 'develop/sdk',
'engine/admin/live-restore/' => 'config/containers',
'engine/api/' => 'develop/sdk',
'engine/userguide/networking/get-started-overlay' => 'network',
'security/security/' => 'engine/security',
'engine/installation/linux/docker-ce/binaries/' => 'install/linux/docker-ce',
'engine/reference/commandline/' => 'edge/engine/reference/commandline',
'engine/admin/systemd/' => 'config/daemon',
'engine/userguide/storagedriver/imagesandcontainers/' => 'storage/storagedriver',
'engine/userguide/networking/overlay-security-model/' => 'network',
'engine/admin/volumes/' => 'storage/volumes/',
'engine/userguide/networking//' => 'network',
} }
end end
@ -137,5 +258,11 @@ module Docs
options[:container] = '#docs' options[:container] = '#docs'
options[:only_patterns] << /\Aswarm\// options[:only_patterns] << /\Aswarm\//
end end
def get_latest_version(opts)
doc = fetch_doc('https://docs.docker.com/', opts)
label = doc.at_css('.nav-container button.dropdown-toggle').content.strip
label.scan(/([0-9.]+)/)[0][0]
end
end end
end end

@ -36,6 +36,11 @@ module Docs
urls.map { |url| "<a href='#{url}'>#{url}</a>" }.join urls.map { |url| "<a href='#{url}'>#{url}</a>" }.join
end end
def get_latest_version(opts)
doc = fetch_doc('https://dojotoolkit.org/api/', opts)
doc.at_css('#versionSelector > option[selected]').content
end
private private
def get_url_list(json, set = Set.new) def get_url_list(json, set = Set.new)

@ -98,5 +98,10 @@ module Docs
/\A[\w\-\.]+\.php\/7\.x\z/ /\A[\w\-\.]+\.php\/7\.x\z/
] ]
end end
def get_latest_version(opts)
json = fetch_json('https://packagist.org/packages/drupal/drupal.json', opts)
json['package']['versions'].keys.find {|version| !version.end_with?('-dev')}
end
end end
end end

@ -22,5 +22,10 @@ module Docs
&copy; 2013&ndash;2018 GitHub Inc.<br> &copy; 2013&ndash;2018 GitHub Inc.<br>
Licensed under the MIT license. Licensed under the MIT license.
HTML HTML
def get_latest_version(opts)
doc = fetch_doc('https://electronjs.org/docs', opts)
doc.at_css('.docs-version').content
end
end end
end end

@ -33,8 +33,34 @@ module Docs
"https://elixir-lang.org/getting-started/introduction.html" ] "https://elixir-lang.org/getting-started/introduction.html" ]
end end
version '1.9' do
self.release = '1.9.1'
self.base_urls = [
"https://hexdocs.pm/elixir/#{release}/",
"https://hexdocs.pm/eex/#{release}/",
"https://hexdocs.pm/ex_unit/#{release}/",
"https://hexdocs.pm/iex/#{release}/",
"https://hexdocs.pm/logger/#{release}/",
"https://hexdocs.pm/mix/#{release}/",
'https://elixir-lang.org/getting-started/'
]
end
version '1.8' do
self.release = '1.8.2'
self.base_urls = [
"https://hexdocs.pm/elixir/#{release}/",
"https://hexdocs.pm/eex/#{release}/",
"https://hexdocs.pm/ex_unit/#{release}/",
"https://hexdocs.pm/iex/#{release}/",
"https://hexdocs.pm/logger/#{release}/",
"https://hexdocs.pm/mix/#{release}/",
'https://elixir-lang.org/getting-started/'
]
end
version '1.7' do version '1.7' do
self.release = '1.7.3' self.release = '1.7.4'
self.base_urls = [ self.base_urls = [
"https://hexdocs.pm/elixir/#{release}/", "https://hexdocs.pm/elixir/#{release}/",
"https://hexdocs.pm/eex/#{release}/", "https://hexdocs.pm/eex/#{release}/",
@ -47,7 +73,7 @@ module Docs
end end
version '1.6' do version '1.6' do
self.release = '1.6.5' self.release = '1.6.6'
self.base_urls = [ self.base_urls = [
"https://hexdocs.pm/elixir/#{release}/", "https://hexdocs.pm/elixir/#{release}/",
"https://hexdocs.pm/eex/#{release}/", "https://hexdocs.pm/eex/#{release}/",
@ -97,5 +123,10 @@ module Docs
'https://elixir-lang.org/getting-started/' 'https://elixir-lang.org/getting-started/'
] ]
end end
def get_latest_version(opts)
doc = fetch_doc('https://hexdocs.pm/elixir/api-reference.html', opts)
doc.at_css('h2.sidebar-projectVersion').content.strip[1..-1]
end
end end
end end

@ -56,5 +56,10 @@ module Docs
https://emberjs.com/api/ember-data/2.14/classes/DS https://emberjs.com/api/ember-data/2.14/classes/DS
) )
end end
def get_latest_version(opts)
doc = fetch_doc('https://emberjs.com/api/ember/release', opts)
doc.at_css('.sidebar > .select-container .ember-power-select-selected-item').content.strip
end
end end
end end

@ -55,5 +55,10 @@ module Docs
version '18' do version '18' do
self.release = '18.3' self.release = '18.3'
end end
def get_latest_version(opts)
doc = fetch_doc('https://www.erlang.org/downloads', opts)
doc.at_css('.col-lg-3 > ul > li').content.strip.sub(/OTP /, '')
end
end end
end end

@ -20,5 +20,9 @@ module Docs
&copy; JS Foundation and other contributors<br> &copy; JS Foundation and other contributors<br>
Licensed under the MIT License. Licensed under the MIT License.
HTML HTML
def get_latest_version(opts)
get_npm_version('eslint', opts)
end
end end
end end

@ -28,5 +28,9 @@ module Docs
&copy; 2017 StrongLoop, IBM, and other expressjs.com contributors.<br> &copy; 2017 StrongLoop, IBM, and other expressjs.com contributors.<br>
Licensed under the Creative Commons Attribution-ShareAlike License v3.0. Licensed under the Creative Commons Attribution-ShareAlike License v3.0.
HTML HTML
def get_latest_version(opts)
get_npm_version('express', opts)
end
end end
end end

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save