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

Support standalone docs apps #409

Merged
merged 2 commits into from
Nov 1, 2019

Conversation

ef4
Copy link
Contributor

@ef4 ef4 commented Oct 10, 2019

This makes it possible to separate your docs application from your addon's dummy app. Fixes #383.

The way it works is:

  • you're still required to keep both the addon and the docs app in the same repo (so we don't need to worry about separately versioning each)
  • but they can be peers or subdirectories of each other
  • in your docs application you add ember-cli-addon-docs
  • in your docs application you must set the documentingAddonAt option to point at the path of the actual addon. This option is what opts you into the new behavior, otherwise nothing should be changed.

As a side-effect of refactoring the way "Edit this page" links work, I think I also fixed them for API-docs pages in all addon docs sites (not just ones using this new architecture).

This makes it possible to separate your docs application from your addon's dummy app. Fixes ember-learn#383.

The way it works is:
 - you're still required to keep both the addon and the docs app in the same repo (so we don't need to worry about separately versioning each)
 - but they can be peers or subdirectories of each other
 - in your docs application you add ember-cli-addon-docs
 - in your docs application you must set the `documentingAddonAt` option to point at the path of the actual addon.

As a side-effect of refactoring the way "Edit this page" links work, I think I also fixed them for API-docs pages in all addon docs sites (not just ones using this new architecture).
@@ -1,5 +1,5 @@
import DS from 'ember-data';
import config from 'dummy/config/environment';
import config from 'ember-get-config';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This and the many other edits like it are because we don't want to hard-code the name "dummy" as our app's modulePrefix.

let rootEditUrl = `${projectHref}/edit/${primaryBranch}${projectPath}`;
let match = this._locateFile(path);
if (match) {
let { projectHref, addonPathInRepo, docsAppPathInRepo, primaryBranch } = config['ember-cli-addon-docs'];
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now instead of a single projectPathInRepo, we have separate addonPathInRepo and docsAppPathInRepo.

@ef4
Copy link
Contributor Author

ef4 commented Oct 10, 2019

As of ember-animation/ember-animated#171 ember-animated is using this fork, so you can see how it works. It's deployed as https://ember-animation.github.io/ember-animated/versions/master/

@samselikoff
Copy link
Contributor

Amazing amount of effort + work. Thanks for donating so much to this community project!

Could you give us a tl;dr of the steps an Addon should/would take to move from the dummy app to a standalone /docs app?

@ef4
Copy link
Contributor Author

ef4 commented Oct 11, 2019

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. 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. Configure the docs app's ember-cli-build.js to tell ember-cli-addon-docs to point at the addon:

    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 (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. Remember to configure CI to run ember test in both the addon and the docs app.

  8. If you have a nested docs app, remember to configure .npmignore or equivalent so you don't publish the whole docs app to NPM.

@samselikoff
Copy link
Contributor

@ef4 any idea if Dependabot will work with both the root addon and the app in a subdirectory?

@ef4
Copy link
Contributor Author

ef4 commented Oct 11, 2019

I think dependabot lets you configure individual directories in a repo, but somebody should try it.

@RobbieTheWagner
Copy link
Member

@samselikoff are we good to merge this?

@samselikoff
Copy link
Contributor

I think it would be fine to merge but also would be good to get one other app testing it? Ideally even a test-project within this repo but if that's too much work just convert some other Addon to use a separate project.

@josemarluedke
Copy link
Contributor

I started working on a new set of addons and created an app for the docs. I tested this branch with my setup and it is working as expected. It would be awesome to get this merged into master and released.

My setup is here: https://github.com/josemarluedke/frontile/tree/docs-app

@RobbieTheWagner
Copy link
Member

@samselikoff is that good enough to merge?

@samselikoff samselikoff merged commit 5fb1cc8 into ember-learn:master Nov 1, 2019
@samselikoff
Copy link
Contributor

Seems good! Will try to do this on one of my addons soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enforce a hard boundary between addon and docs
4 participants