ramile
ramile copied to clipboard
Add Python language support and fix processors intialization
Feature:
- general comment block filter and Python multiline docstrings filter
- sharp("#") comment filter for Python
- Python processor
Update:
- move filters to another package named
filters
Fix:
- processor initialization
filters
was a class property of FilterProcessorBase
and not re-defined in subclassess. In each subclass, some filters were appended to this class property, led to all subclasses shared the class property from their base class but using their own.
`filters` 是基类 `FilterProcessorBase` 的一个类属性, 但是并没有在各子类中重新定义,
而是在子类的初始化方法中添加元素;而且子类均没有调用基类的初始化方法。
这导致每一个子类最终的 `filter` 属性都包含所有被添加过的 filter,与预期行为应该是不一致的。
originally
class FileProcessorBase(object):
""" Base class for file processors. The processor for each lanuage should inherit from this class.
"""
expected_extensions = []
filters = []
def __init__(self):
# by default, processors of all languages will always starts with a blank line filter
self.filters.append(BlankLineFilter())
return
class JsProcessor(FileProcessorBase):
expected_extensions = ['.js', '.jsx', '.vue']
expected_extensions = ['.js', '.jsx', '.vue', '.wpy']
def __init__(self):
self.filters.append(BlankLineFilter())
self.filters.append(CStyleCommentBlockFilter())
self.filters.append(DoubleSlashCommentFilter())
return
fixed
class FileProcessorBase(object):
""" Base class for file processors. The processor for each lanuage should inherit from this class.
"""
expected_extensions = []
def __init__(self):
# by default, processors of all languages will always starts with a blank line filter
self.filters = []
self.filters.append(BlankLineFilter())
return
class JsProcessor(FileProcessorBase):
expected_extensions = ['.js', '.jsx', '.vue', '.wpy']
def __init__(self):
super().__init__()
self.filters.append(CStyleCommentBlockFilter())
self.filters.append(DoubleSlashCommentFilter())
Hi, @Dectinc. Thanks for your contribution.
But it fails when comments start with just a line-break. See fix in PR https://github.com/Dectinc/ramile/pull/1.
Would you kindly merge it into this PR if it is possible.
Hi, @Dectinc. Thanks for your contribution.
But it fails when comments start with just a line-break. See fix in PR Dectinc#1.
Would you kindly merge it into this PR if it is possible.
Thanks, merged.
Thx!