From efdcb3793ac2235ba6d9c75f74dbbc2815e3779d Mon Sep 17 00:00:00 2001 From: Benjamin Attal Date: Fri, 11 Apr 2014 13:14:59 -0400 Subject: [PATCH] Add docstrings for functions in parser. Add ivar for syntax tree to codelet documentation. --- bitshift/codelet.py | 2 ++ bitshift/parser/__init__.py | 15 ++++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/bitshift/codelet.py b/bitshift/codelet.py index 453ace0..ead8524 100644 --- a/bitshift/codelet.py +++ b/bitshift/codelet.py @@ -18,6 +18,8 @@ class Codelet(object): code was last modified. :ivar rank: (float) A quanitification of the source code's quality, as per available ratings (stars, forks, upvotes, etc.). + :ivar symbols: Dictionary containing dictionaries of functions, classes, + variable definitions, etc. """ def __init__(self, name, code, filename, language, authors, code_url, diff --git a/bitshift/parser/__init__.py b/bitshift/parser/__init__.py index 4d787c7..03d812c 100644 --- a/bitshift/parser/__init__.py +++ b/bitshift/parser/__init__.py @@ -7,13 +7,26 @@ _all__ = ["parse"] # TODO: modify to incorporate tags from stackoverflow def _lang(codelet): + """ + Private function to identify the language of a codelet. + + :param codelet: The codelet object to identified. + + :type code: Codelet + """ if codelet.filename is not None: return pgl.guess_lexer_for_filename(codelet.filename).name return pgl.guess_lexer(codelet.code) -# dispatches the codelet to the correct parser def parser(codelet): + """ + Dispatch codelet to correct parser by language of code. + + :param codelet: The codelet object to parsed. + + :type code: Codelet + """ lang = _lang(codelet) if lang == "Python":