xref: /aosp_15_r20/external/ktfmt/core/src/main/java/com/facebook/ktfmt/kdoc/ParagraphList.kt (revision 5be3f65c8cf0e6db0a7e312df5006e8e93cdf9ec)
1 /*
2  * Copyright (c) Tor Norbye.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.facebook.ktfmt.kdoc
18 
19 /**
20  * A list of paragraphs. Each paragraph should start on a new line and end with a newline. In
21  * addition, if a paragraph is marked with "separate=true", we'll insert an extra blank line in
22  * front of it.
23  */
24 class ParagraphList(private val paragraphs: List<Paragraph>) : Iterable<Paragraph> {
isSingleParagraphnull25   fun isSingleParagraph() = paragraphs.size <= 1
26 
27   override fun iterator(): Iterator<Paragraph> = paragraphs.iterator()
28 
29   override fun toString(): String = paragraphs.joinToString { it.content }
30 }
31