angular-cn/aio
Peter Bacon Darwin 58f080a325 build(aio): add `doc-watch` yarn task for docs authors
This task is suitable for day to day docs authoring.

This task cuts corners, which makes it much faster than a full `yarn docs`
run but it does not produce completely valid output.
In general this isgood enough for authors to see their changes as they make them.

The task is triggered by a call to

```
yarn docs-watch
```

This sets up watchers on the `aio/contents` and `packages` folders.
Any changes to files below these folders new doc generation run to start.
The input to the generation is confined to a collection of files related
to the changed file. For example:

* a change to a file in `aio/content/marketing` will generate all the
marketing files.
* a change to a file in `aio/content/tutorial` or `aio/examples/toh-*`
will generate all the tutorial files (and their embedded examples).
* a change to a file in `aio/guide` or `aio/examples` (but not a `toh-`
example) will generate the appropriate guide and its embedded examples
* a change to a file in `packages` or `packages/examples` will generate
the appropriate API doc and its embedded examples.

Be aware that the mapping between docs and its examples are based on doc file
and example folder structure being equivalent. Sometimes a doc will reference
an example in a different folder, in which case the generated doc will be
inaccurate. Mostly this is not a big problem.
2017-04-16 20:56:10 +01:00
..
aio-builds-setup feat(aio): add log rotation in preview server 2017-04-15 10:22:40 +01:00
content docs(aio): fix jade leftover from toh5 2017-04-16 20:32:40 +01:00
e2e feat(aio): marketing page styles 2017-04-03 15:48:52 -07:00
scripts ci(aio): do not fail if PWA score testing fails on staging 2017-04-15 17:14:28 +01:00
src feat(aio): edit page link styling and placement 2017-04-16 11:28:27 +01:00
tools docs(aio): final migration from old site 2017-04-12 21:01:55 +01:00
transforms build(aio): add `doc-watch` yarn task for docs authors 2017-04-16 20:56:10 +01:00
.angular-cli.json feat(aio): improve ProgressiveWepApp-ability (#15628) 2017-03-30 12:35:15 -07:00
.firebaserc build(aio): big move of docs related files (#14361) 2017-02-09 11:58:36 -08:00
.gitignore build(aio): update project config for @angular/cli v1.0.0 2017-03-27 11:55:26 -07:00
README.md build(aio): add `doc-watch` yarn task for docs authors 2017-04-16 20:56:10 +01:00
database.rules.json build(aio): big move of docs related files (#14361) 2017-02-09 11:58:36 -08:00
firebase.json fix(aio): do not fallback to `index.html` for file requests (#15401) 2017-03-22 15:31:47 -07:00
karma.conf.js build(aio): update project config for @angular/cli v1.0.0 2017-03-27 11:55:26 -07:00
ngsw-manifest.json feat(aio): support @angular/service-worker using the CLI generated service worker manifest (#15042) 2017-03-10 14:05:29 -08:00
package.json build(aio): add `doc-watch` yarn task for docs authors 2017-04-16 20:56:10 +01:00
protractor.conf.js build(aio): update project config for @angular/cli v1.0.0 2017-03-27 11:55:26 -07:00
tsconfig.json build(aio): update project config for @angular/cli v1.0.0 2017-03-27 11:55:26 -07:00
tslint.json test(aio): enable tslint rule for focused jasmine tests/suites 2017-04-01 20:56:16 +01:00
yarn.lock build(aio): add `doc-watch` yarn task for docs authors 2017-04-16 20:56:10 +01:00

README.md

Angular documentation project (https://angular.io)

Everything in this folder is part of the documentation project. This includes

  • the web site for displaying the documentation
  • the dgeni configuration for converting source files to rendered files that can be viewed in the web site.
  • the tooling for setting up examples for development; and generating plunkers and zip files from the examples.

Developer tasks

We use yarn to manage the dependencies and to run build tasks. You should run all these tasks from the angular/aio folder. Here are the most important tasks you might need to use:

  • yarn - install all the dependencies.

  • yarn start - run a development web server that watches the files; then builds the doc-viewer and reloads the page, as necessary.

  • yarn lint - check that the doc-viewer code follows our style rules.

  • yarn test - watch all the source files, for the doc-viewer, and run all the unit tests when any change.

  • yarn e2e - run all the e2e tests for the doc-viewer.

  • yarn docs - generate all the docs from the source files.

  • yarn docs-watch - watch the Angular source and the docs files and run a short-circuited doc-gen for the docs that changed.

  • yarn docs-lint - check that the doc gen code follows our style rules.

  • yarn docs-test - run the unit tests for the doc generation code.

  • yarn boilerplate:add - generate all the boilerplate code for the examples, so that they can be run locally.

  • yarn boilerplate:remove - remove all the boilerplate code that was added via yarn boilerplate:add.

  • yarn generate-plunkers - generate the plunker files that are used by the live-example tags in the docs.

Guide to authoring

There are two types of content in the documentatation:

  • API docs: descriptions of the modules, classes, interfaces, decorators, etc that make up the Angular platform. API docs are generated directly from the source code. The source code is contained in TypeScript files, located in the angular/packages folder. Each API item may have a preceding comment, which contains JSDoc style tags and content. The content is written in markdown.

  • Other content: guides, tutorials, and other marketing material. All other content is written using markdown in text files, located in the angular/aio/content folder. More specifically, there are sub-folders that contain particular types of content: guides, tutorial and marketing.

We use the dgeni tool to convert these files into docs that can be viewed in the doc-viewer.

Generating the complete docs

The main task for generating the docs is yarn docs. This will process all the source files (API and other), extracting the documentation and generating JSON files that can be consumed by the doc-viewer.

Partial doc generation for editors

Full doc generation can take up to one minute. That's too slow for efficient document creation and editing.

While you can make small changes in a smart editor that displays formatted markdown (e.g,. VS Code), you also want to see those changes displayed properly in the doc viewer. You'll want a quicker edit/view cycle time.

For this purpose, use the yarn docs-watch task, which watches for changes to source files and only re-processes the the files necessary to generate the docs that are related to the file that has changed. Since this task takes shortcuts, it is much faster (often less than 1 second) but it won't produce full fidelity content. For example, links to other docs and code examples may not render correctly. This is most particularly noticed in links to other docs and in the embedded examples, which may not always render correctly.

The general setup is as follows:

  • Open a terminal, ensure the dependencies are installed; run an initial doc generation; then start the doc-viewer:
yarn
yarn docs
yarn start
  • Open a second terminal and start watching the docs
yarn docs-watch
  • Open a browser at https://localhost:4200/ and navigate to the document on which you want to work. You can automatically open the browser by using yarn start -- -o in the first terminal.

  • Make changes to the page's associated doc or example files. Every time a file is saved, the doc will be regenerated, the app will rebuild and the page will reload.