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

transcribe

v1.1.2

Published

Generate Markdown documentation from code comments

Downloads

6,927

Readme

Transcribe

Transcribe is a simple program which generates Markdown documentation from code comments.

The general idea is that each "export" should be accompanied by a "docstring". The first line of the "docstring" should be a Haskell-inspired type signature in the form <heading-prefix> <name> :: <type>.

//# map :: (a -> b) -> Array a -> Array b
//.
//. Transforms a list of elements of type `a` into a list of elements
//. of type `b` using the provided function of type `a -> b`.
//.
//. ```javascript
//. > map (String) ([1, 2, 3, 4, 5])
//. ['1', '2', '3', '4', '5']
//. ```
function map(f) {
  return function(xs) {
    var output = [];
    for (var idx = 0; idx < xs.length; idx += 1) {
      output.push (f (xs[idx]));
    }
    return output;
  };
}

The --heading-prefix option specifies which lines in the source files contain type signatures to become headings in the output. The default value is //#; specify a different value if using a different comment style. For example:

--heading-prefix '#%'

The --prefix option specifies which lines in the source files should appear in the output along with the lines prefixed with <heading-prefix>. The default value is //.; specify a different value if using a different comment style. For example:

--prefix '#.'

Each line beginning with zero or more whitespace characters followed by the prefix is included in the output, sans prefix and leading whitespace. The . in the default prefix makes it possible to be selective about which comments are included in the output: comments such as // Should never get here! will be ignored.

The --url option specifies a template for generating links to specific lines of source code on GitHub or another code-hosting site. The value should include {filename} and {line} placeholders to be replaced with the filename and line number of each of the signature lines. For example:

--url 'https://github.com/plaid/sanctuary/blob/v0.4.0/{filename}#L{line}'

Avoid pointing to a moving target: include a tag name or commit hash rather than a branch name such as master.

The --heading-level option specifies the heading level, an integer in range [1, 6]. The default value is 3, which corresponds to an <h3> element in HTML. Specify a different value if desired. For example:

--heading-level 4

The --insert-into option specifies the name of a file into which Transcribe will insert the generated output. By default, Transcribe writes to stdout. However, if --insert-into is provided, Transcribe will insert the output in the specified file between two special tags: <!--transcribe--> and <!--/transcribe-->. For example:

--insert-into README.md

The options should be followed by one or more filenames. The filenames may be separated from the options by --. Files are processed in the order in which they are specified.

Here's a complete example:

$ transcribe \
>   --url 'https://github.com/plaid/example/blob/v1.2.3/{filename}#L{line}' \
>   -- examples/fp.js
### <a name="map" href="https://github.com/plaid/example/blob/v1.2.3/examples/fp.js#L3">`map :: (a -⁠> b) -⁠> Array a -⁠> Array b`</a>

Transforms a list of elements of type `a` into a list of elements
of type `b` using the provided function of type `a -> b`.

```javascript
> map (String) ([1, 2, 3, 4, 5])
['1', '2', '3', '4', '5']
```

### <a name="filter" href="https://github.com/plaid/example/blob/v1.2.3/examples/fp.js#L23">`filter :: (a -⁠> Boolean) -⁠> Array a -⁠> Array a`</a>

Returns the list of elements which satisfy the provided predicate.

```javascript
> filter (function(n) { return n % 2 === 0; }) ([1, 2, 3, 4, 5])
[2, 4]
```

By default, the output is written to stdout. One could redirect it to a file to generate lightweight API documentation:

$ printf '\n## API\n\n' >>README.md
$ transcribe \
>   --url 'https://github.com/plaid/example/blob/v1.2.3/{filename}#L{line}' \
>   -- examples/fp.js >>README.md

Reading from stdin is not currently supported.

One could also insert the output into an existing file by providing the --insert-into option:

$ transcribe \
>   --url 'https://github.com/plaid/example/blob/v1.2.3/{filename}#L{line}' \
>   --insert-into README.md
>   -- examples/fp.js