cloudflare / doca

A CLI tool that scaffolds API documentation based on JSON HyperSchemas.
BSD 3-Clause "New" or "Revised" License
228 stars 36 forks source link

Making changes to schemas.js #27

Closed Relequestual closed 7 years ago

Relequestual commented 7 years ago

I'm building a documentation pipeline with doca being a large part of it.

I've hit a snag. Your docs say you only run doca init once to bootstrap the project. Making the same call again just throws an error. However, there's no doca function to update and/or pull in new schemas from the parent folder.

The only way I can see this currently working is to remove the documentation folder, and re-run doca init any time I add or remove any schemas.

That in itself is not a problem, but I have to run npm install before I can run npm build when in the documentation folder. npm install takes a bit of time...

It would be great if there could be a new command, like doca update to simply update the list of schemas doca should use.

I'm happy to try and make a pull request, but I don't write node, and I wouldn't know how to write tests for this change either.

tajo commented 7 years ago

The behavior you describing is intentional. doca init is a destructive command because it overwrites your whole project. That's why it stops you and you have to manually delete your project first.

I'm assuming that once you've used it you should not ever needed again. In case you are not doing any modifications in your project (besides adding schemas), it's ok use it again but there is no reason to do it every day. We don't release new versions that often. Most of the changes are in different packages (doca-bootstrap-theme or loaders), not in the app itself. Those can be updated just through npm update (unless it's a major release).

If you need to add another schema, just edit the ./schemas.js and add one more row. Fast and simple.

Also, you can use npm replacement call yarn. It's much faster.

handrews commented 7 years ago

If you need to add another schema, just edit the ./schemas.js and add one more row. Fast and simple.

@Relequestual does that fit your workflow smoothly enough? Is there a way we can make the documentation more clear?

Relequestual commented 7 years ago

Thanks @tajo @handrews. I wasn't expecting that to be how things behave. I've changed my code to anticipate this. I should be able to make the script update the ./schemas.js file as part of the workflow. It's just not something I want to do manually; all for as automated as possible.

My workflow currently runs build, then extracts the output to a different location. We don't want to run a node server right now.

I agree, once the right schema files are added, that list won't be updated often, only the content of them, potentially.

Relequestual commented 7 years ago

May be worth documenting that this is expected behaviour. It wasn't clear to me and I spent a half day trying to work it out (which part of the workflow wasn't working). Only figured it out when I inspected the doca code... =D