MCPcopy Index your code
hub / github.com/KhronosGroup/Vulkan-Docs / transformParagraph

Method transformParagraph

scripts/reflow.py:278–446  ·  view source on GitHub ↗

Reflow a given paragraph, respecting the paragraph lead and hanging indentation levels. The algorithm also respects trailing '+' signs that indicate embedded newlines, and will not reflow a very long word immediately after a bullet point. Just return the paragraph u

(self, para, state)

Source from the content-addressed store, hash-verified

276 return outPara, hangIndent
277
278 def transformParagraph(self, para, state):
279 """Reflow a given paragraph, respecting the paragraph lead and
280 hanging indentation levels.
281
282 The algorithm also respects trailing '+' signs that indicate embedded newlines,
283 and will not reflow a very long word immediately after a bullet point.
284
285 Just return the paragraph unchanged if the -noflow argument was
286 given."""
287
288 self.gatherVUIDs(para)
289
290 # If this is a VU that is missing a VUID, add it to the paragraph now.
291 para, hangIndent = self.addVUID(para, state)
292
293 if not self.reflow:
294 return para
295
296 logDiag('transformParagraph lead indent = ', state.leadIndent,
297 'hangIndent =', state.hangIndent,
298 'para:', para[0], end='')
299
300 # Total words processed (we care about the *first* word vs. others)
301 wordCount = 0
302
303 # Tracks the *previous* word processed. It must not be empty.
304 prevWord = ' '
305
306 # Track the previous line and paragraph being indented, if any
307 outLine = None
308 outPara = []
309
310 for line in para:
311 line = line.rstrip()
312 words = line.split()
313
314 # logDiag('transformParagraph: input line =', line)
315 numWords = len(words) - 1
316
317 for i in range(0, numWords + 1):
318 word = words[i]
319 wordLen = len(word)
320 wordCount += 1
321
322 endEscape = False
323 if i == numWords and word in ('+', '-'):
324 # Trailing ' +' or ' -' must stay on the same line
325 endEscape = word
326 # logDiag('transformParagraph last word of line =', word,
327 # 'prevWord =', prevWord, 'endEscape =', endEscape)
328 else:
329 # logDiag('transformParagraph wordCount =', wordCount,
330 # 'word =', word, 'prevWord =', prevWord)
331 pass
332
333 if wordCount == 1:
334 # The first word of the paragraph is treated specially.
335 # The loop logic becomes trickier if all this code is

Callers 1

emitParaMethod · 0.80

Calls 6

gatherVUIDsMethod · 0.95
addVUIDMethod · 0.95
vuidAnchorMethod · 0.95
endSentenceMethod · 0.95
logDiagFunction · 0.90
appendMethod · 0.80

Tested by

no test coverage detected