Skip to content

Instantly share code, notes, and snippets.

@Gerrit0
Created February 28, 2020 02:48
Show Gist options
  • Save Gerrit0/9d07f3ab3ed3237d134c3635c000b14e to your computer and use it in GitHub Desktop.
Save Gerrit0/9d07f3ab3ed3237d134c3635c000b14e to your computer and use it in GitHub Desktop.
Notes while thinking about TypeDoc's design

There are really three kinds of converters in TypeDoc

  1. File
  2. Modules
  3. Library

Each of these may share individual node converters, but they are fundamentally different. File mode creates a globals map. Modules mode creates a map representing the structure of the package. Library mode creates a map describing the project from one or more entry points.

Furthermore, giving each mode its own converter makes it possible for modes which don't care about which nodes are actually used to create a definition to avoid including those implementation details in their documentation. For instance, a module which is re-exported with export * as ns from './f' in library mode should just be another namespace in the documentation, while modules mode should include it as a module, and create a reference.

Each of these converters should be able to share a common models library, where the model will be picked according to each converters needs. Library mode should not be required to create a "globals" object that it attaches its output to.

Changing this setup will make it possible for parts of TypeDoc to be used by other tools, without needing to drag along all of TypeDoc's baggage for handling HTML rendering, pulling in doc comments from the filesystem, or any other of the many custom features TypeDoc has added.

TypeDoc should really be a fairly light wrapper around a few components.

  • Options
  • Models
  • Converter (pick the relevant one)
  • Serializers
    • JSON
    • HTML
    • (plugin provided)

Once models are well defined, I'd really like to be able to deserialize from JSON to the models (I've said this isn't happening before, but I want it to). Then TypeDoc could be run on a JSON file created with an earlier run.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment