cmake_format.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:cmake_format 作者: cheshirekow 项目源码 文件源码
def format_single_arg(config, line_width, arg):
    """Return a list of lines that reflow the single arg and all it's comments
       into a block with width at most line_width."""
    if arg.comments:
        comment_stream = ' '.join([comment[1:].strip()
                                   for comment in arg.comments])
        initial_indent = arg.contents + ' # '
        subsequent_indent = ' ' * len(arg.contents) + ' # '
        wrapper = textwrap.TextWrapper(width=line_width,
                                       expand_tabs=True,
                                       replace_whitespace=True,
                                       drop_whitespace=True,
                                       initial_indent=initial_indent,
                                       subsequent_indent=subsequent_indent)
        return wrapper.wrap(comment_stream)
    else:
        return [arg.contents]
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号