nodejs / api-docs-tooling

Node.js's tooling for API generation
https://nodejs.org/api
MIT License
5 stars 5 forks source link

feat: allow non-cli execution #137

Closed RedYetiDev closed 5 days ago

RedYetiDev commented 2 weeks ago

Description

This PR adds the ability to execute this from another JS file, without the use of the CLI. That way, man-page, and any future generators wouldn't be limited to the CLI for execution

Validation

Verify that all execution is working as planned.

Check List

RedYetiDev commented 2 weeks ago

Thanks for the approvals! Once this lands, I'll be able to implement it with https://github.com/nodejs/node/pull/55268, which will really bring the new man-page generator into the core :-)!

AugustinMauroy commented 2 weeks ago

cc @ovflowd

ovflowd commented 2 weeks ago

Alrighty, I'm back 👋

So pretty much my idea here is:

Instead of exporting an one does everything function, cli.js should still do exactly what it is doing, parsing cli args and doing whatever it needs to be done to be able to run from the CLI.

On index.js simply only export all the functions that exist on the other modules. My reasoning is that by exporting this nebulous function it creates a black box and prevents people from actually importing each module.

Hence on node core you'll simply import the exports of this package and create your own instance of whatever you need, which allows you even to make it specific for the needs of man doc gen.

Also don't forget to update package.json so that only the index.mjs file is exported on the module.

How do you feel about this?

RedYetiDev commented 1 week ago

Thanks for your feedback. I've updated this to just export the other files. PTAL when you get a chance :-)

ovflowd commented 1 week ago

Thank you, @RedYetiDev and apologies for blocking you!