Skip to content

Commit a69a16c

Browse files
authored
Merge pull request #12601 from ominitay/autodocs-shortdesc
autodocs: improve first-line descriptions
2 parents 02e6960 + b63667d commit a69a16c

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

lib/docs/main.js

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2839,16 +2839,20 @@ var zigAnalysis;
28392839

28402840
function shortDescMarkdown(docs) {
28412841
const trimmed_docs = docs.trim();
2842-
let index = trimmed_docs.indexOf(".");
2843-
if (index < 0) {
2844-
index = trimmed_docs.indexOf("\n");
2845-
if (index < 0) {
2846-
index = trimmed_docs.length;
2847-
}
2848-
} else {
2849-
index += 1; // include the period
2842+
let index = trimmed_docs.indexOf("\n\n");
2843+
let cut = false;
2844+
2845+
if (index < 0 || index > 80) {
2846+
if (trimmed_docs.length > 80) {
2847+
index = 80;
2848+
cut = true;
2849+
} else {
2850+
index = trimmed_docs.length;
2851+
}
28502852
}
2851-
const slice = trimmed_docs.slice(0, index);
2853+
2854+
let slice = trimmed_docs.slice(0, index);
2855+
if (cut) slice += "...";
28522856
return markdown(slice);
28532857
}
28542858

0 commit comments

Comments
 (0)