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
4 changes: 2 additions & 2 deletions .scripts/gen-function/gen-function.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import { DOCS_OVERRIDES } from "./override.ts";
import { transform } from "./transform.ts";
import { downloadString } from "../utils.ts";

const VIM_VERSION = "9.1.0399";
const NVIM_VERSION = "0.9.5";
const VIM_VERSION = "9.1.0448";
const NVIM_VERSION = "0.10.0";

const commonGenerateModule = "../../function/_generated.ts";
const vimGenerateModule = "../../function/vim/_generated.ts";
Expand Down
5 changes: 4 additions & 1 deletion .scripts/gen-function/parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,11 @@ export function parse(content: string): Definition[] {
} else {
const line = content.substring(0, start + 1).split("\n").length;
console.error(
`Failed to parse function definition for ${fn} at line ${line}`,
`Failed to parse function definition for '${fn}' at line ${line}:`,
);
console.error("----- block start -----");
console.error(block);
console.error("----- block end -----");
}
}
return definitions;
Expand Down
8 changes: 4 additions & 4 deletions .scripts/gen-option/gen-option.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import { DOCS_OVERRIDES } from "./override.ts";
import { transform } from "./transform.ts";
import { downloadString } from "../utils.ts";

const VIM_VERSION = "9.1.0399";
const NVIM_VERSION = "0.9.5";
const VIM_VERSION = "9.1.0448";
const NVIM_VERSION = "0.10.0";

const commonGenerateModule = "../../option/_generated.ts";
const vimGenerateModule = "../../option/vim/_generated.ts";
Expand Down Expand Up @@ -36,7 +36,7 @@ for (const vimHelpDownloadUrl of vimHelpDownloadUrls) {
console.log(`Download from ${vimHelpDownloadUrl}`);
}
const vimHelps = await Promise.all(vimHelpDownloadUrls.map(downloadString));
const vimDefs = vimHelps.map(parse).flat();
const vimDefs = parse(vimHelps.join("\n"));
const vimOptionSet = new Set(vimDefs.map((def) => def.name)).difference(
manualOptionSet,
);
Expand All @@ -48,7 +48,7 @@ for (const nvimHelpDownloadUrl of nvimHelpDownloadUrls) {
console.log(`Download from ${nvimHelpDownloadUrl}`);
}
const nvimHelps = await Promise.all(nvimHelpDownloadUrls.map(downloadString));
const nvimDefs = nvimHelps.map(parse).flat();
const nvimDefs = parse(nvimHelps.join("\n"));
const nvimOptionSet = new Set(nvimDefs.map((def) => def.name)).difference(
manualOptionSet,
);
Expand Down
14 changes: 9 additions & 5 deletions .scripts/gen-option/parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export function parse(content: string) {

const options: Option[] = [];
const succeeds = new Set<number>();
const errors: Array<{ name: string; start: number }> = [];
const errors: Array<{ name: string; start: number; block: string }> = [];
let last = -1;
for (const match of content.matchAll(/\*'(\w+)'\*/g)) {
const name = match[1];
Expand All @@ -45,17 +45,20 @@ export function parse(content: string) {
succeeds.add(start);
last = end;
} else {
errors.push({ name, start });
errors.push({ name, start, block });
}
}

if (errors.length) {
for (const { name, start } of errors) {
for (const { name, start, block } of errors) {
if (!succeeds.has(start)) {
const line = content.substring(0, start + 1).split("\n").length;
console.error(
`Failed to parse option definition for ${name} at line ${line}`,
`Failed to parse option definition for '${name}' at line ${line}:`,
);
console.error("----- block start -----");
console.error(block);
console.error("----- block end -----");
}
}
}
Expand Down Expand Up @@ -107,7 +110,8 @@ function parseBlock(name: string, body: string): Option | undefined {
const reTags = /(?:[ \t]+\*[^*\s]+\*)+[ \t]*$/.source;
const reShortNames = /(?:[ \t]+'\w+')*/.source;
const reType = /[ \t]+(?<type>\w+)/.source;
const reDefaults = /[ \t]+(?<defaults>\(.*?(?:\n\t{3,}[ \t].*?)*?\))/.source;
const reDefaults =
/[ \t]+(?<defaults>\(.*?(?:\n(?:\t{3,}| {24,})[ \t].*?)*?\))/.source;
const reDefinition =
`^'${name}'${reShortNames}(?:${reType}(?:${reDefaults})?)?(?:${reTags})?$`;
const m1 = body.match(new RegExp(reDefinition, "dm"));
Expand Down
4 changes: 2 additions & 2 deletions .scripts/markdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ export function createMarkdownFromHelp(body: string): string {
const codeBlockIndent = " ";
let lastIndent = firstlineIndent;
body = body.replaceAll(
/(?<normal>.*?)[\n ]>\n(?<code>.*?)(?:\n(?=<)|$)|(?<rest>.*)/gs,
(_, normal: string, code: string, rest: string) => {
/(?<normal>.*?)[\n ]>(?<ft>\w*)\n(?<code>.*?)(?:\n(?=<)|$)|(?<rest>.*)/gs,
(_, normal: string, _ft: string, code: string, rest: string) => {
if (rest !== undefined) {
return formatNormalBlock(rest);
}
Expand Down
2 changes: 1 addition & 1 deletion .scripts/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import * as streams from "@std/streams";
*/
export async function downloadString(url: string): Promise<string> {
const response = await fetch(url);
if (!response.body) {
if (response.status >= 400 || !response.body) {
throw new Error(`Failed to read ${url}`);
}
//const reader = streams.readerFromStreamReader(response.body.getReader());
Expand Down
Loading