devdocs/README.md

191 lines
16 KiB
Markdown
Raw Normal View History

2021-03-29 15:04:38 +02:00
# [DevDocs](https://devdocs.io) — API Documentation Browser
2013-10-24 20:25:52 +02:00
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.
2013-10-24 20:25:52 +02:00
DevDocs was created by [Thibaut Courouble](https://thibaut.me) and is operated by [freeCodeCamp](https://www.freecodecamp.org).
2013-10-24 20:25:52 +02:00
2020-10-21 17:06:06 +02:00
## We are currently searching for maintainers
2022-07-06 17:40:27 +02:00
Please reach out to the community on [Discord](https://discord.gg/PRyKn3Vbay) if you would like to join the team!
2020-10-21 17:06:06 +02:00
2016-03-27 17:39:38 +02:00
Keep track of development news:
2013-10-24 20:25:52 +02:00
2022-07-06 17:40:27 +02:00
* Join the devdocs chat room on [Discord](https://discord.gg/PRyKn3Vbay)
2018-03-26 14:00:00 +02:00
* Watch the repository on [GitHub](https://github.com/freeCodeCamp/devdocs/subscription)
2013-10-24 20:25:52 +02:00
* Follow [@DevDocs](https://twitter.com/DevDocs) on Twitter
2019-09-02 02:34:41 +02:00
**Table of Contents:** [Quick Start](#quick-start) · [Vision](#vision) · [App](#app) · [Scraper](#scraper) · [Commands](#available-commands) · [Contributing](#contributing) · [Documentation](#documentation) · [Related Projects](#related-projects) · [License](#copyright--license) · [Questions?](#questions)
2013-10-24 20:25:52 +02:00
## Quick Start
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.
2013-10-24 20:25:52 +02:00
2016-03-27 17:39:38 +02:00
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.
2013-10-24 20:25:52 +02:00
DevDocs requires Ruby 2.7.4, 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:
2013-10-24 20:25:52 +02:00
2020-11-18 22:22:46 +01:00
```sh
2018-03-26 14:00:00 +02:00
git clone https://github.com/freeCodeCamp/devdocs.git && cd devdocs
2013-10-24 20:25:52 +02:00
gem install bundler
bundle install
bundle exec thor docs:download --default
bundle exec rackup
2013-10-24 20:25:52 +02:00
```
2013-10-24 20:25:52 +02:00
Finally, point your browser at [localhost:9292](http://localhost:9292) (the first request will take a few seconds to compile the assets). You're all set.
2020-05-18 15:07:50 +02:00
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`.
2013-10-24 20:25:52 +02:00
2021-03-29 15:11:39 +02:00
**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](https://github.com/freeCodeCamp/devdocs/subscription) this repository.
2013-10-24 20:25:52 +02:00
2015-12-01 21:46:16 +01:00
Alternatively, DevDocs may be started as a Docker container:
2020-11-18 22:22:46 +01:00
```sh
2015-12-01 21:46:16 +01:00
# First, build the image
2018-03-26 14:00:00 +02:00
git clone https://github.com/freeCodeCamp/devdocs.git && cd devdocs
2015-12-01 21:46:16 +01:00
docker build -t thibaut/devdocs .
# Finally, start a DevDocs container (access http://localhost:9292)
docker run --name devdocs -d -p 9292:9292 thibaut/devdocs
```
2013-10-24 20:25:52 +02:00
## Vision
2013-12-12 17:17:32 +01:00
DevDocs aims to make reading and searching reference documentation fast, easy and enjoyable.
2013-10-24 20:25:52 +02:00
2022-07-26 11:49:11 +02:00
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
2022-07-26 11:49:11 +02:00
* 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.
2013-10-24 20:25:52 +02:00
2016-03-27 17:39:38 +02:00
**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.
2013-10-24 20:25:52 +02:00
## App
2016-03-27 17:39:38 +02:00
The web app is all client-side JavaScript, written in [CoffeeScript](http://coffeescript.org), and powered by a small [Sinatra](http://www.sinatrarb.com)/[Sprockets](https://github.com/rails/sprockets) application. It relies on files generated by the [scraper](#scraper).
2013-10-24 20:25:52 +02:00
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.
2019-07-07 14:30:31 +02:00
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.
2013-10-24 20:25:52 +02:00
DevDocs being a developer tool, the browser requirements are high:
2018-10-09 00:08:23 +02:00
* Recent versions of Firefox, Chrome, or Opera
2019-07-10 21:10:36 +02:00
* Safari 11.1+
* Edge 17+
* iOS 11.3+
2013-10-24 20:25:52 +02:00
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](#app). It's written in Ruby under the `Docs` module.
2014-04-19 18:28:24 +02:00
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](http://nokogiri.org).
2013-10-24 20:25:52 +02:00
Modifications made to each document include:
2015-01-14 02:29:19 +01:00
2014-01-27 00:26:37 +01:00
* removing content such as the document structure (`<html>`, `<head>`, etc.), comments, empty nodes, etc.
2013-10-24 20:25:52 +02:00
* 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
2014-01-27 00:26:37 +01:00
* adding content, such as a title and link to the original document
* ensuring correct syntax highlighting using [Prism](http://prismjs.com/)
2013-10-24 20:25:52 +02:00
2016-03-27 17:39:38 +02:00
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.
2013-10-24 20:25:52 +02:00
2016-03-27 17:39:38 +02:00
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.).
2013-10-24 20:25:52 +02:00
More information about [scrapers](./docs/scraper-reference.md) and [filters](./docs/filter-reference.md) is available in the `docs` folder.
2013-10-24 20:25:52 +02:00
## Available Commands
The command-line interface uses [Thor](http://whatisthor.com). To see all commands and options, run `thor list` from the project's root.
2020-11-18 22:22:46 +01:00
```sh
2013-10-24 20:25:52 +02:00
# 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
2013-10-24 20:25:52 +02:00
# Console
thor console # Start a REPL
thor console:docs # Start a REPL in the "Docs" module
2020-11-18 22:22:46 +01:00
# Tests can be run quickly from within the console using the "test" command.
# Run "help test" for usage instructions.
2013-10-24 20:25:52 +02:00
thor test:all # Run all tests
thor test:docs # Run "Docs" tests
thor test:app # Run "App" tests
2013-10-24 20:25:52 +02:00
# 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`.
2013-10-24 20:25:52 +02:00
## Contributing
Contributions are welcome. Please read the [contributing guidelines](./.github/CONTRIBUTING.md).
2013-10-24 20:25:52 +02:00
2019-01-07 21:22:52 +01:00
## 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)
2019-09-02 02:15:15 +02:00
## Related Projects
Made something cool? Feel free to open a PR to add a new row to this table!
2019-09-02 02:15:15 +02:00
| Project | Description | Last commit |
|---------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Sublime Text plugin](https://sublime.wbond.net/packages/DevDocs) | Sublime Text plugin to search DevDocs by selection or by input. | [![Latest GitHub commit](https://img.shields.io/github/last-commit/vitorbritto/sublime-devdocs?logo=github&label)](https://github.com/vitorbritto/sublime-devdocs) |
| [Atom plugin](https://atom.io/packages/devdocs) | Atom plugin adding the `doc` command to search DevDocs. | [![Latest GitHub commit](https://img.shields.io/github/last-commit/masnun/atom-devdocs?logo=github&label)](https://github.com/masnun/atom-devdocs) |
| [gruehle/dev-docs-viewer](https://github.com/gruehle/dev-docs-viewer) | Brackets extension for searching and viewing DevDocs content. | [![Latest GitHub commit](https://img.shields.io/github/last-commit/gruehle/dev-docs-viewer?logo=github&label)](https://github.com/gruehle/dev-docs-viewer) |
| [naquad/devdocs-shell](https://github.com/naquad/devdocs-shell) | GTK shell with Vim integration. | [![Latest GitHub commit](https://img.shields.io/github/last-commit/naquad/devdocs-shell?logo=github&label)](https://github.com/naquad/devdocs-shell) |
| [skeeto/devdocs-lookup](https://github.com/skeeto/devdocs-lookup) | Quick Emacs API lookup on DevDocs. | [![Latest GitHub commit](https://img.shields.io/github/last-commit/skeeto/devdocs-lookup?logo=github&label)](https://github.com/skeeto/devdocs-lookup) |
| [yannickglt/alfred-devdocs](https://github.com/yannickglt/alfred-devdocs) | Alfred workflow for DevDocs. | [![Latest GitHub commit](https://img.shields.io/github/last-commit/yannickglt/alfred-devdocs?logo=github&label)](https://github.com/yannickglt/alfred-devdocs) |
| [waiting-for-dev/vim-www](https://github.com/waiting-for-dev/vim-www) | Vim search plugin with DevDocs in its defaults. | [![Latest GitHub commit](https://img.shields.io/github/last-commit/waiting-for-dev/vim-www?logo=github&label)](https://github.com/waiting-for-dev/vim-www) |
| [vscode-devdocs for VS Code](https://marketplace.visualstudio.com/items?itemName=akfish.vscode-devdocs) | VS Code plugin to open and search DevDocs inside VS Code. | [![Latest GitHub commit](https://img.shields.io/github/last-commit/akfish/vscode-devdocs?logo=github&label)](https://github.com/akfish/vscode-devdocs) |
| [devdocs for VS Code](https://marketplace.visualstudio.com/items?itemName=deibit.devdocs) | VS Code plugin to open the browser to search selected text on DevDocs. | [![Latest GitHub commit](https://img.shields.io/github/last-commit/deibit/vscode-devdocs?logo=github&label)](https://github.com/deibit/vscode-devdocs) |
| [egoist/devdocs-desktop](https://github.com/egoist/devdocs-desktop) | Cross-platform desktop application for DevDocs. | [![Latest GitHub commit](https://img.shields.io/github/last-commit/egoist/devdocs-desktop?logo=github&label)](https://github.com/egoist/devdocs-desktop) |
| [qwfy/doc-browser](https://github.com/qwfy/doc-browser) | Native Linux app that supports DevDocs docsets. | [![Latest GitHub commit](https://img.shields.io/github/last-commit/qwfy/doc-browser?logo=github&label)](https://github.com/qwfy/doc-browser) |
| [hardpixel/devdocs-desktop](https://github.com/hardpixel/devdocs-desktop) | GTK3 application for DevDocs with search integrated in the headerbar. | [![Latest GitHub commit](https://img.shields.io/github/last-commit/hardpixel/devdocs-desktop?logo=github&label)](https://github.com/hardpixel/devdocs-desktop) |
| [dteoh/devdocs-macos](https://github.com/dteoh/devdocs-macos) | Native macOS application for DevDocs. | [![Latest GitHub commit](https://img.shields.io/github/last-commit/dteoh/devdocs-macos?logo=github&label)](https://github.com/dteoh/devdocs-macos) |
| [Merith-TK/devdocs_webapp_kotlin](https://github.com/Merith-TK/devdocs_webapp_kotlin) | Android application which shows DevDocs in a webview. | [![Latest GitHub commit](https://img.shields.io/github/last-commit/Merith-TK/devdocs_webapp_kotlin?logo=github&label)](https://github.com/Merith-TK/devdocs_webapp_kotlin) |
| [astoff/devdocs.el](https://github.com/astoff/devdocs.el) | Emacs viewer for DevDocs | [![Latest GitHub commit](https://img.shields.io/github/last-commit/astoff/devdocs.el?logo=github&label)](https://github.com/astoff/devdocs.el) |
| [DevDocs Tab for VS Code](https://github.com/mohamed3nan/DevDocs-Tab) | VS Code extension to search displaying DevDocs.io in a tab. | [![Latest GitHub commit](https://img.shields.io/github/last-commit/mohamed3nan/DevDocs-Tab?logo=github&label)](https://github.com/mohamed3nan/DevDocs-Tab) |
| [quickDocs](https://github.com/mdh34/quickDocs) | DevDocs viewer written in Vala/Python. | [![Latest GitHub commit](https://img.shields.io/github/last-commit/mdh34/quickDocs?logo=github&label)](https://github.com/mdh34/quickDocs) |
| [romainl/vim-devdocs](https://github.com/romainl/vim-devdocs) | Look up keyword on DevDocs from Vim. | [![Latest GitHub commit](https://img.shields.io/github/last-commit/romainl/vim-devdocs?logo=github&label)](https://github.com/romainl/vim-devdocs) |
2019-01-27 22:48:37 +01:00
2013-10-24 20:25:52 +02:00
## Copyright / License
2021-02-15 19:01:05 +01:00
Copyright 20132021 Thibaut Courouble and [other contributors](https://github.com/freeCodeCamp/devdocs/graphs/contributors)
2013-10-24 20:25:52 +02:00
This software is licensed under the terms of the Mozilla Public License v2.0. See the [COPYRIGHT](./COPYRIGHT) and [LICENSE](./LICENSE) files.
2013-10-24 20:25:52 +02:00
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.
2013-10-24 20:25:52 +02:00
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!
2013-10-24 20:25:52 +02:00
## Questions?
2022-07-06 17:40:27 +02:00
If you have any questions, please feel free to ask them on the contributor chat room on [Discord](https://discord.gg/PRyKn3Vbay).