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

atomdoc

v1.2.0

Published

An atomdoc parser

Downloads

156

Readme

AtomDoc parser

OS X Build Status Windows Build Status Dependency Status

Parse atomdoc with JavaScript / CoffeeScript.

Atomdoc is a code documentation format based on markdown. The atom team writes a lot of markdown, and its rules are deep in our brains. So rather than adopting some other format we'd need to learn, we decided to build a parser around a few markdown conventions.

Usage

It's on npm.

npm install atomdoc

It has only one method, parse:

AtomDoc = require 'atomdoc'

docString = """
  Public: My awesome method that does stuff, but returns nothing and has
  no arguments.
"""
doc = AtomDoc.parse(docString)

# Alternatively, you can avoid parsing "Returns" statements in documentation (useful for class-level documentation):
doc = AtomDoc.parse(docString, {parseReturns: false})

doc will be an object:

{
  "visibility": "Public",
  "description": "My awesome method that does stuff, but returns nothing and has\nno arguments.",
  "summary": "My awesome method that does stuff, but returns nothing and has\nno arguments."
}

Maximal example

Using all the features.

AtomDoc = require 'atomdoc'

docString = """
    Public: My awesome method that does stuff.

    It does things and stuff and even more things, this is the description. The
    next section is the arguments. They can be nested. Useful for explaining the
    arguments passed to any callbacks.

    * `count` {Number} representing count
    * `callback` {Function} that will be called when finished
      * `options` Options {Object} passed to your callback with the options:
        * `someOption` A {Bool}
        * `anotherOption` Another {Bool}

    ## Events

    ### contents-modified

    Public: Fired when this thing happens.

    * `options` {Object} An options hash
      * `someOption` {Object} An options hash

    ## Examples

    This is an example. It can have a description.

    ```coffee
    myMethod 20, ({someOption, anotherOption}) ->
      console.log someOption, anotherOption
    ```

    Returns null in some cases
    Returns an {Object} with these keys:
      * `someBool` a {Boolean}
      * `someNumber` a {Number}
"""
doc = AtomDoc.parse(docString)

doc will be an object:

{
  "visibility": "Public",
  "summary": "My awesome method that does stuff.",
  "description": """
    My awesome method that does stuff.
    It does things and stuff and even more things, this is the description. The
    next section is the arguments. They can be nested. Useful for explaining the
    arguments passed to any callbacks.
  """,
  "arguments": [
    {
      "name": "count",
      "description": "{Number} representing count",
      "type": "Number",
      "isOptional": false
    },
    {
      "children": [
        {
          "name": "options",
          "description": "Options {Object} passed to your callback with the options:",
          "type": "Object",
          "isOptional": false
          "children": [
            {
              "name": "someOption",
              "description": "A {Bool}",
              "type": "Bool",
              "isOptional": false
            },
            {
              "name": "anotherOption",
              "description": "Another {Bool}",
              "type": "Bool",
              "isOptional": false
            }
          ],
        }
      ],
      "name": "callback",
      "description": "{Function} that will be called when finished",
      "type": "Function",
      "isOptional": false
    }
  ],
  "events": [
    {
      "name": "contents-modified",
      "summary": "Fired when this thing happens.",
      "description": "Fired when this thing happens.",
      "visibility": "Public",
      "arguments": [
        {
          "children": [
            {
              "name": "someOption",
              "description": "{Object} An options hash",
              "type": "Object",
              "isOptional": false
            }
          ],
          "name": "options",
          "description": "{Object} An options hash",
          "type": "Object",
          "isOptional": false
        }
      ]
    }
  ],
  "examples": [
    {
      "description": "This is an example. It can have a description",
      "lang": "coffee",
      "code": "myMethod 20, ({someOption, anotherOption}) ->\n  console.log someOption, anotherOption",
      "raw": "```coffee\nmyMethod 20, ({someOption, anotherOption}) ->\n  console.log someOption, anotherOption\n```"
    }
  ],
  "returnValues": [
    {
      "type": null,
      "description": "Returns null in some case"
    },
    {
      "type": "Object",
      "description": "Returns an {Object} with the keys:\n\n* `someBool` a {Boolean}\n* `someNumber` a {Number}"
    }
  ]
}

Notes

The parser uses marked's lexer.