Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Reviewing changes by yacomink: fixed some typos, vars now have a more…

… meaningful name.
  • Loading branch information...
commit 9b5b5182f7fea60e0c4ddc34293a4020c7cbd04d 1 parent 0b3da0e
Stefano authored
17 python/jsbeautifier/__init__.py
View
@@ -34,7 +34,7 @@ class BeautifierOptions:
def __init__(self):
self.indent_size = 4
self.indent_char = ' '
- self.tabs = False
+ self.indent_with_tabs = False
self.preserve_newlines = True
self.max_preserve_newlines = 10.
self.jslint_happy = False
@@ -52,7 +52,7 @@ def __repr__(self):
preserve_newlines = %s
max_preserve_newlines = %d
jslint_happy = %s
-tab = %s
+indent_with_tabs = %s
brace_style = %s
keep_array_indentation = %s
eval_code = %s
@@ -61,6 +61,7 @@ def __repr__(self):
self.preserve_newlines,
self.max_preserve_newlines,
self.jslint_happy,
+ self.indent_with_tabs,
self.brace_style,
self.keep_array_indentation,
self.eval_code,
@@ -120,13 +121,13 @@ def usage():
-s, --indent-size=NUMBER indentation size. (default 4).
-c, --indent-char=CHAR character to indent with. (default space).
- -t, --tabs Indent with tabs, overrides -s and -c
+ -t, --indent-with-tabs Indent with tabs, overrides -s and -c
-d, --disable-preserve-newlines do not preserve existing line breaks.
-j, --jslint-happy more jslint-compatible output
-b, --brace-style=collapse brace style (collapse, expand, end-expand)
-k, --keep-array-indentation keep array indentation.
-o, --outfile=FILE specify a file to output to (default stdout)
- -f, --keep-function-indentaion Do not re-indent function bodies defined in var lines.
+ -f, --keep-function-indentation Do not re-indent function bodies defined in var lines.
Rarely needed options:
@@ -161,7 +162,7 @@ def blank_state(self):
self.just_added_newline = False
self.do_block_just_closed = False
- if self.opts.tabs:
+ if self.opts.indent_with_tabs:
self.indent_string = "\t"
else:
self.indent_string = self.opts.indent_char * self.opts.indent_size
@@ -1077,7 +1078,7 @@ def main():
opts, args = getopt.getopt(argv, "s:c:o:djbkil:h:t:f", ['indent-size=','indent-char=','outfile=', 'disable-preserve-newlines',
'jslint-happy', 'brace-style=',
'keep-array-indentation', 'indent-level=', 'help',
- 'usage', 'stdin', 'eval-code', 'tabs', 'keep-function-indentation'])
+ 'usage', 'stdin', 'eval-code', 'indent-with-tabs', 'keep-function-indentation'])
except getopt.GetoptError:
usage()
sys.exit(2)
@@ -1100,8 +1101,8 @@ def main():
js_options.indent_size = int(arg)
elif opt in ('--indent-char', '-c'):
js_options.indent_char = arg
- elif opt in ('--tabs', '-t'):
- js_options.tabs = True
+ elif opt in ('--indent-with-tabs', '-t'):
+ js_options.indent_with_tabs = True
elif opt in ('--disable-preserve_newlines', '-d'):
js_options.preserve_newlines = False
elif opt in ('--jslint-happy', '-j'):
9 python/jsbeautifier/tests/testindentation.py
View
@@ -1,6 +1,3 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-
import re
import unittest
import jsbeautifier
@@ -9,13 +6,13 @@ class TestJSBeautifierIndentation(unittest.TestCase):
def test_tabs(self):
test_fragment = self.decodesto
- self.options.tabs = 1;
+ self.options.indent_with_tabs = 1;
test_fragment('{tabs()}', "{\n\ttabs()\n}");
def test_function_indent(self):
test_fragment = self.decodesto
-
- self.options.tabs = 1;
+
+ self.options.indent_with_tabs = 1;
self.options.keep_function_indentation = 1;
test_fragment('var foo = function(){ bar() }();', "var foo = function() {\n\tbar()\n}();");
Please sign in to comment.
Something went wrong with that request. Please try again.