This commit is contained in:
CismonX 2020-10-11 01:36:05 +08:00
parent 43a3154398
commit 67d743b77a
Signed by: cismonx
GPG Key ID: 3094873E29A482FB
9 changed files with 58 additions and 59 deletions

View File

@ -1,14 +0,0 @@
{
"root": true,
"parser": "@typescript-eslint/parser",
"plugins": [
"@typescript-eslint"
],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended"
],
"rules": {
"@typescript-eslint/explicit-module-boundary-types": "off"
}
}

View File

@ -4,7 +4,7 @@ out/test/**
src/**
.gitignore
.yarnrc
.travis.yml
**/tsconfig.json
**/.eslintrc.json
**/*.map
**/*.ts

47
package-lock.json generated
View File

@ -61,12 +61,6 @@
"strip-json-comments": "^3.1.1"
}
},
"@types/color-name": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/@types/color-name/-/color-name-1.1.1.tgz",
"integrity": "sha512-rr+OQyAjxze7GgWrSaJwydHStIhHq2lvY3BOC2Mj7KnzI7XK0Uw1TOOdI9lDoajEbSWLiYgoo4f1R51erQfhPQ==",
"dev": true
},
"@types/eslint-visitor-keys": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/@types/eslint-visitor-keys/-/eslint-visitor-keys-1.0.0.tgz",
@ -80,15 +74,15 @@
"dev": true
},
"@types/node": {
"version": "14.11.5",
"resolved": "https://registry.npmjs.org/@types/node/-/node-14.11.5.tgz",
"integrity": "sha512-jVFzDV6NTbrLMxm4xDSIW/gKnk8rQLF9wAzLWIOg+5nU6ACrIMndeBdXci0FGtqJbP9tQvm6V39eshc96TO2wQ==",
"version": "14.11.8",
"resolved": "https://registry.npmjs.org/@types/node/-/node-14.11.8.tgz",
"integrity": "sha512-KPcKqKm5UKDkaYPTuXSx8wEP7vE9GnuaXIZKijwRYcePpZFDVuy2a57LarFKiORbHOuTOOwYzxVxcUzsh2P2Pw==",
"dev": true
},
"@types/vscode": {
"version": "1.49.0",
"resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.49.0.tgz",
"integrity": "sha512-wfNQmLmm1VdMBr6iuNdprWmC1YdrgZ9dQzadv+l2eSjJlElOdJw8OTm4RU4oGTBcfvG6RZI2jOcppkdSS18mZw==",
"version": "1.50.0",
"resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.50.0.tgz",
"integrity": "sha512-QnIeyi4L2DiD9M2bAQKRzT/EQvc80qP9UL6JD5TiLlNRL1khIDg4ej4mDSRbtFrDAsRntFI1RhMvdomUThMsqg==",
"dev": true
},
"@typescript-eslint/eslint-plugin": {
@ -163,9 +157,9 @@
}
},
"acorn": {
"version": "7.4.0",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-7.4.0.tgz",
"integrity": "sha512-+G7P8jJmCHr+S+cLfQxygbWhXy+8YTVGzAkpEbcLo2mLoL7tij/VG41QSHACSf5QgYRhMZYHuNc6drJaO0Da+w==",
"version": "7.4.1",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-7.4.1.tgz",
"integrity": "sha512-nQyp0o1/mNdbTO1PO6kHkwSrmgZ0MT/jCCpNiwbUjGoRN4dlBhqJtoQuCnEOKzgTVwg0ZWiCoQy6SxMebQVh8A==",
"dev": true
},
"acorn-jsx": {
@ -255,12 +249,11 @@
},
"dependencies": {
"ansi-styles": {
"version": "4.2.1",
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.2.1.tgz",
"integrity": "sha512-9VGjrMsG1vePxcSweQsN20KY/c4zN0h9fLjqAbwbPfahM3t+NL+M9HC8xeXG2I8pX5NoamTGNuomEUFI7fcUjA==",
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz",
"integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
"dev": true,
"requires": {
"@types/color-name": "^1.1.1",
"color-convert": "^2.0.1"
}
},
@ -410,9 +403,9 @@
"dev": true
},
"eslint": {
"version": "7.10.0",
"resolved": "https://registry.npmjs.org/eslint/-/eslint-7.10.0.tgz",
"integrity": "sha512-BDVffmqWl7JJXqCjAK6lWtcQThZB/aP1HXSH1JKwGwv0LQEdvpR7qzNrUT487RM39B5goWuboFad5ovMBmD8yA==",
"version": "7.11.0",
"resolved": "https://registry.npmjs.org/eslint/-/eslint-7.11.0.tgz",
"integrity": "sha512-G9+qtYVCHaDi1ZuWzBsOWo2wSwd70TXnU6UHA3cTYHp7gCTXZcpggWFoUVAMRarg68qtPoNfFbzPh+VdOgmwmw==",
"dev": true,
"requires": {
"@babel/code-frame": "^7.0.0",
@ -425,7 +418,7 @@
"enquirer": "^2.3.5",
"eslint-scope": "^5.1.1",
"eslint-utils": "^2.1.0",
"eslint-visitor-keys": "^1.3.0",
"eslint-visitor-keys": "^2.0.0",
"espree": "^7.3.0",
"esquery": "^1.2.0",
"esutils": "^2.0.2",
@ -452,6 +445,14 @@
"table": "^5.2.3",
"text-table": "^0.2.0",
"v8-compile-cache": "^2.0.3"
},
"dependencies": {
"eslint-visitor-keys": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-2.0.0.tgz",
"integrity": "sha512-QudtT6av5WXels9WjIM7qz1XD1cWGvX4gGXvp/zBn9nXG02D0utdU3Em2m/QjTnrsk6bBjmCygl3rmj118msQQ==",
"dev": true
}
}
},
"eslint-scope": {

View File

@ -15,12 +15,12 @@
},
"icon": "assets/texinfo.png",
"devDependencies": {
"@types/node": "^14.11.5",
"@types/vscode": "^1.49.0",
"@types/node": "^14.11.8",
"@types/vscode": "^1.50.0",
"@typescript-eslint/eslint-plugin": "^3.8.0",
"@typescript-eslint/parser": "^3.8.0",
"cson": "^7.20.0",
"eslint": "^7.10.0",
"eslint": "^7.11.0",
"language-texinfo": "^1.0.0",
"typescript": "^4.0.3"
},
@ -35,8 +35,24 @@
"lint": "eslint --ext ts --fix src",
"watch": "tsc -watch -p ./"
},
"eslintConfig": {
"root": true,
"parser": "@typescript-eslint/parser",
"plugins": [
"@typescript-eslint"
],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended"
],
"rules": {
"comma-dangle": ["warn", "always-multiline"],
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/semi": "warn"
}
},
"engines": {
"vscode": "^1.49.0"
"vscode": "^1.40.0"
},
"categories": [
"Programming Languages",

View File

@ -14,14 +14,13 @@ export class CompletionItemProvider implements vscode.CompletionItemProvider {
private readonly completionItems = [
command('c', 'Line comment'),
snippet('header', 'c', 'Declare header block', 1,
'@c %**start of header\n\n@c %**end of header',
snippet('header', 'c', 'Declare header block', 1, '@c %**start of header\n\n@c %**end of header',
'c %**${1:start of header}\n$2\n@c %**${3:end of header}'),
command('setfilename', 'Set output file name'),
command('settitle', 'Set document title'),
command('copying', 'Declare copying permissions', { sortOrder: 1 }),
blockSnippet('copying', 'Declare copying permissions'),
command('copyright', 'The \'©\' symbol', { hasEmptyArguments: true }),
command('copyright', 'The "©" symbol', { hasEmptyArguments: true }),
command('insertcopying', 'Include permissions text'),
command('titlepage', 'Declare title page', { sortOrder: 1 }),
blockSnippet('titlepage', 'Declare title page'),
@ -76,10 +75,10 @@ function command(name: string, detail: string, extraArgs?: {
label: '@' + name,
kind: vscode.CompletionItemKind.Function,
detail: detail,
sortText: name + extraArgs?.sortOrder?.toString() ?? '',
sortText: name + (extraArgs?.sortOrder?.toString() ?? ''),
filterText: name,
insertText: name + extraArgs?.hasEmptyArguments ? '{}' : '',
}
insertText: name + (extraArgs?.hasEmptyArguments ? '{}' : ''),
};
}
function blockSnippet(name: string, detail: string): vscode.CompletionItem {
@ -112,7 +111,7 @@ function snippet(
sortText: keyword + sortOrder.toString(),
filterText: keyword,
insertText: new vscode.SnippetString(insertText),
}
};
}
/**
@ -121,5 +120,5 @@ function snippet(
* @param snippet The snippet code
*/
function snippetDocumentation(snippet: string) {
return new vscode.MarkdownString(`\`\`\`texinfo\n${snippet}\n\`\`\``);
return new vscode.MarkdownString('```texinfo\n' + snippet + '\n```');
}

View File

@ -17,7 +17,7 @@ export class Converter {
* Convert a Texinfo document to HTML.
*
* @param path Path to the Texinfo document.
* @yields HTML code, or `undefined` if conversion fails.
* @returns HTML code, or `undefined` if conversion fails.
*/
static async convertToHtml(path: string) {
return await new Converter().convert(path);

View File

@ -17,10 +17,7 @@ let options: Options | undefined;
export class Options {
private static get instance() {
if (options === undefined) {
options = new Options('texinfo');
}
return options;
return options ?? (options = new Options('texinfo'));
}
static clear() {

View File

@ -14,7 +14,7 @@ import * as vscode from 'vscode';
*
* @param message The message to be displayed on the prompt.
* @param confirm Text to be displayed on the "Confirm" button.
* @yields Whether the user clicked the "Confirm" button.
* @returns Whether the user clicked the "Confirm" button.
*/
export async function prompt(message: string, confirm: string) {
return confirm === await vscode.window.showInformationMessage(message, confirm, 'Cancel');
@ -26,7 +26,7 @@ export async function prompt(message: string, confirm: string) {
* @param path Path to the executable file.
* @param args Arguments to be passed to the command.
* @param maxBuffer Max output buffer size.
* @yields The output data, or `undefined` if execution fails.
* @returns The output data, or `undefined` if execution fails.
*/
export function exec(path: string, args: string[], maxBuffer: number) {
return new Promise<string | undefined>((resolve) => {
@ -55,7 +55,7 @@ export function transformHtmlImageUri(htmlCode: string, transformer: (src: strin
elements.forEach((element) => {
const src = element.getAttribute('src');
src && element.setAttribute('src', transformer(src));
})
});
// If nothing is transformed, return the original HTML code, for better performance.
return elements.length === 0 ? htmlCode : dom.outerHTML;
}

View File

@ -1,6 +1,6 @@
{
"compilerOptions": {
"module": "commonjs",
"module": "CommonJS",
"target": "ES2019",
"outDir": "out",
"lib": [