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

pg-doc

v0.2.2

Published

Produce schema documentation for your Postgres database in markdown format

Downloads

85

Readme

npm version

pg-doc

Produce markdown schema documentation for your Postgres database.

Installation

npm i pg-doc

or globally:

npm i -g pg-doc

Usage

Usage: pg-doc [options]

Options:
  --version                Show version number                         [boolean]
  --connection, --db       Database Connection URL           [string] [required]
  --out, -o                The file name of the output                  [string]
  --title, -t              The title of the document                    [string]
  --excluded, --ex         Tables to be excluded                         [array]
  --toc                    Add a table of contents (TOC) section
                                                       [boolean] [default: true]
  --split-by-initial, -s   Split TOC by initial letter                 [boolean]
  --split-limit, --sl      Split TOC only if number of tables is greater that
                           this limit                     [number] [default: 20]
  --no-descriptions, --nd  Don't output table/column descriptions      [boolean]
  --help                   Show help                                   [boolean]

Configuration

There are 2 alternative ways to pass configuration options appart from the command line.

Options file

You can put your options in a .pg-doc.json file in your project:

{
    "connection": <postgres connection url>,
    "excluded": <string array>,
    "noDescriptions": <boolean>,
    "toc": <boolean>,
    "splitByInitial": <boolean>,
    "splitLimit": <number>,
    "title": <string>,
    "out": <filename>
}

Environment variables

Use the following variables to pass options to pg-doc:

PGDOC_CONNECTION=<postgres connection url> 
PGDOC_OUT=<filename>
PGDOC_TITLE=<string>
PGDOC_EXCLUDED=<comma separated strings>
PGDOC_SPLIT_LIMIT=<number>
PGDOC_SPLIT_BY_INITIAL=<boolean>
PGDOC_NO_DESCRIPTIONSL=<boolean>
PGDOC_TOC=<boolean>

Precedence

Configuration options are applied in the following order (from lowest to highest precedence):

.pg-doc.json --> env variables --> command line options

Table and Column descriptions

By default pg-doc will show the description you have defined as table/column comments in your database, ie:

sql> COMMENT ON TABLE foo IS 'This is my foo table.';

will be rendered as

...

|# |Table Name| Description| |--:|----------|------------| |1| foo | This is my foo table. |

Details

table1

This is my foo table.

...

If you have no comments defined you can either disable this by setting the noDescriptions option to true or provide your descriptions by adding a descriptions section in your .pg-doc.json file like so:

{
    "descriptions": {
        "tableName": "this is my tableName description",
        "tableName.columnName": "this is my columnName description"
    }
}