docblockr2

A helper package for writing documentation

Pranav-Dakshina

2,158

0

2.0.0

MIT

GitHub

This package consumes the following services:

Docblockr Package

Build Status

View the changelog

DocBlockr is a package for Atom which is designed to make writing documentation faster and easier.

The package currently supports the following languages -

Installing

Use the Atom package manager, which can be found in the Settings view or run apm install docblockr from the command line.

Feature requests & bug reports

The main development branch is develop and the stable 'production' branch is master. Please remember to base your branch from develop and issue the pull request back to that branch.

Usage

Below are some examples of what the package does. Note that there are no keyboard shortcuts required to trigger these completions - just type as normal and it happens for you!

Docblock completion

Pressing enter or tab after /** (or ###* for Coffee-Script) (or //* for Sass) will yield a new line and will close the comment.

Single-asterisk comment blocks behave similarly:

Function documentation

However, if the line directly afterwards contains a function definition, then its name and parameters are parsed and some documentation is automatically added.

You can then press tab to move between the different fields.

If you have many arguments, or long variable names, it might be useful to spread your arguments across multiple lines. DocBlockr will handle this situation too:

In languages which support type hinting or default values, then those types are prefilled as the datatypes.

DocBlockr will try to make an intelligent guess about the return value of the function.

Variable documentation

If the line following your docblockr contains a variable declaration, DocBlockr will try to determine the data type of the variable and insert that into the comment.

If you press shift+enter after the opening /** then the docblockr will be inserted inline.

DocBlockr will also try to determine the type of the variable from its name. Variables starting with is or has are assumed to be booleans, and callback, cb, done, fn, and next are assumed to be functions. If you use your own variable naming system (eg: hungarian notation: booleans all start with b, arrays start with arr), you can define these rules yourself.

Comment extension

Pressing enter inside a docblock will automatically insert a leading asterisk and maintain your indentation.

This applies to docblock comments /** like this */ as well as inline double-slash comments // like this

In either case, you can press shift+enter to stop the automatic extension.

Oftentimes, when documenting a parameter, or adding a description to a tag, your description will cover multiple lines. If the line you are on is directly following a tag line, pressing tab will move the indentation to the correct position.

Multiline comment decoration

If you write a multiline comment and use Docblockr:Decorate Multiline, Docblockr will create block comment decoration.

Comment decoration

If you write a double-slash comment and then use Docblockr:Decorate, DocBlockr will 'decorate' that line for you.

// Foo bar baz<<Docblockr:Decorate>>

-- becomes

/////////////////
// Foo bar baz //
/////////////////

Reparsing a DocBlock

Sometimes, you'll perform some action which clears the fields (sections of text which you can navigate through using tab). This leaves you with a number of placeholders in the DocBlock with no easy way to jump to them.

With DocBlockr, you can reparse a comment and reactivate the fields by using command Docblockr:Reparse

Reformatting paragraphs

Inside a comment block, hit Docblockr:Wrap Lines to wrap the lines to make them fit within your rulers. If you would like subsequent lines in a paragraph to be indented, you can adjust the indentation_spaces_same_para setting. For example, a value of 3 might look like this:

/**
 * Duis sed arcu non tellus eleifend ullamcorper quis non erat. Curabitur
 *   metus elit, ultrices et tristique a, blandit at justo.
 * @param  {String} foo Lorem ipsum dolor sit amet.
 * @param  {Number} bar Nullam fringilla feugiat pretium. Quisque
 *   consectetur, risus eu pellentesque tincidunt, nulla ipsum imperdiet
 *   massa, sit amet adipiscing dolor.
 * @return {[Type]}
 */

Configuration

You can access the configuration settings by entering Docblockr in atom settings window

Note

All credits for this package goes to SublimeJsdocs who have created a wonderful plugin for Sublime Text. I have just ported the package to Atom and Javascript.

All features except macros have been implemented. Please create issues for bugs.

TODO

Add test cases.