mirror of
https://github.com/ziglang/zig.git
synced 2026-02-13 04:48:20 +00:00
Merge pull request #12601 from ominitay/autodocs-shortdesc
autodocs: improve first-line descriptions
This commit is contained in:
commit
a69a16c6bd
@ -2839,16 +2839,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);
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user