autodocs: improve first-line descriptions

This commit is contained in:
ominitay 2022-08-23 18:42:46 +01:00
parent 583175dc1d
commit b63667dda3
No known key found for this signature in database
GPG Key ID: DD7CAB34AB04B8E2

View File

@ -2835,16 +2835,20 @@ var zigAnalysis;
function shortDescMarkdown(docs) {
const trimmed_docs = docs.trim();
let index = trimmed_docs.indexOf(".");
if (index < 0) {
index = trimmed_docs.indexOf("\n");
if (index < 0) {
index = trimmed_docs.length;
}
} else {
index += 1; // include the period
let index = trimmed_docs.indexOf("\n\n");
let cut = false;
if (index < 0 || index > 80) {
if (trimmed_docs.length > 80) {
index = 80;
cut = true;
} else {
index = trimmed_docs.length;
}
}
const slice = trimmed_docs.slice(0, index);
let slice = trimmed_docs.slice(0, index);
if (cut) slice += "...";
return markdown(slice);
}