-
Notifications
You must be signed in to change notification settings - Fork 15
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(plugin-jsdocs): add plugin-jsdocs to analyze documentation in ts/js projects #896
Open
aramirezj
wants to merge
62
commits into
code-pushup:main
Choose a base branch
from
aramirezj:feat--plugin-doc-coverage
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.
Open
Changes from all commits
Commits
Show all changes
62 commits
Select commit
Hold shift + click to select a range
bf1775d
feat(plugin-doc-coverage): add mvp version of a plugin doc coverage b…
aramirezj b07eb8a
feat: change from compodoc to typedoc
aramirezj 0de6d3f
feat(plugin-doc-coverage): change to use ts-morph instead of typedoc.…
aramirezj 164a86a
feat: doc-processer give coverage by type of property. Some tests enh…
aramirezj 3fe6e3b
feat(plugin-doc-coverage): improve code fragmentation, tests and mode…
aramirezj 40c8daa
test(plugin-doc-coverage): finish remaining tests, add format to cove…
aramirezj 47486c8
feat(plugin-doc-coverage): add skipAudits options to the plugin, crea…
aramirezj f21fbe2
chore(plugin-doc-coverage): fix linter problems
aramirezj 4fb478e
fix: return code-pushup config to original state
aramirezj feefa0a
feat(plugin-doc-coverage): add support for variable statement to be d…
aramirezj 1a5a614
chore(plugin-doc-coverage): remove unused file and update readme file
aramirezj 8909855
Update packages/plugin-doc-coverage/src/lib/constants.ts
aramirezj b8cdf77
Update packages/plugin-doc-coverage/package.json
aramirezj 24ab2e0
chore(plugin-doc-coverage): from Michael comments, remakes some tests…
aramirezj 6c83208
chore(plugin-doc-coverage): remove extra line
aramirezj 8c2d274
chore: put back plugin config
aramirezj a70c03b
chore: fix plugin config, remove unused snapshot
aramirezj 6be3803
chore(plugin-doc-coverage): stuff of the pr and rename file
aramirezj 2f29728
Update code-pushup.config.ts
aramirezj adec386
Update packages/plugin-doc-coverage/src/lib/doc-coverage-plugin.unit.…
aramirezj 47cff4b
Update packages/plugin-doc-coverage/src/lib/runner/doc-processer.inte…
aramirezj c644029
Update packages/plugin-doc-coverage/src/lib/constants.ts
aramirezj 09d9eb0
Update packages/plugin-doc-coverage/src/lib/constants.ts
aramirezj 3901955
Update packages/plugin-doc-coverage/src/lib/constants.ts
aramirezj 11ad4bb
Update packages/plugin-doc-coverage/src/lib/constants.ts
aramirezj 19d43a5
Update packages/plugin-doc-coverage/src/lib/constants.ts
aramirezj 49e5b56
Update packages/plugin-doc-coverage/README.md
aramirezj 54d1621
Update packages/plugin-doc-coverage/README.md
aramirezj b3105ae
Update packages/plugin-doc-coverage/src/lib/constants.ts
aramirezj 89893a0
Update packages/plugin-doc-coverage/src/lib/constants.ts
aramirezj 97d32bf
Update packages/plugin-doc-coverage/src/lib/config.unit.test.ts
aramirezj 79b6a02
Update packages/plugin-doc-coverage/src/lib/config.unit.test.ts
aramirezj fd3bd5e
chore(plugin-doc-coverage): add js files for integration test, remove…
aramirezj 0ecc193
chore: run nx format
aramirezj 7e0acbd
chore(plugin-doc-coverage): improve readme and audits
aramirezj 24468cc
chore(plugin-doc-coverage): remove unused async
aramirezj ef77df0
chore(plugin-doc-coverage): fix tests, fully remove unnecessary await
aramirezj b09aa57
chore: fix scope of sourceGlob
aramirezj b9f5333
fix: mock word
aramirezj 6f0f19c
chore: wips
aramirezj 6634f3c
fix e2e
BioPhoton 5fc371c
chore: nx format
aramirezj b609608
test(plugin-doc-coverage): create better test of integration
aramirezj 2dbdb7d
chore(plugin-doc-coverage): fix lint
aramirezj da133e9
chore(plugin-doc-coverage): fix linter e2e
aramirezj 7a80f85
polish integration tests
BioPhoton 12e3f4e
wip
BioPhoton c9443a0
chore(plugin-doc-coverage): change string detection
aramirezj ac83605
chore: format
aramirezj 1107ae4
chore: import
aramirezj 7fc7c2e
Merge remote-tracking branch 'origin/main' into feat--plugin-doc-cove…
aramirezj b7a42c7
chore(plugin-doc-coverage): use new path matching helpers
aramirezj 206340e
chore(plugin-doc-coverage): add setupFile for path matcher
aramirezj dec6fbd
Update code-pushup.preset.ts
aramirezj baac33c
Update packages/plugin-doc-coverage/README.md
aramirezj ac72432
Update code-pushup.preset.ts
aramirezj 177a186
Update packages/plugin-doc-coverage/src/lib/runner/runner.unit.test.ts
aramirezj 4531347
Update packages/plugin-doc-coverage/src/lib/doc-coverage-plugin.ts
aramirezj 4700bea
Update packages/plugin-doc-coverage/src/lib/runner/doc-processer.ts
aramirezj c386373
chore(plugin-doc-coverage): wip request in pr
aramirezj 4a75b86
chore(plugin-doc-coverage): rename processer to processor
aramirezj 0089b1f
chore(plugin-jsdocs): rename plugin
aramirezj File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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 @@ | ||
import tseslint from 'typescript-eslint'; | ||
import baseConfig from '../../eslint.config.js'; | ||
|
||
export default tseslint.config(...baseConfig, { | ||
files: ['**/*.ts'], | ||
languageOptions: { | ||
parserOptions: { | ||
projectService: true, | ||
tsconfigRootDir: import.meta.dirname, | ||
}, | ||
}, | ||
}); |
5 changes: 5 additions & 0 deletions
5
e2e/plugin-doc-coverage-e2e/mocks/fixtures/angular/code-pushup.config.ts
This file contains 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,5 @@ | ||
import docCoveragePlugin from '@code-pushup/doc-coverage-plugin'; | ||
|
||
export default { | ||
plugins: [await docCoveragePlugin({ sourceGlob: ['**/*.ts'] })], | ||
}; |
4 changes: 4 additions & 0 deletions
4
e2e/plugin-doc-coverage-e2e/mocks/fixtures/angular/src/app.component.css
This file contains 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,4 @@ | ||
h1 { | ||
color: #336699; | ||
text-align: center; | ||
} |
1 change: 1 addition & 0 deletions
1
e2e/plugin-doc-coverage-e2e/mocks/fixtures/angular/src/app.component.html
This file contains 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 @@ | ||
<h1>{{ title }}</h1> |
3 changes: 3 additions & 0 deletions
3
e2e/plugin-doc-coverage-e2e/mocks/fixtures/angular/src/app.component.spec.ts
This file contains 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 @@ | ||
function notRealisticFunction() { | ||
return 'notRealisticFunction'; | ||
} |
18 changes: 18 additions & 0 deletions
18
e2e/plugin-doc-coverage-e2e/mocks/fixtures/angular/src/app.component.ts
This file contains 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,18 @@ | ||
/** | ||
* Basic Angular component that displays a welcome message | ||
*/ | ||
export class AppComponent { | ||
protected readonly title = 'My Angular App'; | ||
|
||
/** | ||
* Dummy method that returns a welcome message | ||
* @returns {string} - The welcome message | ||
*/ | ||
getWelcomeMessage() { | ||
return 'Welcome to My Angular App!'; | ||
} | ||
|
||
sendEvent() { | ||
return 'Event sent'; | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
e2e/plugin-doc-coverage-e2e/mocks/fixtures/angular/src/map-event.function.ts
This file contains 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 @@ | ||
export const someVariable = 'Hello World 1'; | ||
|
||
export function mapEventToCustomEvent(event: string) { | ||
return event; | ||
} | ||
|
||
/** Commented */ | ||
export function mapCustomEventToEvent(event: string) { | ||
return event; | ||
} |
5 changes: 5 additions & 0 deletions
5
e2e/plugin-doc-coverage-e2e/mocks/fixtures/react/code-pushup.config.ts
This file contains 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,5 @@ | ||
import docCoveragePlugin from '@code-pushup/doc-coverage-plugin'; | ||
|
||
export default { | ||
plugins: [await docCoveragePlugin({ sourceGlob: ['**/*.ts'] })], | ||
}; |
10 changes: 10 additions & 0 deletions
10
e2e/plugin-doc-coverage-e2e/mocks/fixtures/react/component.js
This file contains 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 @@ | ||
function MyComponent() { | ||
return ( | ||
<div> | ||
<h1>Hello World</h1> | ||
<p>This is a basic React component</p> | ||
</div> | ||
); | ||
} | ||
|
||
export default MyComponent; |
This file contains 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,23 @@ | ||
{ | ||
"name": "plugin-doc-coverage-e2e", | ||
"$schema": "../../node_modules/nx/schemas/project-schema.json", | ||
"sourceRoot": "e2e/plugin-doc-coverage-e2e/src", | ||
"projectType": "application", | ||
"tags": ["scope:plugin", "type:e2e"], | ||
"implicitDependencies": ["cli", "plugin-jsdocs"], | ||
"targets": { | ||
"lint": { | ||
"executor": "@nx/linter:eslint", | ||
"outputs": ["{options.outputFile}"], | ||
"options": { | ||
"lintFilePatterns": ["e2e/plugin-doc-coverage-e2e/**/*.ts"] | ||
} | ||
}, | ||
"e2e": { | ||
"executor": "@nx/vite:test", | ||
"options": { | ||
"configFile": "e2e/plugin-doc-coverage-e2e/vite.config.e2e.ts" | ||
} | ||
} | ||
} | ||
} |
This file contains 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,72 @@ | ||
import { cp } from 'node:fs/promises'; | ||
import path from 'node:path'; | ||
import { afterAll, afterEach, beforeAll, describe, expect, it } from 'vitest'; | ||
import { type Report, reportSchema } from '@code-pushup/models'; | ||
import { nxTargetProject } from '@code-pushup/test-nx-utils'; | ||
import { teardownTestFolder } from '@code-pushup/test-setup'; | ||
import { | ||
E2E_ENVIRONMENTS_DIR, | ||
TEST_OUTPUT_DIR, | ||
omitVariableReportData, | ||
removeColorCodes, | ||
} from '@code-pushup/test-utils'; | ||
import { executeProcess, readJsonFile } from '@code-pushup/utils'; | ||
|
||
describe('PLUGIN collect report with doc-coverage-plugin NPM package', () => { | ||
const fixturesDir = path.join( | ||
'e2e', | ||
'plugin-doc-coverage-e2e', | ||
'mocks', | ||
'fixtures', | ||
); | ||
const fixturesAngularDir = path.join(fixturesDir, 'angular'); | ||
const fixturesReactDir = path.join(fixturesDir, 'react'); | ||
|
||
const envRoot = path.join( | ||
E2E_ENVIRONMENTS_DIR, | ||
nxTargetProject(), | ||
TEST_OUTPUT_DIR, | ||
); | ||
const angularDir = path.join(envRoot, 'angular'); | ||
const reactDir = path.join(envRoot, 'react'); | ||
const angularOutputDir = path.join(angularDir, '.code-pushup'); | ||
const reactOutputDir = path.join(reactDir, '.code-pushup'); | ||
|
||
beforeAll(async () => { | ||
await cp(fixturesAngularDir, angularDir, { recursive: true }); | ||
await cp(fixturesReactDir, reactDir, { recursive: true }); | ||
}); | ||
|
||
afterAll(async () => { | ||
await teardownTestFolder(angularDir); | ||
await teardownTestFolder(reactDir); | ||
}); | ||
|
||
afterEach(async () => { | ||
await teardownTestFolder(angularOutputDir); | ||
await teardownTestFolder(reactOutputDir); | ||
}); | ||
|
||
it('should run Doc Coverage plugin for Angular example dir and create report.json', async () => { | ||
const { code, stdout } = await executeProcess({ | ||
command: 'npx', | ||
args: ['@code-pushup/cli', 'collect', '--no-progress'], | ||
cwd: angularDir, | ||
}); | ||
|
||
expect(code).toBe(0); | ||
|
||
expect(removeColorCodes(stdout)).toMatchFileSnapshot( | ||
'__snapshots__/report.txt', | ||
); | ||
|
||
const report = await readJsonFile( | ||
path.join(angularOutputDir, 'report.json'), | ||
); | ||
|
||
expect(() => reportSchema.parse(report)).not.toThrow(); | ||
expect( | ||
JSON.stringify(omitVariableReportData(report as Report), null, 2), | ||
).toMatchFileSnapshot('__snapshots__/report.json'); | ||
}); | ||
}); |
This file contains 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,20 @@ | ||
{ | ||
"extends": "../../tsconfig.base.json", | ||
"compilerOptions": { | ||
"module": "ESNext", | ||
"forceConsistentCasingInFileNames": true, | ||
"strict": true, | ||
"noImplicitOverride": true, | ||
"noPropertyAccessFromIndexSignature": true, | ||
"noImplicitReturns": true, | ||
"noFallthroughCasesInSwitch": true, | ||
"types": ["vitest"] | ||
}, | ||
"files": [], | ||
"include": [], | ||
"references": [ | ||
{ | ||
"path": "./tsconfig.test.json" | ||
} | ||
] | ||
} |
This file contains 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,15 @@ | ||
{ | ||
"extends": "./tsconfig.json", | ||
"compilerOptions": { | ||
"outDir": "../../dist/out-tsc", | ||
"types": ["vitest/globals", "vitest/importMeta", "vite/client", "node"], | ||
"target": "ES2020" | ||
}, | ||
"exclude": ["__test-env__/**"], | ||
"include": [ | ||
"vite.config.e2e.ts", | ||
"tests/**/*.e2e.test.ts", | ||
"tests/**/*.d.ts", | ||
"mocks/**/*.ts" | ||
] | ||
} |
This file contains 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 @@ | ||
/// <reference types="vitest" /> | ||
import { defineConfig } from 'vite'; | ||
import { tsconfigPathAliases } from '../../tools/vitest-tsconfig-path-aliases.js'; | ||
|
||
export default defineConfig({ | ||
cacheDir: '../../node_modules/.vite/plugin-doc-coverage-e2e', | ||
test: { | ||
reporters: ['basic'], | ||
testTimeout: 120_000, | ||
globals: true, | ||
alias: tsconfigPathAliases(), | ||
pool: 'threads', | ||
poolOptions: { threads: { singleThread: true } }, | ||
cache: { | ||
dir: '../../node_modules/.vitest', | ||
}, | ||
environment: 'node', | ||
include: ['tests/**/*.e2e.test.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'], | ||
setupFiles: ['../../testing/test-setup/src/lib/reset.mocks.ts'], | ||
}, | ||
}); |
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you also rename the E2E project to
plugin-jsdocs-e2e
, so it matches the new name? 🙏