tydoc
The TypeScript documenter that meets you where you are
Last updated 4 months ago by jasonkuhrt .
MIT · Original npm · Tarball · package.json
$ cnpm install tydoc 
SYNC missed versions from official npm registry.
Work in progress ????‍

jsdoc-extractor

Development

  • yarn -s dev:test gives fast feedback with many simple unit tests.

  • https://ts-ast-viewer.com can be extremely help when trying to get a birds eye view of the AST. Sometimes you see data that you wish you were shown the API navigation calls to get it. But even without that it is still very handy to at least get a sense.

  • Amazing use-case for Quokka.js if you have it. Set yourself up a test module using techniques like those seen in test/setup.ts and get the best possible feedback loop going!

  • Very little information about the TS AST seems available. There is the Wiki and a bit of information here https://sandersn.github.io/manual/Typescript-compiler-implementation.html.

API

renderMarkdown

(docs: DocPackage, opts: Options) => string

fromProject

(opts: Options) => DocPackage

fromModule

(docs: Manager, sourceFile: SourceFile) => DocPackage

Exported Types

I RenderMarkdownOptions

typeIndexRef

Type Index

I Options

export interface Options {
  /**
   * Whether or not the API terms section should have a title and nest its term
   * entries under it. If false, term entry titles are de-nested by one level.
   */
  flatTermsSection: boolean
}

T DocPackage

//
// Package node
//

export type DocPackage = {
  modules: DocModule[]
  typeIndex: TypeIndex
}

T DocModule

//
// Module Node
//

export type DocModule = {
  kind: 'module'
  name: string
  mainExport: null | Node
  namedExports: Expor[]
}

& DocTypeUnion

//
// Union Node
//

export type DocTypeUnion = {
  kind: 'union'
  isDiscriminated: boolean
  discriminantProperties: null | string[]
  types: Node[]
} & Raw

| Node

export type Node =
  | DocTypeUnion
  | DocTypePrimitive
  | DocTypeLiteral
  | DocTypeAlias
  | DocTypeInterface
  | DocTypeCallable
  | DocTypeArray
  | DocTypeObject
  | DocTypeIndexRef
  | DocUnsupported
  | DocTypeIntersection
  // todo unused?
  | { kind: 'function'; signatures: DocSig[] }
  | ({
      kind: 'callable_object'
      signatures: DocSig[]
      properties: DocProp[]
    } & Raw)
  | ({
      kind: 'callable_interface'
      properties: DocProp[]
      signatures: DocSig[]
    } & Raw)

T DocTypePrimitive

export type DocTypePrimitive = { kind: 'primitive'; type: string }

T DocTypeLiteral

export type DocTypeLiteral = { kind: 'literal'; base: string }

& DocTypeAlias

export type DocTypeAlias = { kind: 'alias'; name: string; type: Node } & Raw

T Raw

export type Raw = {
  raw: {
    typeText: string
    nodeText: string
    nodeFullText: string
  }
}

& DocTypeInterface

export type DocTypeInterface = {
  kind: 'interface'
  name: string
  props: DocProp[]
} & Raw

T DocProp

export type DocProp = { kind: 'prop'; name: string; type: Node }

& DocTypeCallable

export type DocTypeCallable = {
  kind: 'callable'
  isOverloaded: boolean
  hasProps: boolean
  sigs: DocSig[]
  props: DocProp[]
} & Raw

T DocSig

export type DocSig = { kind: 'sig'; params: DocSigParam[]; return: Node }

T DocSigParam

export type DocSigParam = { kind: 'sigParam'; name: string; type: Node }

T DocTypeArray

export type DocTypeArray = { kind: 'array'; innerType: Node }

& DocTypeObject

export type DocTypeObject = { kind: 'object'; props: DocProp[] } & Raw

T DocTypeIndexRef

/**
 * A link to the type index. All named types go into the type index. When a type
 * or export includes a named type, rather than documenting it inline, a
 * reference to the type index is created.
 *
 */
export type DocTypeIndexRef = {
  kind: 'typeIndexRef'
  /**
   * An identifier that can be used to lookup the type in the type index.
   *
   * @example
   *
   * ```ts
   * docs.typeIndex[typeIndexRef.link]
   * ```
   */
  link: string
}

& DocUnsupported

export type DocUnsupported = { kind: 'unsupported' } & Raw

& DocTypeIntersection

//
// Intersection Node
//

export type DocTypeIntersection = { kind: 'intersection'; types: Node[] } & Raw

T Expor

//
// Export Node
//

export type Expor = {
  kind: 'export'
  name: string
  isTerm: boolean
  isType: boolean
  type: Node
}

I Options

interface Options {
  entrypoints: string[]
  project?: tsm.Project
}

I Manager

export interface Manager {
  d: DocPackage
  isIndexable(t: tsm.Type): boolean
  isIndexed(name: string): boolean
  getFromIndex(name: string): Node
  indexIfApplicable(t: tsm.Type, doc: Thunk<Node>): Node
}

F Thunk

export type Thunk<T> = () => T

Current Tags

  • 0.0.0                                ...           latest (4 months ago)
  • 0.0.0-pr.27.0080e6a                                ...           pr.27 (4 months ago)

2 Versions

  • 0.0.0-pr.27.0080e6a                                ...           4 months ago
  • 0.0.0                                ...           4 months ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 2
Dependencies (13)
Dev Dependencies (14)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |