autodoc: better short description algorithm

This commit is contained in:
r00ster91 2022-07-28 20:49:55 +02:00
parent e863292fe2
commit 2c7387aef5

View file

@ -2639,14 +2639,23 @@ var zigAnalysis;
});
}
function shortDescMarkdown(docs) {
let parts = docs.trim().split("\n");
let firstLine = parts[0];
return markdown(firstLine);
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
}
const slice = trimmed_docs.slice(0, index);
return markdown(slice);
}
function markdown(input) {
const raw_lines = input.split('\n'); // zig allows no '\r', so we don't need to split on CR