Skip to content

Commit 7ba88f5

Browse files
committed
add test; update README; bump to v0.1.1
1 parent 84e846b commit 7ba88f5

File tree

14 files changed

+4484
-10
lines changed

14 files changed

+4484
-10
lines changed

.github/workflows/test.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Test
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- master
8+
pull_request:
9+
branches:
10+
- main
11+
- master
12+
13+
jobs:
14+
build:
15+
runs-on: ${{ matrix.os }}
16+
strategy:
17+
max-parallel: 4
18+
matrix:
19+
os:
20+
- ubuntu-latest
21+
- macos-latest
22+
- windows-latest
23+
node: [10.x, 12.x, 14.x]
24+
25+
steps:
26+
- uses: actions/checkout@v2
27+
- name: Set up Node.js
28+
uses: actions/setup-node@v1
29+
with:
30+
node-version: ${{ matrix.node }}
31+
- name: Install modules
32+
run: yarn
33+
- name: Run tests
34+
run: yarn test

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
test/docs
2+
test/docs2
13

24
# Logs
35
logs

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
This [TypeDoc](https://typedoc.org/) plugin can force inclusion of specific symbols (variables) that are not exported, by making them fake exports.
66

7+
(Requires TypeDoc ≥ v0.20.16 (2021-01-17))
8+
79
## Usage
810

911
Install the plugin with [npm](https://www.npmjs.com/):
@@ -67,8 +69,6 @@ Or, if you are using `@internalDoNotUse` tag instead of `@notExported`, run:
6769
typedoc --includeTag internalDoNotUse src/index.ts
6870
```
6971

70-
That's it.
71-
7272
## Links, Tips & Others
7373

7474
Originally from [here](https://github.com/TypeStrong/typedoc/issues/1474#issuecomment-766178261).

package.json

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
{
22
"name": "typedoc-plugin-not-exported",
3-
"version": "0.1.0",
3+
"version": "0.1.1",
44
"description": "TypeDoc plugin that forces inclusion of non-exported symbols (variables)",
55
"main": "src/main.js",
6-
"scripts": {},
6+
"scripts": {
7+
"test": "npm run test:gen && npm run test:jest && npm run test:cleanup",
8+
"test:cleanup": "rimraf test/docs test/docs2",
9+
"test:gen": "npm run test:cleanup && typedoc --options test/typedoc.json && typedoc --options test/typedoc2.json",
10+
"test:jest": "jest"
11+
},
712
"files": [
813
"src"
914
],
@@ -13,11 +18,10 @@
1318
"plugin",
1419
"exported",
1520
"nonexported",
16-
"include",
17-
"plugin"
21+
"include"
1822
],
1923
"author": "Tom Chen <tomchen.org@gmail.com>",
20-
"license": "CC0",
24+
"license": "CC0-1.0",
2125
"homepage": "https://github.com/tomchen/typedoc-plugin-not-exported",
2226
"repository": {
2327
"type": "git",
@@ -27,12 +31,17 @@
2731
"url": "https://github.com/tomchen/typedoc-plugin-not-exported/issues"
2832
},
2933
"peerDependencies": {
30-
"typedoc": ">=0.20.0"
34+
"typedoc": ">=0.20.16"
3135
},
3236
"devDependencies": {
37+
"cheerio": "^1.0.0-rc.5",
3338
"eslint": "^7.18.0",
3439
"eslint-config-prettier": "^7.2.0",
3540
"eslint-plugin-prettier": "^3.3.1",
36-
"prettier": "^2.2.1"
41+
"jest": "^26.6.3",
42+
"prettier": "^2.2.1",
43+
"rimraf": "^3.0.2",
44+
"typedoc": "0.20.16",
45+
"typescript": "^4.1.3"
3746
}
3847
}

src/main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
//@ts-check
1010

11-
const { Converter, TypeScript } = require('typedoc') // version 0.20.x
11+
const { Converter, TypeScript } = require('typedoc') // version 0.20.16+
1212

1313
const ModuleFlags =
1414
TypeScript.SymbolFlags.ValueModule | TypeScript.SymbolFlags.NamespaceModule

test/docs.test.js

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
const cheerio = require('cheerio')
2+
const fs = require('fs')
3+
4+
const $ = cheerio.load(fs.readFileSync('./test/docs/index.html'))
5+
6+
test('Cls', () => {
7+
expect(
8+
$(
9+
'body > div.container.container-main > div > div.col-8.col-content > section.tsd-panel-group.tsd-index-group > section > div > section:nth-child(1) > ul > li > a'
10+
).text()
11+
).toBe('Cls')
12+
})
13+
14+
test('threeNumbers', () => {
15+
expect(
16+
$(
17+
'body > div.container.container-main > div > div.col-8.col-content > section.tsd-panel-group.tsd-index-group > section > div > section:nth-child(2) > ul > li:nth-child(1) > a'
18+
).text()
19+
).toBe('threeNumbers')
20+
})
21+
22+
test('notexported tag', () => {
23+
expect(
24+
$(
25+
'body > div.container.container-main > div > div.col-8.col-content > section:nth-child(2) > section:nth-child(3) > div.tsd-comment.tsd-typography > dl > dt'
26+
).text()
27+
).toBe('notexported')
28+
})
29+
30+
test('twonumbers href', () => {
31+
expect(
32+
$(
33+
'body > div.container.container-main > div > div.col-8.col-content > section:nth-child(2) > section:nth-child(4) > div > a:nth-child(4)'
34+
).attr('href')
35+
).toBe('index.html#twonumbers')
36+
})
37+
38+
test('cls href', () => {
39+
expect(
40+
$(
41+
'body > div.container.container-main > div > div.col-8.col-content > section:nth-child(3) > section > div > a'
42+
).attr('href')
43+
).toBe('classes/cls.html')
44+
})
45+
46+
test('class count', () => {
47+
expect(
48+
$(
49+
'body > div.container.container-main > div > div.col-8.col-content > section.tsd-panel-group.tsd-index-group > section > div > section:nth-child(1) > ul > li.tsd-kind-class'
50+
).length
51+
).toBe(1)
52+
})
53+
54+
test('type count', () => {
55+
expect(
56+
$(
57+
'body > div.container.container-main > div > div.col-8.col-content > section.tsd-panel-group.tsd-index-group > section > div > section:nth-child(2) > ul > li.tsd-kind-type-alias'
58+
).length
59+
).toBe(3)
60+
})

test/docs2.test.js

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
const cheerio = require('cheerio')
2+
const fs = require('fs')
3+
4+
const $ = cheerio.load(fs.readFileSync('./test/docs2/index.html'))
5+
6+
test('Cls', () => {
7+
expect(
8+
$(
9+
'body > div.container.container-main > div > div.col-8.col-content > section.tsd-panel-group.tsd-index-group > section > div > section:nth-child(1) > ul > li > a'
10+
).text()
11+
).toBe('Cls')
12+
})
13+
14+
test('threeNumbers', () => {
15+
expect(
16+
$(
17+
'body > div.container.container-main > div > div.col-8.col-content > section.tsd-panel-group.tsd-index-group > section > div > section:nth-child(2) > ul > li:nth-child(1) > a'
18+
).text()
19+
).toBe('threeNumbers')
20+
})
21+
22+
test('notexported tag', () => {
23+
expect(
24+
$(
25+
'body > div.container.container-main > div > div.col-8.col-content > section:nth-child(2) > section:nth-child(3) > div.tsd-comment.tsd-typography > dl > dt'
26+
).text()
27+
).toBe('internaldonotuse')
28+
})
29+
30+
test('twonumbers href', () => {
31+
expect(
32+
$(
33+
'body > div.container.container-main > div > div.col-8.col-content > section:nth-child(2) > section:nth-child(4) > div > a:nth-child(4)'
34+
).attr('href')
35+
).toBe('index.html#twonumbers')
36+
})
37+
38+
test('cls href', () => {
39+
expect(
40+
$(
41+
'body > div.container.container-main > div > div.col-8.col-content > section:nth-child(3) > section > div > a'
42+
).attr('href')
43+
).toBe('classes/cls.html')
44+
})
45+
46+
test('class count', () => {
47+
expect(
48+
$(
49+
'body > div.container.container-main > div > div.col-8.col-content > section.tsd-panel-group.tsd-index-group > section > div > section:nth-child(1) > ul > li.tsd-kind-class'
50+
).length
51+
).toBe(1)
52+
})
53+
54+
test('type count', () => {
55+
expect(
56+
$(
57+
'body > div.container.container-main > div > div.col-8.col-content > section.tsd-panel-group.tsd-index-group > section > div > section:nth-child(2) > ul > li.tsd-kind-type-alias'
58+
).length
59+
).toBe(3)
60+
})

test/index.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/**
2+
* @notExported
3+
*/
4+
type twoNumbers = [number, number]
5+
/**
6+
* @notExported
7+
*/
8+
type threeNumbers = [number, number, number]
9+
10+
type fourNumbers = [number, number, number, number]
11+
12+
export type twoOrThreeNumbers = twoNumbers | threeNumbers
13+
14+
export function sum2(ns: twoOrThreeNumbers): number {
15+
return ns.reduce((a, b) => a + b)
16+
}
17+
18+
/**
19+
* My class
20+
* @notExported
21+
*/
22+
class Cls {
23+
convert(str: string): string {
24+
return str
25+
}
26+
}
27+
28+
class HiddenCls {
29+
convert(str: string): string {
30+
return str
31+
}
32+
}
33+
34+
export const me = new Cls()

test/index2.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/**
2+
* @internalDoNotUse
3+
*/
4+
type twoNumbers = [number, number]
5+
/**
6+
* @internalDoNotUse
7+
*/
8+
type threeNumbers = [number, number, number]
9+
10+
type fourNumbers = [number, number, number, number]
11+
12+
export type twoOrThreeNumbers = twoNumbers | threeNumbers
13+
14+
export function sum2(ns: twoOrThreeNumbers): number {
15+
return ns.reduce((a, b) => a + b)
16+
}
17+
18+
/**
19+
* My class
20+
* @internalDoNotUse
21+
*/
22+
class Cls {
23+
convert(str: string): string {
24+
return str
25+
}
26+
}
27+
28+
class HiddenCls {
29+
convert(str: string): string {
30+
return str
31+
}
32+
}
33+
34+
export const me = new Cls()

test/jest.config.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module.exports = {
2+
roots: ['<rootDir>/test'],
3+
testMatch: [
4+
'**/__tests__/**/*.+js',
5+
'**/?(*.)+(spec|test).+js',
6+
],
7+
}

0 commit comments

Comments
 (0)