Disable long word wrapping entirely in comments.
authorAlex Vallée <avallee@google.com>
Fri, 27 Nov 2015 21:09:34 +0000 (16:09 -0500)
committerAlex Vallée <avallee@google.com>
Fri, 27 Nov 2015 21:09:34 +0000 (16:09 -0500)
As pointed out by nico, we should unconditionally disable breaking of
long words in comments. It is unlikely long words that are in comments
should be split (like pathnames).

misc/ninja_syntax.py
misc/ninja_syntax_test.py

index f285420..73d2209 100644 (file)
@@ -22,10 +22,8 @@ class Writer(object):
         self.output.write('\n')
 
     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):
+        for line in textwrap.wrap(text, self.width - 2, break_long_words=False,
+                                  break_on_hyphens=False):
             self.output.write('# ' + line + '\n')
 
     def variable(self, key, value, indent=0):
index 46ce382..c9755b8 100755 (executable)
@@ -46,13 +46,8 @@ class TestLineWordWrap(unittest.TestCase):
                          self.out.getvalue())
 
     def test_comment_wrap(self):
-        # We should wrap the comments
-        self.n.comment('Hello there')
-        self.assertEqual('# Hello\n# there\n', self.out.getvalue())
-
-    def test_comment_wrap_filename(self):
         # Filenames shoud not be wrapped
-        self.n.comment('Hello /usr/local/build-tools/bin', has_path=True)
+        self.n.comment('Hello /usr/local/build-tools/bin')
         self.assertEqual('# Hello\n# /usr/local/build-tools/bin\n',
                          self.out.getvalue())