Find a file
2020-02-07 20:04:16 +01:00
.github Process review comments 2019-08-21 20:06:32 +02:00
assets Highlight table rows that are :target 2020-01-29 22:32:58 -05:00
docs Find steps that work on macOS 2020-01-14 12:22:49 -05:00
lib Skip broken page in Bootstrap 4 2020-01-31 16:15:59 -05:00
public Merge pull request #1161 from simon04/flow 2020-01-29 11:23:35 -05:00
test Merge pull request #1024 from jmerle/fix-openjdk-read-file 2019-07-20 02:50:18 +02:00
views Simplify service worker and don't show analytics setting/notification in development 2019-08-17 22:55:40 +02:00
.dockerignore Improved dockerfile, and added alpine version 2017-05-21 12:03:09 -04:00
.editorconfig Documentation maintenance 2019-05-03 16:31:35 +02:00
.gitignore gitignore: add vendor from bundle install 2019-09-02 19:25:23 +02:00
.image_optim.yml Disable optipng 2017-07-16 19:44:04 -04:00
.ruby-version Update .ruby-version 2019-10-11 18:02:47 +02:00
.slugignore Remove public/icons from .slugignore and remove it later 2019-07-20 03:44:22 +02:00
.travis.yml Fix Heroku auth token 2020-01-08 13:58:35 -05:00
config.ru Going open source 2013-10-24 20:49:33 +02:00
COPYRIGHT It’s 2020 2020-01-13 12:30:54 -05:00
Dockerfile Update dockerfiles 2019-10-11 18:08:33 +02:00
Dockerfile-alpine Update dockerfiles 2019-10-11 18:08:33 +02:00
Gemfile Update gems and any Ruby 2.6.x version 2019-10-11 17:55:09 +02:00
Gemfile.lock bundle update ffi 2020-02-07 20:04:16 +01:00
LICENSE Going open source 2013-10-24 20:49:33 +02:00
newrelic.yml Add Heroku config files 2018-03-24 15:06:19 -04:00
Procfile Add Heroku config files 2018-03-24 15:06:19 -04:00
Rakefile Fix tests and docker build 2018-11-04 08:54:32 -05:00
README.md It’s 2020 2020-01-13 12:30:54 -05:00
Thorfile Going open source 2013-10-24 20:49:33 +02:00

DevDocs — API Documentation Browser Build Status

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 was created by Thibaut Courouble and is operated by freeCodeCamp.

Keep track of development news:

  • Join the contributor chat room on Gitter
  • Watch the repository on GitHub
  • Follow @DevDocs on Twitter

Table of Contents: Quick Start · Vision · App · Scraper · Commands · Contributing · Documentation · Related Projects · License · Questions?

Quick Start

Unless you wish to contribute to the project, we recommend using the hosted version at 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.6.x, libcurl, and a JavaScript runtime supported by ExecJS (included in OS X and Windows; Node.js on Linux). Once you have these installed, run the following commands:

git clone https://github.com/freeCodeCamp/devdocs.git && cd devdocs
gem install bundler
bundle install
bundle exec thor docs:download --default
bundle exec rackup

Finally, point your browser at localhost:9292 (the first request will take a few seconds to compile the assets). You're all set.

The thor docs:download command is used to download pre-generated documentations from DevDocs's servers (e.g. thor docs:download html css). You can see the list of available documentations and versions by running thor docs:list. To update all downloaded documentations, run thor docs:download --installed.

Note: there is currently no update mechanism other than git pull origin master to update the code and thor docs:download --installed to download the latest version of the docs. To stay informed about new releases, be sure to watch this repository.

Alternatively, DevDocs may be started as a Docker container:

# First, build the image
git clone https://github.com/freeCodeCamp/devdocs.git && cd devdocs
docker build -t thibaut/devdocs .

# Finally, start a DevDocs container (access http://localhost:9292)
docker run --name devdocs -d -p 9292:9292 thibaut/devdocs

Vision

DevDocs aims to make reading and searching reference documentation fast, easy and enjoyable.

The app's main goals are to: keep load times as short as possible; improve the quality, speed, and order of search results; maximize the use of caching and other performance optimizations; maintain a clean and readable user interface; be fully functional offline; support full keyboard navigation; reduce “context switch” by using a consistent typography and design across all documentations; reduce clutter by focusing on a specific category of content (API/reference) and indexing only the minimum useful to most developers.

Note: DevDocs is neither a programming guide nor a search engine. All our content is pulled from third-party sources and the project doesn't intend to compete with full-text search engines. Its backbone is metadata; each piece of content is identified by a unique, "obvious" and short string. Tutorials, guides and other content that don't meet this requirement are outside the scope of the project.

App

The web app is all client-side JavaScript, written in CoffeeScript, and powered by a small Sinatra/Sprockets application. It relies on files generated by the scraper.

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. 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 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!

Scraper

The scraper is responsible for generating the documentation and index files (metadata) used by the app. It's written in Ruby under the Docs module.

There are currently two kinds of scrapers: UrlScraper which downloads files via HTTP and FileScraper which reads them from the local filesystem. They both make copies of HTML documents, recursively following links that match a set of rules and applying all sorts of modifications along the way, in addition to building an index of the files and their metadata. Documents are parsed using Nokogiri.

Modifications made to each document include:

  • removing content such as the document structure (<html>, <head>, etc.), comments, empty nodes, etc.
  • fixing links (e.g. to remove duplicates)
  • 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

These modifications are applied via a set of filters using the 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 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 in the docs folder.

Available Commands

The command-line interface uses Thor. To see all commands and options, run thor list from the project's root.

# Server
rackup              # Start the server (ctrl+c to stop)
rackup --help       # List server options

# Docs
thor docs:list      # List available documentations
thor docs:download  # Download one or more documentations
thor docs:manifest  # Create the manifest file used by the app
thor docs:generate  # Generate/scrape a documentation
thor docs:page      # Generate/scrape a documentation page
thor docs:package   # Package a documentation for use with docs:download
thor docs:clean     # Delete documentation packages

# Console
thor console        # Start a REPL
thor console:docs   # Start a REPL in the "Docs" module
Note: tests can be run quickly from within the console using the "test" command. Run "help test"
for usage instructions.

# Tests
thor test:all       # Run all tests
thor test:docs      # Run "Docs" tests
thor test:app       # Run "App" tests

# Assets
thor assets:compile # Compile assets (not required in development mode)
thor assets:clean   # Clean old assets

If multiple versions of Ruby are installed on your system, commands must be run through bundle exec.

Contributing

Contributions are welcome. Please read the contributing guidelines.

Documentation

Made something cool? Feel free to open a PR to add a new row to this table!

Project Description Last commit
Chrome web app Chrome Web App which adds a shortcut to DevDocs apps page. N/A
Ubuntu Touch app Application for devices running Ubuntu Touch. N/A
Sublime Text plugin Sublime Text plugin to search DevDocs by selection or by input. Latest GitHub commit
Atom plugin Atom plugin adding the doc command to search DevDocs. Latest GitHub commit
gruehle/dev-docs-viewer Brackets extension for searching and viewing DevDocs content. Latest GitHub commit
naquad/devdocs-shell GTK shell with Vim integration. Latest GitHub commit
skeeto/devdocs-lookup Quick Emacs API lookup on DevDocs. Latest GitHub commit
yannickglt/alfred-devdocs Alfred workflow for DevDocs. Latest GitHub commit
waiting-for-dev/vim-www Vim search plugin with DevDocs in its defaults. Latest GitHub commit
vscode-devdocs for VS Code VS Code plugin to open and search DevDocs inside VS Code. Latest GitHub commit
devdocs for VS Code VS Code plugin to open the browser to search selected text on DevDocs. Latest GitHub commit
egoist/devdocs-desktop Cross-platform desktop application for DevDocs. Latest GitHub commit
qwfy/doc-browser Native Linux app that supports DevDocs docsets. Latest GitHub commit
hardpixel/devdocs-desktop GTK3 application for DevDocs with search integrated in the headerbar. Latest GitHub commit
dteoh/devdocs-macos Native macOS application for DevDocs. Latest GitHub commit
Merith-TK/devdocs_webapp_kotlin Android application which shows DevDocs in a webview. Latest GitHub commit

Copyright 2013-2020 Thibaut Courouble and other contributors

This software is licensed under the terms of the Mozilla Public License v2.0. See the COPYRIGHT and LICENSE files.

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.

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 contributor chat room on Gitter.