mirror of https://github.com/freeCodeCamp/devdocs
commit
14049dac0c
@ -1 +1 @@
|
||||
2.6.0
|
||||
2.6.3
|
||||
|
@ -1,2 +1 @@
|
||||
public/icons
|
||||
test
|
||||
test
|
||||
|
@ -1,7 +1,26 @@
|
||||
language: ruby
|
||||
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- libcurl4-openssl-dev
|
||||
|
||||
cache: bundler
|
||||
|
||||
before_script:
|
||||
before_install:
|
||||
- "echo 'gem: --no-document' > ~/.gemrc"
|
||||
- gem update --system
|
||||
- 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="
|
||||
|
@ -0,0 +1,2 @@
|
||||
|
||||
> Our Code of Conduct is available here: <https://code-of-conduct.freecodecamp.org/>
|
@ -0,0 +1 @@
|
||||
sprites/**/*
|
Before Width: | Height: | Size: 45 KiB |
Before Width: | Height: | Size: 119 KiB |
Before Width: | Height: | Size: 20 KiB |
Before Width: | Height: | Size: 48 KiB |
@ -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
|
@ -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
|
@ -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+$/
|
||||
|
||||
@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
|
@ -1,28 +1,32 @@
|
||||
try {
|
||||
if (app.config.env == 'production') {
|
||||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
||||
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
||||
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
||||
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
|
||||
ga('create', 'UA-5544833-12', 'devdocs.io');
|
||||
page.track(function() {
|
||||
ga('send', 'pageview', {
|
||||
page: location.pathname + location.search + location.hash,
|
||||
dimension1: app.router.context && app.router.context.doc && app.router.context.doc.slug_without_version
|
||||
if (app.config.env === 'production') {
|
||||
if (Cookies.get('analyticsConsent') === '1') {
|
||||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
||||
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
||||
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
||||
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
|
||||
ga('create', 'UA-5544833-12', 'devdocs.io');
|
||||
page.track(function() {
|
||||
ga('send', 'pageview', {
|
||||
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() {
|
||||
if (window._gauges)
|
||||
_gauges.push(['track']);
|
||||
else
|
||||
(function() {
|
||||
var _gauges=_gauges||[];!function(){var a=document.createElement("script");
|
||||
a.type="text/javascript",a.async=!0,a.id="gauges-tracker",
|
||||
a.setAttribute("data-site-id","51c15f82613f5d7819000067"),
|
||||
a.src="https://secure.gaug.es/track.js";var b=document.getElementsByTagName("script")[0];
|
||||
b.parentNode.insertBefore(a,b)}();
|
||||
})();
|
||||
});
|
||||
page.track(function() {
|
||||
if (window._gauges)
|
||||
_gauges.push(['track']);
|
||||
else
|
||||
(function() {
|
||||
var _gauges=_gauges||[];!function(){var a=document.createElement("script");
|
||||
a.type="text/javascript",a.async=!0,a.id="gauges-tracker",
|
||||
a.setAttribute("data-site-id","51c15f82613f5d7819000067"),
|
||||
a.src="https://secure.gaug.es/track.js";var b=document.getElementsByTagName("script")[0];
|
||||
b.parentNode.insertBefore(a,b)}();
|
||||
})();
|
||||
});
|
||||
} else {
|
||||
resetAnalytics();
|
||||
}
|
||||
}
|
||||
} catch(e) { }
|
||||
|
File diff suppressed because one or more lines are too long
@ -0,0 +1,3 @@
|
||||
._hide-in-development {
|
||||
<%= App.environment != :production ? 'display: none;' : '' %>
|
||||
}
|
@ -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('')
|
||||
%>
|
@ -0,0 +1,21 @@
|
||||
._cypress {
|
||||
@extend %simple;
|
||||
|
||||
.note {
|
||||
h1 {
|
||||
margin-left: inherit
|
||||
}
|
||||
|
||||
&.danger {
|
||||
@extend %note-red
|
||||
}
|
||||
|
||||
&.info {
|
||||
@extend %note-blue
|
||||
}
|
||||
|
||||
&.success {
|
||||
@extend %note-green
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
._octave {
|
||||
@extend %simple;
|
||||
|
||||
dl:not([compact]) > dt { @extend %block-label, %label-blue; }
|
||||
|
||||
dl[compact] > dt { @extend %block-label; }
|
||||
|
||||
.footnotes-heading { @extend %block-heading; }
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
._rxjs {
|
||||
@extend %simple;
|
||||
|
||||
.pre-title { @extend %pre-heading; }
|
||||
|
||||
.breadcrumbs { @extend %note; }
|
||||
.banner { @extend %note-green; }
|
||||
code.stable { @extend %label-green; }
|
||||
code.experimental { @extend %label-orange; }
|
||||
code.deprecated { @extend %label-red; }
|
||||
.alert.is-important { @extend %note-red; }
|
||||
.alert.is-helpful, .breadcrumbs { @extend %note-blue; }
|
||||
|
||||
.breadcrumbs { padding-left: 2em; }
|
||||
|
||||
img { margin: 1em 0; }
|
||||
|
||||
.location-badge {
|
||||
font-style: italic;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
td h3 { margin: 0 !important; }
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
._scala {
|
||||
@extend %simple;
|
||||
.deprecated { @extend %label-red; }
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
._wordpress {
|
||||
@extend %simple;
|
||||
|
||||
.breadcrumbs {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.callout-warning {
|
||||
@extend %note, %note-red;
|
||||
}
|
||||
|
||||
.callout-alert {
|
||||
@extend %note, %note-orange;
|
||||
}
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
module Docs
|
||||
class Composer
|
||||
class CleanHtmlFilter < Filter
|
||||
def call
|
||||
# Remove unneeded elements
|
||||
css('#searchbar, .toc, .fork-and-edit, .anchor').remove
|
||||
|
||||
# Fix the home page titles
|
||||
if subpath == ''
|
||||
css('h1').each do |node|
|
||||
node.name = 'h2'
|
||||
end
|
||||
|
||||
# Add a main title before the first subtitle
|
||||
at_css('h2').before('<h1>Composer</h1>')
|
||||
end
|
||||
|
||||
# Code blocks
|
||||
css('pre').each do |node|
|
||||
code = node.at_css('code[class]')
|
||||
|
||||
unless code.nil?
|
||||
node['data-language'] = 'javascript' if code['class'].include?('javascript')
|
||||
node['data-language'] = 'php' if code['class'].include?('php')
|
||||
end
|
||||
|
||||
node.content = node.content.strip
|
||||
node.remove_attribute('class')
|
||||
end
|
||||
|
||||
doc
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,36 @@
|
||||
module Docs
|
||||
class Composer
|
||||
class EntriesFilter < Docs::EntriesFilter
|
||||
def get_name
|
||||
title = at_css('h1').content
|
||||
title = "#{Integer(subpath[1]) + 1}. #{title}" if type == 'Book'
|
||||
title
|
||||
end
|
||||
|
||||
def get_type
|
||||
return 'Articles' if subpath.start_with?('articles/')
|
||||
'Book'
|
||||
end
|
||||
|
||||
def additional_entries
|
||||
entries = []
|
||||
|
||||
if subpath == '04-schema.md' # JSON Schema
|
||||
css('h3').each do |node|
|
||||
name = node.content.strip
|
||||
name.remove!(' (root-only)')
|
||||
entries << [name, node['id'], 'JSON Schema']
|
||||
end
|
||||
end
|
||||
|
||||
if subpath == '06-config.md' # Composer config
|
||||
css('h2').each do |node|
|
||||
entries << [node.content.strip, node['id'], 'Configuration Options']
|
||||
end
|
||||
end
|
||||
|
||||
entries
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,26 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Docs
|
||||
class Cypress
|
||||
class CleanHtmlFilter < Filter
|
||||
def call
|
||||
article_div = at_css('#article > div')
|
||||
@doc = article_div unless article_div.nil?
|
||||
|
||||
header = at_css('h1.article-title')
|
||||
doc.prepend_child(header) unless header.nil?
|
||||
|
||||
css('.article-edit-link').remove
|
||||
css('.article-footer').remove
|
||||
css('.article-footer-updated').remove
|
||||
|
||||
css('pre').each do |node|
|
||||
node.content = node.content
|
||||
node['data-language'] = 'javascript'
|
||||
end
|
||||
|
||||
doc
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,34 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Docs
|
||||
class Cypress
|
||||
class EntriesFilter < Docs::EntriesFilter
|
||||
SECTIONS = %w[
|
||||
commands
|
||||
core-concepts
|
||||
cypress-api
|
||||
events
|
||||
getting-started
|
||||
guides
|
||||
overview
|
||||
plugins
|
||||
references
|
||||
utilities
|
||||
].freeze
|
||||
|
||||
def get_name
|
||||
at_css('h1.article-title').content.strip
|
||||
end
|
||||
|
||||
def get_type
|
||||
path = context[:url].path
|
||||
|
||||
SECTIONS.each do |section|
|
||||
if path.match?("/#{section}/")
|
||||
return section.split('-').map(&:capitalize).join(' ')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,46 @@
|
||||
module Docs
|
||||
class Octave
|
||||
class CleanHtmlFilter < Filter
|
||||
def call
|
||||
root_page? ? root : other
|
||||
doc
|
||||
end
|
||||
|
||||
def root
|
||||
@doc = at_css('.contents')
|
||||
end
|
||||
|
||||
def other
|
||||
css('.header', 'hr').remove
|
||||
|
||||
css('.footnote > h3').each do |node|
|
||||
node.name = 'h5'
|
||||
end
|
||||
|
||||
at_css('h2, h3, h4').name = 'h1'
|
||||
|
||||
css('.example').each do |node|
|
||||
node.name = 'pre'
|
||||
node['data-language'] = 'matlab'
|
||||
node.content = node.content.strip
|
||||
end
|
||||
|
||||
css('a[name] + dl, a[name] + h4').each do |node|
|
||||
node['id'] = node.previous_element['name']
|
||||
end
|
||||
|
||||
css('dt > a[name]', 'th > a[name]').each do |node|
|
||||
node.parent['id'] = node['name']
|
||||
node.parent.content = node.parent.content.strip
|
||||
end
|
||||
|
||||
css('h5 > a').each do |node|
|
||||
node.parent['id'] = node['name']
|
||||
node.parent.content = node.content
|
||||
end
|
||||
|
||||
xpath('//td[text()=" " and not(descendant::*)]').remove
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,22 @@
|
||||
module Docs
|
||||
class Octave
|
||||
class EntriesFilter < Docs::EntriesFilter
|
||||
def get_name
|
||||
at_css('h1').content.sub(/(A?[0-9.]+ )/, '')
|
||||
end
|
||||
|
||||
def get_type
|
||||
return 'Manual: Appendices' if name.start_with?('Appendix')
|
||||
return 'Manual: Indexes' if name.end_with?('Index')
|
||||
'Manual'
|
||||
end
|
||||
|
||||
def additional_entries
|
||||
css('dl:not([compact]) > dt').each_with_object [] do |node, entries|
|
||||
name = node.content.gsub(/[A-z0-9\,… ]*\=/, '').strip.split(' ')[0]
|
||||
entries << [name, node['id'], 'Functions'] unless node['id'] =~ /-\d+\Z/
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,16 @@
|
||||
module Docs
|
||||
class Pony
|
||||
class CleanHtmlFilter < Filter
|
||||
def call
|
||||
css('.headerlink').remove
|
||||
css('hr').remove
|
||||
|
||||
css('pre').each do |node|
|
||||
node.content = node.content
|
||||
end
|
||||
|
||||
doc
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,35 @@
|
||||
module Docs
|
||||
class Pony
|
||||
class EntriesFilter < Docs::EntriesFilter
|
||||
def get_name
|
||||
title = context[:html_title].sub(/ - .*/, '').split(' ').last
|
||||
title = "1. #{type}" if title == 'Package'
|
||||
title
|
||||
end
|
||||
|
||||
def get_type
|
||||
subpath.split(/-([^a-z])/)[0][0..-1].sub('-', '/')
|
||||
end
|
||||
|
||||
def additional_entries
|
||||
return [] if root_page? || name.start_with?("1. ")
|
||||
|
||||
entries = []
|
||||
|
||||
css('h3').each do |node|
|
||||
member_name = node.content
|
||||
|
||||
is_field = member_name.start_with?('let ')
|
||||
member_name = member_name[4..-1] if is_field
|
||||
|
||||
member_name = member_name.scan(/^([a-zA-Z0-9_]+)/)[0][0]
|
||||
member_name += '()' unless is_field
|
||||
|
||||
entries << ["#{name}.#{member_name}", node['id']]
|
||||
end
|
||||
|
||||
entries
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,139 @@
|
||||
module Docs
|
||||
class Rxjs
|
||||
class CleanHtmlFilter < Filter
|
||||
def call
|
||||
if root_page?
|
||||
css('.card-container').remove
|
||||
at_css('h1').content = 'RxJS Documentation'
|
||||
end
|
||||
|
||||
if at_css('h1').nil?
|
||||
title = subpath.rpartition('/').last.titleize
|
||||
doc.prepend_child("<h1>#{title}</h1>")
|
||||
end
|
||||
|
||||
css('br', 'hr', '.material-icons', '.header-link', '.breadcrumb').remove
|
||||
|
||||
css('.content', 'article', '.api-header', 'section', '.instance-member').each do |node|
|
||||
node.before(node.children).remove
|
||||
end
|
||||
|
||||
css('label', 'h2 > em', 'h3 > em').each do |node|
|
||||
node.name = 'code'
|
||||
end
|
||||
|
||||
css('h1 + code').each do |node|
|
||||
node.before('<p></p>')
|
||||
while node.next_element.name == 'code'
|
||||
node.previous_element << ' '
|
||||
node.previous_element << node.next_element
|
||||
end
|
||||
node.previous_element.prepend_child(node)
|
||||
end
|
||||
|
||||
css('td h3', '.l-sub-section > h3', '.alert h3', '.row-margin > h3', '.api-heading ~ h3', '.api-heading + h2', '.metadata-member h3').each do |node|
|
||||
node.name = 'h4'
|
||||
end
|
||||
|
||||
css('.l-sub-section', '.alert', '.banner').each do |node|
|
||||
node.name = 'blockquote'
|
||||
end
|
||||
|
||||
css('.file').each do |node|
|
||||
node.content = node.content.strip
|
||||
end
|
||||
|
||||
css('.filetree .children').each do |node|
|
||||
node.css('.file').each do |n|
|
||||
n.content = " #{n.content}"
|
||||
end
|
||||
end
|
||||
|
||||
css('.filetree').each do |node|
|
||||
node.content = node.css('.file').map(&:inner_html).join("\n")
|
||||
node.name = 'pre'
|
||||
node.remove_attribute('class')
|
||||
end
|
||||
|
||||
css('pre').each do |node|
|
||||
node.content = node.content.strip
|
||||
|
||||
node['data-language'] = 'typescript' if node['path'].try(:ends_with?, '.ts')
|
||||
node['data-language'] = 'html' if node['path'].try(:ends_with?, '.html')
|
||||
node['data-language'] = 'css' if node['path'].try(:ends_with?, '.css')
|
||||
node['data-language'] = 'js' if node['path'].try(:ends_with?, '.js')
|
||||
node['data-language'] = 'json' if node['path'].try(:ends_with?, '.json')
|
||||
node['data-language'] = node['language'].sub(/\Ats/, 'typescript').strip if node['language']
|
||||
node['data-language'] ||= 'typescript' if node.content.start_with?('@')
|
||||
|
||||
node.before(%(<div class="pre-title">#{node['title']}</div>)) if node['title']
|
||||
|
||||
if node['class'] && node['class'].include?('api-heading')
|
||||
node.name = 'h3'
|
||||
|
||||
unless node.ancestors('.instance-method').empty?
|
||||
matches = node.inner_html.scan(/([^(& ]+)[(&]/)
|
||||
|
||||
unless matches.empty? || matches[0][0] == 'constructor'
|
||||
node['name'] = matches[0][0]
|
||||
node['id'] = node['name'].downcase + '-'
|
||||
end
|
||||
end
|
||||
|
||||
node.inner_html = "<code>#{node.inner_html}</code>"
|
||||
end
|
||||
|
||||
node.remove_attribute('path')
|
||||
node.remove_attribute('region')
|
||||
node.remove_attribute('linenums')
|
||||
node.remove_attribute('title')
|
||||
node.remove_attribute('language')
|
||||
node.remove_attribute('hidecopy')
|
||||
node.remove_attribute('class')
|
||||
end
|
||||
|
||||
css('td > .overloads').each do |node|
|
||||
node.replace node.at_css('.detail-contents')
|
||||
end
|
||||
|
||||
css('td.short-description p').each do |node|
|
||||
signature = node.parent.parent.next_element.at_css('h3[id]')
|
||||
signature.after(node) unless signature.nil?
|
||||
end
|
||||
|
||||
css('.method-table').each do |node|
|
||||
node.replace node.at_css('tbody')
|
||||
end
|
||||
|
||||
css('.api-body > table > caption').each do |node|
|
||||
node.name = 'center'
|
||||
lift_out_of_table node
|
||||
end
|
||||
|
||||
css('.api-body > table > tbody > tr:not([class]) > td > *').each do |node|
|
||||
lift_out_of_table node
|
||||
end
|
||||
|
||||
css('.api-body > table').each do |node|
|
||||
node.remove if node.content.strip.blank?
|
||||
end
|
||||
|
||||
css('h1[class]').remove_attr('class')
|
||||
css('table[class]').remove_attr('class')
|
||||
css('table[width]').remove_attr('width')
|
||||
css('tr[style]').remove_attr('style')
|
||||
|
||||
css('code code').each do |node|
|
||||
node.before(node.children).remove
|
||||
end
|
||||
|
||||
doc
|
||||
end
|
||||
|
||||
def lift_out_of_table(node)
|
||||
table = node.ancestors('table').first
|
||||
table.previous_element.after(node)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,29 @@
|
||||
module Docs
|
||||
class Rxjs
|
||||
class EntriesFilter < Docs::EntriesFilter
|
||||
def get_name
|
||||
title = at_css('h1')
|
||||
name = title.nil? ? subpath.rpartition('/').last.titleize : title.content
|
||||
name.prepend "#{$1}. " if subpath =~ /\-pt(\d+)/
|
||||
name += '()' unless at_css('.api-type-label.function').nil?
|
||||
name
|
||||
end
|
||||
|
||||
def get_type
|
||||
if slug.start_with?('guide')
|
||||
'Guide'
|
||||
elsif slug.start_with?('api/')
|
||||
slug.split('/').second
|
||||
else
|
||||
'Miscellaneous'
|
||||
end
|
||||
end
|
||||
|
||||
def additional_entries
|
||||
css('h3[id]').map do |node|
|
||||
["#{name}.#{node['name']}()", node['id']]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,27 @@
|
||||
module Docs
|
||||
class SaltStack
|
||||
class CleanHtmlFilter < Filter
|
||||
def call
|
||||
if root_page?
|
||||
doc.inner_html = '<h1>SaltStack</h1>'
|
||||
return doc
|
||||
end
|
||||
|
||||
css('.headerlink').remove
|
||||
|
||||
css('div[class^="highlight-"]').each do |node|
|
||||
node.name = 'pre'
|
||||
node['data-language'] = node['class'].scan(/highlight-([a-z]+)/i)[0][0]
|
||||
node.content = node.content.strip
|
||||
end
|
||||
|
||||
css('.function > dt').each do |node|
|
||||
node.name = 'h3'
|
||||
node.content = node.content
|
||||
end
|
||||
|
||||
doc
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,38 @@
|
||||
module Docs
|
||||
class SaltStack
|
||||
class EntriesFilter < Docs::EntriesFilter
|
||||
SALT_REF_RGX = /salt\.([^\.]+)\.([^\s]+)/
|
||||
|
||||
def get_name
|
||||
header = at_css('h1').content
|
||||
|
||||
ref_match = SALT_REF_RGX.match(header)
|
||||
if ref_match
|
||||
ns, mod = ref_match.captures
|
||||
"#{ns}.#{mod}"
|
||||
else
|
||||
header
|
||||
end
|
||||
end
|
||||
|
||||
def get_type
|
||||
slug.split('/', 3)[1]
|
||||
end
|
||||
|
||||
def include_default_entry?
|
||||
slug.split('/').last.start_with? 'salt'
|
||||
end
|
||||
|
||||
def additional_entries
|
||||
entries = []
|
||||
|
||||
css('.function > h3').each do |node|
|
||||
name = node.content.remove('salt.').split('(')[0] + '()'
|
||||
entries << [name, node['id']]
|
||||
end
|
||||
|
||||
entries
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,109 @@
|
||||
module Docs
|
||||
class Scala
|
||||
class CleanHtmlFilter < Filter
|
||||
def call
|
||||
@doc = at_css('#content')
|
||||
|
||||
always
|
||||
add_title
|
||||
|
||||
doc
|
||||
end
|
||||
|
||||
def always
|
||||
# Remove deprecated sections
|
||||
css('.members').each do |members|
|
||||
header = members.at_css('h3')
|
||||
members.remove if header.text.downcase.include? 'deprecate'
|
||||
end
|
||||
|
||||
css('#mbrsel, #footer').remove
|
||||
|
||||
css('.diagram-container').remove
|
||||
css('.toggleContainer > .toggle').each do |node|
|
||||
title = node.at_css('span')
|
||||
next if title.nil?
|
||||
|
||||
content = node.at_css('.hiddenContent')
|
||||
next if content.nil?
|
||||
|
||||
title.name = 'dt'
|
||||
|
||||
content.remove_attribute('class')
|
||||
content.remove_attribute('style')
|
||||
content.name = 'dd'
|
||||
|
||||
attributes = at_css('.attributes')
|
||||
unless attributes.nil?
|
||||
title.parent = attributes
|
||||
content.parent = attributes
|
||||
end
|
||||
end
|
||||
|
||||
signature = at_css('#signature')
|
||||
signature.replace "<h2 id=\"signature\">#{signature.inner_html}</h2>"
|
||||
|
||||
css('div.members > h3').each do |node|
|
||||
node.name = 'h2'
|
||||
end
|
||||
|
||||
css('div.members > ol').each do |list|
|
||||
list.css('li').each do |li|
|
||||
h3 = doc.document.create_element 'h3'
|
||||
h3['id'] = li['name'].rpartition('#').last unless li['name'].nil?
|
||||
|
||||
li.prepend_child h3
|
||||
li.css('.shortcomment').remove
|
||||
|
||||
modifier = li.at_css('.modifier_kind')
|
||||
modifier.parent = h3 unless modifier.nil?
|
||||
|
||||
kind = li.at_css('.modifier_kind .kind')
|
||||
kind.content = kind.content + ' ' unless kind.nil?
|
||||
|
||||
symbol = li.at_css('.symbol')
|
||||
symbol.parent = h3 unless symbol.nil?
|
||||
|
||||
li.swap li.children
|
||||
end
|
||||
|
||||
list.swap list.children
|
||||
end
|
||||
|
||||
css('.fullcomment pre, .fullcommenttop pre').each do |pre|
|
||||
pre['data-language'] = 'scala'
|
||||
pre.content = pre.content
|
||||
end
|
||||
|
||||
# Sections of the documentation which do not seem useful
|
||||
%w(#inheritedMembers #groupedMembers .permalink .hiddenContent .material-icons).each do |selector|
|
||||
css(selector).remove
|
||||
end
|
||||
|
||||
# Things that are not shown on the site, like deprecated members
|
||||
css('li[visbl=prt]').remove
|
||||
end
|
||||
|
||||
def add_title
|
||||
css('.permalink').remove
|
||||
|
||||
definition = at_css('#definition')
|
||||
return if definition.nil?
|
||||
|
||||
type_full_name = {a: 'Annotation', c: 'Class', t: 'Trait', o: 'Object', p: 'Package'}
|
||||
type = type_full_name[definition.at_css('.big-circle').text.to_sym]
|
||||
name = CGI.escapeHTML definition.at_css('h1').text
|
||||
|
||||
package = definition.at_css('#owner').text rescue ''
|
||||
package = package + '.' unless name.empty? || package.empty?
|
||||
|
||||
other = definition.at_css('.morelinks').dup
|
||||
other_content = other ? "<h3>#{other.to_html}</h3>" : ''
|
||||
|
||||
title_content = root_page? ? 'Package root' : "#{type} #{package}#{name}".strip
|
||||
title = "<h1>#{title_content}</h1>"
|
||||
definition.replace title + other_content
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,103 @@
|
||||
module Docs
|
||||
class Scala
|
||||
class EntriesFilter < Docs::EntriesFilter
|
||||
REPLACEMENTS = {
|
||||
'$eq' => '=',
|
||||
'$colon' => ':',
|
||||
'$less' => '<',
|
||||
}
|
||||
|
||||
def get_name
|
||||
if is_package?
|
||||
symbol = at_css('#definition h1')
|
||||
symbol ? symbol.text.gsub(/\W+/, '') : "package"
|
||||
else
|
||||
name = slug.split('/').last
|
||||
|
||||
# Some objects have inner objects, show ParentObject$.ChildObject$ instead of ParentObject$$ChildObject$
|
||||
name = name.gsub('$$', '$.')
|
||||
|
||||
REPLACEMENTS.each do |key, value|
|
||||
name = name.gsub(key, value)
|
||||
end
|
||||
|
||||
# If a dollar sign is used as separator between two characters, replace it with a dot
|
||||
name.gsub(/([^$.])\$([^$.])/, '\1.\2')
|
||||
end
|
||||
end
|
||||
|
||||
def get_type
|
||||
# if this entry is for a package, we group the package under the parent package
|
||||
if is_package?
|
||||
parent_package
|
||||
# otherwise, group it under the regular package name
|
||||
else
|
||||
package_name
|
||||
end
|
||||
end
|
||||
|
||||
def include_default_entry?
|
||||
true
|
||||
end
|
||||
|
||||
def additional_entries
|
||||
entries = []
|
||||
|
||||
full_name = "#{type}.#{name}".remove('$')
|
||||
css(".members li[name^=\"#{full_name}\"]").each do |node|
|
||||
# Ignore packages
|
||||
kind = node.at_css('.modifier_kind > .kind')
|
||||
next if !kind.nil? && kind.content == 'package'
|
||||
|
||||
# Ignore deprecated members
|
||||
next unless node.at_css('.symbol > .name.deprecated').nil?
|
||||
|
||||
id = node['name'].rpartition('#').last
|
||||
member_name = node.at_css('.name')
|
||||
|
||||
# Ignore members only existing of hashtags, we can't link to that
|
||||
next if member_name.nil? || member_name.content.strip.remove('#').blank?
|
||||
|
||||
member = "#{name}.#{member_name.content}()"
|
||||
entries << [member, id]
|
||||
end
|
||||
|
||||
entries
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# For the package name, we use the slug rather than parsing the package
|
||||
# name from the HTML because companion object classes may be broken out into
|
||||
# their own entries (by the source documentation). When that happens,
|
||||
# we want to group these classes (like `scala.reflect.api.Annotations.Annotation`)
|
||||
# under the package name, and not the fully-qualfied name which would
|
||||
# include the companion object.
|
||||
def package_name
|
||||
name = package_drop_last(slug_parts)
|
||||
name.empty? ? '_root_' : name
|
||||
end
|
||||
|
||||
def parent_package
|
||||
parent = package_drop_last(package_name.split('.'))
|
||||
parent.empty? ? '_root_' : parent
|
||||
end
|
||||
|
||||
def package_drop_last(parts)
|
||||
parts[0...-1].join('.')
|
||||
end
|
||||
|
||||
def slug_parts
|
||||
slug.split('/')
|
||||
end
|
||||
|
||||
def owner
|
||||
at_css('#owner')
|
||||
end
|
||||
|
||||
def is_package?
|
||||
slug.ends_with?('index') || slug.ends_with?('package')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,58 @@
|
||||
module Docs
|
||||
class Trio
|
||||
class CleanHtmlFilter < Filter
|
||||
def call
|
||||
@doc = at_css('div[role="main"]')
|
||||
|
||||
css('.section, [itemprop=articleBody]').each do |node|
|
||||
node.replace node.children
|
||||
end
|
||||
|
||||
css('.headerlink').remove
|
||||
|
||||
css('dt').each do |node|
|
||||
node.name = 'h3'
|
||||
|
||||
if node.parent.classes.include? 'field-list'
|
||||
node.name = 'h4'
|
||||
node['style'] = 'margin: 0'
|
||||
|
||||
if node.text == 'Parameters' or node.text == 'Raises'
|
||||
node.next_element.css('strong').each do |n|
|
||||
n.name = 'code'
|
||||
end
|
||||
end
|
||||
else
|
||||
code = doc.document.create_element 'code'
|
||||
|
||||
if em = node.at_css('.property')
|
||||
code.inner_html = "<em>#{em.text.strip}</em> "
|
||||
em.remove
|
||||
end
|
||||
|
||||
code.inner_html += node.inner_text.strip
|
||||
node.inner_html = code
|
||||
end
|
||||
end
|
||||
|
||||
css('pre').each do |node|
|
||||
node.content = node.content.strip
|
||||
|
||||
classes = node.parent.parent.classes
|
||||
if classes.include? 'highlight-python3'
|
||||
node['data-language'] = 'python'
|
||||
end
|
||||
|
||||
node.parent.parent.replace(node)
|
||||
end
|
||||
|
||||
css('.admonition').each do |node|
|
||||
node.name = 'blockquote'
|
||||
node.at_css('.admonition-title').name = 'h4'
|
||||
end
|
||||
|
||||
doc
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,48 @@
|
||||
module Docs
|
||||
class Trio
|
||||
class EntriesFilter < Docs::EntriesFilter
|
||||
def get_name
|
||||
at_css('h1').text[0...-1]
|
||||
end
|
||||
|
||||
def get_type
|
||||
at_css('h1').text[0...-1]
|
||||
end
|
||||
|
||||
def additional_entries
|
||||
css('.descname').each_with_object [] do |node, entries|
|
||||
name = node.text
|
||||
if node.previous.classes.include? 'descclassname'
|
||||
name = node.previous.text + name
|
||||
end
|
||||
name.strip!
|
||||
|
||||
dl = node.parent.parent
|
||||
|
||||
if dl.classes.include?('attribute') \
|
||||
or dl.classes.include?('method') \
|
||||
or dl.classes.include?('data')
|
||||
parent = dl.parent.previous_element
|
||||
cls = ''
|
||||
|
||||
if n = parent.at_css('.descclassname')
|
||||
cls += n.text
|
||||
end
|
||||
|
||||
if n = parent.at_css('.descname')
|
||||
if n.text == "The nursery interface"
|
||||
cls += "Nursery."
|
||||
else
|
||||
cls += n.text + '.'
|
||||
end
|
||||
end
|
||||
|
||||
name = cls + name
|
||||
end
|
||||
|
||||
entries << [name, node.parent['id']]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,21 @@
|
||||
module Docs
|
||||
class VueRouter
|
||||
class CleanHtmlFilter < Filter
|
||||
def call
|
||||
@doc = at_css('.content')
|
||||
|
||||
# Remove unneeded elements
|
||||
css('.bit-sponsor, .header-anchor').remove
|
||||
|
||||
css('.custom-block').each do |node|
|
||||
node.name = 'blockquote'
|
||||
|
||||
title = node.at_css('.custom-block-title')
|
||||
title.name = 'strong' unless title.nil?
|
||||
end
|
||||
|
||||
doc
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,71 @@
|
||||
module Docs
|
||||
class VueRouter
|
||||
class EntriesFilter < Docs::EntriesFilter
|
||||
def get_name
|
||||
name = at_css('h1').content
|
||||
name.remove! '# '
|
||||
name
|
||||
end
|
||||
|
||||
def get_type
|
||||
return 'Other Guides' if subpath.start_with?('guide/advanced')
|
||||
return 'Basic Guides' if subpath.start_with?('guide') || subpath.start_with?('installation')
|
||||
'API Reference'
|
||||
end
|
||||
|
||||
def include_default_entry?
|
||||
name != 'API Reference'
|
||||
end
|
||||
|
||||
def additional_entries
|
||||
return [] unless subpath.start_with?('api')
|
||||
|
||||
entries = [
|
||||
['<router-link>', 'router-link', 'API Reference'],
|
||||
['<router-view>', 'router-view', 'API Reference'],
|
||||
['$route', 'the-route-object', 'API Reference'],
|
||||
['Component Injections', 'component-injections', 'API Reference']
|
||||
]
|
||||
|
||||
css('h3').each do |node|
|
||||
entry_name = node.content.strip
|
||||
|
||||
# Get the previous h2 title
|
||||
title = node
|
||||
title = title.previous_element until title.name == 'h2'
|
||||
title = title.content.strip
|
||||
title.remove! '# '
|
||||
|
||||
entry_name.remove! '# '
|
||||
|
||||
case title
|
||||
when 'Router Construction Options'
|
||||
entry_name = "RouterOptions.#{entry_name}"
|
||||
when '<router-view> Props'
|
||||
entry_name = "<router-view> `#{entry_name}` prop"
|
||||
when '<router-link> Props'
|
||||
entry_name = "<router-link> `#{entry_name}` prop"
|
||||
when 'Router Instance Methods'
|
||||
entry_name = "#{entry_name}()"
|
||||
end
|
||||
|
||||
entry_name = entry_name.split(' API ')[0] if entry_name.start_with?('v-slot')
|
||||
|
||||
unless title == "Component Injections" || node['id'] == 'route-object-properties'
|
||||
entries << [entry_name, node['id'], 'API Reference']
|
||||
end
|
||||
end
|
||||
|
||||
css('#route-object-properties + ul > li > p:first-child > strong').each do |node|
|
||||
entry_name = node.content.strip
|
||||
id = "route-object-#{entry_name.remove('$route.')}"
|
||||
|
||||
node['id'] = id
|
||||
entries << [entry_name, node['id'], 'API Reference']
|
||||
end
|
||||
|
||||
entries
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue