Skip to content
This repository has been archived by the owner on Dec 12, 2024. It is now read-only.

Add docsReporterIgnore option #111

Merged
merged 1 commit into from
Jan 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
13 changes: 9 additions & 4 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ author: 'TBD54566975'

inputs:
entry_points:
description: 'List of each project you want to run tbdocs against (YAML format)'
description:
'List of each project you want to run tbdocs against (YAML format)'
required: false
default: |
- file: src/index.ts
Expand All @@ -14,6 +15,7 @@ inputs:
# entry point yaml fields:
# file: path to the entry point file
# docsReporter: name of the docs reporter tool
# docsReporterIgnore: list of errors to ignore `extractor:ae-missing-release-tag`, `docs:tsdoc-param-tag-with-invalid-name`, etc.
# docsGenerator: name of the docs generator tool
# targetRepoPath: path to push the generated docs in the target repo (see docs_target_owner_repo below)

Expand Down Expand Up @@ -49,13 +51,15 @@ inputs:
default: 'false'

group_docs:
description: 'Should it group the generated docs files in the `.tbdocs/docs` folder?'
description:
'Should it group the generated docs files in the `.tbdocs/docs` folder?'
required: false
default: 'false'

# generated docs params, if you want to open a PR to a different repo with the generated docs
docs_target_owner_repo:
description: 'Target owner/repo for the generated docs PR (skips opening a PR if empty)'
description:
'Target owner/repo for the generated docs PR (skips opening a PR if empty)'
required: false
docs_target_branch:
description: 'Target branch for the generated docs PR'
Expand All @@ -68,7 +72,8 @@ inputs:

# generator params
docs_generator:
description: 'Name of the docs generator tool (skips docs generation if empty)'
description:
'Name of the docs generator tool (skips docs generation if empty)'
required: false
outputs:
report:
Expand Down
2 changes: 1 addition & 1 deletion badges/coverage.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 17 additions & 5 deletions src/docs-report/api-extractor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ import {
import { EntryPoint } from '../interfaces'

export const generateApiExtractorReport = async (
entryPoint: EntryPoint
entryPoint: EntryPoint,
ignoreMessages?: string[]
): Promise<DocsReport> => {
const extractorConfig = await initializeExtractorConfig(entryPoint.file)
entryPoint.projectName = extractorConfig.packageJson?.name
Expand All @@ -43,7 +44,8 @@ export const generateApiExtractorReport = async (
localBuild: true,
// showVerboseMessages: true,
// showDiagnostics: true,
messageCallback: message => processApiExtractorMessage(report, message)
messageCallback: message =>
processApiExtractorMessage(report, message, ignoreMessages)
})

if (extractorResult.errorCount !== report.errorsCount) {
Expand All @@ -63,7 +65,8 @@ export const generateApiExtractorReport = async (

const processApiExtractorMessage = (
report: DocsReport,
message: ExtractorMessage
message: ExtractorMessage,
ignoreMessages: string[] = []
): void => {
if (
message.category === ExtractorMessageCategory.Console ||
Expand All @@ -72,10 +75,19 @@ const processApiExtractorMessage = (
return
}

const category = getCategoryFromApiExtractor(message.category)
const messageId = message.messageId

const fullMessageId = `${category}:${messageId}`
if (ignoreMessages.includes(fullMessageId)) {
console.info(`Ignoring message: ${fullMessageId}`)
return
}

const reportMessage: ReportMessage = {
level: message.logLevel,
category: getCategoryFromApiExtractor(message.category),
messageId: message.messageId,
category,
messageId,
text: escapeTextForGithub(message.text),
sourceFilePath: message.sourceFilePath,
sourceFileLine: message.sourceFileLine,
Expand Down
12 changes: 8 additions & 4 deletions src/docs-report/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,20 @@ export * from './interfaces'
**/
export const runDocsReport = async (
entryPoint: EntryPoint,
changedFiles?: FilesDiffsMap
changedFiles?: FilesDiffsMap,
ignoreMessages?: string[]
): Promise<DocsReport> => {
const report = await generateReport(entryPoint)
const report = await generateReport(entryPoint, ignoreMessages)
return changedFiles ? filterReport(report, changedFiles) : report
}

const generateReport = async (entryPoint: EntryPoint): Promise<DocsReport> => {
const generateReport = async (
entryPoint: EntryPoint,
ignoreMessages?: string[]
): Promise<DocsReport> => {
switch (entryPoint.docsReporter) {
case 'api-extractor':
return generateApiExtractorReport(entryPoint)
return generateApiExtractorReport(entryPoint, ignoreMessages)
default:
throw new Error(`Unknown docs report: ${entryPoint.docsReporter}`)
}
Expand Down
9 changes: 9 additions & 0 deletions src/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@ export interface EntryPointInputs {
**/
docsReporter?: DocsReporterType

/**
* List of errors to ignore from the reporter.
* Example:
* - extractor:ae-missing-release-tag
* - docs:tsdoc-param-tag-with-invalid-name
* - etc...
*/
docsReporterIgnore?: string[]

/**
* Type of docs-generator to run, eg: typedoc-markdown;
* If not present, no docs will be generated.
Expand Down
6 changes: 5 additions & 1 deletion src/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ export async function run(): Promise<void> {

if (entryPoint.docsReporter) {
console.info(`Executing docs reporter ${entryPoint.docsReporter} ...`)
entryPoint.report = await runDocsReport(entryPoint, changedFiles)
entryPoint.report = await runDocsReport(
entryPoint,
changedFiles,
entryPoint.docsReporterIgnore
)
}

if (entryPoint.docsGenerator) {
Expand Down