Skip to content

Commit

Permalink
Indent list items 2 spaces (in addition to any indentation from neste…
Browse files Browse the repository at this point in the history
…d lists)

MOE_MIGRATED_REVID=134770008
  • Loading branch information
cpovirk authored and cushon committed Oct 3, 2016
1 parent 41d4254 commit 28937f9
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ final class JavadocWriter {
private boolean continuingListItemOfInnermostList;
private boolean continuingFooterTag;
private final NestingCounter continuingListItemCount = new NestingCounter();
private final NestingCounter continuingListCount = new NestingCounter();
private int remainingOnLine;
private boolean atStartOfLine;
private RequestedWhitespace requestedWhitespace = NONE;
Expand Down Expand Up @@ -103,6 +104,7 @@ void writeFooterJavadocTagStart(Token token) {
*/
continuingListItemOfInnermostList = false;
continuingListItemCount.reset();
continuingListCount.reset();

if (!wroteAnythingSignificant) {
// Javadoc consists solely of tags. This is frowned upon in general but OK for @Overrides.
Expand All @@ -123,6 +125,7 @@ void writeListOpen(Token token) {

writeToken(token);
continuingListItemOfInnermostList = false;
continuingListCount.increment();

requestNewline();
}
Expand All @@ -131,6 +134,7 @@ void writeListClose(Token token) {
requestNewline();

continuingListItemCount.decrementIfPositive();
continuingListCount.decrementIfPositive();
writeToken(token);

// TODO(cushon): only if continuingListItemCount == 0?
Expand Down Expand Up @@ -378,7 +382,7 @@ enum AutoIndent {
}

private int innerIndent() {
int innerIndent = continuingListItemCount.value() * 4;
int innerIndent = continuingListItemCount.value() * 4 + continuingListCount.value() * 2;
if (continuingFooterTag) {
innerIndent += 4;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -698,14 +698,14 @@ public void lists() {
" * Foo.",
" *",
" * <ul>",
" * <li>1",
" * <ul>",
" * <li>1a",
" * <li>1b",
" * </ul>",
" * more 1",
" * <p>still more 1",
" * <li>2",
" * <li>1",
" * <ul>",
" * <li>1a",
" * <li>1b",
" * </ul>",
" * more 1",
" * <p>still more 1",
" * <li>2",
" * </ul>",
" */",
"class Test {}",
Expand All @@ -729,9 +729,9 @@ public void listItemWrap() {
" * Foo.",
" *",
" * <ul>",
" * <li>234567890 234567890 234567890 234567890 234567890 234567890 234567890 234567890"
" * <li>234567890 234567890 234567890 234567890 234567890 234567890 234567890 234567890"
+ " 234567890",
" * 234567890",
" * 234567890",
" * </ul>",
" */",
"class Test {}",
Expand All @@ -755,7 +755,7 @@ public void unclosedList() {
" * Foo.",
" *",
" * <ul>",
" * <li>1",
" * <li>1",
" *",
" * @return blah",
" */",
Expand Down Expand Up @@ -928,10 +928,10 @@ public void paramsOtherIndents() {
" * @param foo a",
" * <p>b",
" * <ul>",
" * <li>a",
" * <ul>",
" * <li>x",
" * </ul>",
" * <li>a",
" * <ul>",
" * <li>x",
" * </ul>",
" * </ul>",
" *", // TODO(cpovirk): Ideally we would probably eliminate this.
" * @param bar another",
Expand Down Expand Up @@ -1066,8 +1066,8 @@ public void inferParagraphTags() {
" * </pre>",
" *",
" * <ul>",
" * <li>foo",
" * <p>bar",
" * <li>foo",
" * <p>bar",
" * </ul>",
" */",
"class Test {}",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* one
*
* <ol>
* <li>two
* <li>two
* </ol>
*
* <p>
Expand All @@ -14,13 +14,13 @@ class T {
* One
*
* <ul>
* <li>a
* <ul>
* <li>b
* <li>c
* </ul>
* <li>a
* <ul>
* <li>b
* <li>c
* </ul>
*
* <li>e
* <li>e
* </ul>
*/
int x;
Expand Down

0 comments on commit 28937f9

Please sign in to comment.