diff --git a/lesscpy/lessc/formatter.py b/lesscpy/lessc/formatter.py index ba74d5e..07f6444 100644 --- a/lesscpy/lessc/formatter.py +++ b/lesscpy/lessc/formatter.py @@ -1,9 +1,11 @@ +# -*- coding: utf8 -*- """ - CSS Formatter class. +.. module:: lesscpy.lessc.formatter + :synopsis: CSS Formatter class. Copyright (c) See LICENSE for details. - +.. moduleauthor:: Jóhann T. Maríusson """ class Formatter(object): def __init__(self, args): diff --git a/lesscpy/plib/__init__.py b/lesscpy/plib/__init__.py index 813d639..647676b 100644 --- a/lesscpy/plib/__init__.py +++ b/lesscpy/plib/__init__.py @@ -1,3 +1,12 @@ +# -*- coding: utf8 -*- +""" +.. module:: lesscpy.plib + :synopsis: Parse Nodes for Lesscpy + + Copyright (c) + See LICENSE for details. +.. moduleauthor:: Jóhann T. Maríusson +""" __all__ = [ 'Block', 'Call', diff --git a/lesscpy/plib/deferred.py b/lesscpy/plib/deferred.py index d1dd8f7..cf381d1 100644 --- a/lesscpy/plib/deferred.py +++ b/lesscpy/plib/deferred.py @@ -1,21 +1,41 @@ +# -*- coding: utf8 -*- """ +.. module:: lesscpy.plib.deferred + :synopsis: Deferred mixin call. + + Copyright (c) + See LICENSE for details. +.. moduleauthor:: Jóhann T. Maríusson """ from .node import Node class Deferred(Node): def __init__(self, mixin, args): - """ + """This node represents mixin calls + within the body of other mixins. The calls + to these mixins are deferred until the parent + mixin is called. + args: + mixin (Mixin): Mixin object + args (list): Call arguments """ self.mixin = mixin self.args = args def parse(self, scope): - """ + """ Parse function. + args: + scope (Scope): Scope object + returns: + mixed """ if hasattr(self.mixin, 'call'): return self.mixin.call(scope, self.args) mixins = scope.mixins(self.mixin.raw()) if not mixins: return mixins - for m in mixins: - res = m.call(scope, self.args) - if res: return res + for mixin in mixins: + res = mixin.call(scope, self.args) + if res: + return res + return False + diff --git a/lesscpy/plib/node.py b/lesscpy/plib/node.py index cedbaea..1cfcc7c 100644 --- a/lesscpy/plib/node.py +++ b/lesscpy/plib/node.py @@ -1,17 +1,41 @@ +# -*- coding: utf8 -*- """ +.. module:: lesscpy.plib.node + :synopsis: Base Node + + Copyright (c) + See LICENSE for details. +.. moduleauthor:: Jóhann T. Maríusson """ from lesscpy.lessc import utility + class Node(object): - def __init__(self, p, ln=0): - self.tokens = p - self.lineno = ln + def __init__(self, tokens, lineno=0): + """ Base Node + args: + tokens (list): tokenlist + lineno (int): Line number of node + """ + self.tokens = tokens + self.lineno = lineno self.parsed = False def parse(self, scope): + """ Base parse function + args: + scope (Scope): Scope object + returns: + self + """ return self def process(self, tokens, scope): - """ + """ Process tokenslist, flattening and parsing it + args: + tokens (list): tokenlist + scope (Scope): Scope object + returns: + list """ while True: tokens = list(utility.flatten(tokens)) @@ -29,7 +53,12 @@ class Node(object): return tokens def replace_variables(self, tokens, scope): - """ + """ Replace variables in tokenlist + args: + tokens (list): tokenlist + scope (Scope): Scope object + returns: + list """ return [scope.swap(t) if utility.is_variable(t) @@ -37,4 +66,10 @@ class Node(object): for t in tokens] def fmt(self, fills): + """ Format node + args: + fills (dict): replacements + returns: + str + """ raise ValueError('No defined format') diff --git a/lesscpy/plib/variable.py b/lesscpy/plib/variable.py index 49d1d39..d6e2417 100644 --- a/lesscpy/plib/variable.py +++ b/lesscpy/plib/variable.py @@ -1,9 +1,21 @@ +# -*- coding: utf8 -*- """ +.. module:: lesscpy.plib.variable + :synopsis: Variable declaration + + Copyright (c) + See LICENSE for details. +.. moduleauthor:: Jóhann T. Maríusson """ from .node import Node + class Variable(Node): def parse(self, scope): - """ + """ Parse function + args: + scope (Scope): Scope object + returns: + self """ self.name = self.tokens.pop(0) self.value = self.tokens[1]