Example #1
0
  Object.keys(sourceFiles).forEach(function (file) {
    var source;
    // links are keyed to the shortened path in each doclet's `meta.shortpath` property
    var sourceOutfile = helper.getUniqueFilename(sourceFiles[file].shortened);
    helper.registerLink(sourceFiles[file].shortened, sourceOutfile);

    try {

      var language = "javascript";
      var matches = /\.([a-z0-9]+?)$/i.exec(file);
      if (matches && matches.length > 0) {
        language = matches[1];
        language = (language == "js") ? "javascript" : language;
      }

      source = {
        kind: 'source',
        lang: language,
        code: helper.htmlsafe(fs.readFileSync(sourceFiles[file].resolved, 'utf8'))
      };
    } catch (e) {
      handle(e);
    }

    generate('source', 'Source: ' + sourceFiles[file].shortened, [source], sourceOutfile, false);
  });
Example #2
0
    Object.keys(sourceFiles).forEach(function(file) {
        var source;
        // links are keyed to the shortened path in each doclet's `meta.shortpath` property
        var sourceOutfile = helper.getUniqueFilename(sourceFiles[file].shortened);
        helper.registerLink(sourceFiles[file].shortened, sourceOutfile);

        try {
            source = {
                kind: 'source',
                code: fs.readFileSync(sourceFiles[file].resolved, encoding)
            };
        }
        catch(e) {
            logger.error('Error while generating source file %s: %s', file, e.message);
        }

        if (hljs) {
            //source.code = hljs.highlightAuto(source.code).value;
            // For a generic template this should be auto.
            // OpenSeadragon is pure javascript, so this speeds things up.
            source.code = hljs.highlight('javascript', source.code).value;

            source.code = generateSourceLineNumberIds(source.code);
        }
        else {
            source.code = helper.htmlsafe(source.code);
        }

        generate('Source: ' + sourceFiles[file].shortened, [source], sourceOutfile,
            false);
    });
Example #3
0
    Object.keys(sourceFiles).forEach(function (file) {
        var source
        // links are keyed to the shortened path in each doclet's `meta.shortpath` property
        var sourceOutfile = helper.getUniqueFilename(sourceFiles[file].shortened)
        helper.registerLink(sourceFiles[file].shortened, sourceOutfile)

        try {
            source = {
                kind: "source",
                code: helper.htmlsafe(
                    fs.readFileSync(sourceFiles[file].resolved, encoding)
                )
            }
        } catch (e) {
            logger.error("Error while generating source file %s: %s", file, e.message)
        }

        generate(
            "Source",
            sourceFiles[file].shortened,
            [source],
            sourceOutfile,
            false
        )
    })
Example #4
0
        it("returns a string array of the doclet's types", function() {
            var doc = new doclet.Doclet('/** @const {number|Array.<boolean>} ASDF */', {}),
                types = helper.getSignatureTypes(doc);

            expect(types.length).toBe(2);
            expect(types).toContain('number');
            expect(types).toContain(helper.htmlsafe('Array.<boolean>')); // should be HTML safe
        });
Example #5
0
function link(item, linkText, linkClass, fragmentId) {
    let htmlLink;
    let regExp;

    if (linkText) {
        linkText = templateHelper.htmlsafe(linkText);
        regExp = new RegExp(util.format('(>(%s)<\\/)', escape(linkText)));
    }

    htmlLink = templateHelper.linkto(item, linkText, linkClass, fragmentId);
    if (regExp) {
        htmlLink = htmlLink.replace(regExp, (match, p1, p2) => p1.replace(p2, softBreak(p2)));
    }

    return htmlLink;
}
Example #6
0
		function( file ) {
			var source;
			// links are keyed to the shortened path in each doclet's `meta.shortpath` property
			var sourceOutfile = helper.getUniqueFilename( sourceFiles[file].shortened );
			helper.registerLink( sourceFiles[file].shortened, sourceOutfile );

			try {
				source = {
					kind : 'source',
					code : helper.htmlsafe( fs.readFileSync( sourceFiles[file].resolved, encoding ) )
				};
			} catch( e ) {
				logger.error( 'Error while generating source file %s: %s', file, e.message );
			}

			generate( 'Source', sourceFiles[file].shortened, [source], sourceOutfile, false );
		}
Example #7
0
  Object.keys(sourceFiles).forEach(function (file) {
    var source;
    // links are keyed to the shortened path in each doclet's `meta.shortpath` property
    var sourceOutfile = helper.getUniqueFilename(sourceFiles[file].shortened);
    helper.registerLink(sourceFiles[file].shortened, sourceOutfile);

    try {
      source = {
        kind: 'source',
        code: helper.htmlsafe(fs.readFileSync(sourceFiles[file].resolved, 'utf8'))
      };
    } catch (e) {
      handle(e);
    }

    generate('source', 'Source: ' + sourceFiles[file].shortened, [source], sourceOutfile, false);
  });
Example #8
0
        Object.keys(pathMap).forEach(function(file) {
            var data = {
                docs: null,
                pageCategory: CATEGORIES.SOURCES,
                pageTitle: pathMap[file],
                pageTitlePrefix: this.pageTitlePrefix
            };

            // links are keyed to the shortened path
            url = helper.getUniqueFilename(pathMap[file]);
            helper.registerLink(pathMap[file], url);

            try {
                data.docs = helper.htmlsafe(fs.readFileSync(file, encoding));
            }
            catch (e) {
                logger.error('Unable to generate output for source file %s: %s', file, e.message);
                return;
            }

            self.generate('source', data, url);
        }, this);
 item.type.names.forEach(function(name) {
   types.push( helper.linkto(name, helper.htmlsafe(name)) );
 });
Example #10
0
 it('should convert all occurences of < to &lt;', function() {
     var inp = '<h1>Potentially dangerous.</h1>',
         out = helper.htmlsafe(inp);
     expect(out).toBe('&lt;h1>Potentially dangerous.&lt;/h1>');
 });
Example #11
0
 it('should simply return the input string, HTML-safe, if no email is detected', function() {
     var str = 'John Doe <dummy>',
         out = helper.resolveAuthorLinks(str);
     expect(out).toBe(helper.htmlsafe(str));
 });
Example #12
0
 it('should HTML-safe author names', function() {
     var str = ' John<Doe  <*****@*****.**> ',
         out = helper.resolveAuthorLinks(str);
     expect(out).toBe('<a href="mailto:asdf.fdsa-2@gmail.com">' + helper.htmlsafe('John<Doe') + '</a>');
 });