Read-only mirror — the public repositories of the Forgejo instance, refreshed every 10 minutes. The live instance (fg.dieschoenewolke.de) is reachable only over the VPN; clone here with https://git.dieschoenewolke.de/git/<owner>/<repo>.git.
summaryrefslogtreecommitdiff
path: root/src/misc/generate-docs.ts
diff options
context:
space:
mode:
authoreric sciple <ericsciple@users.noreply.github.com>2020-03-11 15:55:17 -0400
committerGitHub <noreply@github.com>2020-03-11 15:55:17 -0400
commit1b406b27feed694fb3a05a638c92124514baa6ea (patch)
tree05a8d7cd5c1748d2e83782e43edb2c274882ea90 /src/misc/generate-docs.ts
parentad8315eb967265115b59c3b9dc1516f8ac5917ba (diff)
add ssh support (#163)
Diffstat (limited to 'src/misc/generate-docs.ts')
-rw-r--r--src/misc/generate-docs.ts31
1 files changed, 25 insertions, 6 deletions
diff --git a/src/misc/generate-docs.ts b/src/misc/generate-docs.ts
index 884d606..defda5a 100644
--- a/src/misc/generate-docs.ts
+++ b/src/misc/generate-docs.ts
@@ -59,13 +59,17 @@ function updateUsage(
// Constrain the width of the description
const width = 80
- let description = input.description as string
+ let description = (input.description as string)
+ .trimRight()
+ .replace(/\r\n/g, '\n') // Convert CR to LF
+ .replace(/ +/g, ' ') // Squash consecutive spaces
+ .replace(/ \n/g, '\n') // Squash space followed by newline
while (description) {
// Longer than width? Find a space to break apart
let segment: string = description
if (description.length > width) {
segment = description.substr(0, width + 1)
- while (!segment.endsWith(' ') && segment) {
+ while (!segment.endsWith(' ') && !segment.endsWith('\n') && segment) {
segment = segment.substr(0, segment.length - 1)
}
@@ -77,15 +81,30 @@ function updateUsage(
segment = description
}
- description = description.substr(segment.length) // Remaining
- segment = segment.trimRight() // Trim the trailing space
- newReadme.push(` # ${segment}`)
+ // Check for newline
+ const newlineIndex = segment.indexOf('\n')
+ if (newlineIndex >= 0) {
+ segment = segment.substr(0, newlineIndex + 1)
+ }
+
+ // Append segment
+ newReadme.push(` # ${segment}`.trimRight())
+
+ // Remaining
+ description = description.substr(segment.length)
}
- // Input and default
if (input.default !== undefined) {
+ // Append blank line if description had paragraphs
+ if ((input.description as string).trimRight().match(/\n[ ]*\r?\n/)) {
+ newReadme.push(` #`)
+ }
+
+ // Default
newReadme.push(` # Default: ${input.default}`)
}
+
+ // Input name
newReadme.push(` ${key}: ''`)
firstInput = false