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

dochammer

v1.1.0

Published

Project documentation made easy and fun

Downloads

3

Readme

dochammer

Code documentation made easy and fun.

Motivation

Most of the projects uses the documentation in a different place (wiki, a readme, etc) and all the docs are centralized there.

The problem with this approach is because some times the members could forgot to update the doc because it's not directly visible.

The dochammer was created to have the markdown documentation side-by-side with your code without changing your code file (like jsdocs, etc).

Setup

Install dochammer:

npm install -g dochammer

In your project, create a dochammer.config.js on the root (same level as node_modules).

module.exports = {
  outputDir: './docs',
  inputDir: './my-app-src',
  inputFileExt: '.doc.md'
}

| config | type | required | description | | ------ | ---- | -------- | ----------- | | outputDir | string | yes | Where the generated documentation should be stored | | inputDir | string | yes | Where dochammer should look for documentation files | | inputFileExt | string | yes | The extensions of the documentation file. The dochammer will use it to find the docs. In the sample, dochammer will considere all the files ending with .doc.md as documentation file. |

Usage

The dochammer has 2 types of documents you can create: page and component.

Page

A page is a document that will be generated. To explain better, let's use this sample:

You have a service in your application that returns a user by it's id:

+ services/
  + user/
    - get-user.service.js
module.exports = async id => {
  // ...
  return {
    // user data
  }
}

You can create a doc file for the service:

+ services/
  + user/
    - get-user.service.js
    - get-user.service.doc.md
---
type: page
filename: services
---

## Get User Service

This service returns a user by it's id.

### Usage:

const service = require('./get-user.service')
const user = await service('user-id-1')

Where:

| header | description | | ------ | ----------- | | type | the type of the doc, in this case: page | | filename | all the pages will be generated in a file. The filename header indicate the name of the file. If more than one doc uses the same filename, it will be concatenated in the same file |

Ok, we are done with our page.

Now, in the terminal in the root of your project, just run:

dochammer

It will generate a folder named docs (that we configured in the dochammer.config.js as outputFolder) with a file services.md (that was the filename in the doc header)

+ docs/
  - services.md

Component

Components are the best way to reuse documentation inside other documents.

To create a component, you just need to create a doc with:

---
type: component
id: my-component
---

## My component

bla bla bla

You can use it in your pages using:

---
type: page
filename: services
---

## My service

%{component:my-component}

Where my-component is the id of your component.

Now, if you run dochammer to generate the docs, the %{component:my-component} will be replaced with the content of the component doc.

component

---
type: component
id: my-component
---

## My component

bla bla bla

page

---
type: page
filename: services
---

## My service

%{component:my-component}

result

---
type: page
filename: services
---

## My service

## My component

bla bla bla

Using variables

You can use pre-configured variables in your template rendering.

To use it, you need to:

Add the variables to dochammer.config.js

// dochammer.config.js
module.exports = {
  variables: {
    api_url: 'http://api.com'
  },
  //...
}

Use the variable inside your doc

---
type: component
id: my-component
---

Hey this is a component

%{variable:api_url}

Including a table of contents in pages

Each generated page file can have an index guide if you want.

To add the table of contents index, just add includeTableOfContent to your config file:

// dochammer.config.js
module.exports = {
  includeTableOfContent: true,
  //...
}