Module Index

Constructor

Class: CodeBaseDoc

Represents the documentation for an entire codebase.

This takes a list of root paths. The resulting object acts like a dictionary of FileDoc objects, keyed by the filename of the file (relative to the source root).

>>> CodeBaseDoc(['examples'])['class.js'].name
'class.js'

It also handles dependency & subclass analysis, setting the appropriate fields on the contained objects. Note that the keys (after prefix chopping) should match the names declared in @dependency or @see tags; otherwise, you may get MissingDependencyErrors.

Constructor

__init__ (self, root_paths, include_private=False)

Create a new CodeBaseDoc. root_paths is a list of directories where JavaScript files can be found. @see and @dependency tags are relative to these paths.

By default, private methods are not included. Pass True to include_private to include them.

Methods

build_see_html (self, see_tags, header_tag, in_comment=None)

save_docs (self, files=None, output_dir=None)

Save documentation files for codebase into output_dir. If output dir is None, it'll refrain from building the index page and build the file(s) in the current directory.

If files is None, it'll build all files in the codebase.

to_dict (self, files=None)

Converts the CodeBaseDoc into a dictionary containing the to_dict() representations of each contained file. The optional files list lets you restrict the dict to include only specific files.

>>> CodeBaseDoc(['examples']).to_dict(['class.js']).get('module.js')
>>> CodeBaseDoc(['examples']).to_dict(['class.js'])['class.js'][0]['name']
'MyClass'

to_html (self)

Builds basic HTML for the full module index.

to_json (self, files=None)

Converts the full CodeBaseDoc into JSON text. The optional files list lets you restrict the JSON dict to include only specific files.

Turn all @link tags in text into HTML anchor tags.

in_comment is the CommentDoc that contains the text, for relative method lookups.

translate_ref_to_url (self, ref, in_comment=None)

Translates an @see or @link reference to a URL. If the ref is of the form #methodName, it looks for a method of that name on the class in_comment or parent class of method in_comment. In this case, it returns a local hash URL, since the method is guaranteed to be on the same page:

>>> doc = CodeBaseDoc(['examples'])
>>> doc.translate_ref_to_url('#public_method', doc.all_methods['private_method'])
'#public_method'
>>> doc.translate_ref_to_url('#public_method', doc.all_classes['MySubClass'])
'#public_method'

If it doesn't find it there, it looks for a global function:

>>> doc.translate_ref_to_url('#make_class')
'module_closure.html#make_class'

A reference of the form ClassName#method_name looks up a specific method:

>>> doc.translate_ref_to_url('MyClass#first_method')
'class.html#first_method'

Finally, a reference of the form ClassName looks up a specific class:

>>> doc.translate_ref_to_url('MyClass')
'class.html#MyClass'

Properties

all_classes

Read only

Returns a dict of all classes in all modules.

all_functions

Read only

Returns a dict of all functions in all modules of the codebase, keyed by their name.

all_methods

Read only

Returns a dict of all methods in all modules.

Attributes

clear

Value of clear

<method 'clear' of 'dict' objects>

copy

Value of copy

<method 'copy' of 'dict' objects>

fromkeys

Value of fromkeys

<built-in method fromkeys of type object at 0x97d463c>

get

Value of get

<method 'get' of 'dict' objects>

has_key

Value of has_key

<method 'has_key' of 'dict' objects>

items

Value of items

<method 'items' of 'dict' objects>

iteritems

Value of iteritems

<method 'iteritems' of 'dict' objects>

iterkeys

Value of iterkeys

<method 'iterkeys' of 'dict' objects>

itervalues

Value of itervalues

<method 'itervalues' of 'dict' objects>

keys

Value of keys

<method 'keys' of 'dict' objects>

pop

Value of pop

<method 'pop' of 'dict' objects>

popitem

Value of popitem

<method 'popitem' of 'dict' objects>

setdefault

Value of setdefault

<method 'setdefault' of 'dict' objects>

update

Value of update

<method 'update' of 'dict' objects>

values

Value of values

<method 'values' of 'dict' objects>