Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
implement a plugin framework
  • Loading branch information
mmomtchev committed Nov 30, 2021
commit 8dfb58ffc49ac585980eaca63f373b3b9cdf2751
156 changes: 156 additions & 0 deletions __tests__/__snapshots__/bin.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2024,6 +2024,162 @@ f5 comment

exports[`lint command generates lint output 1`] = `""`;

exports[`load a plugin 1`] = `
Array [
Object {
"augments": Array [],
"context": Object {
"file": "[path]",
"loc": Object {
"end": Object {
"column": 2,
"line": 8,
},
"start": Object {
"column": 0,
"line": 5,
},
},
},
"description": Object {
"children": Array [
Object {
"children": Array [
Object {
"type": "text",
"value": "This function returns the number one.",
},
],
"type": "paragraph",
},
],
"type": "root",
},
"examples": Array [],
"implements": Array [],
"kind": "function",
"loc": Object {
"end": Object {
"column": 3,
"line": 4,
},
"start": Object {
"column": 0,
"line": 1,
},
},
"members": Object {
"events": Array [],
"global": Array [],
"inner": Array [],
"instance": Array [],
"static": Array [],
},
"name": "simple.input",
"namespace": "simple.input",
"params": Array [],
"path": Array [
Object {
"kind": "function",
"name": "simple.input",
},
],
"properties": Array [],
"returns": Array [
Object {
"description": Object {
"children": Array [
Object {
"children": Array [
Object {
"type": "text",
"value": "numberone",
},
],
"type": "paragraph",
},
],
"type": "root",
},
"title": "returns",
"type": Object {
"name": "number",
"type": "NameExpression",
},
},
],
"sees": Array [],
"tags": Array [
Object {
"description": "numberone",
"lineNumber": 2,
"title": "returns",
"type": Object {
"name": "number",
"type": "NameExpression",
},
},
],
"throws": Array [],
"todos": Array [],
"yields": Array [],
},
Object {
"after": "",
"api": false,
"augments": Array [],
"context": Object {
"file": "[path]",
"loc": Object {
"end": Object {
"column": 4,
"line": 5,
},
"start": Object {
"column": 1,
"line": 5,
},
},
},
"end": 19,
"examples": Array [],
"implements": Array [],
"loc": Object {
"end": Object {
"column": 1,
"line": 2,
},
"start": Object {
"column": 1,
"line": 0,
},
},
"members": Object {
"events": Array [],
"global": Array [],
"inner": Array [],
"instance": Array [],
"static": Array [],
},
"namespace": "",
"params": Array [],
"path": Array [],
"properties": Array [],
"returns": Array [],
"sees": Array [],
"start": 0,
"tags": Array [],
"throws": Array [],
"todos": Array [],
"type": "CommentBlock",
"value": "*
* @method dummy
",
"yields": Array [],
},
]
`;

exports[`should use browser resolve 1`] = `
Array [
Object {
Expand Down
164 changes: 164 additions & 0 deletions __tests__/__snapshots__/test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,170 @@ Array [
]
`;

exports[`Check that plugins are loaded 1`] = `
Array [
Object {
"augments": Array [],
"context": Object {
"loc": SourceLocation {
"end": Position {
"column": 2,
"line": 8,
},
"filename": undefined,
"identifierName": undefined,
"start": Position {
"column": 0,
"line": 5,
},
},
},
"description": Object {
"children": Array [
Object {
"children": Array [
Object {
"type": "text",
"value": "This function returns the number one.",
},
],
"type": "paragraph",
},
],
"type": "root",
},
"errors": Array [],
"examples": Array [],
"implements": Array [],
"kind": "function",
"loc": SourceLocation {
"end": Position {
"column": 3,
"line": 4,
},
"filename": undefined,
"identifierName": undefined,
"start": Position {
"column": 0,
"line": 1,
},
},
"members": Object {
"events": Array [],
"global": Array [],
"inner": Array [],
"instance": Array [],
"static": Array [],
},
"name": "simple.input",
"namespace": "simple.input",
"params": Array [],
"path": Array [
Object {
"kind": "function",
"name": "simple.input",
},
],
"properties": Array [],
"returns": Array [
Object {
"description": Object {
"children": Array [
Object {
"children": Array [
Object {
"type": "text",
"value": "numberone",
},
],
"type": "paragraph",
},
],
"type": "root",
},
"title": "returns",
"type": Object {
"name": "number",
"type": "NameExpression",
},
},
],
"sees": Array [],
"tags": Array [
Object {
"description": "numberone",
"lineNumber": 2,
"title": "returns",
"type": Object {
"name": "number",
"type": "NameExpression",
},
},
],
"throws": Array [],
"todos": Array [],
"yields": Array [],
},
Object {
"after": "",
"api": false,
"augments": Array [],
"context": Object {
"loc": Object {
"end": Object {
"column": 4,
"line": 5,
},
"start": Object {
"column": 1,
"line": 5,
},
},
},
"end": 19,
"errors": Array [
Object {
"message": "could not determine @name for hierarchy",
},
],
"examples": Array [],
"implements": Array [],
"loc": Object {
"end": Object {
"column": 1,
"line": 2,
},
"start": Object {
"column": 1,
"line": 0,
},
},
"members": Object {
"events": Array [],
"global": Array [],
"inner": Array [],
"instance": Array [],
"static": Array [],
},
"namespace": "",
"params": Array [],
"path": Array [],
"properties": Array [],
"returns": Array [],
"sees": Array [],
"start": 0,
"tags": Array [],
"throws": Array [],
"todos": Array [],
"type": "CommentBlock",
"value": "*
* @method dummy
",
"yields": Array [],
},
]
`;

exports[`Use Source attribute only 1`] = `
Array [
Object {
Expand Down
8 changes: 7 additions & 1 deletion __tests__/bin.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import path from 'path';
import os from 'os';
import { exec } from 'child_process';
import tmp from 'tmp';
import fs from 'fs-extra';
import { fileURLToPath } from 'url';

Expand Down Expand Up @@ -60,6 +59,13 @@ test.skip('defaults to parsing package.json main', async function () {
expect(data.length).toBeTruthy();
});

test('load a plugin', async function () {
const data = await documentation([
'build fixture/simple.input.js fixture/plugin.txt --plugin=../src/mock_plugin.js'
]);
expect(normalize(data)).toMatchSnapshot();
});

test('accepts config file', async function () {
const data = await documentation([
'build fixture/sorting/input.js -c fixture/config.json'
Expand Down
6 changes: 6 additions & 0 deletions __tests__/fixture/plugin.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/**
* @method test
*/

test

Loading