- Notifications
You must be signed in to change notification settings - Fork737
markdown checker#226
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Draft
oyilmaztekin wants to merge36 commits intotc39:mainChoose a base branch fromoyilmaztekin:ozer-check-markdown
base:main
Could not load branches
Branch not found:{{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline, and old review comments may become outdated.
Uh oh!
There was an error while loading.Please reload this page.
Draft
markdown checker#226
Changes fromall commits
Commits
Show all changes
36 commits Select commitHold shift + click to select a range
e3d07a9 added source code reader
527c524 moved package into the tools folder
5cf1533 downgraded version from 1 to 0
1f6afca Update tablerow object dot notation
oyilmaztekinde265d5 update private property
oyilmaztekincde54af Update Object dot notation
oyilmaztekinb01b4a5 Update test description
oyilmaztekinade9c4c Update test description
oyilmaztekin5204588 Update dot notation in test
oyilmaztekin346b29a Update dot notation
oyilmaztekin2545fe6 Update destructuring assignment
oyilmaztekin853044f reduced analyzeTable function
421e31d Merge branch 'ozer-check-markdown' of https://github.com/oyilmaztekin…
a78ac0b eslint integration
0601099 added new line
4c96e44 Merge pull request #1 from oguzzkilic/patch-1
oyilmaztekina9710f7 added tested for resolver, parser and recursive test for tokenization
oyilmaztekin0df11c5 Merge branch 'master' of https://github.com/tc39/proposals into ozer-…
oyilmaztekin5325939 added test for collectLinkDefinitions.js
oyilmaztekin2f5a10b added detectTables test
oyilmaztekind068b15 added tables Represantation mock
oyilmaztekin1d15acb fixed grammar
oyilmaztekin8ba807c Merge branch 'master' into ozer-check-markdown
f19f819 adds handler for table head
829789a removes unused function
oyilmaztekincf70ee9 adds cell handler
oyilmaztekinb7cce4d fixes handlers to group array by proposals
oyilmaztekin84d8c3d makes refactoring on handleTables function
oyilmaztekin8a433ba Merge branch 'master' into ozer-check-markdown
oyilmaztekin142a78b adds doc into index.js
oyilmaztekin215ea12 ignores editor files
oyilmaztekina14e799 removes extra spaces
oyilmaztekin43683bc removes extra spaces
oyilmaztekin812d0ca removes .gitignore
oyilmaztekine591bdd creates final JSON for stage1
oyilmaztekin6a347ee adds some refactoring
oyilmaztekinFile filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
1 change: 1 addition & 0 deletionstools/markdown-checker/.eslintignore
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| *_tests_* |
21 changes: 21 additions & 0 deletionstools/markdown-checker/.eslintrc.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| { | ||
| "env": { | ||
| "node": true, | ||
| "es6": true | ||
| }, | ||
| "extends": [ | ||
| "airbnb-base" | ||
| ], | ||
| "globals": { | ||
| "Atomics": "readonly", | ||
| "SharedArrayBuffer": "readonly" | ||
| }, | ||
| "parserOptions": { | ||
| "ecmaVersion": 2018 | ||
| }, | ||
| "rules": { | ||
| "no-underscore-dangle": 0, | ||
| "import/no-extraneous-dependencies": 0, | ||
| "no-unused-vars": 0 | ||
| } | ||
| } |
21 changes: 21 additions & 0 deletionstools/markdown-checker/.gitignore
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| # Logs | ||
| logs | ||
| *.log | ||
| npm-debug.log* | ||
| yarn-debug.log* | ||
| yarn-error.log* | ||
| # environment variables | ||
| .env | ||
| .env.test | ||
| */node_modules/* | ||
| yarn.lock | ||
| #chunks | ||
| .DS_Store | ||
| .cache | ||
| **/.idea/** | ||
| # packages | ||
| node_modules/ | ||
| */node_modules/* |
3 changes: 3 additions & 0 deletionstools/markdown-checker/.prettierrc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| { | ||
| "singleQuote": true | ||
| } |
29 changes: 29 additions & 0 deletionstools/markdown-checker/README.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| ### MarkdownChecker | ||
| a script that generates a JSON file from the markdown which contains status of proposals. | ||
| #### modules | ||
| this script consist of three main stage like other compilers have | ||
| - parser | ||
| - analyzer | ||
| - transformer | ||
| - generator | ||
| ##### Parser | ||
| - **_readMarkdown_** : `string` | ||
| - source file will be parsed as an AST | ||
| - **_parseToAST_** : `object` | ||
| - an AST representation of the markdown | ||
| ##### Analyzer | ||
| - **_collectLinkDefinitions_** : `object` | ||
| - detects all link definitions declared from bottom of the markdown file and returns these definitions | ||
| - **_detectTables_** : `object` | ||
| - extracts all of the tables from the markdown and returns it as a tree | ||
| - **_detectHeaders_** : `object` | ||
| - extracts all of the row from the table nodes and returns it as a tree | ||
| ##### Transformer | ||
| - **_traverser_** | ||
| - takes current node as an input if it has an children nodes then applies the logic with given callback functions and returns something declared in the callback function | ||
| ##### Generator |
12 changes: 12 additions & 0 deletionstools/markdown-checker/enums.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| module.exports = { | ||
| stage3: './../../../../README.md', | ||
| stage1: './../../../../stage-1-proposals.md', | ||
| DEFINITION: 'definition', | ||
| TABLE: 'table', | ||
| TEXT: 'text', | ||
| ROW: 'tableRow', | ||
| CELL: 'tableCell', | ||
| HTML: 'html', | ||
| LINK: 'linkReference', | ||
| INLINE_CODE: 'inlineCode' | ||
| }; |
33 changes: 33 additions & 0 deletionstools/markdown-checker/index.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| const readMarkdown = require('./lib/parser/readMarkdown'); | ||
| const parseToAST = require('./lib/parser/parseToAst'); | ||
| const globalData = require('./lib/data'); | ||
| const generateJSONFile = require('./lib/writeFile'); | ||
| const { | ||
| collectLinkDefinitions, | ||
| } = require('./lib/analyzer/collectLinkDefinitions'); | ||
| const { generateTable } = require('./lib/analyzer/analyzeTable'); | ||
| const enums = require('./enums.js'); | ||
| const processStage3 = (stage) => { | ||
| /** | ||
| * TODO: handle multiple table in readme.md | ||
| * TODO: handle "Test" columns in stage3 | ||
| * TODO: handle different column lengths | ||
| */ | ||
| // | ||
| const activeStage = enums[stage]; | ||
| // parse stage | ||
| const markdownStage = readMarkdown(activeStage); | ||
| const parsedFile = parseToAST(markdownStage); | ||
| globalData.linkDefinitions = collectLinkDefinitions(parsedFile); | ||
| const table = generateTable(parsedFile); | ||
| // creates JSON file | ||
| const fileName = `${stage}Table.json`; | ||
| generateJSONFile(fileName, JSON.stringify(table)) | ||
| .then(_ => console.log(`The ${fileName} has been created!`)) | ||
| .catch(err => console.log(`err: ${err}`)); | ||
| }; | ||
| processStage3('stage1'); |
43 changes: 43 additions & 0 deletionstools/markdown-checker/lib/analyzer/__tests__/collectLinkDefinitions.test.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| const readMarkdown = require('./../../parser/readMarkdown'); | ||
| const parseToAST = require('./../../parser/parseToAst'); | ||
| const { | ||
| collectLinkDefinitions, | ||
| addLinkIntoDefintions | ||
| } = require('../collectLinkDefinitions'); | ||
| const definitionNode = require('../../../mocks/definitionNode'); | ||
| describe('testing collectLinkDefiniton function', () => { | ||
| let parsedMarkdown; | ||
| let allLinkDefinitions; | ||
| beforeAll(() => { | ||
| const markdownFile = readMarkdown('../../mocks/stage3Mock.md'); | ||
| parsedMarkdown = parseToAST(markdownFile); | ||
| allLinkDefinitions = collectLinkDefinitions(parsedMarkdown); | ||
| }); | ||
| test('function is defined', () => { | ||
| expect(collectLinkDefinitions).toBeDefined(); | ||
| expect(typeof collectLinkDefinitions).toBe('function'); | ||
| }); | ||
| test('definition added into hash', () => { | ||
| const definitions = addLinkIntoDefintions({}, definitionNode); | ||
| const { label, url } = definitions; | ||
| expect(typeof definitions).toBe('object'); | ||
| expect(typeof label && typeof url).toBe('string'); | ||
| expect(label).toBe('regexp-legacy'); | ||
| expect(url).toBe('https://github.com/tc39/proposal-regexp-legacy-features'); | ||
| }); | ||
| test('link definitions are collected', () => { | ||
| expect(allLinkDefinitions).toBeDefined(); | ||
| expect(typeof allLinkDefinitions).toBe('object'); | ||
| expect(allLinkDefinitions['buffer-transfer']).toBe( | ||
| 'https://github.com/domenic/proposal-arraybuffer-transfer/' | ||
| ); | ||
| expect(allLinkDefinitions['private-methods']).toBe( | ||
| 'https://github.com/tc39/proposal-private-methods' | ||
| ); | ||
| }); | ||
| }); |
41 changes: 41 additions & 0 deletionstools/markdown-checker/lib/analyzer/__tests__/detectTableChildren.test.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| const detectTables = require('../detectTables'); | ||
| const detectHeaders = require('../handleTables'); | ||
| const parsedMarkdownTree = require('../../../mocks/parsedMarkdownTree'); | ||
| const markdownTables = detectTables(parsedMarkdownTree); | ||
| const [child] = markdownTables; | ||
| describe('testing detectTables function', () => { | ||
| test('is defined', () => { | ||
| expect(detectTables).toBeDefined(); | ||
| }); | ||
| test('length is matched', () => { | ||
| expect(markdownTables.length).toEqual(2); | ||
| }); | ||
| test('has correct size of thead', () => { | ||
| expect(child.align.length).toBe(5); | ||
| }) | ||
| test('is returned table', () => { | ||
| expect(child.type).toBe('table'); | ||
| }); | ||
| test('has row and cell children', () => { | ||
| const [rowChild] = child.children; | ||
| expect(rowChild.type).toBe('tableRow'); | ||
| const [cellChild] = rowChild.children; | ||
| expect(cellChild.type).toBe('tableCell'); | ||
| }); | ||
| }); | ||
| describe('testing detectHeaders function', () => { | ||
| let rowChild; | ||
| beforeAll(() => { | ||
| [rowChild] = child.children; | ||
| }); | ||
| test('is defined', ()=>{ | ||
| expect(detectHeaders).toBeDefined(); | ||
| }) | ||
| test('is defined', ()=>{ | ||
| rowChild; | ||
| }) | ||
| }) |
36 changes: 36 additions & 0 deletionstools/markdown-checker/lib/analyzer/analyzeTable.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| const detectTables = require('./detectTables'); | ||
| const handleTables = require('./handleTables'); | ||
| const { checkNodeHasChildren } = require('../utils'); | ||
| /** | ||
| * | ||
| * @param {Object} node | ||
| * @returns {Array} | ||
| */ | ||
| const extractAllTablesFromTree = (node) => { | ||
| if (checkNodeHasChildren(node)) { | ||
| return detectTables(node); | ||
| } | ||
| return []; | ||
| }; | ||
| /** | ||
| * | ||
| * @param {Object} node - current node of the parsed AST | ||
| * @param {Object} linkDefinitions - represents all of the link shortcuts | ||
| */ | ||
| const generateTable = (node) => { | ||
| const tables = extractAllTablesFromTree(node); | ||
| let JSONTables = []; | ||
| if (tables && tables.length > 0) { | ||
| tables.forEach((table) => { | ||
| if (Object.values(table).length > 0) { | ||
| JSONTables = handleTables(table); | ||
| } | ||
| }); | ||
| } | ||
| return JSONTables; | ||
| }; | ||
| module.exports = { generateTable, extractAllTablesFromTree }; |
32 changes: 32 additions & 0 deletionstools/markdown-checker/lib/analyzer/collectLinkDefinitions.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| const { DEFINITION } = require('./../../enums.js'); | ||
| /** | ||
| * | ||
| * @param {Object} definitions | ||
| * @param {Object} node | ||
| * @returns {Object} | ||
| */ | ||
| function addLinkIntoDefinitions(definitions, node) { | ||
| const { label, url } = node; | ||
| // eslint-disable-next-line no-param-reassign | ||
| definitions[label] = url; | ||
| return { | ||
| label, | ||
| url, | ||
| }; | ||
| } | ||
| /** | ||
| * @param {Object} AST | ||
| * @returns {Object} - collected link definitions | ||
| */ | ||
| function collectLinkDefinitions(AST) { | ||
| const definitions = {}; | ||
| AST.children.forEach((node) => { | ||
| // eslint-disable-next-line no-unused-expressions | ||
| node.type === DEFINITION && addLinkIntoDefinitions(definitions, node); | ||
| }); | ||
| return definitions; | ||
| } | ||
| module.exports = { collectLinkDefinitions }; |
10 changes: 10 additions & 0 deletionstools/markdown-checker/lib/analyzer/detectTables.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| const { TABLE } = require('./../../enums.js'); | ||
| /** | ||
| * @param {Object} node - Parsed markdown file an AST Object | ||
| * @returns {Array} - contains detected table nodes of the AST | ||
| */ | ||
| function detectTables(node) { | ||
| return node.children.filter(({ type }) => type === TABLE); | ||
| } | ||
| module.exports = detectTables; |
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.