Description
I have been using typedoc for a while, it has great potential and it works great but it's not developer friendly when it comes to plugins...
Here are some things I think would help:
- Allow ES6/ES2015-style import syntax for plugins (PR ready, support ES6/ES2015-style import syntax for plugins #594)
- Host library under an organisation (npm scope)
- Create monorepo structure for the repository, moving non-core plugins to a separate package under the org.
- Arrange
extensibility
related symbols in a single module (see info below) - Simplify external plugin registration. (
@Component
wont work outside of the core package) - Refactor JSON generation process to support a plugin architecture (PR Ready, Refactor JSON generation process to support a plugin architecture #597)
- Support
object
type for options (might come from js file, or CLI stringified argument). It will help complex plugins to "own" an object for options and not share the root options object. - Think how to avoid auto-plugin registration (via
@Component
). This will allow inheriting plugins without registering them (or manually unreging them) - Better docs... (cobbler, shoes, not there... )
The approach is to simplify the codebase, making the core small and allowing plugins to add features.
I have several plugins already built, thing like:
- 3rd party modules plugin: Make documentation aware of 3rd party modules either by linking symbols to external documentation or by fully embedding type info from
d.ts
files (2 modes)
I was able to include the whole@angular
docs, creating selective mashups etc... 2nd mode is not that useful but it's nice.
Supports binding import declaration (
import X from 'Y'
) and namespace import declaration (import * as Y from 'Y'
)
-
library-mode plugin: multi-mode plugin that allows exporting libraries from a single endpoint, creating a multi-lib documentation (monorepo) and other stuff...
-
objectify: A plugin approach for creating JSON (
toObject()
). Reflection, Type, Source, Group, etc are all serialized to JSON via plugins that hook into events using the core plugin architecture. This plugin provides the core plugin logic and routing plus coretoObject()
plugin replacements for all native symbols (reflection, types, source etc..). -
json-datasource: Using objectify to tap in an convert the JSON into a datasource/table like structure, having all reflection in one reflection table (hash), types in type table, sources in source table etc... The graph is kept in tact by having pointers (id numbers) instead of objects.
This is structure is suitable for SPA apps that require lookpups, quick access etc.
In addition, the plugin will normalize the output so flags will output in their numeric form and not verbose form. It will add a table for each flag enum as a reference. -
json-links: Another extension to objectify that parses comments searching for markup links (
[[ XX ]]
or{@link ,,,}
) and when found adds a link section that contains the link, caption, position and length so it can be replaced later. -
ng-decorator-meta: Create angular aware documentation. Uses 3rd party modules plugin for linking to angular docs and objectify to output the data to JSON.
Comes with a group plugin that adds symbols to angular groups (Components, Directives, Output, Input etc...). It also hooks into thedefault
theme to provide minimal UI representation.
Will post screen shorts in the next issue-comment
Arrange extensibility
related symbols in a single module
Currently the entry point of the library exports about 6 modules (Application
, CliApplication
...). This is fine for simple usage through CLI or via API in node.
For plugin creators, importing is cluttered.. leading to this:
import { Component } from "typedoc/dist/lib/converter/components";
import { ChildableComponent } from "typedoc/dist/lib/utils";
import { ComponentClass } from "typedoc/dist/lib/utils/component";
import { Application, ProjectReflection } from "typedoc";
This is not developer friendly... making adoption harder.
An extensibility module should export all extensibility related symbols, this can be in typedoc/ext
or @typedoc/core
if moving to npm org/scope
Refactor JSON creation to support a plugins
The current method to convert all reflections/types/groups/sources/etc to one big JSON object uses inheritance, which does not allow customisation as a plugin system would. Since a plugin architecture already exists and the JSON convertion logic already exists (in toObject()
methods) it is fairly easy to implement. I have a fully working solution the uses the current plugin system and just does convertion from Reflection
, Type
, Source
, Group
and any other type to JSON, just register a serializer and it will work.
Why? It will allow building SPA documentation app's that relay on a JSON or multiple JSON's.
Using my solution, I have added extra plugins to it that completely restructure the JSON making it more like a datasource/table like and less document oriented...
Note on CLI:
While using CLI exclusively is nice it does not scale. Once the complexity gets bigger, plugins start to pile and options/flags/customisability is required things become a nightmare to manage.
IMHO, using a config file (i.e. typedoc.js
) is the best option and the one that should be recommended (and documented). This is where plugins should be configured, opt in-out etc.