JoinNestedOuter attempts to de-indent the items after the first so that the operator appears in the right margin. This replacement is only done if there are enough "simple spaces" (as per previous uses of Align) to de-indent. No attempt is made to de-indent hard tabs, otherwise alignment may break o
(lbl string, docFn func(string) Doc, d ...Doc)
| 166 | // physical tab width. docFn should be set to Text or Keyword and will be |
| 167 | // used when converting lbl to a Doc. |
| 168 | func JoinNestedOuter(lbl string, docFn func(string) Doc, d ...Doc) Doc { |
| 169 | sep := docFn(lbl) |
| 170 | return &snesting{ |
| 171 | f: func(k int16) Doc { |
| 172 | if k < int16(len(lbl)+1) { |
| 173 | // If there is not enough space, don't even try. Just use a |
| 174 | // regular nested section. |
| 175 | return JoinNestedRight(sep, d...) |
| 176 | } |
| 177 | // If there is enough space, on the other hand, we can de-indent |
| 178 | // every line after the first. |
| 179 | return Concat(d[0], |
| 180 | NestS(int16(-len(lbl)-1), |
| 181 | FoldMap( |
| 182 | Concat, |
| 183 | func(x Doc) Doc { |
| 184 | return Concat( |
| 185 | Line, |
| 186 | ConcatSpace(sep, Align(Group(x)))) |
| 187 | }, |
| 188 | d[1:]...))) |
| 189 | }, |
| 190 | } |
| 191 | } |
| 192 | |
| 193 | // TableRow is the data for one row of a RLTable (see below). |
| 194 | type TableRow struct { |
no test coverage detected
searching dependent graphs…