mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 13:54:21 +00:00
autodoc: better short description algorithm
This commit is contained in:
parent
e863292fe2
commit
2c7387aef5
1 changed files with 14 additions and 5 deletions
|
|
@ -2639,14 +2639,23 @@ var zigAnalysis;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function shortDescMarkdown(docs) {
|
function shortDescMarkdown(docs) {
|
||||||
let parts = docs.trim().split("\n");
|
const trimmed_docs = docs.trim();
|
||||||
let firstLine = parts[0];
|
let index = trimmed_docs.indexOf('.');
|
||||||
return markdown(firstLine);
|
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) {
|
function markdown(input) {
|
||||||
const raw_lines = input.split('\n'); // zig allows no '\r', so we don't need to split on CR
|
const raw_lines = input.split('\n'); // zig allows no '\r', so we don't need to split on CR
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue