--- layout: doc-page.html --- # Documentation infrastructure The documentation is authored in markdown in the `docs` directory. We're using [markdown-it](https://www.npmjs.com/package/markdown-it) (but staying close to [Github Flavored Markdown](https://help.github.com/articles/github-flavored-markdown/)) to convert the markdown to HTML. [markdownlint](https://github.com/DavidAnson/markdownlint/) is there to lint the files, its configuration is maintained in `build/markdownlint.js`, see the [Rules](https://github.com/DavidAnson/markdownlint/blob/master/doc/Rules.md). The idea is to create a documentation that can be read on github and on the generated website. :::note If this is your first contact with ally.js, make sure to run `npm run init` after cloning the repository. This will run `npm install`, `npm run clean`, `npm run build` and `npm run build:website` to make sure your local copy is ready. ::: ## Building the website The doc source are converted to HTML by [metalsmith](http://metalsmith.io/), the scripts and configuration are maintained in the `build/metalsmith` directory. The website is comprised of 3 elements, the markdown sources, data tables and some legacy files from `./tests`. ```sh # lint the markdown npm run lint:md # build the library (to `./dist`) npm run build # generate website (to `./web`) npm run build:website # generate only the markdown files npm run build:docs # generate only the data tables npm run build:data-tables # generate only the legacy files npm run build:legacy ``` The commands `lint:md` and `build:website` are also executed by `npm run lint` and `npm run build`. :::note Before you build the website using `npm run build:website` you need to have run `npm run build` before, in order for the library components to be available to the website build. You don't need to build the library every time you build the website, which is why this step is disconnected. If you ran `npm run init` after cloning the repository, everything is taken care of already. ::: If you're new to metalsmith, have a look at [simple static site demo](https://github.com/segmentio/metalsmith/tree/master/examples/static-site) and [getting to know metalsmith](http://www.robinthrift.com/posts/getting-to-know-metalsmith/). We use the following plugins: * [metalsmith-packagejson](https://www.npmjs.com/package/metalsmith-packagejson) to import `package.json` * [metalsmith-markdownit](https://github.com/attentif/metalsmith-markdownit) * [metalsmith-register-helpers](https://github.com/losttype/metalsmith-register-helpers) to use custom handlebar helpers * [metalsmith-layouts](https://github.com/superwolff/metalsmith-layouts) to use [handlebars](http://handlebarsjs.com/) templates * [metalsmith-collections](https://github.com/segmentio/metalsmith-collections) to deal with groups of files * [metalsmith-static](https://github.com/TheHydroImpulse/metalsmith-static) to copy static assets * [metalsmith-redirect](https://github.com/aymericbeaumet/metalsmith-redirect/) to create HTML redirection files to forward old URLs to their new homes ## Website search The website's autosuggest-based search is powered by [Algolia](https://www.algolia.com/). As part of `npm run build:website` the index files `web/algolia.*.json` are generated, which can be uploaded using `npm run publish:algolia`. ## Authoring documentation The public API provided by ally.js needs to be explained in `docs/api`. As every component has its source file, it has an accompanying markdown file for documentation. ally.js contains components that are not meant to be used directly, thus do not have to be documented in detail. Anything you document should be written in a way that caters to an audience that may not know very much about accessibility. If bigger picture explanations are required, consider writing a tutorial instead of cramming it into the API docs. ### Embedding examples and Demos Using [markdown-it-container](https://www.npmjs.com/package/markdown-it-container) the documentation accepts `@@@` fenced markdown blocks to embed [jsbin.com](https://jsbin.com) hosted code examples. ```markdown @@@example /api/path/to/name.example.html ### title of example @@@ ``` The example block's first headline's text is automatically replaced by the example document's title. Additional content (like notes, warnings) may be provided in the example block. The example file is referenced by its absolute path from the perspective of the `docs` directory. An example document is named `${slug}.example.html` (for multiple `${slug}.example-2.html`) and placed in the same directory as the referencing document. So for `docs/api/element/disabled.md` the example file would be `docs/api/element/disabled.example.html`. Example documents must follow the following general structure. ```html ally.js ${example_title} Example

Accessible ${example_title} Tutorial

${example_description}

${example_markup}
``` The command `npm run publish:jsbin` uses [jsbin-sync](https://github.com/rodneyrehm/jsbin-sync) to find all `example*.html` files and upload them to [JSBin.com](https://jsbin.com). *This can only be executed by [Rod](https://github.com/rodneyrehm), as we're using his personal JSBin pro account for this.* New examples will have their empty `` element updated to the URL returned by JSBin, but this is the only change applied to source files. Contents of `#example-js` and `#example-css` go into the bin's JavaScript and CSS sections, respecively. The bin's HTML section contains the HTML document, *without* the `