Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/bug-report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ body:
Your bug can be investigated much faster if your code can be run without any dependencies other than `node-llama-cpp`.
Issues without reproduction steps or code examples may be closed as not actionable.
Please try to provide a Minimal, Complete, and Verifiable example ([link](http://stackoverflow.com/help/mcve)).
Also, please enable enable debug logs by using `getLlama({logLevel: LlamaLogLevel.debug})` to get more information.
placeholder: >-
Please try to provide a Minimal, Complete, and Verifiable example.
http://stackoverflow.com/help/mcve
Expand Down
9 changes: 5 additions & 4 deletions .vitepress/utils/getCommandHtmlDoc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {htmlEscape} from "./htmlEscape.js";
import {cliBinName, npxRunPrefix} from "../../src/config.js";
import {buildHtmlTable} from "./buildHtmlTable.js";
import {buildHtmlHeading} from "./buildHtmlHeading.js";
import {htmlEscapeWithCodeMarkdown} from "./htmlEscapeWithCodeMarkdown.js";

export async function getCommandHtmlDoc(command: CommandModule<any, any>, {
cliName = cliBinName,
Expand Down Expand Up @@ -45,7 +46,7 @@ export async function getCommandHtmlDoc(command: CommandModule<any, any>, {

return [
`<a href="${subCommandsParentPageLink != null ? (subCommandsParentPageLink + "/") : ""}${commandPageLink}"><code>` + htmlEscape(cliName + " " + cliCommand) + "</code></a>",
htmlEscape(String(subCommand.describe ?? ""))
htmlEscapeWithCodeMarkdown(String(subCommand.describe ?? ""))
];
})
.filter((row): row is string[] => row != null)
Expand All @@ -61,7 +62,7 @@ export async function getCommandHtmlDoc(command: CommandModule<any, any>, {
for (const group of optionGroups) {
let groupName = group.name;
if (groupName !== "default") {
res += buildHtmlHeading("h3", htmlEscape(groupName), encodeURIComponent(groupName.toLowerCase()));
res += buildHtmlHeading("h3", htmlEscapeWithCodeMarkdown(groupName), encodeURIComponent(groupName.toLowerCase()));
}

res += renderOptionsGroupOptionsTable(group.options) + "\n";
Expand Down Expand Up @@ -207,7 +208,7 @@ function renderOptionsGroupOptionsTable(options: {name: string, option: Options}
}
}

let optionDescription: string[] = option.description != null ? [htmlEscape(option.description)] : [];
let optionDescription: string[] = option.description != null ? [htmlEscapeWithCodeMarkdown(option.description)] : [];

const hasDefaultDescription = option.defaultDescription != null && option.defaultDescription.trim().length > 0;
if (option.default != null || hasDefaultDescription) {
Expand All @@ -218,7 +219,7 @@ function renderOptionsGroupOptionsTable(options: {name: string, option: Options}
}

if (option.type != null) {
optionDescription.push(`<code><span style="opacity: 0.4">(</span>${htmlEscape(option.type)}<span style="opacity: 0.4">)</span></code>`);
optionDescription.push(`<code><span style="opacity: 0.4">(</span>${htmlEscape(option.type + (option.array ? "[]" : ""))}<span style="opacity: 0.4">)</span></code>`);
}

if (option.demandOption) {
Expand Down
26 changes: 26 additions & 0 deletions .vitepress/utils/htmlEscapeWithCodeMarkdown.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import {htmlEscape} from "./htmlEscape.js";

export function htmlEscapeWithCodeMarkdown(string?: string | number | boolean) {
const escapedString = htmlEscape(string);

let res = ""
let backtickIndex = escapedString.indexOf("`");
let textIndex = 0;

while (backtickIndex >= 0 && backtickIndex < escapedString.length - 1 && textIndex < escapedString.length) {
const nextBacktickIndex = escapedString.indexOf("`", backtickIndex + 1);
if (nextBacktickIndex < 0)
break;

res += escapedString.slice(textIndex, backtickIndex) + "<code>" + escapedString.slice(backtickIndex + 1, nextBacktickIndex) + "</code>";
textIndex = nextBacktickIndex + 1;

if (textIndex < escapedString.length)
backtickIndex = escapedString.indexOf("`", textIndex);
}

res += escapedString.slice(textIndex);

return res;
}

3 changes: 2 additions & 1 deletion docs/guide/cli/cli.data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {buildHtmlHeading} from "../../../.vitepress/utils/buildHtmlHeading.js";
import {buildHtmlTable} from "../../../.vitepress/utils/buildHtmlTable.js";
import {setIsInDocumentationMode} from "../../../src/state.js";
import {InspectMeasureCommand} from "../../../src/cli/commands/inspect/commands/InspectMeasureCommand.js";
import {htmlEscapeWithCodeMarkdown} from "../../../.vitepress/utils/htmlEscapeWithCodeMarkdown.js";

export default {
async load() {
Expand Down Expand Up @@ -71,7 +72,7 @@ function buildIndexTable(commands: [pageLink: string, command: CommandModule<any

return [
`<a href="${pageLink}"><code>` + htmlEscape(cliName + " " + command.command) + "</code></a>",
htmlEscape(String(command.describe ?? ""))
htmlEscapeWithCodeMarkdown(String(command.describe ?? ""))
];
})
.filter((row): row is string[] => row != null)
Expand Down
Loading