Closed Bug 391591 Opened 12 years ago Closed 8 months ago

standardize license headers for preprocessed JS files

Categories

(Firefox :: General, defect)

defect
Not set

Tracking

()

RESOLVED WORKSFORME

People

(Reporter: myk, Unassigned)

References

Details

We use (at least) three different formats for license headers in preprocessed JavaScript files.


Preprocessor comment (f.e. browser.js):

# -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
# ***** BEGIN LICENSE BLOCK *****
...
# ***** END LICENSE BLOCK *****


Preprocessor conditional outside JS comment (f.e. nsUpdateService.js.in):

#if 0
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
...
 * ***** END LICENSE BLOCK ***** */
#endif


Preprocesser conditional inside JS comment (f.e. browser-contentPrefSink.js):

/*
#ifdef 0
 * ***** BEGIN LICENSE BLOCK *****
...
 * ***** END LICENSE BLOCK *****
#endif
 */


We should standardize on one of these formats, change all preprocessed JavaScript files to it, and add it to the JavaScript style guide <http://developer.mozilla.org/en/docs/JavaScript_style_guide>.

I recommend we standardize on the last format, even though it results in extraneous open and close comment delimiters in the processed output, since it is the only one of the three that does not trigger a syntax error in syntax-checking editors like Komodo.  But we should use |#if 0| instead of |#ifdef 0|, since that makes more sense semantically.

We should also figure out whether we want the mode line comment to specify the C++ or Java mode.
There's also this style, from nsHelperAppDlg.js.in, which is like the third format in comment 0 except that it doesn't need the preprocessor conditional:

/*
# -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
# ***** BEGIN LICENSE BLOCK *****
...
# ***** END LICENSE BLOCK *****
*/

I like this one a bit more, since it's simpler.
Depends on: 392419
I feel your pain; I had to make various hacks to the license checking script to deal with all these variations.

What I'd prefer is to use a simple:

/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
 * ...
 * ***** END LICENSE BLOCK *****
 */

form (which also doesn't lead to syntax errors), and for the preprocessor to detect the LICENSE BLOCK tags and compress the license block into something like:

/* License: MPL 1.1/GPL 2.0/LGPL 2.1 */

After all, computer processing one of the reasons we have the tags. And it leaves license information intact, in skeleton form, rather than removing it entirely.

Gerv

Many years ago, we had a license rewrite. We're also generally not preprocessing javascript files.

So I think we can close this now, and file new bugs for anything that we want to do that remains.

Status: NEW → RESOLVED
Closed: 8 months ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.