diff --git a/.editorconfig b/.editorconfig index 73db316c..03c17bf8 100644 --- a/.editorconfig +++ b/.editorconfig @@ -6,3 +6,6 @@ indent_style = space indent_size = 2 insert_final_newline = true trim_trailing_whitespace = true + +[*.md] +trim_trailing_whitespace = false diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index bdb36d55..0c53b8e9 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -24,20 +24,18 @@ Want to contribute? Great. Please review the following guidelines carefully and ## Requesting new features 1. Search for similar feature requests; someone may have already requested it. -2. Make sure your feature fits DevDocs's [vision](https://github.com/freeCodeCamp/devdocs/blob/master/README.md#vision). +2. Make sure your feature fits DevDocs's [vision](../README.md#vision). 3. Provide a clear and detailed explanation of the feature and why it's important to add it. -For general feedback and ideas, please use the [mailing list](https://groups.google.com/d/forum/devdocs). - ## Requesting new documentations -Please don't open issues to request new documentations. +Please don't open issues to request new documentations. Use the [Trello board](https://trello.com/b/6BmTulfx/devdocs-documentation) where everyone can vote. ## Contributing code and features 1. Search for existing issues; someone may already be working on a similar feature. -2. Before embarking on any significant pull request, please open an issue describing the changes you intend to make. Otherwise you risk spending a lot of time working on something I may not want to merge. This also tells other contributors that you're working on the feature. +2. Before embarking on any significant pull request, please open an issue describing the changes you intend to make. Otherwise you risk spending a lot of time working on something we may not want to merge. This also tells other contributors that you're working on the feature. 3. Follow the [coding conventions](#coding-conventions). 4. If you're modifying the Ruby code, include tests and ensure they pass. 5. Try to keep your pull request small and simple. @@ -46,7 +44,7 @@ Use the [Trello board](https://trello.com/b/6BmTulfx/devdocs-documentation) wher ## Contributing new documentations -See the [wiki](https://github.com/freeCodeCamp/devdocs/wiki) to learn how to add new documentations. +See the [`docs` folder](https://github.com/freeCodeCamp/devdocs/tree/master/docs) to learn how to add new documentations. **Important:** the documentation's license must permit alteration, redistribution and commercial use, and the documented software must be released under an open source license. Feel free to get in touch if you're not sure if a documentation meets those requirements. @@ -57,20 +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.). * Names must be as short as possible and unique across the documentation. * 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 -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). - -## Other contributions - -Besides new docs and features, here are other ways you can contribute: +Please don't submit a pull request updating only the version number and/or the attribution of a documentation. Do submit a pull request if a bigger change is required in the scraper and you've verified that it works. -* **Improve our copy.** English isn't my first language so if you notice grammatical or usage errors, feel free to submit a pull request — it'll be much appreciated. -* **Participate in the issue tracker.** Your opinion matters — feel free to add comments to existing issues. You're also welcome to participate to the [mailing list](https://groups.google.com/d/forum/devdocs). +To ask that an existing documentation be updated, first check the latest [documentation versions report](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 @@ -80,4 +70,4 @@ Besides new docs and features, here are other ways you can contribute: ## Questions? -If you have any questions, please feel free to ask on the [mailing list](https://groups.google.com/d/forum/devdocs). +If you have any questions, please feel free to ask them on the contributor chat room on [Gitter](https://gitter.im/FreeCodeCamp/DevDocs). diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index 4b173394..0fb624d4 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -1,7 +1,7 @@ diff --git a/.gitignore b/.gitignore index 8b222826..f89ecb61 100644 --- a/.gitignore +++ b/.gitignore @@ -1,10 +1,9 @@ .DS_Store .bundle -*.pxm -*.sketch +log tmp public/assets public/fonts public/docs/**/* -!public/docs/docs.json -!public/docs/**/index.json +docs/**/* +!docs/*.md diff --git a/.ruby-version b/.ruby-version index 4fd0fe3c..ec1cf33c 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -2.5.1 \ No newline at end of file +2.6.3 diff --git a/.slugignore b/.slugignore index 6a7070f5..9daeafb9 100644 --- a/.slugignore +++ b/.slugignore @@ -1,2 +1 @@ -public/icons -test \ No newline at end of file +test diff --git a/.travis.yml b/.travis.yml index d5e5a6aa..6c59f0be 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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=" diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 00000000..26f8ab09 --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,2 @@ + +> Our Code of Conduct is available here: diff --git a/COPYRIGHT b/COPYRIGHT index 719895e9..c71d2d7a 100644 --- a/COPYRIGHT +++ b/COPYRIGHT @@ -1,13 +1,13 @@ -Copyright 2013-2018 Thibaut Courouble and other contributors +Copyright 2013-2019 Thibaut Courouble and other contributors This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. Please do not use the name DevDocs to endorse or promote products -derived from this software without my permission, except as may be -necessary to comply with the notice/attribution requirements. +derived from this software without the maintainers' permission, except +as may be necessary to comply with the notice/attribution requirements. -I also wish that any documentation file generated using this software +We also wish that any documentation file generated using this software be attributed to DevDocs. Let's be fair to all contributors by giving credit where credit's due. Thanks. \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 2c216e96..b033427a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,12 @@ -FROM ruby:2.5.1 +FROM ruby:2.6.3 ENV LANG=C.UTF-8 +ENV ENABLE_SERVICE_WORKER=true WORKDIR /devdocs RUN apt-get update && \ - apt-get -y install git nodejs && \ + apt-get -y install git nodejs libcurl4 && \ gem install bundler && \ rm -rf /var/lib/apt/lists/* diff --git a/Dockerfile-alpine b/Dockerfile-alpine index 1c162d23..33a06b0e 100644 --- a/Dockerfile-alpine +++ b/Dockerfile-alpine @@ -1,12 +1,13 @@ -FROM ruby:2.5.1-alpine +FROM ruby:2.6.3-alpine ENV LANG=C.UTF-8 +ENV ENABLE_SERVICE_WORKER=true WORKDIR /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 && \ bundle install --system --without test && \ thor docs:download --all && \ diff --git a/Gemfile b/Gemfile index 59f47930..3c9ce68b 100644 --- a/Gemfile +++ b/Gemfile @@ -1,9 +1,9 @@ source 'https://rubygems.org' -ruby '2.5.1' +ruby '2.6.3' gem 'rake' gem 'thor' -gem 'pry', '~> 0.11.0' +gem 'pry', '~> 0.12.0' gem 'activesupport', '~> 5.2', require: false gem 'yajl-ruby', require: false gem 'html-pipeline' @@ -22,6 +22,8 @@ group :app do gem 'browser' gem 'sass' gem 'coffee-script' + gem 'chunky_png' + gem 'sprockets-sass' end group :production do @@ -39,6 +41,8 @@ group :docs do gem 'progress_bar', require: false gem 'unix_utils', require: false gem 'tty-pager', require: false + gem 'net-sftp', '>= 2.1.3.rc2', require: false + gem 'terminal-table', require: false end group :test do diff --git a/Gemfile.lock b/Gemfile.lock index 0e177c4d..d1abb66b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,124 +1,131 @@ GEM remote: https://rubygems.org/ specs: - activesupport (5.2.1) + activesupport (5.2.3) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 0.7, < 2) minitest (~> 5.1) tzinfo (~> 1.1) - backports (3.11.4) - better_errors (2.5.0) + backports (3.15.0) + better_errors (2.5.1) coderay (>= 1.0.0) erubi (>= 1.0.0) rack (>= 0.9.0) - browser (2.5.3) + browser (2.6.1) + chunky_png (1.3.11) coderay (1.1.2) coffee-script (2.4.1) coffee-script-source execjs coffee-script-source (1.12.2) - concurrent-ruby (1.0.5) - daemons (1.2.6) - erubi (1.7.1) - ethon (0.11.0) + concurrent-ruby (1.1.5) + daemons (1.3.1) + erubi (1.8.0) + ethon (0.12.0) ffi (>= 1.3.0) eventmachine (1.2.7) execjs (2.7.0) - exifr (1.3.4) - ffi (1.9.25) - fspath (3.1.0) - highline (2.0.0) - html-pipeline (2.8.4) + exifr (1.3.6) + ffi (1.11.1) + fspath (3.1.2) + highline (2.0.2) + html-pipeline (2.11.1) activesupport (>= 2) nokogiri (>= 1.4) - i18n (1.1.0) + i18n (1.6.0) concurrent-ruby (~> 1.0) - image_optim (0.26.2) + image_optim (0.26.5) exifr (~> 1.2, >= 1.2.2) fspath (~> 3.0) image_size (>= 1.5, < 3) in_threads (~> 1.3) progress (~> 3.0, >= 3.0.1) - image_optim_pack (0.5.1) + image_optim_pack (0.5.6) fspath (>= 2.1, < 4) image_optim (~> 0.19) - image_size (2.0.0) - in_threads (1.5.0) - method_source (0.9.0) - mini_portile2 (2.3.0) + image_size (2.0.2) + in_threads (1.5.3) + method_source (0.9.2) + mini_portile2 (2.4.0) minitest (5.11.3) multi_json (1.13.1) mustermann (1.0.3) - newrelic_rpm (5.4.0.347) - nokogiri (1.8.4) - mini_portile2 (~> 2.3.0) + net-sftp (3.0.0.beta1) + net-ssh (>= 5.0.0, < 6.0.0) + net-ssh (5.2.0) + newrelic_rpm (6.5.0.357) + nokogiri (1.10.3) + mini_portile2 (~> 2.4.0) options (2.3.2) - progress (3.4.0) + progress (3.5.2) progress_bar (1.3.0) highline (>= 1.6, < 3) options (~> 2.3.0) - pry (0.11.3) + pry (0.12.2) coderay (~> 1.1.0) method_source (~> 0.9.0) - rack (2.0.5) - rack-protection (2.0.4) + rack (2.0.7) + rack-protection (2.0.5) rack rack-ssl-enforcer (0.2.9) rack-test (1.1.0) rack (>= 1.0, < 3) - rake (12.3.1) + rake (12.3.2) rb-fsevent (0.10.3) - rb-inotify (0.9.10) - ffi (>= 0.5.0, < 2) + rb-inotify (0.10.0) + ffi (~> 1.0) rr (1.2.1) - sass (3.6.0) + sass (3.7.4) sass-listen (~> 4.0.0) sass-listen (4.0.0) rb-fsevent (~> 0.9, >= 0.9.4) rb-inotify (~> 0.9, >= 0.9.7) - sinatra (2.0.4) + sinatra (2.0.5) mustermann (~> 1.0) rack (~> 2.0) - rack-protection (= 2.0.4) + rack-protection (= 2.0.5) tilt (~> 2.0) - sinatra-contrib (2.0.4) - activesupport (>= 4.0.0) + sinatra-contrib (2.0.5) backports (>= 2.8.2) multi_json mustermann (~> 1.0) - rack-protection (= 2.0.4) - sinatra (= 2.0.4) + rack-protection (= 2.0.5) + sinatra (= 2.0.5) tilt (>= 1.3, < 3) sprockets (3.7.2) concurrent-ruby (~> 1.0) rack (> 1, < 3) sprockets-helpers (1.2.1) sprockets (>= 2.2) - strings (0.1.4) - strings-ansi (~> 0.1.0) - unicode-display_width (~> 1.4.0) - unicode_utils (~> 1.4.0) + sprockets-sass (2.0.0.beta2) + sprockets (>= 2.0, < 4.0) + strings (0.1.5) + strings-ansi (~> 0.1) + unicode-display_width (~> 1.5) + unicode_utils (~> 1.4) strings-ansi (0.1.0) + terminal-table (1.8.0) + unicode-display_width (~> 1.1, >= 1.1.1) thin (1.7.2) daemons (~> 1.0, >= 1.0.9) eventmachine (~> 1.0, >= 1.0.4) rack (>= 1, < 3) - thor (0.20.0) + thor (0.20.3) thread_safe (0.3.6) - tilt (2.0.8) - tty-pager (0.11.0) - strings (~> 0.1.0) - tty-screen (~> 0.6.4) - tty-which (~> 0.3.0) - tty-screen (0.6.5) - tty-which (0.3.0) - typhoeus (1.3.0) + tilt (2.0.9) + tty-pager (0.12.1) + strings (~> 0.1.4) + tty-screen (~> 0.6) + tty-which (~> 0.4) + tty-screen (0.7.0) + tty-which (0.4.1) + typhoeus (1.3.1) ethon (>= 0.9.0) tzinfo (1.2.5) thread_safe (~> 0.1) - uglifier (4.1.19) + uglifier (4.1.20) execjs (>= 0.3.0, < 3) - unicode-display_width (1.4.0) + unicode-display_width (1.6.0) unicode_utils (1.4.0) unix_utils (0.0.15) yajl-ruby (1.4.1) @@ -130,16 +137,18 @@ DEPENDENCIES activesupport (~> 5.2) better_errors browser + chunky_png coffee-script erubi html-pipeline image_optim image_optim_pack minitest + net-sftp (>= 2.1.3.rc2) newrelic_rpm nokogiri progress_bar - pry (~> 0.11.0) + pry (~> 0.12.0) rack rack-ssl-enforcer rack-test @@ -150,6 +159,8 @@ DEPENDENCIES sinatra-contrib sprockets sprockets-helpers + sprockets-sass + terminal-table thin thor tty-pager @@ -159,7 +170,7 @@ DEPENDENCIES yajl-ruby RUBY VERSION - ruby 2.5.1p57 + ruby 2.6.3p62 BUNDLED WITH - 1.16.1 + 2.0.2 diff --git a/PULL_REQUEST_TEMPLATE.md b/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 00000000..0df55970 --- /dev/null +++ b/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,11 @@ +If you’re adding a new scraper, please ensure that you have: + +- [ ] Tested the scraper on a local copy of DevDocs +- [ ] Ensured that the docs are styled similarly to other docs on DevDocs + +- [ ] Added these files to the public/icons/*your_scraper_name*/ directory: + - [ ] `16.png`: a 16×16 pixel icon for the doc + - [ ] `16@2x.png`: a 32×32 pixel icon for the doc + - [ ] `SOURCE`: A text file containing the URL to the page the image can be found on or the URL of the original image itself + + diff --git a/README.md b/README.md index eec50904..630142d4 100644 --- a/README.md +++ b/README.md @@ -1,25 +1,24 @@ -# [DevDocs](https://devdocs.io) [![Build Status](https://travis-ci.org/freeCodeCamp/devdocs.svg?branch=master)](https://travis-ci.org/freeCodeCamp/devdocs) +# [DevDocs](https://devdocs.io) — API Documentation Browser [![Build Status](https://travis-ci.org/freeCodeCamp/devdocs.svg?branch=master)](https://travis-ci.org/freeCodeCamp/devdocs) -DevDocs combines multiple API documentations in a fast, organized, and searchable interface. +DevDocs combines multiple developer documentations in a clean and organized web UI with instant search, offline support, mobile version, dark theme, keyboard shortcuts, and more. -* Created by [Thibaut Courouble](https://thibaut.me) +DevDocs was created by [Thibaut Courouble](https://thibaut.me) and is operated by [freeCodeCamp](https://www.freecodecamp.org). Keep track of development news: * Join the contributor chat room on [Gitter](https://gitter.im/FreeCodeCamp/DevDocs) * Watch the repository on [GitHub](https://github.com/freeCodeCamp/devdocs/subscription) * Follow [@DevDocs](https://twitter.com/DevDocs) on Twitter -* Join the [mailing list](https://groups.google.com/d/forum/devdocs) -**Table of Contents:** [Quick Start](#quick-start) · [Vision](#vision) · [App](#app) · [Scraper](#scraper) · [Commands](#available-commands) · [Contributing](#contributing) · [License](#copyright--license) · [Questions?](#questions) +**Table of Contents:** [Quick Start](#quick-start) · [Vision](#vision) · [App](#app) · [Scraper](#scraper) · [Commands](#available-commands) · [Contributing](#contributing) · [Documentation](#documentation) · [Plugins and Extensions](#plugins-and-extensions) · [License](#copyright--license) · [Questions?](#questions) ## Quick Start -Unless you wish to contribute to the project, I recommend using the hosted version at [devdocs.io](https://devdocs.io). It's up-to-date and works offline out-of-the-box. +Unless you wish to contribute to the project, we recommend using the hosted version at [devdocs.io](https://devdocs.io). It's up-to-date and works offline out-of-the-box. DevDocs is made of two pieces: a Ruby scraper that generates the documentation and metadata, and a JavaScript app powered by a small Sinatra app. -DevDocs requires Ruby 2.5.1, libcurl, and a JavaScript runtime supported by [ExecJS](https://github.com/rails/execjs#readme) (included in OS X and Windows; [Node.js](https://nodejs.org/en/) on Linux). Once you have these installed, run the following commands: +DevDocs requires Ruby 2.6.0, libcurl, and a JavaScript runtime supported by [ExecJS](https://github.com/rails/execjs#readme) (included in OS X and Windows; [Node.js](https://nodejs.org/en/) on Linux). Once you have these installed, run the following commands: ``` git clone https://github.com/freeCodeCamp/devdocs.git && cd devdocs @@ -60,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. -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: * Recent versions of Firefox, Chrome, or Opera -* Safari 9.1+ -* Edge 16+ -* iOS 10+ +* Safari 11.1+ +* Edge 17+ +* 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! @@ -84,12 +83,13 @@ Modifications made to each document include: * replacing all external (not scraped) URLs with their fully qualified counterpart * replacing all internal (scraped) URLs with their unqualified and relative counterpart * adding content, such as a title and link to the original document +* ensuring correct syntax highlighting using [Prism](http://prismjs.com/) These modifications are applied via a set of filters using the [HTML::Pipeline](https://github.com/jch/html-pipeline) library. Each scraper includes filters specific to itself, one of which is tasked with figuring out the pages' metadata. The end result is a set of normalized HTML partials and two JSON files (index + offline data). Because the index files are loaded separately by the [app](#app) following the user's preferences, the scraper also creates a JSON manifest file containing information about the documentations currently available on the system (such as their name, version, update date, etc.). -More information about scrapers and filters is available on the [wiki](https://github.com/freeCodeCamp/devdocs/wiki). +More information about [scrapers](./docs/scraper-reference.md) and [filters](./docs/filter-reference.md) is available in the `docs` folder. ## Available Commands @@ -129,20 +129,45 @@ If multiple versions of Ruby are installed on your system, commands must be run ## Contributing -Contributions are welcome. Please read the [contributing guidelines](https://github.com/freeCodeCamp/devdocs/blob/master/CONTRIBUTING.md). - -DevDocs's own documentation is available on the [wiki](https://github.com/freeCodeCamp/devdocs/wiki). +Contributions are welcome. Please read the [contributing guidelines](./.github/CONTRIBUTING.md). + +## Documentation + +* [Adding documentations to DevDocs](./docs/adding-docs.md) +* [Scraper Reference](./docs/scraper-reference.md) +* [Filter Reference](./docs/filter-reference.md) +* [Maintainers’ Guide](./docs/maintainers.md) + +## Plugins and Extensions + +* [Chrome web app](https://chrome.google.com/webstore/detail/devdocs/mnfehgbmkapmjnhcnbodoamcioleeooe) +* [Ubuntu Touch app](https://uappexplorer.com/app/devdocsunofficial.berkes) +* [Sublime Text plugin](https://sublime.wbond.net/packages/DevDocs) +* [Atom plugin](https://atom.io/packages/devdocs) +* [Brackets extension](https://github.com/gruehle/dev-docs-viewer) +* [Fluid](http://fluidapp.com) for turning DevDocs into a real OS X app +* [GTK shell / Vim integration](https://github.com/naquad/devdocs-shell) +* [Emacs lookup](https://github.com/skeeto/devdocs-lookup) +* [Alfred Workflow](https://github.com/yannickglt/alfred-devdocs) +* [Vim search plugin with Devdocs in its defaults](https://github.com/waiting-for-dev/vim-www) Just set `let g:www_shortcut_engines = { 'devdocs': ['Devdocs', 'dd'] }` to have a `:Devdocs` command and a `dd` mapping. +* [Visual Studio Code plugin](https://marketplace.visualstudio.com/items?itemName=akfish.vscode-devdocs ) (1) +* [Visual Studio Code plugin](https://marketplace.visualstudio.com/items?itemName=deibit.devdocs) (2) +* [Desktop application](https://github.com/egoist/devdocs-desktop) +* [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 +* [macOS Application](https://github.com/dteoh/devdocs-macos) +* [Android Application](https://github.com/Merith-TK/devdocs_webapp_kotlin) is a fully working, advanced WebView ## Copyright / License -Copyright 2013-2018 Thibaut Courouble and [other contributors](https://github.com/freeCodeCamp/devdocs/graphs/contributors) +Copyright 2013-2019 Thibaut Courouble and [other contributors](https://github.com/freeCodeCamp/devdocs/graphs/contributors) -This software is licensed under the terms of the Mozilla Public License v2.0. See the [COPYRIGHT](https://github.com/freeCodeCamp/devdocs/blob/master/COPYRIGHT) and [LICENSE](https://github.com/freeCodeCamp/devdocs/blob/master/LICENSE) files. +This software is licensed under the terms of the Mozilla Public License v2.0. See the [COPYRIGHT](./COPYRIGHT) and [LICENSE](./LICENSE) files. -Please do not use the name DevDocs to endorse or promote products derived from this software without my permission, except as may be necessary to comply with the notice/attribution requirements. +Please do not use the name DevDocs to endorse or promote products derived from this software without the maintainers' permission, except as may be necessary to comply with the notice/attribution requirements. -I also wish that any documentation file generated using this software be attributed to DevDocs. Let's be fair to all contributors by giving credit where credit's due. Thanks! +We also wish that any documentation file generated using this software be attributed to DevDocs. Let's be fair to all contributors by giving credit where credit's due. Thanks! ## Questions? -If you have any questions, please feel free to ask them on the [mailing list](https://groups.google.com/d/forum/devdocs). +If you have any questions, please feel free to ask them on the contributor chat room on [Gitter](https://gitter.im/FreeCodeCamp/DevDocs). diff --git a/assets/images/.gitignore b/assets/images/.gitignore new file mode 100644 index 00000000..4a72ec74 --- /dev/null +++ b/assets/images/.gitignore @@ -0,0 +1 @@ +sprites/**/* diff --git a/assets/images/docs-1.png b/assets/images/docs-1.png deleted file mode 100644 index c5bfb6b8..00000000 Binary files a/assets/images/docs-1.png and /dev/null differ diff --git a/assets/images/docs-1@2x.png b/assets/images/docs-1@2x.png deleted file mode 100644 index 1f81ecd9..00000000 Binary files a/assets/images/docs-1@2x.png and /dev/null differ diff --git a/assets/images/docs-2.png b/assets/images/docs-2.png deleted file mode 100644 index bd9d44a8..00000000 Binary files a/assets/images/docs-2.png and /dev/null differ diff --git a/assets/images/docs-2@2x.png b/assets/images/docs-2@2x.png deleted file mode 100644 index 512ea7a5..00000000 Binary files a/assets/images/docs-2@2x.png and /dev/null differ diff --git a/assets/javascripts/app/app.coffee b/assets/javascripts/app/app.coffee index e90f1d61..b55e552c 100644 --- a/assets/javascripts/app/app.coffee +++ b/assets/javascripts/app/app.coffee @@ -13,10 +13,12 @@ @el = $('._app') @localStorage = new LocalStorageStore - @appCache = new app.AppCache if app.AppCache.isEnabled() + @serviceWorker = new app.ServiceWorker if app.ServiceWorker.isEnabled() @settings = new app.Settings @db = new app.DB() + @settings.initLayout() + @docs = new app.collections.Docs @disabledDocs = new app.collections.Docs @entries = new app.collections.Entries @@ -76,7 +78,7 @@ .install() @previousErrorHandler = onerror window.onerror = @onWindowError.bind(@) - CookieStore.onBlocked = @onCookieBlocked + CookiesStore.onBlocked = @onCookieBlocked return bootOne: -> @@ -138,7 +140,10 @@ @docs.sort() @initDoc(doc) @saveDocs() - _onSuccess() + if app.settings.get('autoInstall') + doc.install(_onSuccess, onError) + else + _onSuccess() return doc.load onSuccess, onError, writeCache: true @@ -147,7 +152,7 @@ saveDocs: -> @settings.setDocs(doc.slug for doc in @docs.all()) @db.migrate() - @appCache?.updateInBackground() + @serviceWorker?.updateInBackground() welcomeBack: -> visitCount = @settings.get('count') @@ -158,7 +163,7 @@ @updateChecker = new app.UpdateChecker() reboot: -> - if location.pathname isnt '/' + if location.pathname isnt '/' and location.pathname isnt '/settings' window.location = "/##{location.pathname}" else window.location = '/' @@ -167,14 +172,14 @@ reload: -> @docs.clearCache() @disabledDocs.clearCache() - if @appCache then @appCache.reload() else @reboot() + if @serviceWorker then @serviceWorker.reload() else @reboot() return reset: -> @localStorage.reset() @settings.reset() @db?.reset() - @appCache?.update() + @serviceWorker?.update() window.location = '/' return @@ -193,9 +198,9 @@ return 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. - @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...) -> @trigger 'bootError' @@ -252,7 +257,7 @@ matchMedia: !!window.matchMedia insertAdjacentHTML: !!document.body.insertAdjacentHTML 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 Raven.captureMessage "unsupported/#{key}", level: 'info' diff --git a/assets/javascripts/app/appcache.coffee b/assets/javascripts/app/appcache.coffee deleted file mode 100644 index 8ad83904..00000000 --- a/assets/javascripts/app/appcache.coffee +++ /dev/null @@ -1,46 +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', -> - if location.pathname isnt '/' - window.location = "/##{location.pathname}" - else - window.location = '/' - @notifyUpdate = false - @notifyProgress = true - try @cache.update() catch - return - - onProgress: (event) => - @trigger 'progress', event if @notifyProgress - return - - onUpdateReady: => - @trigger 'updateready' if @notifyUpdate - return diff --git a/assets/javascripts/app/config.coffee.erb b/assets/javascripts/app/config.coffee.erb index ec26b697..a822f7e2 100644 --- a/assets/javascripts/app/config.coffee.erb +++ b/assets/javascripts/app/config.coffee.erb @@ -13,3 +13,6 @@ app.config = version: <%= Time.now.to_i %> release: <%= Time.now.utc.httpdate.to_json %> 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' %> diff --git a/assets/javascripts/app/serviceworker.coffee b/assets/javascripts/app/serviceworker.coffee new file mode 100644 index 00000000..40235566 --- /dev/null +++ b/assets/javascripts/app/serviceworker.coffee @@ -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 diff --git a/assets/javascripts/app/settings.coffee b/assets/javascripts/app/settings.coffee index 8d309c41..350a08c0 100644 --- a/assets/javascripts/app/settings.coffee +++ b/assets/javascripts/app/settings.coffee @@ -5,11 +5,13 @@ class app.Settings 'manualUpdate' 'fastScroll' 'arrowScroll' + 'analyticsConsent' 'docs' 'dark' 'layout' 'size' 'tips' + 'autoInstall' ] INTERNAL_KEYS = [ @@ -19,6 +21,8 @@ class app.Settings 'news' ] + LAYOUTS: ['_max-width', '_sidebar-hidden', '_native-scrollbars'] + @defaults: count: 0 hideDisabled: false @@ -26,9 +30,10 @@ class app.Settings news: 0 manualUpdate: false schema: 1 + analyticsConsent: false constructor: -> - @store = new CookieStore + @store = new CookiesStore @cache = {} get: (key) -> @@ -38,6 +43,7 @@ class app.Settings set: (key, value) -> @store.set(key, value) delete @cache[key] + @toggleDark(value) if key == 'dark' return del: (key) -> @@ -63,6 +69,8 @@ class app.Settings return setLayout: (name, enable) -> + @toggleLayout(name, enable) + layout = (@store.get('layout') || '').split(' ') $.arrayDelete(layout, '') @@ -104,3 +112,28 @@ class app.Settings @store.reset() @cache = {} 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 diff --git a/assets/javascripts/app/update_checker.coffee b/assets/javascripts/app/update_checker.coffee index 5630b488..3558d6bc 100644 --- a/assets/javascripts/app/update_checker.coffee +++ b/assets/javascripts/app/update_checker.coffee @@ -3,13 +3,13 @@ class app.UpdateChecker @lastCheck = Date.now() $.on window, 'focus', @onFocus - app.appCache.on 'updateready', @onUpdateReady if app.appCache + app.serviceWorker?.on 'updateready', @onUpdateReady setTimeout @checkDocs, 0 check: -> - if app.appCache - app.appCache.update() + if app.serviceWorker + app.serviceWorker.update() else ajax url: $('script[src*="application"]').getAttribute('src') diff --git a/assets/javascripts/lib/cookie_store.coffee b/assets/javascripts/lib/cookies_store.coffee similarity index 76% rename from assets/javascripts/lib/cookie_store.coffee rename to assets/javascripts/lib/cookies_store.coffee index 3b340571..eaf1bd4f 100644 --- a/assets/javascripts/lib/cookie_store.coffee +++ b/assets/javascripts/lib/cookies_store.coffee @@ -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: -> diff --git a/assets/javascripts/lib/favicon.coffee b/assets/javascripts/lib/favicon.coffee new file mode 100644 index 00000000..2f2d9f93 --- /dev/null +++ b/assets/javascripts/lib/favicon.coffee @@ -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 diff --git a/assets/javascripts/lib/license.coffee b/assets/javascripts/lib/license.coffee index 8ff7c6e2..7f7ca938 100644 --- a/assets/javascripts/lib/license.coffee +++ b/assets/javascripts/lib/license.coffee @@ -1,5 +1,5 @@ ### - * Copyright 2013-2018 Thibaut Courouble and other contributors + * Copyright 2013-2019 Thibaut Courouble and other contributors * * This source code is licensed under the terms of the Mozilla * Public License, v. 2.0, a copy of which may be obtained at: diff --git a/assets/javascripts/lib/page.coffee b/assets/javascripts/lib/page.coffee index 5d3f6c88..91d73432 100644 --- a/assets/javascripts/lib/page.coffee +++ b/assets/javascripts/lib/page.coffee @@ -199,5 +199,21 @@ page.track = (fn) -> return 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] == '_' && name[1] != '_' + Cookies.expire(name) return diff --git a/assets/javascripts/lib/util.coffee b/assets/javascripts/lib/util.coffee index 058106fd..001b13de 100644 --- a/assets/javascripts/lib/util.coffee +++ b/assets/javascripts/lib/util.coffee @@ -352,6 +352,10 @@ isIE = null $.isIE = -> 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 = -> isAndroid ?= navigator.userAgent?.indexOf('Android') >= 0 diff --git a/assets/javascripts/models/doc.coffee b/assets/javascripts/models/doc.coffee index 2d5f7e4a..c51e13fa 100644 --- a/assets/javascripts/models/doc.coffee +++ b/assets/javascripts/models/doc.coffee @@ -142,4 +142,6 @@ class app.models.Doc extends app.Model return 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 diff --git a/assets/javascripts/news.json b/assets/javascripts/news.json index 32da738e..0266dea3 100644 --- a/assets/javascripts/news.json +++ b/assets/javascripts/news.json @@ -1,4 +1,12 @@ [ + [ + "2019-07-21", + "Fixed several bugs, added an option to automatically download documentation and more." + ], + [ + "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", "New documentations: Puppeteer and Handlebars.js" diff --git a/assets/javascripts/templates/error_tmpl.coffee b/assets/javascripts/templates/error_tmpl.coffee index 37e2b5e4..9cca1f9d 100644 --- a/assets/javascripts/templates/error_tmpl.coffee +++ b/assets/javascripts/templates/error_tmpl.coffee @@ -12,8 +12,8 @@ app.templates.notFoundPage = -> app.templates.pageLoadError = -> error """ The page failed to load. """, - """ It may be missing from the server (try reloading the app) or you could be offline.
- If you keep seeing this, you're likely behind a proxy or firewall that blocks cross-domain requests. """, + """ It may be missing from the server (try reloading the app) or you could be offline (try installing the documentation for offline usage when online again).
+ If you're online and you keep seeing this, you're likely behind a proxy or firewall that blocks cross-domain requests. """, """ #{back} · Reload · Retry """ @@ -57,17 +57,17 @@ app.templates.unsupportedBrowser = """

DevDocs is an API documentation browser which supports the following browsers:

  • Recent versions of Firefox, Chrome, or Opera -
  • Safari 9.1+ -
  • Edge 16+ -
  • iOS 10+ +
  • Safari 11.1+ +
  • Edge 17+ +
  • iOS 11.3+

- If you're unable to upgrade, I apologize. - I decided to prioritize speed and new features over support for older browsers. + If you're unable to upgrade, we apologize. + We decided to prioritize speed and new features over support for older browsers.

Note: if you're already using one of the browsers above, check your settings and add-ons. The app uses feature detection, not user agent sniffing.

- — Thibaut @DevDocs + — @DevDocs """ diff --git a/assets/javascripts/templates/notif_tmpl.coffee b/assets/javascripts/templates/notif_tmpl.coffee index 93611a5c..0821036e 100644 --- a/assets/javascripts/templates/notif_tmpl.coffee +++ b/assets/javascripts/templates/notif_tmpl.coffee @@ -68,3 +68,9 @@ app.templates.notifShare = -> app.templates.notifUpdateDocs = -> textNotif """ Documentation updates available. """, """ Install them 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. +
Accept or Decline """ diff --git a/assets/javascripts/templates/pages/about_tmpl.coffee b/assets/javascripts/templates/pages/about_tmpl.coffee index e0ef245f..b09dcda9 100644 --- a/assets/javascripts/templates/pages/about_tmpl.coffee +++ b/assets/javascripts/templates/pages/about_tmpl.coffee @@ -11,22 +11,18 @@ app.templates.aboutPage = -> """

DevDocs: API Documentation Browser

-

DevDocs combines multiple API documentations in a clean and organized web UI with instant search, offline support, mobile version, dark theme, keyboard shortcuts, and more. -

+

DevDocs combines multiple developer documentations in a clean and organized web UI with instant search, offline support, mobile version, dark theme, keyboard shortcuts, and more. +

DevDocs is free and open source. It was created by Thibaut Courouble and is operated by freeCodeCamp.

To keep up-to-date with the latest news:

- Copyright 2013–2018 Thibaut Courouble and other contributors
+ Copyright 2013–2019 Thibaut Courouble and other contributors
This software is licensed under the terms of the Mozilla Public License v2.0.
You may obtain a copy of the source code at github.com/freeCodeCamp/devdocs.
For more information, see the COPYRIGHT @@ -48,11 +44,10 @@ app.templates.aboutPage = -> """

Where can I suggest new docs and features?
You can suggest and vote for new docs on the Trello board.
If you have a specific feature request, add it to the issue tracker.
- Otherwise use the mailing list. + Otherwise, come talk to us in the Gitter chat room.
Where can I report bugs?
In the issue tracker. Thanks! -

For anything else, feel free to email me at thibaut@devdocs.io.

Credits

@@ -76,12 +71,13 @@ app.templates.aboutPage = -> """

Privacy Policy

    -
  • devdocs.io ("App") is operated by Thibaut Courouble ("We"). -
  • We do not collect personal information. -
  • We use Google Analytics, Gauges and Sentry to collect anonymous traffic information and improve the app. +
  • devdocs.io ("App") is operated by freeCodeCamp ("We"). +
  • We do not collect personal information through the app. +
  • 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 settings. +
  • We use Sentry to collect crash data and improve the app.
  • The app uses cookies to store user preferences.
  • 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. -
  • If you have any questions regarding privacy, please email thibaut@devdocs.io. +
  • If you have any questions regarding privacy, please email privacy@freecodecamp.org.
""" @@ -92,7 +88,7 @@ credits = [ 'https://creativecommons.org/licenses/by/4.0/' ], [ 'Ansible', - '2012-2018 Michael DeHaan
© 2018 Red Hat, Inc.', + '2012-2018 Michael DeHaan
© 2018–2019 Red Hat, Inc.', 'GPLv3', 'https://raw.githubusercontent.com/ansible/ansible/devel/COPYING' ], [ @@ -127,7 +123,7 @@ credits = [ 'https://raw.githubusercontent.com/petkaantonov/bluebird/master/LICENSE' ], [ 'Bootstrap', - '2011-2018 Twitter, Inc.
2011-2018 The Bootstrap Authors', + '2011-2019 Twitter, Inc.
2011-2019 The Bootstrap Authors', 'CC BY', 'https://creativecommons.org/licenses/by/3.0/' ], [ @@ -167,7 +163,7 @@ credits = [ 'https://github.com/clojure/clojure/blob/master/epl-v10.html' ], [ 'CMake', - '2000-2018 Kitware, Inc. and Contributors', + '2000-2019 Kitware, Inc. and Contributors', 'BSD', 'https://cmake.org/licensing/' ], [ @@ -190,6 +186,11 @@ credits = [ '2009-2018 Jeremy Ashkenas', 'MIT', 'https://raw.githubusercontent.com/jashkenas/coffeescript/master/LICENSE' + ], [ + 'Composer', + 'Nils Adermann, Jordi Boggiano', + 'MIT', + 'https://raw.githubusercontent.com/composer/composer/master/LICENSE' ], [ 'Cordova', '2012-2018 The Apache Software Foundation', @@ -206,6 +207,12 @@ credits = [ 'Apache', 'https://raw.githubusercontent.com/crystal-lang/crystal/master/LICENSE' ], [ + 'Cypress', + '2017 Cypress.io', + 'MIT', + 'https://raw.githubusercontent.com/cypress-io/cypress-documentation/develop/LICENSE.md' + ], + [ 'D', '1999-2018 The D Language Foundation', 'Boost', @@ -227,7 +234,7 @@ credits = [ 'https://raw.githubusercontent.com/django/django/master/LICENSE' ], [ 'Docker', - '2017 Docker, Inc.
Docker and the Docker logo are trademarks of Docker, Inc.', + '2019 Docker, Inc.
Docker and the Docker logo are trademarks of Docker, Inc.', 'Apache', 'https://raw.githubusercontent.com/docker/docker.github.io/master/LICENSE' ], [ @@ -397,7 +404,7 @@ credits = [ 'https://raw.githubusercontent.com/koajs/koa/master/LICENSE' ], [ 'Kotlin', - '2010-2018 JetBrains s.r.o.', + '2010-2019 JetBrains s.r.o.', 'Apache', 'https://raw.githubusercontent.com/JetBrains/kotlin/master/license/LICENSE.txt' ], [ @@ -407,7 +414,7 @@ credits = [ 'https://raw.githubusercontent.com/laravel/framework/master/LICENSE.txt' ], [ 'Leaflet', - '2010-2018 Vladimir Agafonkin
© 2010-2011, CloudMade
Maps © OpenStreetMap contributors.', + '2010-2019 Vladimir Agafonkin
© 2010-2011, CloudMade
Maps © OpenStreetMap contributors.', 'BSD', 'https://raw.githubusercontent.com/Leaflet/Leaflet/master/LICENSE' ], [ @@ -482,7 +489,7 @@ credits = [ 'https://github.com/LearnBoost/mongoose/blob/master/README.md#license' ], [ 'nginx', - '2002-2018 Igor Sysoev
© 2011-2018 Nginx, Inc.', + '2002-2019 Igor Sysoev
© 2011-2019 Nginx, Inc.', 'BSD', 'http://nginx.org/LICENSE' ], [ @@ -527,7 +534,7 @@ credits = [ 'https://raw.githubusercontent.com/OpenTSDB/opentsdb.net/gh-pages/COPYING.LESSER' ], [ 'Padrino', - '2010-2016 Padrino', + '2010-2019 Padrino', 'MIT', 'https://raw.githubusercontent.com/padrino/padrino-framework/master/padrino/LICENSE.txt' ], [ @@ -577,7 +584,7 @@ credits = [ 'https://raw.githubusercontent.com/GoogleChrome/puppeteer/master/LICENSE' ], [ 'Pygame', - 'Pygame Developpers', + 'Pygame Developers', 'LGPLv2.1', 'https://raw.githubusercontent.com/pygame/pygame/master/LICENSE' ], [ @@ -641,11 +648,23 @@ credits = [ 'MIT', 'https://raw.githubusercontent.com/rust-lang/rust/master/LICENSE-MIT' ], [ + 'Salt Stack', + '2019 SaltStack', + 'Apache', + 'https://raw.githubusercontent.com/saltstack/salt/develop/LICENSE' + ], + [ 'Sass', '2006-2016 Hampton Catlin, Nathan Weizenbaum, and Chris Eppstein', 'MIT', 'https://raw.githubusercontent.com/sass/sass/stable/MIT-LICENSE' ], [ + 'Scala', + '2002-2019 EPFL, with contributions from Lightbend', + 'Apache', + 'https://raw.githubusercontent.com/scala/scala-lang/master/license.md' + ], + [ 'scikit-image', '2011 the scikit-image team', 'BSD', @@ -720,6 +739,11 @@ credits = [ '2013-2018 Evan You, Vue.js contributors', 'MIT', 'https://raw.githubusercontent.com/vuejs/vue/master/LICENSE' + ], [ + 'Vue Router', + '2013-present Evan You', + 'MIT', + 'https://raw.githubusercontent.com/vuejs/vue-router/dev/LICENSE' ], [ 'Vulkan', '2014-2017 Khronos Group Inc.
Vulkan and the Vulkan logo are registered trademarks of the Khronos Group Inc.', @@ -731,6 +755,12 @@ credits = [ 'CC BY', 'https://creativecommons.org/licenses/by/4.0/' ], [ + 'Wordpress', + '2003-2019 WordPress Foundation', + 'GPLv2+', + 'https://wordpress.org/about/license/' + ], + [ 'Yarn', '2016-present Yarn Contributors', 'BSD', diff --git a/assets/javascripts/templates/pages/offline_tmpl.coffee b/assets/javascripts/templates/pages/offline_tmpl.coffee index a9a3c21c..bb9e06e8 100644 --- a/assets/javascripts/templates/pages/offline_tmpl.coffee +++ b/assets/javascripts/templates/pages/offline_tmpl.coffee @@ -25,8 +25,8 @@ app.templates.offlinePage = (docs) -> """

Questions & Answers

How does this work? -
Each page is cached as a key-value pair in IndexedDB (downloaded from a single file).
- The app also uses AppCache and localStorage to cache the assets and index files. +
Each page is cached as a key-value pair in IndexedDB (downloaded from a single file).
+ The app also uses Service Workers and localStorage to cache the assets and index files.
Can I close the tab/browser?
#{canICloseTheTab()}
What if I don't update a documentation? @@ -41,10 +41,15 @@ app.templates.offlinePage = (docs) -> """ """ canICloseTheTab = -> - if app.AppCache.isEnabled() + if app.ServiceWorker.isEnabled() """ Yes! Even offline, you can open a new tab, go to devdocs.io, and everything will work as if you were online (provided you installed all the documentations you want to use beforehand). """ else - """ No. AppCache isn't available in your browser (or is disabled), so loading devdocs.io offline won't work.
+ 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 ENABLE_SERVICE_WORKER environment variable to true)" + + """ No. Service Workers #{reason}, so loading devdocs.io offline won't work.
The current tab will continue to function even when you go offline (provided you installed all the documentations beforehand). """ app.templates.offlineDoc = (doc, status) -> diff --git a/assets/javascripts/templates/pages/root_tmpl.coffee.erb b/assets/javascripts/templates/pages/root_tmpl.coffee.erb index b5369403..714e0e20 100644 --- a/assets/javascripts/templates/pages/root_tmpl.coffee.erb +++ b/assets/javascripts/templates/pages/root_tmpl.coffee.erb @@ -8,13 +8,13 @@ app.templates.intro = """

Thanks for downloading DevDocs. Here are a few things you should know:

  1. Your local version of DevDocs won't self-update. Unless you're modifying the code, - I recommend using the hosted version at devdocs.io. + we recommend using the hosted version at devdocs.io.
  2. Run thor docs:list to see all available documentations.
  3. Run thor docs:download <name> to download documentations.
  4. Run thor docs:download --installed to update all downloaded documentations.
  5. To be notified about new versions, don't forget to watch the repository on GitHub.
  6. The issue tracker is the preferred channel for bug reports and - feature requests. For everything else, use the mailing list. + feature requests. For everything else, use Gitter.
  7. Contributions are welcome. See the guidelines.
  8. DevDocs is licensed under the terms of the Mozilla Public License v2.0. For more information, see the COPYRIGHT and @@ -39,7 +39,7 @@ app.templates.intro = """
  9. DevDocs works offline, on mobile, and can be installed on Chrome.
  10. For the latest news, follow @DevDocs.
  11. DevDocs is free and open source. - +
  12. And if you're new to coding, check out freeCodeCamp's open source curriculum.

Happy coding! diff --git a/assets/javascripts/templates/pages/settings_tmpl.coffee b/assets/javascripts/templates/pages/settings_tmpl.coffee index 1d439edb..94afe3df 100644 --- a/assets/javascripts/templates/pages/settings_tmpl.coffee +++ b/assets/javascripts/templates/pages/settings_tmpl.coffee @@ -15,6 +15,14 @@ app.templates.settingsPage = (settings) -> """ Automatically hide and show the sidebar Tip: drag the edge of the sidebar to resize it. + + diff --git a/assets/javascripts/tracking.js b/assets/javascripts/tracking.js index ca05b218..a68ca493 100644 --- a/assets/javascripts/tracking.js +++ b/assets/javascripts/tracking.js @@ -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) { } diff --git a/assets/javascripts/vendor/fastclick.js b/assets/javascripts/vendor/fastclick.js index 3af4f9d6..b6f7b40c 100755 --- a/assets/javascripts/vendor/fastclick.js +++ b/assets/javascripts/vendor/fastclick.js @@ -413,7 +413,7 @@ // when the user next taps anywhere else on the page, new touchstart and touchend events are dispatched // with the same identifier as the touch event that previously triggered the click that triggered the alert. // Sadly, there is an issue on iOS 4 that causes some normal touch events to have the same identifier as an - // immediately preceeding touch event (issue #52), so this fix is unavailable on that platform. + // immediately preceding touch event (issue #52), so this fix is unavailable on that platform. // Issue 120: touch.identifier is 0 when Chrome dev tools 'Emulate touch events' is set with an iOS device UA string, // which causes all touch events to be ignored. As this block only applies to iOS, and iOS identifiers are always long, // random integers, it's safe to to continue if the identifier is 0 here. @@ -805,7 +805,7 @@ } } - // IE11: prefixed -ms-touch-action is no longer supported and it's recomended to use non-prefixed version + // IE11: prefixed -ms-touch-action is no longer supported and it's recommended to use non-prefixed version // http://msdn.microsoft.com/en-us/library/windows/apps/Hh767313.aspx if (layer.style.touchAction === 'none' || layer.style.touchAction === 'manipulation') { return true; diff --git a/assets/javascripts/vendor/raven.js b/assets/javascripts/vendor/raven.js index f36c41b2..176ea361 100644 --- a/assets/javascripts/vendor/raven.js +++ b/assets/javascripts/vendor/raven.js @@ -856,7 +856,7 @@ Raven.prototype = { }, _triggerEvent: function(eventType, options) { - // NOTE: `event` is a native browser thing, so let's avoid conflicting wiht it + // NOTE: `event` is a native browser thing, so let's avoid conflicting with it var evt, key; if (!this._hasDocument) return; diff --git a/assets/javascripts/views/content/content.coffee b/assets/javascripts/views/content/content.coffee index 8c5ba874..4e01733e 100644 --- a/assets/javascripts/views/content/content.coffee +++ b/assets/javascripts/views/content/content.coffee @@ -153,6 +153,9 @@ class app.views.Content extends app.View return afterRoute: (route, context) => + if route != 'entry' and route != 'type' + resetFavicon() + switch route when 'root' @show @rootPage diff --git a/assets/javascripts/views/content/entry_page.coffee b/assets/javascripts/views/content/entry_page.coffee index beae4d77..f6f06511 100644 --- a/assets/javascripts/views/content/entry_page.coffee +++ b/assets/javascripts/views/content/entry_page.coffee @@ -40,6 +40,7 @@ class app.views.EntryPage extends app.View if app.disabledDocs.findBy 'slug', @entry.doc.slug @hiddenView = new app.views.HiddenPage @el, @entry + setFaviconForDoc(@entry.doc) @delay @polyfillMathML @trigger 'loaded' return @@ -123,7 +124,7 @@ class app.views.EntryPage extends app.View @render @tmpl('pageLoadError') @resetClass() @addClass @constructor.errorClass - app.appCache?.update() + app.serviceWorker?.update() return cache: -> diff --git a/assets/javascripts/views/content/settings_page.coffee b/assets/javascripts/views/content/settings_page.coffee index e39b17df..9ca606c6 100644 --- a/assets/javascripts/views/content/settings_page.coffee +++ b/assets/javascripts/views/content/settings_page.coffee @@ -1,7 +1,4 @@ class app.views.SettingsPage extends app.View - LAYOUTS = ['_max-width', '_sidebar-hidden', '_native-scrollbars'] - SIDEBAR_HIDDEN_LAYOUT = '_sidebar-hidden' - @className: '_static' @events: @@ -17,31 +14,31 @@ class app.views.SettingsPage extends app.View settings.dark = app.settings.get('dark') settings.smoothScroll = !app.settings.get('fastScroll') 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 getTitle: -> 'Preferences' toggleDark: (enable) -> - html = document.documentElement - html.classList.toggle('_theme-default') - html.classList.toggle('_theme-dark') app.settings.set('dark', !!enable) - app.appCache?.updateInBackground() return 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.appCache?.updateInBackground() return toggleSmoothScroll: (enable) -> app.settings.set('fastScroll', !enable) return + toggleAnalyticsConsent: (enable) -> + app.settings.set('analyticsConsent', if enable then '1' else '0') + resetAnalytics() unless enable + return + toggle: (name, enable) -> app.settings.set(name, enable) return @@ -85,6 +82,8 @@ class app.views.SettingsPage extends app.View @toggleSmoothScroll input.checked when 'import' @import input.files[0], input + when 'analyticsConsent' + @toggleAnalyticsConsent input.checked else @toggle input.name, input.checked return diff --git a/assets/javascripts/views/content/type_page.coffee b/assets/javascripts/views/content/type_page.coffee index 147fa7ed..ef360c14 100644 --- a/assets/javascripts/views/content/type_page.coffee +++ b/assets/javascripts/views/content/type_page.coffee @@ -9,6 +9,7 @@ class app.views.TypePage extends app.View render: (@type) -> @html @tmpl('typePage', @type) + setFaviconForDoc(@type.doc) return getTitle: -> diff --git a/assets/javascripts/views/layout/document.coffee b/assets/javascripts/views/layout/document.coffee index 02b98c7a..a10d0b3c 100644 --- a/assets/javascripts/views/layout/document.coffee +++ b/assets/javascripts/views/layout/document.coffee @@ -75,9 +75,11 @@ class app.views.Document extends app.View return unless target.hasAttribute('data-behavior') $.stopEvent(event) switch target.getAttribute('data-behavior') - when 'back' then history.back() - when 'reload' then window.location.reload() - when 'reboot' then app.reboot() - when 'hard-reload' then app.reload() - when 'reset' then app.reset() if confirm('Are you sure you want to reset DevDocs?') + when 'back' then history.back() + when 'reload' then window.location.reload() + when 'reboot' then app.reboot() + when 'hard-reload' then app.reload() + when 'reset' then app.reset() if confirm('Are you sure you want to reset DevDocs?') + when 'accept-analytics' then Cookies.set('analyticsConsent', '1', expires: 1e8) && app.reboot() + when 'decline-analytics' then Cookies.set('analyticsConsent', '0', expires: 1e8) && app.reboot() return diff --git a/assets/javascripts/views/layout/resizer.coffee b/assets/javascripts/views/layout/resizer.coffee index 86bb46f5..5584bfbe 100644 --- a/assets/javascripts/views/layout/resizer.coffee +++ b/assets/javascripts/views/layout/resizer.coffee @@ -11,9 +11,6 @@ class app.views.Resizer extends app.View init: -> @el.setAttribute('draggable', 'true') @appendTo $('._app') - - @style = $('style[data-resizer]') - @size = @style.getAttribute('data-size') return MIN = 260 @@ -24,15 +21,11 @@ class app.views.Resizer extends app.View return unless value > 0 value = Math.min(Math.max(Math.round(value), MIN), MAX) newSize = "#{value}px" - @style.innerHTML = @style.innerHTML.replace(new RegExp(@size, 'g'), newSize) - @size = newSize - if save - app.settings.setSize(value) - app.appCache?.updateInBackground() + document.documentElement.style.setProperty('--sidebarWidth', newSize) + app.settings.setSize(value) if save return onDragStart: (event) => - @style.removeAttribute('disabled') event.dataTransfer.effectAllowed = 'link' event.dataTransfer.setData('Text', '') $.on(window, 'dragover', @onDrag) diff --git a/assets/javascripts/views/layout/settings.coffee b/assets/javascripts/views/layout/settings.coffee index 7888118a..6941b9cd 100644 --- a/assets/javascripts/views/layout/settings.coffee +++ b/assets/javascripts/views/layout/settings.coffee @@ -25,7 +25,6 @@ class app.views.Settings extends app.View if super @render() document.body.classList.remove(SIDEBAR_HIDDEN_LAYOUT) - app.appCache?.on 'progress', @onAppCacheProgress return deactivate: -> @@ -33,7 +32,6 @@ class app.views.Settings extends app.View @resetClass() @docPicker.detach() document.body.classList.add(SIDEBAR_HIDDEN_LAYOUT) if app.settings.hasLayout(SIDEBAR_HIDDEN_LAYOUT) - app.appCache?.off 'progress', @onAppCacheProgress return render: -> @@ -52,7 +50,7 @@ class app.views.Settings extends app.View docs = @docPicker.getSelectedDocs() 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.uninstall -> app.db.migrate() @@ -83,9 +81,3 @@ class app.views.Settings extends app.View $.stopEvent(event) app.router.show '/' return - - onAppCacheProgress: (event) => - if event.lengthComputable - percentage = Math.round event.loaded * 100 / event.total - @saveBtn.textContent = "Downloading\u2026 (#{percentage}%)" - return diff --git a/assets/javascripts/views/search/search.coffee b/assets/javascripts/views/search/search.coffee index 8fab885c..7d05f0a0 100644 --- a/assets/javascripts/views/search/search.coffee +++ b/assets/javascripts/views/search/search.coffee @@ -30,6 +30,9 @@ class app.views.Search extends app.View .on 'results', @onResults .on 'end', @onEnd + @scope + .on 'change', @onScopeChange + app.on 'ready', @onReady $.on window, 'hashchange', @searchUrl $.on window, 'focus', @onWindowFocus @@ -138,6 +141,11 @@ class app.views.Search extends app.View $.stopEvent(event) return + onScopeChange: => + @value = '' + @onInput() + return + afterRoute: (name, context) => return if app.shortcuts.eventInProgress?.name is 'escape' @reset(true) if not context.init and app.router.isIndex() diff --git a/assets/javascripts/views/search/search_scope.coffee b/assets/javascripts/views/search/search_scope.coffee index 24de57ce..52ff753a 100644 --- a/assets/javascripts/views/search/search_scope.coffee +++ b/assets/javascripts/views/search/search_scope.coffee @@ -6,7 +6,9 @@ class app.views.SearchScope extends app.View tag: '._search-tag' @events: + click: 'onClick' keydown: 'onKeydown' + textInput: 'onTextInput' @routes: after: 'afterRoute' @@ -87,17 +89,33 @@ class app.views.SearchScope extends app.View @trigger 'change', null, previousDoc 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) => if event.which is 8 # backspace - if @doc and not @input.value - $.stopEvent(event) + if @doc and @input.selectionEnd is 0 @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 if event.which is 9 or # tab (event.which is 32 and app.isMobile()) # space - @search @input.value[0...@input.selectionStart] - $.stopEvent(event) if @doc + @doScopeSearch(event) + return + + onTextInput: (event) => + return unless $.isChromeForAndroid() + if not @doc and @input.value and event.data == ' ' + @doScopeSearch(event) return extractHashValue: -> diff --git a/assets/javascripts/views/sidebar/sidebar.coffee b/assets/javascripts/views/sidebar/sidebar.coffee index c8dc52a6..f3ae3bd4 100644 --- a/assets/javascripts/views/sidebar/sidebar.coffee +++ b/assets/javascripts/views/sidebar/sidebar.coffee @@ -28,7 +28,7 @@ class app.views.Sidebar extends app.View 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) return diff --git a/assets/stylesheets/application.css.scss b/assets/stylesheets/application.css.scss index fd6ffffd..4374e60c 100644 --- a/assets/stylesheets/application.css.scss +++ b/assets/stylesheets/application.css.scss @@ -1,10 +1,9 @@ -//= depend_on docs-1.png -//= depend_on docs-1@2x.png -//= depend_on docs-2.png -//= depend_on docs-2@2x.png +//= depend_on sprites/docs.png +//= depend_on sprites/docs@2x.png +//= depend_on sprites/docs.json /*! - * Copyright 2013-2018 Thibaut Courouble and other contributors + * Copyright 2013-2019 Thibaut Courouble and other contributors * * This source code is licensed under the terms of the Mozilla * Public License, v. 2.0, a copy of which may be obtained at: @@ -46,6 +45,7 @@ 'pages/coffeescript', 'pages/cordova', 'pages/crystal', + 'pages/cypress', 'pages/d', 'pages/d3', 'pages/dart', @@ -94,6 +94,7 @@ 'pages/rfc', 'pages/rubydoc', 'pages/rust', + 'pages/scala', 'pages/sinon', 'pages/socketio', 'pages/sphinx', @@ -106,5 +107,6 @@ 'pages/underscore', 'pages/vue', 'pages/webpack', + 'pages/wordpress', 'pages/yard', 'pages/yii'; diff --git a/assets/stylesheets/components/_fail.scss b/assets/stylesheets/components/_fail.scss index 535100ac..c520977e 100644 --- a/assets/stylesheets/components/_fail.scss +++ b/assets/stylesheets/components/_fail.scss @@ -32,5 +32,3 @@ } ._fail-text:last-child { margin: 0; } - -._fail-link { float: right; } diff --git a/assets/stylesheets/components/_header.scss b/assets/stylesheets/components/_header.scss index 5bae8901..e74830aa 100644 --- a/assets/stylesheets/components/_header.scss +++ b/assets/stylesheets/components/_header.scss @@ -215,5 +215,6 @@ color: var(--textColorLight); background: var(--searchTagBackground); border-radius: 2px; + cursor: pointer; @extend %truncate-text; } diff --git a/assets/stylesheets/components/_notif.scss b/assets/stylesheets/components/_notif.scss index dd23c43a..f0880fdd 100644 --- a/assets/stylesheets/components/_notif.scss +++ b/assets/stylesheets/components/_notif.scss @@ -134,3 +134,7 @@ ._notif-info { color: var(--textColorLight); } } + +._notif-right { + float: right; +} diff --git a/assets/stylesheets/global/_icons.scss b/assets/stylesheets/global/_icons.scss deleted file mode 100644 index e7a805f4..00000000 --- a/assets/stylesheets/global/_icons.scss +++ /dev/null @@ -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; } diff --git a/assets/stylesheets/global/_icons.scss.erb b/assets/stylesheets/global/_icons.scss.erb new file mode 100644 index 00000000..b2b22c22 --- /dev/null +++ b/assets/stylesheets/global/_icons.scss.erb @@ -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('') + %> diff --git a/assets/stylesheets/pages/_cypress.scss b/assets/stylesheets/pages/_cypress.scss new file mode 100644 index 00000000..aa1108d2 --- /dev/null +++ b/assets/stylesheets/pages/_cypress.scss @@ -0,0 +1,21 @@ +._cypress { + @extend %simple; + + .note { + h1 { + margin-left: inherit + } + + &.danger { + @extend %note-red + } + + &.info { + @extend %note-blue + } + + &.success { + @extend %note-green + } + } +} diff --git a/assets/stylesheets/pages/_mdn.scss b/assets/stylesheets/pages/_mdn.scss index d2b9b643..fb2cce38 100644 --- a/assets/stylesheets/pages/_mdn.scss +++ b/assets/stylesheets/pages/_mdn.scss @@ -30,6 +30,7 @@ .notice, .warning, .overheadIndicator, + .blockIndicator, .syntaxbox, // CSS, JavaScript .twopartsyntaxbox, // CSS .inheritsbox, // JavaScript @@ -104,4 +105,28 @@ .cleared { clear: both; } // CSS/box-shadow code > strong { font-weight: normal; } + + // Compatibility tablees + + .bc-github-link { + float: right; + font-size: .75rem; + } + + .bc-supports-yes, .bc-supports-yes + dd, .bc-supports-yes + dd + dd { background: var(--noteGreenBackground); } + .bc-supports-partial, .bc-supports-partial + dd, .bc-supports-partial + dd + dd { background: var(--noteOrangeBackground); } + .bc-supports-no, .bc-supports-no + dd, .bc-supports-no + dd + dd { background: var(--noteRedBackground); } + + .bc-table { + min-width: 100%; + + dl { + margin: .25rem 0 0; + padding: .25rem 0 0; + font-size: .75rem; + border-top: 1px solid var(--boxBorder); + } + + dd { margin: 0; } + } } diff --git a/assets/stylesheets/pages/_rdoc.scss b/assets/stylesheets/pages/_rdoc.scss index 7873900a..6622e68e 100644 --- a/assets/stylesheets/pages/_rdoc.scss +++ b/assets/stylesheets/pages/_rdoc.scss @@ -33,19 +33,8 @@ } } - .method-description { position: relative; } - .method-source-code { display: none; - position: absolute; - z-index: 1; - top: 0; - left: -1em; - right: 0; - background: var(--contentBackground); - box-shadow: 0 1em 1em 1em var(--contentBackground); - - > pre { margin: 0; } } // Rails guides diff --git a/assets/stylesheets/pages/_scala.scss b/assets/stylesheets/pages/_scala.scss new file mode 100644 index 00000000..b2beb118 --- /dev/null +++ b/assets/stylesheets/pages/_scala.scss @@ -0,0 +1,4 @@ +._scala { + @extend %simple; + .deprecated { @extend %label-red; } +} diff --git a/assets/stylesheets/pages/_wordpress.scss b/assets/stylesheets/pages/_wordpress.scss new file mode 100644 index 00000000..1da15abd --- /dev/null +++ b/assets/stylesheets/pages/_wordpress.scss @@ -0,0 +1,15 @@ +._wordpress { + @extend %simple; + + .breadcrumbs { + display: none; + } + + .callout-warning { + @extend %note, %note-red; + } + + .callout-alert { + @extend %note, %note-orange; + } +} \ No newline at end of file diff --git a/docs/adding-docs.md b/docs/adding-docs.md new file mode 100644 index 00000000..9984a15c --- /dev/null +++ b/docs/adding-docs.md @@ -0,0 +1,24 @@ +Adding a documentation may look like a daunting task but once you get the hang of it, it's actually quite simple. Don't hesitate to ask for help [in Gitter](https://gitter.im/FreeCodeCamp/DevDocs) if you ever get stuck. + +**Note:** please read the [contributing guidelines](../.github/CONTRIBUTING.md) before submitting a new documentation. + +1. Create a subclass of `Docs::UrlScraper` or `Docs::FileScraper` in the `lib/docs/scrapers/` directory. Its name should be the [PascalCase](http://api.rubyonrails.org/classes/String.html#method-i-camelize) equivalent of the filename (e.g. `my_doc` → `MyDoc`) +2. Add the appropriate class attributes and filter options (see the [Scraper Reference](./scraper-reference.md) page). +3. Check that the scraper is listed in `thor docs:list`. +4. Create filters specific to the scraper in the `lib/docs/filters/[my_doc]/` directory and add them to the class's [filter stacks](./scraper-reference.md#filter-stacks). You may create any number of filters but will need at least the following two: + * A [`CleanHtml`](./filter-reference.md#cleanhtmlfilter) filter whose task is to clean the HTML markup (e.g. adding `id` attributes to headings) and remove everything superfluous and/or nonessential. + * An [`Entries`](./filter-reference.md#entriesfilter) filter whose task is to determine the pages' metadata (the list of entries, each with a name, type and path). + The [Filter Reference](./filter-reference.md) page has all the details about filters. +5. Using the `thor docs:page [my_doc] [path]` command, check that the scraper works properly. Files will appear in the `public/docs/[my_doc]/` directory (but not inside the app as the command doesn't touch the index). `path` in this case refers to either the remote path (if using `UrlScraper`) or the local path (if using `FileScraper`). +6. Generate the full documentation using the `thor docs:generate [my_doc] --force` command. Additionally, you can use the `--verbose` option to see which files are being created/updated/deleted (useful to see what changed since the last run), and the `--debug` option to see which URLs are being requested and added to the queue (useful to pin down which page adds unwanted URLs to the queue). +7. Start the server, open the app, enable the documentation, and see how everything plays out. +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. +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. 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. +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.) + +Finally, try to document your scraper and filters' behavior as much as possible using comments (e.g. why some URLs are ignored, HTML markup removed, metadata that way, etc.). It'll make updating the documentation much easier. diff --git a/docs/filter-reference.md b/docs/filter-reference.md new file mode 100644 index 00000000..f5c74c66 --- /dev/null +++ b/docs/filter-reference.md @@ -0,0 +1,224 @@ +**Table of contents:** + +* [Overview](#overview) +* [Instance methods](#instance-methods) +* [Core filters](#core-filters) +* [Custom filters](#custom-filters) + - [CleanHtmlFilter](#cleanhtmlfilter) + - [EntriesFilter](#entriesfilter) + +## Overview + +Filters use the [HTML::Pipeline](https://github.com/jch/html-pipeline) library. They take an HTML string or [Nokogiri](http://nokogiri.org/) node as input, optionally perform modifications and/or extract information from it, and then outputs the result. Together they form a pipeline where each filter hands its output to the next filter's input. Every documentation page passes through this pipeline before being copied on the local filesystem. + +Filters are subclasses of the [`Docs::Filter`](https://github.com/Thibaut/devdocs/blob/master/lib/docs/core/filter.rb) class and require a `call` method. A basic implementation looks like this: + +```ruby +module Docs + class CustomFilter < Filter + def call + doc + end + end +end +``` + +Filters which manipulate the Nokogiri node object (`doc` and related methods) are _HTML filters_ and must not manipulate the HTML string (`html`). Vice-versa, filters which manipulate the string representation of the document are _text filters_ and must not manipulate the Nokogiri node object. The two types are divided into two stacks within the scrapers. These stacks are then combined into a pipeline that calls the HTML filters before the text filters (more details [here](./scraper-reference.md#filter-stacks)). This is to avoid parsing the document multiple times. + +The `call` method must return either `doc` or `html`, depending on the type of filter. + +## Instance methods + +* `doc` [Nokogiri::XML::Node] + The Nokogiri representation of the container element. + See [Nokogiri's API docs](http://www.rubydoc.info/github/sparklemotion/nokogiri/Nokogiri/XML/Node) for the list of available methods. + +* `html` [String] + The string representation of the container element. + +* `context` [Hash] **(frozen)** + The scraper's `options` along with a few additional keys: `:base_url`, `:root_url`, `:root_page` and `:url`. + +* `result` [Hash] + Used to store the page's metadata and pass back information to the scraper. + Possible keys: + + - `:path` — the page's normalized path + - `:store_path` — the path where the page will be stored (equal to `:path` with `.html` at the end) + - `:internal_urls` — the list of distinct internal URLs found within the page + - `:entries` — the [`Entry`](https://github.com/Thibaut/devdocs/blob/master/lib/docs/core/models/entry.rb) objects to add to the index + +* `css`, `at_css`, `xpath`, `at_xpath` + Shortcuts for `doc.css`, `doc.xpath`, etc. + +* `base_url`, `current_url`, `root_url` [Docs::URL] + Shortcuts for `context[:base_url]`, `context[:url]`, and `context[:root_url]` respectively. + +* `root_path` [String] + Shortcut for `context[:root_path]`. + +* `subpath` [String] + The sub-path from the base URL of the current URL. + _Example: if `base_url` equals `example.com/docs` and `current_url` equals `example.com/docs/file?raw`, the returned value is `/file`._ + +* `slug` [String] + The `subpath` removed of any leading slash or `.html` extension. + _Example: if `subpath` equals `/dir/file.html`, the returned value is `dir/file`._ + +* `root_page?` [Boolean] + Returns `true` if the current page is the root page. + +* `initial_page?` [Boolean] + Returns `true` if the current page is the root page or its subpath is one of the scraper's `initial_paths`. + +## Core filters + +* [`ContainerFilter`](https://github.com/Thibaut/devdocs/blob/master/lib/docs/filters/core/container.rb) — changes the root node of the document (remove everything outside) +* [`CleanHtmlFilter`](https://github.com/Thibaut/devdocs/blob/master/lib/docs/filters/core/clean_html.rb) — removes HTML comments, `