Merge pull request #12276 from r00ster91/shortdesc

autodoc: better short description algorithm
This commit is contained in:
Loris Cro 2022-08-02 16:32:08 +02:00 committed by GitHub
commit 2375658da9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2643,14 +2643,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