|
1 | 1 | # Ember JSON API Docs [](https://travis-ci.org/ember-learn/ember-jsonapi-docs)
|
2 | 2 |
|
3 |
| -This is an internal tool for generating API docs for the Ember.js framework and exposing it through [JSON:API](http://jsonapi.org/) for various applications (e.g. https://api.emberjs.com/). The tool allows you to: |
| 3 | +This tool gets the code comments from `ember.js` and `ember-data` libraries, |
| 4 | +turns them into JSON files, and then turns those JSON files into a |
| 5 | +[JSON:API](http://jsonapi.org/) format. |
4 | 6 |
|
5 |
| -- Generate API docs from [YUIDoc](http://yui.github.io/yuidoc/syntax/index.html) comments in the [emberjs/ember.js](https://github.com/emberjs/ember.js/) and [emberjs/data](https://github.com/emberjs/data) repositories in [YUIDoc](http://yui.github.io/yuidoc/) and [JSON:API](http://jsonapi.org/) formats. |
6 |
| -- Publish docs to an Amazon S3 bucket (`s3://api-docs.emberjs.com`). |
7 |
| -- Expose API docs in the JSON:API format through API. |
| 7 | +The files this tool creates are used to power |
| 8 | +[api.emberjs.com](https://api.emberjs.com). |
8 | 9 |
|
9 |
| -All the generated files are stored in the `tmp` folder under the project root: |
10 | 10 |
|
11 |
| -``` |
12 |
| -tmp |
13 |
| -├── json-docs // JSON:API-comlaint docs generated locally from YUIDoc files in `s3-docs`. |
14 |
| -├── rev-index // Rev index files used for generating JSON:API-comlaint docs. |
15 |
| -├── s3-docs // YUIDoc docs generated locally or downloaded from s3://api-docs.emberjs.com. |
16 |
| -``` |
17 |
| - |
18 |
| -> ℹ️ **NOTE:** If you are looking for the app behind https://api.emberjs.com/, visit [ember-api-docs](https://github.com/ember-learn/ember-api-docs) instead. |
| 11 | +> ℹ️ **NOTE:** If you are looking for the front end app behind https://api.emberjs.com/, visit [ember-api-docs](https://github.com/ember-learn/ember-api-docs) instead. |
19 | 12 |
|
20 | 13 | ## Prerequisites
|
21 | 14 |
|
22 |
| -1. Install the latest [Node.js](https://nodejs.org/) LTS. |
23 |
| -2. Install [AWS CLI version 2](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-install.html). |
24 |
| -3. Create an account in [AWS Management Console](https://console.aws.amazon.com). [Create a New Access Key](https://docs.aws.amazon.com/general/latest/gr/managing-aws-access-keys.html) (access key ID and secret access key) in *My Security Credentials* under your profile name to be able to access public AWS S3 buckets. |
| 15 | +- the latest [Node.js](https://nodejs.org/) LTS |
| 16 | +- [yarn v1](https://yarnpkg.com/) |
25 | 17 |
|
26 |
| -## Quickstart |
| 18 | +Clone all of the following repositories into the same directory so they are "siblings" on the file system |
27 | 19 |
|
28 |
| -### Generate Docs from Ember Source |
| 20 | +- This repository, `ember-jsonapi-docs` |
| 21 | +- [ember-api-docs-data](https://github.com/ember-learn/ember-api-docs-data) |
| 22 | +- [ember.js](https://github.com/emberjs/ember.js) |
| 23 | +- [ember-data](https://github.com/emberjs/data/) |
29 | 24 |
|
30 |
| -You can generate docs from your local copies of [emberjs/ember.js](https://github.com/emberjs/ember.js/) and [emberjs/data](https://github.com/emberjs/data) repositories and serve them locally as [JSON:API](http://jsonapi.org/). |
| 25 | +## Generate docs |
31 | 26 |
|
32 |
| -```bash |
33 |
| -# Clone Ember.js and Ember Data repositories into the same root folder. |
34 |
| -git clone https://github.com/emberjs/ember.js/ |
35 |
| -git clone https://github.com/emberjs/data |
| 27 | +Decide which version and project you want to build docs for. |
| 28 | +Then, in `ember.js` and/or `ember-data` repositories, check out the version |
| 29 | +tags you want to generate docs for. For example: |
36 | 30 |
|
37 |
| -# Clone this repository into the same root folder. |
38 |
| -git clone https://github.com/ember-learn/ember-jsonapi-docs |
39 |
| -cd ember-jsonapi-docs |
40 |
| - |
41 |
| -# Install the dependencies. |
42 |
| -yarn |
| 31 | +```sh |
| 32 | +get fetch --all |
| 33 | +git checkout v5.2.0 |
| 34 | +``` |
43 | 35 |
|
44 |
| -# Generate docs for a particular project from its local repository. |
45 |
| -# Version should match the one in `package.json` of a target project. |
46 |
| -yarn gen --project ember --version 3.17.0 |
47 |
| -yarn gen --project ember-data --version 3.17.0 |
| 36 | +Generate the JSON docs for `ember` and/or `ember-data`. This will add new JSON |
| 37 | +files into the `s3-docs` directory of `ember-api-docs-data`: |
48 | 38 |
|
49 |
| -# Run API locally. |
50 |
| -yarn serve |
| 39 | +```sh |
| 40 | +yarn |
| 41 | +yarn gen --project ember --version "5.2.0" |
51 | 42 | ```
|
52 | 43 |
|
53 |
| -> ℹ️ **NOTE:** `--version` should match the one in the `package.json` of a target Ember project. If `package.json` uses a release name (e.g. `beta` or `canary`), omit it and use only numbers. For example, if the `package.json` says `3.19.0-beta.2`, use `3.19.0`. |
54 |
| -
|
55 |
| -> ✅ **TIP:** If you are debugging failed builds, periodically clear out the contents of the `tmp` directory, and run the script again. Past failed runs can cause subsequent runs to fail in unexpected ways. |
| 44 | +I would recommend committing at this stage so that you can see that the following steps work. |
56 | 45 |
|
57 |
| -### Generate Docs from YUIDoc Files Stored in AWS |
| 46 | +```sh |
| 47 | +cd ../ember-api-docs-data/ |
| 48 | +git add . |
| 49 | +git commit -m "add docs for ember v5.2.0" |
| 50 | +``` |
58 | 51 |
|
59 |
| -All [Ember.js](https://github.com/emberjs/ember.js/) and [Ember.js Data](https://github.com/emberjs/data) releases have already generated docs in a public Amazon S3 bucket (`s3://api-docs.emberjs.com`). You can download them and serve locally as [JSON:API](http://jsonapi.org/). |
| 52 | +Next we need to fix the generated files. (Note: this step could probably be incorporated into ember-jsonapi-docs |
| 53 | +but for now this step works). |
60 | 54 |
|
61 |
| -> ⚠️ **WARNING:** The app tries to process all Ember.js and Ember Data versions since 1.0 which takes high memory & time to complete. |
| 55 | +```sh |
| 56 | +node ./clean-urls.js |
| 57 | +node ./fix-rev-index.js |
| 58 | +git add . |
| 59 | +git commit -m "fix urls and rev-index for ember" |
| 60 | +``` |
62 | 61 |
|
63 |
| -```bash |
64 |
| -# Clone the repository. |
65 |
| -git clone https://github.com/ember-learn/ember-jsonapi-docs |
66 |
| -cd ember-jsonapi-docs |
| 62 | +Lastly we need to make sure that each of the new files are valid. You need to run the test suite in `ember-api-docs-data` |
67 | 63 |
|
68 |
| -# Install the dependencies. |
69 |
| -yarn |
70 |
| - |
71 |
| -# Set environment variables to get access to s3://api-docs.emberjs.com. |
72 |
| -# Use Access Keys generated in step 3 in "Prerequisites". |
73 |
| -export AWS_ACCESS_KEY_ID=xxxxxx |
74 |
| -export AWS_SECRET_ACCESS_KEY=xxxxx |
| 64 | +```sh |
| 65 | +npm i |
| 66 | +npm test |
| 67 | +``` |
75 | 68 |
|
76 |
| -# Download YUIDoc docs and index files for all projects/releases from s3://api-docs.emberjs.com. |
77 |
| -# Then, generate JSON:API-comlaint docs from the downloaded files. |
78 |
| -yarn start --sync --max_old_space_size=8192 |
| 69 | +If you see any errors e.g. `AssertionError: expected '' not to be empty` you need to manually fix these. These are caused by bugs in the yuidoc generation and can probably be fixed in the source files somehow. |
79 | 70 |
|
80 |
| -# At this point, you can also generate JSON:API-comlaint docs only for |
81 |
| -# a particular project/release. |
82 |
| -yarn start --project ember --version 3.17.0 |
83 |
| -yarn start --project ember-data --version 3.17.0 |
| 71 | +Once all of the fixes are in place you can commit them: |
84 | 72 |
|
85 |
| -# Run API locally. |
86 |
| -yarn serve |
| 73 | +```sh |
| 74 | +git add . |
| 75 | +git commit -m "fixing tests for ember" |
87 | 76 | ```
|
88 | 77 |
|
89 |
| -> ℹ️ **NOTE:** If docs for a particular version are missing in `s3://api-docs.emberjs.com`, the tool downloads them from npm (e.g. https://unpkg.com/[email protected]/docs/data.json) as a fallback. |
90 |
| -
|
91 |
| -## Overriding a specific version of YUIDoc file with a local copy (for core contributors). |
| 78 | +--- |
92 | 79 |
|
93 |
| -To proceed, you need AWS Access Keys to publish to [api-docs.emberjs.com](http://api-docs.emberjs.com/) and all necessary environemnt variables set. |
| 80 | +Once that is all committed I would recommend doing the same thing for ember-data with new commits: |
94 | 81 |
|
95 |
| -> ⚠️ **WARNING:** In its present form this should be used only when there aren't new docs out there that are yet to be processed. For example, if Ember 3.17 is released but isn't indexed yet you should wait for this app to finish processing it via the cron job on Heroku before you can proceed to modify any of the existing docs from your machine. |
| 82 | +```sh |
| 83 | +cd ../ember-jsonapi-docs |
| 84 | +yarn gen --project ember-data --version "5.2.0" |
96 | 85 |
|
97 |
| -```bash |
98 |
| -# Set environment variables. |
99 |
| -export AWS_ACCESS_KEY_ID=xxxxxx |
100 |
| -export AWS_SECRET_ACCESS_KEY=xxxxx |
| 86 | +cd ../ember-api-docs-data |
101 | 87 |
|
102 |
| -# Download YUIDoc docs and index files for all releases from s3://api-docs.emberjs.com. |
103 |
| -# This is important so that we don't loose other versions of docs that |
104 |
| -# are already out there when the index files are generated. |
105 |
| -yarn start --sync --max_old_space_size=8192 |
| 88 | +git add . |
| 89 | +git commit -m "add docs for ember-data v5.2.0" |
106 | 90 |
|
107 |
| -# Go to the folder and and replace a YUIDoc file that you want to be processed. |
108 |
| -# Ensure that the file name is same as the one that's already there. |
109 |
| -cd tmp/s3-docs/<VERSION_TO_REPLACE> |
| 91 | +node ./clean-urls.js |
| 92 | +node ./fix-rev-index.js |
| 93 | +git add . |
| 94 | +git commit -m "fix urls and rev-index for ember-data" |
110 | 95 |
|
111 |
| -# Set an environment variable to enable publishing to s3://api-docs.emberjs.com. |
112 |
| -export AWS_SHOULD_PUBLISH=yes |
| 96 | +npm test |
113 | 97 |
|
114 |
| -# Regenerate JSON:API-comlaint docs only for a particular project/release and |
115 |
| -# publish them to s3://api-docs.emberjs.com... |
116 |
| -yarn start --project ember --version <VERSION_TO_REPLACE> --ignorePreviouslyIndexedDoc |
117 |
| -yarn start --project ember-data --version <VERSION_TO_REPLACE> --ignorePreviouslyIndexedDoc |
118 |
| - |
119 |
| -# OR |
120 |
| -# Regenerate JSON:API-comlaint docs for ALL projects/releases regardless of indexed version and |
121 |
| -# publish them to s3://api-docs.emberjs.com. |
122 |
| -yarn start --clean --max_old_space_size=8192 |
| 98 | +# if you needed to fix any files you do that now and then |
| 99 | +git add . |
| 100 | +git commit -m "fixing tests for ember-data" |
123 | 101 | ```
|
124 | 102 |
|
125 |
| -## Backing Up Docs |
126 |
| - |
127 |
| -If you plan to run a major migration, back up all the content to a timestamped folder in the Amazon S3 bucket. |
| 103 | +Once that is all done, push it and open a PR 🎉 |
128 | 104 |
|
129 |
| -```bash |
130 |
| -yarn backup |
131 |
| -``` |
| 105 | +> ℹ️ **NOTE:** `--version` should match the one in the `package.json` of a target Ember project. If `package.json` uses a release name (e.g. `beta` or `canary`), omit it and use only numbers. For example, if the `package.json` says `3.19.0-beta.2`, use `3.19.0`. |
132 | 106 |
|
133 |
| -## FAQ |
| 107 | +> ✅ **TIP:** If you are debugging failed builds, periodically discard the changes |
| 108 | +made to `ember-api-docs-data`, since changes are made in-place. |
134 | 109 |
|
135 |
| -### Can I use API from the [ember-api-docs](https://github.com/ember-learn/ember-api-docs) app? |
| 110 | +## (Optional) View the generated docs in a web app |
136 | 111 |
|
137 |
| -Yes, follow one of the quickstarts and then run the `ember-api-docs` application using the following commands. |
| 112 | +The Prembered version of the ember-api-docs expects a folder in its root that links to the `ember-api-docs-data` folder, so all you need to do is create a symbolic link to ember-api-docs-data and you can see the app running locally. |
138 | 113 |
|
139 |
| -```bash |
140 |
| -# Start your local server for this repository |
141 |
| -yarn serve |
| 114 | +Clone the [ember-api-docs](https://github.com/ember-learn/ember-api-docs) |
| 115 | +repository, install dependencies, and start the front end in "local" mode: |
142 | 116 |
|
143 |
| -# Clone the repository with the "ember-api-docs" app. |
| 117 | +```sh |
144 | 118 | git clone https://github.com/ember-learn/ember-api-docs
|
145 | 119 | cd ember-api-docs
|
146 |
| - |
147 |
| -# Install the dependencies. |
| 120 | +ln -s ../ember-api-docs-data # assuming it's checked out in the same folder |
148 | 121 | npm install
|
149 |
| - |
150 |
| -# Run the application side by side with a locally running API. |
151 |
| -npm run start:local |
| 122 | +yarn start |
152 | 123 | ```
|
| 124 | + |
| 125 | +> Note: at the time of writing this the ember-api-docs app needs to be on the `prember` branch but this will change very soon when we go live with it. |
| 126 | +
|
| 127 | +Visit the app in your browser at [http://localhost:4200](http://localhost:4200) |
0 commit comments