├── .gitignore ├── .vscodeignore ├── .vscode ├── extensions.json └── launch.json ├── jsconfig.json ├── CHANGELOG.md ├── src ├── extension.js └── translate.js ├── test ├── suite │ ├── extension.test.js │ └── index.js └── runTest.js ├── .eslintrc.json ├── README.md ├── package.json └── vsc-extension-quickstart.md /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .vscode-test/ 3 | *.vsix 4 | -------------------------------------------------------------------------------- /.vscodeignore: -------------------------------------------------------------------------------- 1 | .vscode/** 2 | .vscode-test/** 3 | test/** 4 | .gitignore 5 | .yarnrc 6 | vsc-extension-quickstart.md 7 | **/jsconfig.json 8 | **/*.map 9 | **/.eslintrc.json 10 | -------------------------------------------------------------------------------- /.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | // See https://go.microsoft.com/fwlink/?LinkId=733558 3 | // for the documentation about the extensions.json format 4 | "recommendations": [ 5 | "dbaeumer.vscode-eslint" 6 | ] 7 | } -------------------------------------------------------------------------------- /jsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonjs", 4 | "target": "ES2020", 5 | "checkJs": false, /* Typecheck .js files. */ 6 | "lib": [ 7 | "ES2020" 8 | ] 9 | }, 10 | "exclude": [ 11 | "node_modules" 12 | ] 13 | } 14 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to the "vscode-diagon" extension will be documented in this file. 4 | 5 | Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file. 6 | 7 | ## [0.0.1] 8 | 9 | - Initial release 10 | 11 | ## [0.0.2] 12 | 13 | - Fix: retrieve the active editor on every instance -------------------------------------------------------------------------------- /src/extension.js: -------------------------------------------------------------------------------- 1 | const vscode = require("vscode"); 2 | const translate = require("./translate"); 3 | 4 | async function activate(context) { 5 | let disposable = vscode.commands.registerCommand( 6 | "vscode-diagon.diagonTranslate", 7 | () => { 8 | translate(); 9 | } 10 | ); 11 | 12 | context.subscriptions.push(disposable); 13 | } 14 | 15 | 16 | module.exports = { 17 | activate, 18 | }; 19 | -------------------------------------------------------------------------------- /test/suite/extension.test.js: -------------------------------------------------------------------------------- 1 | const assert = require('assert'); 2 | 3 | // You can import and use all API from the 'vscode' module 4 | // as well as import your extension to test it 5 | const vscode = require('vscode'); 6 | // const myExtension = require('../extension'); 7 | 8 | suite('Extension Test Suite', () => { 9 | vscode.window.showInformationMessage('Start all tests.'); 10 | 11 | test('Sample test', () => { 12 | assert.strictEqual(-1, [1, 2, 3].indexOf(5)); 13 | assert.strictEqual(-1, [1, 2, 3].indexOf(0)); 14 | }); 15 | }); 16 | -------------------------------------------------------------------------------- /.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "browser": false, 4 | "commonjs": true, 5 | "es6": true, 6 | "node": true, 7 | "mocha": true 8 | }, 9 | "parserOptions": { 10 | "ecmaVersion": 2018, 11 | "ecmaFeatures": { 12 | "jsx": true 13 | }, 14 | "sourceType": "module" 15 | }, 16 | "rules": { 17 | "no-const-assign": "warn", 18 | "no-this-before-super": "warn", 19 | "no-undef": "warn", 20 | "no-unreachable": "warn", 21 | "no-unused-vars": "warn", 22 | "constructor-super": "warn", 23 | "valid-typeof": "warn" 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /test/runTest.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | 3 | const { runTests } = require('@vscode/test-electron'); 4 | 5 | async function main() { 6 | try { 7 | // The folder containing the Extension Manifest package.json 8 | // Passed to `--extensionDevelopmentPath` 9 | const extensionDevelopmentPath = path.resolve(__dirname, '../'); 10 | 11 | // The path to the extension test script 12 | // Passed to --extensionTestsPath 13 | const extensionTestsPath = path.resolve(__dirname, './suite/index'); 14 | 15 | // Download VS Code, unzip it and run the integration test 16 | await runTests({ extensionDevelopmentPath, extensionTestsPath }); 17 | } catch (err) { 18 | console.error('Failed to run tests'); 19 | process.exit(1); 20 | } 21 | } 22 | 23 | main(); 24 | -------------------------------------------------------------------------------- /src/translate.js: -------------------------------------------------------------------------------- 1 | const diagon = require("@elmouradiamine/diagon"); 2 | const vscode = require("vscode"); 3 | 4 | async function translate() { 5 | const editor = vscode.window.activeTextEditor; 6 | const text = editor.document.getText(editor.selection); 7 | 8 | const options = [ 9 | "Math", 10 | "Sequence", 11 | "Tree", 12 | "Table", 13 | "Grammar", 14 | "GraphDAG", 15 | "GraphPlanar", 16 | "Flowchart", 17 | ]; 18 | 19 | const translator = await vscode.window.showQuickPick(options, { 20 | canPickMany: false, 21 | }); 22 | 23 | if (translator) { 24 | const translation = await diagon.translate(translator, text.trim()); 25 | editor.edit((text) => text.replace(editor.selection, translation)); 26 | } 27 | } 28 | 29 | module.exports = translate; 30 | -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | // A launch configuration that launches the extension inside a new window 2 | // Use IntelliSense to learn about possible attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | { 6 | "version": "0.2.0", 7 | "configurations": [ 8 | { 9 | "name": "Run Extension", 10 | "type": "extensionHost", 11 | "request": "launch", 12 | "args": [ 13 | "--extensionDevelopmentPath=${workspaceFolder}" 14 | ] 15 | }, 16 | { 17 | "name": "Extension Tests", 18 | "type": "extensionHost", 19 | "request": "launch", 20 | "args": [ 21 | "--extensionDevelopmentPath=${workspaceFolder}", 22 | "--extensionTestsPath=${workspaceFolder}/test/suite/index" 23 | ] 24 | } 25 | ] 26 | } 27 | -------------------------------------------------------------------------------- /test/suite/index.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | const Mocha = require('mocha'); 3 | const glob = require('glob'); 4 | 5 | function run() { 6 | // Create the mocha test 7 | const mocha = new Mocha({ 8 | ui: 'tdd', 9 | color: true 10 | }); 11 | 12 | const testsRoot = path.resolve(__dirname, '..'); 13 | 14 | return new Promise((c, e) => { 15 | glob('**/**.test.js', { cwd: testsRoot }, (err, files) => { 16 | if (err) { 17 | return e(err); 18 | } 19 | 20 | // Add files to the test suite 21 | files.forEach(f => mocha.addFile(path.resolve(testsRoot, f))); 22 | 23 | try { 24 | // Run the mocha test 25 | mocha.run(failures => { 26 | if (failures > 0) { 27 | e(new Error(`${failures} tests failed.`)); 28 | } else { 29 | c(); 30 | } 31 | }); 32 | } catch (err) { 33 | console.error(err); 34 | e(err); 35 | } 36 | }); 37 | }); 38 | } 39 | 40 | module.exports = { 41 | run 42 | }; 43 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # vscode-diagon 2 | 3 | Level up your commenting skills with Diagon. It will allow you to transform markdown style expressions into an ascii-art representation. 4 | 5 | ![screencast](https://i.imgur.com/ZmdLGrL.gif) 6 | 7 | ## Extension Settings 8 | 9 | This extension contributes the following settings: 10 | 11 | * `vscode-diagon.diagonTranslate`: transforms selected text using diagon translator. 12 | 13 | ## Known Issues 14 | 15 | Please if there are any bugs feel free to open issues on the [github repository](https://github.com/elmouradiamine/vscode-diagon). 16 | 17 | ## Release Notes 18 | 19 | ### 0.0.1 20 | 21 | Initial release of vscode-diagon. 22 | 23 | ### 0.0.2 24 | 25 | Bug fix extension 26 | 27 | 28 | ## Credits 29 | This project wouldn't have been possible without the work of @ArthurSonzogni on `Diagon` project. 30 | 31 | ### For more information 32 | 33 | * [Diagon](https://github.com/ArthurSonzogni/Diagon) 34 | * [vscode-diagon](https://github.com/elmouradiamine/vscode-diagon) 35 | * [Visual Studio Code's Markdown Support](http://code.visualstudio.com/docs/languages/markdown) 36 | * [Markdown Syntax Reference](https://help.github.com/articles/markdown-basics/) 37 | 38 | **Enjoy!** 39 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vscode-diagon", 3 | "displayName": "vscode-diagon", 4 | "description": "", 5 | "version": "0.0.3", 6 | "author": "Amine Elmouradi", 7 | "publisher": "elmouradiamine", 8 | "engines": { 9 | "vscode": "^1.61.0" 10 | }, 11 | "repository": "https://github.com/ElmouradiAmine/vscode-diagon", 12 | "categories": [ 13 | "Other" 14 | ], 15 | "activationEvents": [ 16 | "onCommand:vscode-diagon.diagonTranslate" 17 | ], 18 | "main": "./src/extension.js", 19 | "contributes": { 20 | "commands": [ 21 | { 22 | "command": "vscode-diagon.diagonTranslate", 23 | "title": "Diagon Translate" 24 | } 25 | ], 26 | "menus": { 27 | "editor/context": [ 28 | { 29 | "command": "vscode-diagon.diagonTranslate", 30 | "group": "YourGroup@1" 31 | } 32 | ] 33 | } 34 | }, 35 | "scripts": { 36 | "lint": "eslint .", 37 | "pretest": "npm run lint", 38 | "test": "node ./test/runTest.js" 39 | }, 40 | "devDependencies": { 41 | "@types/glob": "^7.1.4", 42 | "@types/mocha": "^9.0.0", 43 | "@types/node": "14.x", 44 | "@types/vscode": "^1.61.0", 45 | "@vscode/test-electron": "^1.6.2", 46 | "eslint": "^7.32.0", 47 | "glob": "^7.1.7", 48 | "mocha": "^9.1.1", 49 | "typescript": "^4.4.3" 50 | }, 51 | "dependencies": { 52 | "@elmouradiamine/diagon": "^1.0.0" 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /vsc-extension-quickstart.md: -------------------------------------------------------------------------------- 1 | # Welcome to your VS Code Extension 2 | 3 | ## What's in the folder 4 | 5 | * This folder contains all of the files necessary for your extension. 6 | * `package.json` - this is the manifest file in which you declare your extension and command. 7 | * The sample plugin registers a command and defines its title and command name. With this information VS Code can show the command in the command palette. It doesn’t yet need to load the plugin. 8 | * `extension.js` - this is the main file where you will provide the implementation of your command. 9 | * The file exports one function, `activate`, which is called the very first time your extension is activated (in this case by executing the command). Inside the `activate` function we call `registerCommand`. 10 | * We pass the function containing the implementation of the command as the second parameter to `registerCommand`. 11 | 12 | ## Get up and running straight away 13 | 14 | * Press `F5` to open a new window with your extension loaded. 15 | * Run your command from the command palette by pressing (`Ctrl+Shift+P` or `Cmd+Shift+P` on Mac) and typing `Hello World`. 16 | * Set breakpoints in your code inside `extension.js` to debug your extension. 17 | * Find output from your extension in the debug console. 18 | 19 | ## Make changes 20 | 21 | * You can relaunch the extension from the debug toolbar after changing code in `extension.js`. 22 | * You can also reload (`Ctrl+R` or `Cmd+R` on Mac) the VS Code window with your extension to load your changes. 23 | 24 | ## Explore the API 25 | 26 | * You can open the full set of our API when you open the file `node_modules/@types/vscode/index.d.ts`. 27 | 28 | ## Run tests 29 | 30 | * Open the debug viewlet (`Ctrl+Shift+D` or `Cmd+Shift+D` on Mac) and from the launch configuration dropdown pick `Extension Tests`. 31 | * Press `F5` to run the tests in a new window with your extension loaded. 32 | * See the output of the test result in the debug console. 33 | * Make changes to `src/test/suite/extension.test.js` or create new test files inside the `test/suite` folder. 34 | * The provided test runner will only consider files matching the name pattern `**.test.ts`. 35 | * You can create folders inside the `test` folder to structure your tests any way you want. 36 | ## Go further 37 | 38 | * [Publish your extension](https://code.visualstudio.com/api/working-with-extensions/publishing-extension) on the VSCode extension marketplace. 39 | * Automate builds by setting up [Continuous Integration](https://code.visualstudio.com/api/working-with-extensions/continuous-integration). 40 | --------------------------------------------------------------------------------