Skip to content

Commit

Permalink
chore(docs): fix docs report comment (#4920)
Browse files Browse the repository at this point in the history
* chore(docs): round up to the nearest integear for smaller docs changes

* chore(docs): fix formatting for docs report
  • Loading branch information
binoy14 committed Sep 12, 2023
1 parent 2f08a79 commit bf50a77
Showing 1 changed file with 33 additions and 31 deletions.
64 changes: 33 additions & 31 deletions scripts/doc-report/docReport.ts
Expand Up @@ -2,6 +2,7 @@ import fs from 'fs/promises'
import path from 'path'
import {groupBy} from 'lodash'
import {combineLatest, map} from 'rxjs'
import prettier from 'prettier'
import {startTimer} from '../utils/startTimer'
import {createDocClient} from './docClient'
import {readEnv} from './envVars'
Expand Down Expand Up @@ -82,7 +83,7 @@ combineLatest([
package: br.package,
documentedChange: Number.isNaN(documentedPercentDiff)
? 0
: Math.floor(documentedPercentDiff * 100),
: Math.ceil(documentedPercentDiff * 100),
prodDocumented: prod.documented,
prodNotDocumented: prod.notDocumented,
branchDocumented: br.documented,
Expand All @@ -100,9 +101,9 @@ combineLatest([
report = 'No changes to documentation'
} else {
// convert the result to a markdown table with heading
report = `
| Package | Documentation Change |
| ------- | ----------------- |
report = await prettier.format(
`| Package | Documentation Change |
| ------- | ----------------- |
${res
.sort((a, b) => b.documentedChange - a.documentedChange)
.filter((r) => r.documentedChange !== 0)
Expand All @@ -114,34 +115,35 @@ combineLatest([
)
.join('\n')}
<details>
<summary>Full Report</summary>
${res
.sort((a, b) => b.documentedChange - a.documentedChange)
.map(
(r) =>
`<details>
<summary>${r.package}</summary>
<table>
<tr>
<th>This branch</th>
<th>Next branch</th>
</tr>
<tr>
<td>${r.branchDocumented} documented</td>
<td>${r.prodDocumented} documented</td>
</tr>
<tr>
<td>${r.branchNotDocumented} not documented</td>
<td>${r.prodNotDocumented} not documented</td>
</tr>
</table>
</details>
<details>
<summary>Full Report</summary>
${res
.sort((a, b) => b.documentedChange - a.documentedChange)
.map(
(r) =>
` <details>
<summary>${r.package}</summary>
<table>
<tr>
<th>This branch</th>
<th>Next branch</th>
</tr>
<tr>
<td>${r.branchDocumented} documented</td>
<td>${r.prodDocumented} documented</td>
</tr>
<tr>
<td>${r.branchNotDocumented} not documented</td>
<td>${r.prodNotDocumented} not documented</td>
</tr>
</table>
</details>`,
)
.join('\n')}
</details>
`,
)
.join('\n')}
</details>
`
{parser: 'markdown'},
)
}

// save it to a file
Expand Down

2 comments on commit bf50a77

@vercel
Copy link

@vercel vercel bot commented on bf50a77 Sep 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

performance-studio – ./

performance-studio.sanity.build
performance-studio-git-next.sanity.build

@vercel
Copy link

@vercel vercel bot commented on bf50a77 Sep 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

test-studio – ./

test-studio.sanity.build
test-studio-git-next.sanity.build

Please sign in to comment.