From 29e375778322232e11f2c7763dde449c10e1a82e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Collonval?= Date: Wed, 6 Sep 2023 17:37:41 +0200 Subject: [PATCH] Add doc and lint --- package.json | 310 ++++++++++++++++++------------------ packages/lab/src/preview.ts | 24 +++ packages/lab/src/tokens.ts | 15 +- 3 files changed, 192 insertions(+), 157 deletions(-) diff --git a/package.json b/package.json index 81d288c..275daf5 100644 --- a/package.json +++ b/package.json @@ -1,165 +1,165 @@ { - "name": "jupyterlab-rise-meta", - "version": "0.40.0", - "description": "RISE: \"Live\" Reveal.js JupyterLab Slideshow extension.", - "keywords": [ - "jupyter", - "jupyterlab", - "jupyterlab-extension" - ], - "private": true, - "files": [], - "workspaces": { - "packages": [ - "app", - "ui-tests", - "packages/*" - ] - }, - "homepage": "https://github.com/jupyterlab-contrib/rise", - "bugs": { - "url": "https://github.com/jupyterlab-contrib/rise/issues" - }, - "license": "BSD-3-Clause", - "author": { - "name": "Frederic Collonval", - "email": "fcollonval@gmail.com" - }, - "contributors": [ - { - "name": "Thierry Parmentelat", - "url": "https://github.com/parmentelat" - }, - { - "name": "Yiqin Zhang" - } - ], - "repository": { - "type": "git", - "url": "https://github.com/jupyterlab-contrib/rise.git" - }, - "scripts": { - "build": "lerna run build", - "build:prod": "lerna run build:prod", - "clean": "lerna run clean", - "eslint": "jlpm eslint:check --fix", - "eslint:check": "eslint . --cache --ext .ts,.tsx", - "lint": "jlpm stylelint && jlpm prettier && jlpm eslint", - "lint:check": "jlpm stylelint:check && jlpm prettier:check && jlpm eslint:check", - "prettier": "jlpm prettier:base --write --list-different", - "prettier:base": "prettier \"**/*{.ts,.tsx,.js,.jsx,.css,.json,.md}\"", - "prettier:check": "jlpm prettier:base --check", - "stylelint": "jlpm stylelint:check --fix", - "stylelint:check": "stylelint --cache \"packages/*/style/**/*.css\"", - "watch": "run-p watch:lib watch:app", - "watch:app": "lerna exec --stream --scope \"rise-app\" yarn watch", - "watch:lib": "lerna exec --stream --scope \"jupyterlab-rise-application\" --scope \"jupyterlab-rise\" yarn watch" - }, - "devDependencies": { - "@typescript-eslint/eslint-plugin": "^6.1.0", - "@typescript-eslint/parser": "^6.1.0", - "eslint": "^8.45.0", - "eslint-config-prettier": "^8.8.0", - "eslint-plugin-prettier": "^5.0.0", - "lerna": "^7.1.0", - "npm-run-all": "^4.1.5", - "prettier": "^3.0.0", - "rimraf": "^5.0.0", - "stylelint": "^15.10.1", - "stylelint-config-recommended": "^13.0.0", - "stylelint-config-standard": "^34.0.0", - "stylelint-prettier": "^4.0.0", - "typescript": "~5.0.4" - }, - "eslintIgnore": [ - "app/build", - "node_modules", - "dist", - "coverage", - "**/*.d.ts", - "tests", - "**/__tests__", - "ui-tests" - ], - "eslintConfig": { - "extends": [ - "eslint:recommended", - "plugin:@typescript-eslint/eslint-recommended", - "plugin:@typescript-eslint/recommended", - "plugin:prettier/recommended" + "name": "jupyterlab-rise-meta", + "version": "0.40.0", + "description": "RISE: \"Live\" Reveal.js JupyterLab Slideshow extension.", + "keywords": [ + "jupyter", + "jupyterlab", + "jupyterlab-extension" ], - "parser": "@typescript-eslint/parser", - "parserOptions": { - "project": "tsconfig.eslint.json", - "sourceType": "module" + "private": true, + "files": [], + "workspaces": { + "packages": [ + "app", + "ui-tests", + "packages/*" + ] }, - "plugins": [ - "@typescript-eslint" - ], - "rules": { - "@typescript-eslint/naming-convention": [ - "error", + "homepage": "https://github.com/jupyterlab-contrib/rise", + "bugs": { + "url": "https://github.com/jupyterlab-contrib/rise/issues" + }, + "license": "BSD-3-Clause", + "author": { + "name": "Frederic Collonval", + "email": "fcollonval@gmail.com" + }, + "contributors": [ { - "selector": "interface", - "format": [ - "PascalCase" - ], - "custom": { - "regex": "^I[A-Z]", - "match": true - } - } - ], - "@typescript-eslint/no-unused-vars": [ - "warn", + "name": "Thierry Parmentelat", + "url": "https://github.com/parmentelat" + }, { - "args": "none" + "name": "Yiqin Zhang" } - ], - "@typescript-eslint/no-explicit-any": "off", - "@typescript-eslint/no-namespace": "off", - "@typescript-eslint/no-use-before-define": "off", - "@typescript-eslint/quotes": [ - "error", - "single", - { - "avoidEscape": true, - "allowTemplateLiterals": false + ], + "repository": { + "type": "git", + "url": "https://github.com/jupyterlab-contrib/rise.git" + }, + "scripts": { + "build": "lerna run build", + "build:prod": "lerna run build:prod", + "clean": "lerna run clean", + "eslint": "jlpm eslint:check --fix", + "eslint:check": "eslint . --cache --ext .ts,.tsx", + "lint": "jlpm stylelint && jlpm prettier && jlpm eslint", + "lint:check": "jlpm stylelint:check && jlpm prettier:check && jlpm eslint:check", + "prettier": "jlpm prettier:base --write --list-different", + "prettier:base": "prettier \"**/*{.ts,.tsx,.js,.jsx,.css,.json,.md}\"", + "prettier:check": "jlpm prettier:base --check", + "stylelint": "jlpm stylelint:check --fix", + "stylelint:check": "stylelint --cache \"packages/*/style/**/*.css\"", + "watch": "run-p watch:lib watch:app", + "watch:app": "lerna exec --stream --scope \"rise-app\" yarn watch", + "watch:lib": "lerna exec --stream --scope \"jupyterlab-rise-application\" --scope \"jupyterlab-rise\" yarn watch" + }, + "devDependencies": { + "@typescript-eslint/eslint-plugin": "^6.1.0", + "@typescript-eslint/parser": "^6.1.0", + "eslint": "^8.45.0", + "eslint-config-prettier": "^8.8.0", + "eslint-plugin-prettier": "^5.0.0", + "lerna": "^7.1.0", + "npm-run-all": "^4.1.5", + "prettier": "^3.0.0", + "rimraf": "^5.0.0", + "stylelint": "^15.10.1", + "stylelint-config-recommended": "^13.0.0", + "stylelint-config-standard": "^34.0.0", + "stylelint-prettier": "^4.0.0", + "typescript": "~5.0.4" + }, + "eslintIgnore": [ + "app/build", + "node_modules", + "dist", + "coverage", + "**/*.d.ts", + "tests", + "**/__tests__", + "ui-tests" + ], + "eslintConfig": { + "extends": [ + "eslint:recommended", + "plugin:@typescript-eslint/eslint-recommended", + "plugin:@typescript-eslint/recommended", + "plugin:prettier/recommended" + ], + "parser": "@typescript-eslint/parser", + "parserOptions": { + "project": "tsconfig.eslint.json", + "sourceType": "module" + }, + "plugins": [ + "@typescript-eslint" + ], + "rules": { + "@typescript-eslint/naming-convention": [ + "error", + { + "selector": "interface", + "format": [ + "PascalCase" + ], + "custom": { + "regex": "^I[A-Z]", + "match": true + } + } + ], + "@typescript-eslint/no-unused-vars": [ + "warn", + { + "args": "none" + } + ], + "@typescript-eslint/no-explicit-any": "off", + "@typescript-eslint/no-namespace": "off", + "@typescript-eslint/no-use-before-define": "off", + "@typescript-eslint/quotes": [ + "error", + "single", + { + "avoidEscape": true, + "allowTemplateLiterals": false + } + ], + "curly": [ + "error", + "all" + ], + "eqeqeq": "error", + "prefer-arrow-callback": "error" } - ], - "curly": [ - "error", - "all" - ], - "eqeqeq": "error", - "prefer-arrow-callback": "error" - } - }, - "prettier": { - "singleQuote": true, - "trailingComma": "none", - "arrowParens": "avoid", - "endOfLine": "auto", - "overrides": [ - { - "files": "package.json", - "options": { - "tabWidth": 4 + }, + "prettier": { + "singleQuote": true, + "trailingComma": "none", + "arrowParens": "avoid", + "endOfLine": "auto", + "overrides": [ + { + "files": "package.json", + "options": { + "tabWidth": 4 + } + } + ] + }, + "stylelint": { + "extends": [ + "stylelint-config-recommended", + "stylelint-config-standard", + "stylelint-prettier/recommended" + ], + "rules": { + "property-no-vendor-prefix": null, + "selector-class-pattern": null, + "selector-no-vendor-prefix": null, + "value-no-vendor-prefix": null } - } - ] - }, - "stylelint": { - "extends": [ - "stylelint-config-recommended", - "stylelint-config-standard", - "stylelint-prettier/recommended" - ], - "rules": { - "property-no-vendor-prefix": null, - "selector-class-pattern": null, - "selector-no-vendor-prefix": null, - "value-no-vendor-prefix": null } - } } diff --git a/packages/lab/src/preview.ts b/packages/lab/src/preview.ts index f7f8d73..a32898f 100644 --- a/packages/lab/src/preview.ts +++ b/packages/lab/src/preview.ts @@ -239,6 +239,13 @@ export namespace RisePreview { renderOnSave?: boolean; } + /** + * Generate the URL required to open a file as RISE slideshow. + * + * @param path File path + * @param activeCellIndex Active cell index + * @returns URL to open + */ export function getRiseUrl(path: string, activeCellIndex?: number): string { const baseUrl = PageConfig.getBaseUrl(); let url = `${baseUrl}rise/${path}`; @@ -248,6 +255,9 @@ export namespace RisePreview { return url; } + /** + * RISE Preview document factory token implementation. + */ export class FactoryToken implements IRisePreviewFactory { constructor(options: { commands: CommandRegistry; @@ -262,6 +272,14 @@ export namespace RisePreview { this._updateFactory(); } + /** + * Add a new file type to the RISE preview factory. + * + * #### Notes + * Useful to add file types for jupytext. + * + * @param ft File type + */ addFileType(ft: string): void { if (!this._fileTypes.includes(ft)) { this._fileTypes.push(ft); @@ -269,6 +287,9 @@ export namespace RisePreview { } } + /** + * Signal emitted when a RISE preview is created. + */ get widgetCreated(): ISignal { return this._widgetCreated; } @@ -303,6 +324,9 @@ export namespace RisePreview { } } +/** + * RISE Preview widget factory + */ export class RisePreviewFactory extends ABCWidgetFactory< RisePreview, INotebookModel diff --git a/packages/lab/src/tokens.ts b/packages/lab/src/tokens.ts index 033e7d4..08b58ac 100644 --- a/packages/lab/src/tokens.ts +++ b/packages/lab/src/tokens.ts @@ -18,15 +18,26 @@ export const IRisePreviewTracker = new Token( ); /** - * + * RISE Preview document factory interface */ export interface IRisePreviewFactory { + /** + * Signal emitted when a RISE preview is created. + */ readonly widgetCreated: ISignal; + /** + * Add a new file type to the RISE preview factory. + * + * #### Notes + * Useful to add file types for jupytext. + * + * @param ft File type + */ addFileType(ft: string): void; } /** - * + * RISE Preview factory token. */ export const IRisePreviewFactory = new Token( 'jupyterlab-rise:IRisePreviewFactory',