Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document using standalone apps #448

Merged
merged 1 commit into from
Jan 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions tests/dummy/app/pods/docs/standalone-apps/template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Standalone apps

ember-cli-addon-docs now supports shipping your docs site as a separate app,
rather than using the dummy app.

General steps to convert an existing dummy app to a separate app:

## 1. Decide whether you want a monorepo or a nested app.

Either should work, but they have different pros and cons. With a monorepo you only need to run `yarn install` once and you get efficient sharing of dependencies. But it's also harder for users to point their app directly at an unreleased commit or fork of your addon.

In my case, I went with a nested app, meaning I have a regular ember-addon, plus a `/docs` folder that contains a regular ember app. So you need to `yarn install` in both before the docs app will work.

## 2. Generate a new app to be your docs app, with `ember new`.

ember-cli doesn't like to generate new apps inside existing apps, so you may need to generate it elsewhere first and then move it into place.

## 3. Make your docs app depend on your addon.

In my case, I did it as an [in repo addon](https://github.com/ember-animation/ember-animated/blob/152943adb41cdf2de8082b679daafffd6f9c3f77/docs/package.json#L70). If you're using a monorepo with yarn workspaces, you can have a regular `devDependency` on it instead.

## 4. Add `ember-cli-addon-docs` to your docs app.

## 5. Set `documentingAddonAt`

Configure the docs app's `ember-cli-build.js` to tell ember-cli-addon-docs to point at the addon:

```js
let app = new EmberApp(defaults, {
'ember-cli-addon-docs': {
documentingAddonAt: '..'
}
});
```

At this point you should be able to run the docs app and it should look the same as if you had just added ember-cli-addon-docs for the first time to your addon.

## 6. Move all the things

Move all the things (routes, templates, components, styles, etc) in your tests/dummy app into your new docs app. Also move any tests that are specifically about testing the docs app, as opposed to testing the addon. When you're done, you'll still have a dummy app and you can still use it for dev and test, but it won't contain the docs.

## 7. Configure CI

Remember to configure CI to run `ember test` in both the addon and the docs app.

## 8. Configure `.npmignore`

If you have a nested docs app, remember to configure `.npmignore` or equivalent so you don't publish the whole docs app to NPM.
1 change: 1 addition & 0 deletions tests/dummy/app/pods/docs/template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
{{nav.item "Patterns" "docs.patterns"}}
{{nav.item "Build options" "docs.build-options"}}
{{nav.item "Deploying" "docs.deploying"}}
{{nav.item "Standlone Apps" "docs.standalone-apps"}}

{{nav.section "Components"}}
{{nav.item "Header" "docs.components.docs-header"}}
Expand Down
1 change: 1 addition & 0 deletions tests/dummy/app/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Router.map(function() {
this.route('patterns');
this.route('build-options');
this.route('deploying');
this.route('standalone-apps');

this.route('components', function() {
this.route('docs-hero');
Expand Down