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

Adding docs-page blueprint. #343

Merged
merged 6 commits into from
Apr 5, 2019

Conversation

scalvert
Copy link
Contributor

@scalvert scalvert commented Mar 28, 2019

Wanted to push up this WIP PR that adds blueprint support for adding a docs page.

I've been on a bit of a tear updating all my addons to use ember-cli-addon-docs, and I absolutely love it. One thing that feels like it's missing though is a blueprint for adding a docs page. I want it to be able to

  • Add the markdown file under docs
  • Update the router with my docs page route
  • Add the {{nav.item ...}} to the docs.hbs (if it exists)

Sample usage:

ember g docs-page foo-bar-baz

Generates:

installing docs-page
  create tests/dummy/app/templates/docs/foo-bar-baz.md
updating router
  add route foo-bar-baz

Docs update:

Docs page generator documentation

@pzuraq
Copy link
Contributor

pzuraq commented Mar 28, 2019

I'm definitely plus one on this, seems like it could help cut down on a lot of boilerplate work 😄

@scalvert scalvert changed the title [WIP] - Adding docs-page blueprint. Includes router invocation. Adding docs-page blueprint. Includes router invocation. Apr 3, 2019
@scalvert
Copy link
Contributor Author

scalvert commented Apr 3, 2019

I was starting to write some nice tests for this functionality using ember-cli-blueprint-test-helpers, which has some nice helpers to create new addons/test blueprints. Unfortunately, that package uses mocha/chai, and the node tests in this repo use QUnit.

I'm open to still adding tests, but will have to do a bunch of fandangling to make it work. Thoughts on the importance of adding tests for this blueprint, @dfreeman, @samselikoff, @pzuraq? (I have guilt just asking that...).

@samselikoff
Copy link
Contributor

I think I'm ok with merging this for now, @pzuraq @dfreeman?

I think ultimately it'd be great to get a filesystem-based solution perhaps with some frontmatter on docs pages that would do most of this automatically for us. But I think this is a great first step to improving the experience.

@samselikoff
Copy link
Contributor

Could you document the generator somewhere?

@scalvert
Copy link
Contributor Author

scalvert commented Apr 4, 2019

Absolutely. I’ll add to the docs.

@dfreeman
Copy link
Contributor

dfreeman commented Apr 4, 2019

Agreed that it's probably fine to go ahead and merge this—if it does break, at least it won't bring down people's documentation. Thank you for proposing this, @scalvert!

Separately, we might want to consider migrating our node tests to mocha at some point, since that's more aligned with what most projects are using for that.

@scalvert
Copy link
Contributor Author

scalvert commented Apr 4, 2019

@dfreeman if a port to mocha does proceed, I'll circle back and add tests for this blueprint. They're fairly trivial to add once I can use the existing test packages.

@scalvert scalvert changed the title Adding docs-page blueprint. Includes router invocation. Adding docs-page blueprint. Apr 4, 2019
@pzuraq
Copy link
Contributor

pzuraq commented Apr 4, 2019

I'm +1 on merging this for now, haven't had time to review in depth but I trust y'all, and like @dfreeman said it won't break existing things 😄

@scalvert
Copy link
Contributor Author

scalvert commented Apr 4, 2019

OK @samselikoff, I've added docs via the Quickstart. When the directions call for adding the index and usage routes, I prompt the usage of the blueprint. Let me know if that works.

@scalvert
Copy link
Contributor Author

scalvert commented Apr 4, 2019

BTW, I would have use ember-template-recast to do the nav item adding, but that package does some odd things with whitespace and node replacement. I opted to use quick-n-dirty file line manipulation. It ain't pretty, but it gets the job done.

@scalvert
Copy link
Contributor Author

scalvert commented Apr 4, 2019

I'm just going run through some manual testing of the blueprint prior to you merging. I'll ping back here once I've ensured everything is generated in the right way.

@scalvert
Copy link
Contributor Author

scalvert commented Apr 4, 2019

OK, tested out the following scenarios:

Non-pods:

  • Generates markdown doc in correct directory, with correct name and template content
  • Generates route entry in router.js
  • Generates nav item in docs.hbs, if present

Pods:

  • Generates markdown doc in correct directory, with correct name and template content
  • Generates route entry in router.js
  • Generates nav item in pods/docs/template.hbs, if present

These will form the basis for tests if updated to mocha for node tests, as @dfreeman suggested.

@scalvert
Copy link
Contributor Author

scalvert commented Apr 4, 2019

@dfreeman @pzuraq @samselikoff this is good to merge once CI passes.

I'll circle back on the testing front in a subsequent PR.

@samselikoff samselikoff merged commit b7224c3 into ember-learn:master Apr 5, 2019
@samselikoff
Copy link
Contributor

You rock brotha! Nice work 🤙

@scalvert scalvert deleted the docs-page-blueprint branch April 6, 2019 00:54
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.

4 participants