Skip to content

Commit

Permalink
Removed the simplejson requirement when native support is available
Browse files Browse the repository at this point in the history
(Python 2.6.0+).
  • Loading branch information
Adam Moore committed Mar 31, 2010
1 parent 1c76ee6 commit c7395c6
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 25 deletions.
2 changes: 2 additions & 0 deletions INSTALL
Expand Up @@ -33,6 +33,8 @@ Unix (including cygwin):


easy_install pygments easy_install pygments
easy_install Cheetah easy_install Cheetah

* For Python version below 2.6.0, also install simplejson *
easy_install simplejson easy_install simplejson




Expand Down
2 changes: 1 addition & 1 deletion README
Expand Up @@ -5,7 +5,7 @@ in the YUI library. The docs are derived completely from JavaDoc style
comment blocks; no attempt is made to understand the javascript itself. comment blocks; no attempt is made to understand the javascript itself.


yuidoc requires Python 2.3+ with the following extensions: yuidoc requires Python 2.3+ with the following extensions:
simplejson - for reading and writing json simplejson - for reading and writing json (required for Python versions below 2.6.0)
cheetah - for generating the html docs cheetah - for generating the html docs
pygments - for colorizing the source pygments - for colorizing the source


Expand Down
13 changes: 10 additions & 3 deletions bin/yuidoc_generate.py
Expand Up @@ -10,7 +10,14 @@
''' '''


''' Prints documentation with htmltmpl from the json data outputted by parser.py ''' ''' Prints documentation with htmltmpl from the json data outputted by parser.py '''
import os, re, simplejson, shutil, logging, logging.config, time, datetime
try:
import json as simplejson
except:
import simplejson

import os, re, shutil, logging, logging.config, time, datetime

from const import * from const import *
# from cStringIO import StringIO # from cStringIO import StringIO
from Cheetah.Template import Template from Cheetah.Template import Template
Expand Down Expand Up @@ -672,8 +679,8 @@ def completeProp(main, ext):
#remove dups #remove dups
allprops = [] allprops = []
propmap = {} propmap = {}
# for i in self.allprops: for i in self.allprops:
for i in self.allprops_ext: # for i in self.allprops_ext:
url = i[URL] url = i[URL]
if url not in propmap: if url not in propmap:
allprops.append(i) allprops.append(i)
Expand Down
21 changes: 10 additions & 11 deletions bin/yuidoc_parse.py
Expand Up @@ -11,7 +11,14 @@


''' A class to parse Javadoc style comments out of javascript to document ''' A class to parse Javadoc style comments out of javascript to document
an API. It is designed to parse one module at a time ''' an API. It is designed to parse one module at a time '''
import os, re, simplejson, string, sys, pprint, logging, logging.config

try:
import json as simplejson
except:
import simplejson

import os, re, string, sys, pprint, logging, logging.config
from const import * from const import *
# from cStringIO import StringIO # from cStringIO import StringIO
from optparse import OptionParser from optparse import OptionParser
Expand Down Expand Up @@ -40,13 +47,7 @@ def _mkdir(newdir):
if tail: os.mkdir(newdir) if tail: os.mkdir(newdir)


def parseFile(path, file): def parseFile(path, file):
# f=open(os.path.join(path, file))
f = codecs.open(os.path.join(path, file), "r", "utf-8" ) f = codecs.open(os.path.join(path, file), "r", "utf-8" )
#adding a return to the beginning of the line allows for:
# #!/usr/bin/foo
# MOVED to the file marker
# fileStr = StringIO("\n%s" % f.read()).getvalue()
# fileStr = StringIO("%s" % f.read()).getvalue()
fileStr = f.read() fileStr = f.read()
log.info("parsing " + file) log.info("parsing " + file)
# add a file marker token so the parser can keep track of what is in what file # add a file marker token so the parser can keep track of what is in what file
Expand Down Expand Up @@ -163,12 +164,10 @@ def getClassName(self, classString, namespace):
longName = namespace + "." + shortName longName = namespace + "." + shortName
return shortName, longName return shortName, longName


# extract string literals in case they contain the documentation pattern # extract string literals in case they contain the doc comment pattern
literals_pat = re.compile(r'(\'.*?(?<=[^\\])\')|(\".*?(?<=[^\\])\")') literals_pat = re.compile(r'(\'.*?(?<=[^\\])\')|(\".*?(?<=[^\\])\")')


# extract regex literals in case they contain # extract regex literals in case they contain the doc comment pattern
#regex_pat = re.compile(r'(\/.*?(?<=[^\\])\/)')
#regex_pat = re.compile(r'(\/[^\s\/\*][^\n]*?(?<=[^\\])\/)')
regex_pat = re.compile(r'(\/[^\s\/\*][^\n]*\/)') regex_pat = re.compile(r'(\/[^\s\/\*][^\n]*\/)')


# the token we will use to restore the string literals # the token we will use to restore the string literals
Expand Down
37 changes: 27 additions & 10 deletions test/intl/intl.js
Expand Up @@ -4,30 +4,47 @@
* <ul> * <ul>
* <li><em>Languages:</em> RFC 4646 language tags, such as "en-GB" (English as used * <li><em>Languages:</em> RFC 4646 language tags, such as "en-GB" (English as used
* in the United Kingdom), "zh-Hans-CN" (simpified Chinese as used in China). * in the United Kingdom), "zh-Hans-CN" (simpified Chinese as used in China).
* </em></li>
* <li><em>Time zones:</em> tz database identifiers, such as "Europe/Berlin" * <li><em>Time zones:</em> tz database identifiers, such as "Europe/Berlin"
* (time zone of Germany), "America/Los_Angeles" (Pacific time zone in the United States), * (time zone of Germany), "America/Los_Angeles" (Pacific time zone in the United States),
* "Asia/Kolkata" (time zone of India). * "Asia/Kolkata" (time zone of India).
* </em></li>
* </ul> * </ul>
* </p>
* @module text * @module text
* @requires yahoo, json
*/ */


/** /**
* Provides functionality for formatting date and time information. * Provides functionality for formatting date and time information.
* @class DateFormat * @class DateFormat
* @namespace YAHOO.text
* @constructor * @constructor
* @param {Style | Style[] | String} style Style constant or pattern string for the desired date format. * @param {Style | Style[] | String} style Style constant or pattern string for the desired date format.
* @param {String} language The RFC 4646 language tag for the language of the date format. * @param {String} language The RFC 4646 language tag for the language of the date format.
* @param {String} timeZone <b>future</b> The tz database identifier for the time zone of the date format. * @param {String} timeZone <b>future</b> The tz database identifier for the time zone of the date format.
* Optional - the browser time zone is used by default. * Optional - the browser time zone is used by default.
*/ */


/** /**
* <b>future</b> Calendar month format. Examples: * <b>future</b> Calendar month format. Examples:
* <ul> * <ul>
* <li>June 2009 * <li>June 2009
* <li>2009年6月 * <li>2009年6月
* </ul> * </ul>
* @property CALENDAR_MONTH * @property CALENDAR_MONTH
*/ */

/**
* subclass method
* @method subclassmethod
*/

/**
* DateFormat subclass
* @class DateFormatSubclass
* @extends DateFormat
*/

/**
* subclass method
* @method subclassmethod
*/

0 comments on commit c7395c6

Please sign in to comment.