"clear comments" tool
Status: Planning
Brought to you by:
vingoe
We would like to have an automated way to clear
javascript comments and create a "production" version
of our "development" code.
This way we work on the "development" code with full
comments and when ready run the code through the
tool to get a clean "production" version.
Provided some simple commenting standards are kept
while coding, it should be fairly easy to create such a
tool.
A simple command line tool will suffice for the time
being.
Logged In: YES
user_id=1017621
Here follows our design plan for this task. In the testing
forum you can find the relevant testing plan.
Task Analysis:
--------------
When running Javascript programs, end users download the
actual source code. Proper coding style suggests plenty of
comments. These comments add some KBs to the code, so
end users download more than they need to. It is a good
idea to create a tool that automatically clears Javascript from
any comments. This way developers can code using proper
style while end users can save bandwith downloading only
the necessary code
Standard Requirements:
----------------------
1) Make the tool simple to use and simple to develop. This is
a side task and should be quickly completed.
2) Be as analytical as possible. Future developers should
understand what we are doing and how, with very little effort.
Assumptions:
------------
1) In order to make the tool both useful and fast to develop
we will assume a specific commenting style (the one we
use). There is only one requirement really:
-- The comment delimiters (//, /*, */) MUST always be the
first 2 characters of the line.
2) We will assume input from the keyboard and output to the
screen and then use i/o redirection from the operating
system.
3) We will use Java as the development language (we are
more familiar with this language)
Overall Solution Design
-----------------------
Assuming our only commenting style requirement is met the
solution is fairly simple.
We set a flag to false. (signifying if the following lines belong
to a /**/ block comment)
We read a line in.
If it begins with // we do not print it out.
If it begins with /* we do not print it out and at the same
time set the flag to true.
If the line begins with */ we do not print and set the flag to
false.
For any other line if the flag is set we do not print it.
Logged In: YES
user_id=1017621
Final thoughts:
---------------
This tool was quickly built to suit our commenting style.
It requires JRE (Java Runtime) to be present before anyone
can use it.
It also requires all comment delimeters to be the first 2
characters of a commenting line.
Proper usage is as follows:
The java interpreter (java.exe) should be in your PATH
environmental variable.
Copy the uncomment.class in the directory where you want
to use the tool.
Run the tool using redirection of i/o:
java uncomment <inputfile >outputfile