diff options
author | 2017-09-20 21:05:13 +0200 | |
---|---|---|
committer | 2017-09-21 11:03:01 +0200 | |
commit | bc66d0422c2a5a6066107fe7e8ed71e61bab5ce1 (patch) | |
tree | a9570cbc95ba8547f4a05b55574007ce8273df5c /src/tools/skylark/javatests/com | |
parent | 4284f02a0d637cddc8c346fd5aa1571d6e11528f (diff) |
Skylint: be less strict about indentation in docstrings
Instead of enforcing two spaces of indentation, we now
only enforce a positive number of spaces in indented lines.
Reason: Apparently, a lot of docstrings in Skylark files
are badly indented, so we should only warn about the
worst offenders until a formatting tool is available.
RELNOTES: none
PiperOrigin-RevId: 169429429
Diffstat (limited to 'src/tools/skylark/javatests/com')
-rw-r--r-- | src/tools/skylark/javatests/com/google/devtools/skylark/skylint/DocstringUtilsTest.java | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/src/tools/skylark/javatests/com/google/devtools/skylark/skylint/DocstringUtilsTest.java b/src/tools/skylark/javatests/com/google/devtools/skylark/skylint/DocstringUtilsTest.java index eeddd0f491..78b3e629cb 100644 --- a/src/tools/skylark/javatests/com/google/devtools/skylark/skylint/DocstringUtilsTest.java +++ b/src/tools/skylark/javatests/com/google/devtools/skylark/skylint/DocstringUtilsTest.java @@ -116,25 +116,22 @@ public class DocstringUtilsTest { "summary\n" + "\n" + "Args:\n" + + " param0: two spaces indentation\n" + " param1: only one space indentation\n" - + " only three spaces indentation\n" + + " only two spaces indentation in continued line\n" + "unindented line after", 0, errors); Truth.assertThat(info.summary).isEqualTo("summary"); - Truth.assertThat(info.parameters).hasSize(1); - ParameterDoc param = info.parameters.get(0); - Truth.assertThat(param.description) - .isEqualTo("only one space indentation\nonly three spaces indentation"); - Truth.assertThat(errors.toString()) - .contains( - ":4: parameter lines have to be indented by two spaces" - + " (relative to the left margin of the docstring)"); + Truth.assertThat(info.parameters).hasSize(2); + ParameterDoc param0 = info.parameters.get(0); + Truth.assertThat(param0.description).isEqualTo("two spaces indentation"); + ParameterDoc param1 = info.parameters.get(1); + Truth.assertThat(param1.description) + .isEqualTo("only one space indentation\n only two spaces indentation in continued line"); Truth.assertThat(errors.toString()) - .contains( - ":5: continued parameter lines have to be indented by four spaces" - + " (relative to the left margin of the docstring)"); - Truth.assertThat(errors.toString()).contains(":6: end of 'Args' section without blank line"); + .contains(":5: inconsistent indentation of parameter lines (before: 2; here: 1 spaces)"); + Truth.assertThat(errors.toString()).contains(":7: end of 'Args' section without blank line"); } @Test @@ -185,7 +182,7 @@ public class DocstringUtilsTest { Truth.assertThat(firstParam.parameterName).isEqualTo("param1"); Truth.assertThat(firstParam.attributes).isEmpty(); - Truth.assertThat(firstParam.description).isEqualTo("multi-\nline"); + Truth.assertThat(firstParam.description).isEqualTo("multi-\n line"); Truth.assertThat(secondParam.parameterName).isEqualTo("param2"); Truth.assertThat(secondParam.attributes).isEqualTo(Arrays.asList("mutable", "unused")); @@ -227,7 +224,7 @@ public class DocstringUtilsTest { Truth.assertThat(firstParam.parameterName).isEqualTo("param1"); Truth.assertThat(firstParam.attributes).isEmpty(); - Truth.assertThat(firstParam.description).isEqualTo("multi-\n\nline"); + Truth.assertThat(firstParam.description).isEqualTo("multi-\n\n line"); Truth.assertThat(secondParam.parameterName).isEqualTo("param2"); Truth.assertThat(secondParam.attributes).isEmpty(); |