Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

New updates

  • Loading branch information...
commit 285d2776633097dcb4c1d831d857f29f3df96139 1 parent cced75d
Vladimir Carrer authored
8 README.md
Source Rendered
@@ -31,3 +31,11 @@ Demos:
31 31 * [webfont Google](http://dl.dropbox.com/u/2111778/AutoObjectDocumentation/demos/autoDocs-webfont.html)
32 32 * [YUI](http://dl.dropbox.com/u/2111778/AutoObjectDocumentation/demos/autoDocs-YUI.html)
33 33 * [Zepto](http://dl.dropbox.com/u/2111778/AutoObjectDocumentation/demos/autoDocs-Zepto.html)
  34 +
  35 + News:
  36 + ---------------------
  37 + Thanks to [@brandonc](https://github.com/brandonc) for implementing syntax highlighting with google-prettify. [Demo jQuery](http://dl.dropbox.com/u/2111778/AutoObjectDocumentation/demos/autoDocs-jQuery-prettify.html)
  38 +
  39 + Basic object(method) profiling is added like number of lines, number of characters, number of arguments. The idea for object profiling is taken from [kratko js](http://perfectionkills.com/refactoring-javascript-with-kratko-js/)
  40 +
  41 + In the demos [autoDocs-NoName.html](http://dl.dropbox.com/u/2111778/AutoObjectDocumentation/demos/autoDocs-NoName.html) is added that can take any external JS library dynamically and also any JavaScript Object can be added.
53 demos/autoDocs-NoName.html
... ... @@ -0,0 +1,53 @@
  1 +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2 +<html xmlns="http://www.w3.org/1999/xhtml">
  3 +<head>
  4 +<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
  5 + <meta http-equiv="X-UA-Compatible" content="chrome=1">
  6 +
  7 +
  8 +<link rel="stylesheet" href="../src/style.css" type="text/css" media="screen, projection">
  9 +<link rel="stylesheet" href="../lib/prettify.css" type="text/css" media="screen, projection">
  10 +
  11 +<script src="../lib/prettify.js" language="javascript" type="text/javascript"></script>
  12 +<script src="../src/docJS.js" language="javascript" type="text/javascript" ></script>
  13 +
  14 +
  15 +<title>Auto Object Documentation</title>
  16 +
  17 +<script type="text/javascript">
  18 +
  19 +// taken from http://www.nczonline.net/blog/2009/07/28/the-best-way-to-load-external-javascript/
  20 +
  21 +function loadScript(url, callback) {
  22 + var script = document.createElement("script");
  23 + script.type = "text/javascript";
  24 + if (script.readyState) { //IE
  25 + script.onreadystatechange = function () {
  26 + if (script.readyState === "loaded" || script.readyState === "complete") {
  27 + script.onreadystatechange = null;
  28 + eval(callback);
  29 + }
  30 + };
  31 + } else { //Others
  32 + script.onload = function () {
  33 + eval(callback);
  34 + };
  35 + }
  36 + script.src = url;
  37 + document.getElementsByTagName("head")[0].appendChild(script);
  38 +}
  39 +var a = window.prompt('JavaScript library url?');
  40 +var b = window.prompt('Object Name? - docJS(objectname,"objectname")');
  41 +loadScript(a, b);
  42 +
  43 +//loadScript("http://code.jquery.com/jquery-1.6.1.js","docJS(jQuery.fn)");
  44 +
  45 +</script>
  46 +</head>
  47 +
  48 +<body>
  49 +
  50 +
  51 +
  52 +</body>
  53 +</html>
26 src/docJS.js
... ... @@ -1,15 +1,33 @@
1 1 function docJS(d, n) {
2 2 var keys = Object.keys(d).sort().reverse();
3 3 var i = keys.length;
4   -
5 4 var list = "";
6 5 var list1 = "";
  6 + var numOfLines = "";
  7 + var numOfCharacters = "";
  8 + var numOfArguments = 0;
  9 + var x = 0;
7 10 var pp = (typeof prettyPrintOne === 'function');
8 11 while (i--) {
  12 + if (typeof d[keys[i]] === "object") {
  13 + x += 0;
  14 + numOfLines = "undefined";
  15 + numOfCharacters = "undefined";
  16 + numOfArguments = 0;
  17 + } else if (typeof d[keys[i]] === "function") {
  18 + x += d[keys[i]].toString().length;
  19 + numOfLines = d[keys[i]].toString().split('\n').length;
  20 + numOfCharacters = d[keys[i]].toString().length;
  21 + numOfArguments = d[keys[i]].length;
  22 + } else {
  23 + x += d[keys[i]].toString().length;
  24 + numOfLines = d[keys[i]].toString().split('\n').length;
  25 + numOfCharacters = d[keys[i]].toString().length;
  26 + numOfArguments = 0;
  27 + }
9 28 list1 += "<li><a href='#" + keys[i] + "'>- " + keys[i] + "</a></li>";
10   - list += "<li class='l' id=" + keys[i] + "><h3>" + keys[i] + "</h3>:<br><pre> " +
11   - (pp ? prettyPrintOne(String(d[keys[i]]).replace(/\n/g, '<br/>'), 'js', false) : d[keys[i]]) + "</pre></li>";
  29 + list += "<li class='l' id=" + keys[i] + "><h3>" + keys[i] + ":<i> ( lines: " + numOfLines + " characters: " + numOfCharacters + " arguments: " + numOfArguments + " )</i></h3><br><pre> " + (pp ? prettyPrintOne(String(d[keys[i]]).replace(/\n/g, '<br/>'), 'js', false) : d[keys[i]]) + "</pre></li>";
12 30 }
13 31 document.getElementsByTagName("body")[0].innerHTML = '<div id="sidebar"><h3 id="o">' + n + '</h3><ul id="links">' + list1 + '</ul></div><ul id="a">' + list + '</ul>';
14   -
  32 + console.log(x / 1024 + " Kb - It doesn't calculate nested objects");
15 33 }
3  src/style.css
@@ -8,6 +8,9 @@ a{
8 8 a:hover{
9 9 text-decoration: underline;
10 10 }
  11 +i{
  12 + font-size: 12px;
  13 +}
11 14 ul{
12 15 list-style-type: none;
13 16 }

0 comments on commit 285d277

Please sign in to comment.
Something went wrong with that request. Please try again.