diff options
author | Alex Vallée <avallee@google.com> | 2015-10-23 20:36:28 (GMT) |
---|---|---|
committer | Alex Vallée <avallee@google.com> | 2015-10-23 20:36:28 (GMT) |
commit | 8f658d63298c5fae29616b8d922d03bb7ea67c0c (patch) | |
tree | 3dd0d2c40c09c075d663428628ad094d611890c3 /misc/ninja_syntax.py | |
parent | 083b6b040681ec3d8ec3cd40f20406b9e6ec8d56 (diff) | |
download | Ninja-8f658d63298c5fae29616b8d922d03bb7ea67c0c.zip Ninja-8f658d63298c5fae29616b8d922d03bb7ea67c0c.tar.gz Ninja-8f658d63298c5fae29616b8d922d03bb7ea67c0c.tar.bz2 |
Fix wrapping file paths in Writer.comment
Long file names, especially with hyphens will get incorrectly wrapped by
the comment method. Pass has_path=True to prevent this type of wrapping.
This is mainly so that longer path names can show up in comments on
their on line without breaking them up.
Diffstat (limited to 'misc/ninja_syntax.py')
-rw-r--r-- | misc/ninja_syntax.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/misc/ninja_syntax.py b/misc/ninja_syntax.py index 8673518..091e054 100644 --- a/misc/ninja_syntax.py +++ b/misc/ninja_syntax.py @@ -21,8 +21,11 @@ class Writer(object): def newline(self): self.output.write('\n') - def comment(self, text): - for line in textwrap.wrap(text, self.width - 2): + def comment(self, text, has_path=False): + args = {} + if has_path: + args['break_long_words'] = args['break_on_hyphens'] = False + for line in textwrap.wrap(text, self.width - 2, **args): self.output.write('# ' + line + '\n') def variable(self, key, value, indent=0): |