npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

getdocs-ts

v1.0.0

Published

Extract builddocs-style info from typescript sources

Downloads

2,272

Readme

getdocs-ts

This is a tool for extracting documentation and typing information from TypeScript sources. The output is intended for further processing with builddocs.

Usage

$ bin/getdocs-ts.js some-source.ts > some-symbols.json

Or via the API:

const {gather} = require("getdocs-ts")

let items = gather({filename: "/path/to/mainfile.ts"})

You can also pass a basedir option to gather, which provides the directory inside which imported files should be considered internal to the module. This defaults to the parent directory of the main filename.

A second function gatherMany, takes an array of configurations and extracts them all at once. Because this avoids duplicate startup, typechecking, and module loading work, this can be a lot faster when generating docs for a bunch of modules at once.

The tool will omit declarations with a doc comment that includes @internal or @hide from its output.

Output format

These declarations summarize the structore of the returned values. gather returns a {[name: string]: Item} object, listing all the top-level exported items.

export type BindingKind = "class" | "enum" | "enummember" | "interface" |
  "variable" | "property" | "method" | "typealias" | "typeparam" |
  "constructor" | "function" | "parameter" | "reexport"

export type Loc = {file: string, line: number, column: number}

export type Binding = {
  kind: BindingKind,
  id: string,
  description?: string,
  loc?: Loc,
  abstract?: boolean,
  readonly?: boolean,
  optional?: boolean
}

export type BindingType = {
  type: string,
  typeSource?: string, // missing means this is a built-in type
  typeParamSource?: string,
  properties?: {[name: string]: Item},
  instanceProperties?: {[name: string]: Item},
  typeArgs?: readonly BindingType[],
  typeParams?: readonly Param[],
  // Used by mapped types
  key?: Param,
  signatures?: readonly CallSignature[],
  extends?: BindingType,
  construct?: Item,
  implements?: readonly BindingType[]
}

export type CallSignature = {
  type: "function" | "constructor",
  params: readonly Param[],
  returns?: BindingType,
  typeParams?: readonly Param[]
}

export type Param = BindingType & {
  name?: string,
  id: string,
  kind: "parameter" | "typeparam",
  description?: string,
  loc?: Loc,
  optional?: boolean,
  rest?: boolean,
  default?: string
}

export type Item = Binding & BindingType

License

This program is free software: you can redistribute it and/or modify it under the terms of the MIT license. See LICENSE for a copy of the license.