SmartComments is a module for NodeJS that can be useful to automate documentation generation process, Using it you can save time and effort, allowing that your documentation can be always up to date with last source code updates.
According to studies carried out by a very prestigious agency, more than 40 per cent of developers prefer to document code than to write code. What?
My first reaction was think, May be possible that the world is changing so fast? Then, Why hadn’t I noticed it until now? I asked to other team developers, and They told me that they were totally agreed.
For me always was very boring add the formal documentation to the source code made by me. Particularly those functions which when you read the name, you can know all about that. Also hated, update the documentation with every change in the source code.
Why could not I enjoy that, when other developers could? I escaped from this dilemma when I heard my teammates laughing. OMG, It was just a sick joke…
These tools need some input parameters, which should be written explicitly by the developers. For example:
It’s a tedious process, especially taking into account that when some change is made in a source code related with some of these parameters, We must update the related documentation. It becomes more significant, when we deal with well advanced projects, which have a poor documentation.
- What does the code do?
- How does it do it?
- Why does it do it?
Basically, we only should to put our function description, or any other detailed explanation if necessary.
Some SmartComments features are:
Generate the necessary meta-information, to entire files, individually or inside some specific folder.
Sublime Text Plugin, which give us access to the application from this editor. A useful feature of this plugin is to generate comments to a text selection.
Templates customization to add other tags dynamically to the comments. Like @event, @class, @attribute and others. Acording to the framework used by you, or your personal code style.
Online version demo that can be used for meta-information generation without installing the application.
A real use case raised by Mr. Rich Kilgore is this:
I’ve set it up so that we put our minimal comments in the sources and commit them into source control that way.
Then, in our Gruntfile, to generate the docs I copy all the sources to a working dir, run smartcomments on them.
Finally run YUIDocs to generate the docs.
This happens every time we build and deploy our project. The main advantage of this aproach is that the API documentation is always up to date with the last changes in the source code.
It should be noted, however, that SmartCommentsis just a tool. There are always some situations that need the human intervention. Particulary when we need to express the true meaning of the code.
SmartComments is useful to automate the documents generation process, Using it you can save time and effort, allowing that your documentation can be always up to date, with last source code updates. If do you want to collaborate with this open source project you can find out at github.