Devdocs.io

API Documentation Browser

README

DevDocs — API Documentation Browser


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.

We are currently searching for maintainers


Please reach out to the community on Discord if you would like to join the team!

Keep track of development news:

Join the devdocs chat room on Discord
Watch the repository on GitHub
Follow @DevDocs on Twitter


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.7.4, 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:

  1. ```sh
  2. git clone https://github.com/freeCodeCamp/devdocs.git && cd devdocs
  3. gem install bundler
  4. bundle install
  5. bundle exec thor docs:download --default
  6. bundle exec rackup
  7. ```

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. To download and install all documentation this project has available, run thor docs:download --all.

Note: there is currently no update mechanism other than git pull origin main 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:

  1. ```sh
  2. # First, build the image
  3. git clone https://github.com/freeCodeCamp/devdocs.git && cd devdocs
  4. docker build -t thibaut/devdocs .

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

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 theDocs 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 (``, ``, 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 thedocs folder.

Available Commands


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

  1. ```sh
  2. # Server
  3. rackup              # Start the server (ctrl+c to stop)
  4. rackup --help       # List server options

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

  13. # Console
  14. thor console        # Start a REPL
  15. thor console:docs   # Start a REPL in the "Docs" module

  16. # Tests can be run quickly from within the console using the "test" command.
  17. # Run "help test" for usage instructions.
  18. thor test:all       # Run all tests
  19. thor test:docs      # Run "Docs" tests
  20. thor test:app       # Run "App" tests

  21. # Assets
  22. thor assets:compile # Compile assets (not required in development mode)
  23. thor assets:clean   # Clean old assets
  24. ```

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



Related Projects


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

ProjectDescriptionLast
|---------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
[SublimeSublime[![Latest
[AtomAtom[![Latest
[gruehle/dev-docs-viewer](https://github.com/gruehle/dev-docs-viewer)Brackets[![Latest
[naquad/devdocs-shell](https://github.com/naquad/devdocs-shell)GTK[![Latest
[skeeto/devdocs-lookup](https://github.com/skeeto/devdocs-lookup)Quick[![Latest
[yannickglt/alfred-devdocs](https://github.com/yannickglt/alfred-devdocs)Alfred[![Latest
[waiting-for-dev/vim-www](https://github.com/waiting-for-dev/vim-www)Vim[![Latest
[vscode-devdocsVS[![Latest
[devdocsVS[![Latest
[egoist/devdocs-desktop](https://github.com/egoist/devdocs-desktop)Cross-platform[![Latest
[qwfy/doc-browser](https://github.com/qwfy/doc-browser)Native[![Latest
[hardpixel/devdocs-desktop](https://github.com/hardpixel/devdocs-desktop)GTK3[![Latest
[dteoh/devdocs-macos](https://github.com/dteoh/devdocs-macos)Native[![Latest
[Merith-TK/devdocs_webapp_kotlin](https://github.com/Merith-TK/devdocs_webapp_kotlin)Android[![Latest
[astoff/devdocs.el](https://github.com/astoff/devdocs.el)Emacs[![Latest
[DevDocsVS[![Latest
[quickDocs](https://github.com/mdh34/quickDocs)DevDocs[![Latest
[romainl/vim-devdocs](https://github.com/romainl/vim-devdocs)Look[![Latest

Copyright / License


Copyright 2013–2021 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 Discord.