Sha256: c4888389bfd4ccd4bae548699e4ec43892021be49edbd0cbaa5befa58f90dd58

Contents?: true

Size: 1.59 KB

Versions: 89

Compression:

Stored size: 1.59 KB

Contents

JSDOC.PluginManager.registerPlugin(
	"JSDOC.publishSrcHilite",
	{
		onPublishSrc: function(src) {
			if (src.path in JsHilite.cache) {
				return; // already generated src code
			}
			else JsHilite.cache[src.path] = true;
		
			try {
				var sourceCode = IO.readFile(src.path);
			}
			catch(e) {
				print(e.message);
				quit();
			}

			var hiliter = new JsHilite(sourceCode, src.charset);
			src.hilited = hiliter.hilite();
		}
	}
);

function JsHilite(src, charset) {

	var tr = new JSDOC.TokenReader();
	
	tr.keepComments = true;
	tr.keepDocs = true;
	tr.keepWhite = true;
	
	this.tokens = tr.tokenize(new JSDOC.TextStream(src));
	
	// TODO is redefining toString() the best way?
	JSDOC.Token.prototype.toString = function() { 
		return "<span class=\""+this.type+"\">"+this.data.replace(/</g, "&lt;")+"</span>";
	}
	
	if (!charset) charset = "utf-8";
	
	this.header = '<html><head><meta http-equiv="content-type" content="text/html; charset='+charset+'"> '+
	"<style>\n\
	.KEYW {color: #933;}\n\
	.COMM {color: #bbb; font-style: italic;}\n\
	.NUMB {color: #393;}\n\
	.STRN {color: #393;}\n\
	.REGX {color: #339;}\n\
	.line {border-right: 1px dotted #666; color: #666; font-style: normal;}\n\
	</style></head><body><pre>";
	this.footer = "</pre></body></html>";
	this.showLinenumbers = true;
}

JsHilite.cache = {};

JsHilite.prototype.hilite = function() {
	var hilited = this.tokens.join("");
	var line = 1;
	if (this.showLinenumbers) hilited = hilited.replace(/(^|\n)/g, function(m){return m+"<span class='line'>"+((line<10)? " ":"")+((line<100)? " ":"")+(line++)+"</span> "});
	
	return this.header+hilited+this.footer;
}

Version data entries

89 entries across 88 versions & 13 rubygems

Version Path
hquery-patient-api-1.1.1 doc/jsdoc-toolkit/app/plugins/publishSrcHilite.js
hquery-patient-api-1.1.0 doc/jsdoc-toolkit/app/plugins/publishSrcHilite.js
xcodebuild-helper-1.2.5 externals/ios-sim-master/node_modules/JSV/jsdoc-toolkit/app/plugins/publishSrcHilite.js
xcodebuild-helper-1.2.3 externals/ios-sim-master/node_modules/JSV/jsdoc-toolkit/app/plugins/publishSrcHilite.js
quentonc-jsdoc_helper-0.0.2 ext/jsdoc-toolkit/app/plugins/publishSrcHilite.js
quentonc-jsdoc_helper-0.0.2 test/ext/jsdoc-toolkit/app/plugins/publishSrcHilite.js
sproutit-sproutcore-1.0.20090721145236 vendor/jsdoc/app/plugins/publishSrcHilite.js
sproutit-sproutcore-1.0.20090721145251 vendor/jsdoc/app/plugins/publishSrcHilite.js
sproutit-sproutcore-1.0.20090721145280 vendor/jsdoc/app/plugins/publishSrcHilite.js
sproutit-sproutcore-1.0.20090721145281 vendor/jsdoc/app/plugins/publishSrcHilite.js
sproutit-sproutcore-1.0.20090721145282 vendor/jsdoc/app/plugins/publishSrcHilite.js
sproutit-sproutcore-1.0.20090721145285 vendor/jsdoc/app/plugins/publishSrcHilite.js
sproutit-sproutcore-1.0.203 vendor/jsdoc/app/plugins/publishSrcHilite.js
hquery-patient-api-1.0.4 doc/jsdoc-toolkit/app/plugins/publishSrcHilite.js
hquery-patient-api-1.0.3 doc/jsdoc-toolkit/app/plugins/publishSrcHilite.js
hquery-patient-api-1.0.2 doc/jsdoc-toolkit/app/plugins/publishSrcHilite.js
hquery-patient-api-1.0.1 doc/jsdoc-toolkit/app/plugins/publishSrcHilite.js
jsc3d-rails-1.0 vendor/assets/javascripts/tools/doc_generator/app/plugins/publishSrcHilite.js
hquery-patient-api-1.0.0 doc/jsdoc-toolkit/app/plugins/publishSrcHilite.js
hquery-patient-api-0.3.0 doc/jsdoc-toolkit/app/plugins/publishSrcHilite.js