Documentation
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
# -*- coding: utf8 -*-
|
||||
"""
|
||||
CSS Formatter class.
|
||||
.. module:: lesscpy.lessc.formatter
|
||||
:synopsis: CSS Formatter class.
|
||||
|
||||
Copyright (c)
|
||||
See LICENSE for details.
|
||||
<jtm@robot.is>
|
||||
.. moduleauthor:: Jóhann T. Maríusson <jtm@robot.is>
|
||||
"""
|
||||
class Formatter(object):
|
||||
def __init__(self, args):
|
||||
|
||||
@@ -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 <jtm@robot.is>
|
||||
"""
|
||||
__all__ = [
|
||||
'Block',
|
||||
'Call',
|
||||
|
||||
@@ -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 <jtm@robot.is>
|
||||
"""
|
||||
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
|
||||
|
||||
|
||||
@@ -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 <jtm@robot.is>
|
||||
"""
|
||||
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')
|
||||
|
||||
@@ -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 <jtm@robot.is>
|
||||
"""
|
||||
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]
|
||||
|
||||
Reference in New Issue
Block a user