Sfoglia il codice sorgente

Add docstrings for functions in parser. Add ivar for syntax tree to codelet documentation.

tags/v1.0^2
Benjamin Attal 10 anni fa
parent
commit
efdcb3793a
2 ha cambiato i file con 16 aggiunte e 1 eliminazioni
  1. +2
    -0
      bitshift/codelet.py
  2. +14
    -1
      bitshift/parser/__init__.py

+ 2
- 0
bitshift/codelet.py Vedi File

@@ -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,


+ 14
- 1
bitshift/parser/__init__.py Vedi File

@@ -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":


Caricamento…
Annulla
Salva