-
Notifications
You must be signed in to change notification settings - Fork 482
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
[RFC] Project Restructure #986
Conversation
WOW. This is amazing: thanks for submitting this RFC, @obfu5c8! cc @anthony-redFox @arv @anandthakker to take a look at this. Re: the changes -
Overall, really excellent work, and interested to hear what the other contributors have to say! |
ThemesI 100% agree about removing dependencies from the themes - I think they exist in this commit because i hadn't yet managed to extricate the shared functions from the core. I've been pondering today whether the Also, i think that separating file generation and output would be beneficial as it would allow the possibility of adding other types of Output handlers ( Conceptconst docs = new DocumentationEngine();
docs.parse(['index.js'], config)
.then( comments => docs.format(comments, MarkdownFormatter))
.then( files => docs.output( files, FilesystemOutputter )) Concept CLI implementationlet formatter;
switch(argv.format) {
case 'json':
formatter = JsonFormatter;
break;
case 'markdown':
formatter = MarkdownFormatter;
break;
case 'html':
formatter = require('documentation-theme-default');
break;
default:
// allow loading any node module as a formatter
formatter = require(argv.format);
}
docs.format(comments, formatter) /* ... */ CLI yargs validationI feel that the CLI should only be responsible for very basic validation of the arguments as they are received - only enough to populate a Next StepsI'll try and find time in the next day or two to push up a couple more commits to show the separation process so far, hopefully it will better illustrate my thinking in these areas |
OK so i've got the most basic functionality back in place again.
you can also write the markdown to a folder with Still to do
|
Project Restructure RFC
Proposal to heavily reorganise the project structure to separate the concerns of different parts of the system.
Introduction
I've been trying to find a good es6 documentation generator for a while. I like
documentation
a lot, but it's not quite flexible enough to do everything i'd like. yet.I thought i'd share my vision for how i think a more decoupled codebase might look - a proper separation of concerns would make make iterating features much easier (and safer) as well as opening the door for a plugin ecosystem (implementing plugins was what got me thinking about this restructure in the first place).
This PR is by no means ready for integration at this point. It is shared here more to exemplify my ideas and to start a conversation on the topic. Many of the usage examples below are not yet implemented - I wanted to see how the RFC was received before I committed too much time to it.
Separation of Concerns
I've tried to separate out concerns as much as possible into different packages that can (if desired) be imported separately. This means that end-users can use as much, or as little, of
documentation
's code as they wish.Package Overviews
documentation-core
This package contains the core nodejs API for parsing comments and creating formatted outputs with them. The majority of the existing documentation codebase lives in this package.
It provides no CLI or server options, and is very low-level, requiring fine-grained configuration to use. This is for advanced users who wish to do funky things with their doc generator.
Example usage
documentation-cli
Contains a CLI wrapper for the core API - At the moment I have simply extracted the existing CLI from the
documentation
package.(Also, it needs to be updated so that it builds and passes a tidily structured config object to the core API, rather than polluting the
DocumentationConfig
object with all sorts ofyargs
argv crap </rant>)Depends on:
documentation-core
documentation-theme-basic
documentation-theme-basic
Contains the default HTML theme for formatted output. Has been extracted wholesale from the existing
documentation
codebase.documentation
This package would replace the existing
documentation
package and serve as a thin wrapper to bring together the decoupled parts while maintaining backwards-compatability. This makes it really easy to consume in normal use cases.Depends On:
documentation-core
documentation-cli
documentation-theme-basic
Example implementation