Description
Not sure if this is the best place to raise this, but here it goes:
We've been working on documentation for Dojo 2 and are interested in making some hopefully useful changes to improve TypeDoc. We'd rather reach out to collaborate than start yet another project.
Overall, some of our goals include:
Decouple the parsing from rendering approach
The main reason for this is that we would probably prefer a different approach to how we render our API docs, and a fairly substantial part of TypeDoc is focused on how things will be rendered. This would also make it easier to include partial API docs, e.g. say you want to embed a small API subset into a tutorial.
We think that decoupling doc parsing and rendering into separate packages would lead to better architecture decisions by having one package that parses docs into an intermediate format, and then the separate rendering package that reads content in this format. We realize they are in separate modules today, but the dependency chain for the rendering side of things is pretty large. It would also likely remove a few patterns we see today such as copying backbone/events directly into the project, and including all of lodash rather than just the sub-packages that are needed.
Another goal with this would be to keep things smaller and easier for someone to follow, rather than a large, somewhat monolithic package for all things related to generating API documentation from TypeScript (I say somewhat, because things are separated into modules, but the assumption with the current architecture is that you want to use the current approach and opinions around rendering).
Override code with comments
We have an implementation of an object composition system, dojo/compose, and TypeDoc currently makes supporting this nearly impossible because TypeDoc doesn't know what to do with objects that are created using our composition system. So we’d like to propose a way to extend TypeDoc to introduce other object type systems that can be re-used. Our initial thoughts here are to offer an optional ability to look to function and variable comments (like jsdoc) for type information, and override the inferred type if they are present.
Model based design, annotations, and decorators
It does feel like there's quite a bit of complexity and code to model the model. It feels like there's a pretty strong drive to leverage Domain Driven Design (DDD) and annotations/decorators are commonplace. This approach is not widely used in JavaScript, which we feel may limit third party contributions due to the complexity it is adding currently.
Also Decorators are used pretty heavily, and the TS implementation and the version in ES.next are starting to diverge. It's probably ok, but it may be worth a rethink with this approach.
Some minor nitpicks
- Remove remaining uses of
var
- Use
util/fs
consistently - Directory exports with
index.js
, we would probably change this approach
POC
We created a couple of POCs ( https://github.com/rishson/api-doc and https://github.com/kitsonk/api-doc ) that leverage TypeScript Language Services (similar to how TypeDoc does), to determine how we would address our dojo/compose challenge, and to try to identify a fairly simple alternative to TypeDoc.
The general approach of this POC is to follow a publishing pathway:
grunt doc
(task creates the documentation by running theCollector
.. obviously it doesn't need to be Grunt, we just found this to be an easy option)Collector
(finds all repos in a top level dir, by finding.tsconfig
files)Runner
(bootstraps theParser
with repo files)Parser
(takes TS code from repo files and createsDoc
object)Generator
(takesDoc
object and creates Markdown files)grunt doc -publish
(task takes markdown files and creates git tag of changes and pushes to a repo)
The above solution produces markdown (.md) files, which we can store to then be leveraged elsewhere (for example, use something like hexo to go from markdown to HTML).
This POC is relatively simple and small, and of course doesn't come close to solving all of the needs of TypeDoc. But it might provide something useful in thinking through how a refactored TypeDoc might work?
We would much rather work together than build something separate as there aren't likely to be that many people in the world interested in working on something like this, assuming there's some agreement with the things we're proposing. :)
Please let us know your thoughts and feedback. We look forward to getting involved!