Skip to content

Commit

Permalink
ci: fix documentation coverage check (#8907)
Browse files Browse the repository at this point in the history
* ci: fix documentation coverage check

* fix

* fix: lock

* fix: node

* fix

* ci

* fix: ci
  • Loading branch information
chenjiahan authored Jan 2, 2025
1 parent f0a406f commit d2721e9
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 25 deletions.
9 changes: 4 additions & 5 deletions .github/workflows/reusable-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -375,11 +375,6 @@ jobs:
echo "===================================="
pnpm api-extractor:ci
# TODO: fixme
# - name: Documentation coverage check
# if: ${{ inputs.target == 'x86_64-unknown-linux-gnu' && !inputs.skipable }}
# run: pnpm doc-coverage

### write the latest metric into branch gh-pages
### Note that, We can't merge this script, because this script only runs on main branch
- name: Update main branch test compatibility metric
Expand All @@ -394,6 +389,10 @@ jobs:
github-token: ${{ secrets.GITHUB_TOKEN }}
sha: ${{ github.sha }}

- name: Documentation coverage check
if: ${{ inputs.target == 'x86_64-unknown-linux-gnu' && !inputs.skipable }}
run: pnpm doc-coverage

bench:
name: Bench
needs: build
Expand Down
3 changes: 2 additions & 1 deletion packages/rspack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"dev:js": "tsup --watch",
"prepare": "prebundle",
"prepare-container-runtime": "node ./scripts/prepare-container-runtime.js",
"doc-coverage": "node scripts/check-documentation-coverage.mjs",
"doc-coverage": "tsx ./scripts/check-documentation-coverage.ts",
"api-extractor": "api-extractor run --verbose",
"api-extractor:ci": "api-extractor run --verbose || diff temp/core.api.md etc/core.api.md"
},
Expand Down Expand Up @@ -62,6 +62,7 @@
"prebundle": "^1.1.0",
"tsc-alias": "^1.8.8",
"tsup": "^8.3.0",
"tsx": "^4.19.2",
"typescript": "^5.7.2",
"watchpack": "^2.4.0",
"webpack-dev-server": "5.0.4",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { basename, dirname, extname, join, resolve } from "node:path";
import { fileURLToPath } from "node:url";
import { ApiItemKind, ApiModel } from "@microsoft/api-extractor-model";
import { ZodObject, ZodOptional, ZodUnion } from "../compiled/zod/index.js";
import { rspackOptions } from "../dist/config/zod.js";
import { rspackOptions } from "../src/config/zod.ts";

const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
Expand All @@ -30,8 +30,8 @@ function toCamelCase(s) {

function extractMarkdownHeadings(markdown) {
const headingRegex = /^(#{1,6})\s+(.+)$/gm;
const headings = [];
let match;
const headings: string[] = [];
let match: RegExpExecArray | null;
while ((match = headingRegex.exec(markdown)) !== null) {
headings.push(match[2].trim());
}
Expand Down Expand Up @@ -108,8 +108,12 @@ function checkPluginsDocumentationCoverage() {
const implementedPlugins = getImplementedPlugins();
const documentedPlugins = getDocumentedPlugins();

const excludedPlugins = ["OriginEntryPlugin"];

const undocumentedPlugins = Array.from(implementedPlugins).filter(
plugin => !documentedPlugins.has(plugin)
plugin =>
!documentedPlugins.has(plugin) &&
!excludedPlugins.includes(plugin as string)
);
const unimplementedPlugins = Array.from(documentedPlugins).filter(
plugin => !implementedPlugins.has(plugin)
Expand Down Expand Up @@ -137,6 +141,12 @@ function checkPluginsDocumentationCoverage() {
}
}

type Section = {
title: string;
level: number;
text: string;
};

/**
* The process of checking the documentation coverage of Rspack configuration
*
Expand All @@ -151,7 +161,7 @@ function checkConfigsDocumentationCoverage() {
const CONFIG_DOCS_DIR = resolve(__dirname, "../../../website/docs/en/config");

function getImplementedConfigs() {
const implementedConfigs = [];
const implementedConfigs: string[] = [];
function visit(zod, path = "") {
if (zod instanceof ZodObject) {
for (const [key, schema] of Object.entries(zod.shape)) {
Expand Down Expand Up @@ -181,13 +191,15 @@ function checkConfigsDocumentationCoverage() {

function parseConfigDocuments() {
function parseMarkdownContent(content) {
const sections = [];
let section;
const sections: Section[] = [];
let section: Section | null = null;

const lines = content.split("\n");

for (let i = 0; i < lines.length; i++) {
const line = lines[i];
if (line.startsWith("#")) {
let level;
let level: number | undefined;
for (let j = 0; j < line.length; j++) {
if (level === undefined) {
if (line[j] !== "#") {
Expand All @@ -204,18 +216,18 @@ function checkConfigsDocumentationCoverage() {
.replace(/\\/g, "");
section = {
title: title.includes(".") ? title : toCamelCase(title),
level,
level: level!,
text: ""
};
sections.push(section);
sections.push(section!);
} else if (section) {
section.text += line;
}
}
return sections;
}

const sections = [];
const sections: Section[] = [];
function visitDir(dir) {
const items = readdirSync(dir, { withFileTypes: true });
for (const item of items) {
Expand Down Expand Up @@ -283,9 +295,9 @@ function checkConfigsDocumentationCoverage() {
].some(c => config.startsWith(c));
});
const markdownSections = parseConfigDocuments();

const undocumentedConfigs = [];
const undocumentedConfigs: string[] = [];
const map = new Map();

for (const config of implementedConfigs) {
let documented = false;
for (const section of markdownSections) {
Expand All @@ -296,8 +308,8 @@ function checkConfigsDocumentationCoverage() {
}
if (!documented) {
const parts = config.split(".");
const subs = [];
let part;
const subs: string[] = [];
let part: string | undefined;
while ((part = parts.pop())) {
subs.push(part);
const section = map.get(parts.join("."));
Expand Down
36 changes: 32 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions website/docs/en/plugins/webpack/internal-plugins.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -150,3 +150,9 @@ Internal plugins used with Module Federation, which are the basis of the `Module
### SharePlugin

`sharing.SharePlugin(options)`

## experiments

### RemoveDuplicateModulesPlugin

`experiments.RemoveDuplicateModulesPlugin()`
6 changes: 6 additions & 0 deletions website/docs/zh/plugins/webpack/internal-plugins.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -150,3 +150,9 @@ import WebpackLicense from '@components/WebpackLicense';
### SharePlugin

`sharing.SharePlugin(options)`

## experiments

### RemoveDuplicateModulesPlugin

`experiments.RemoveDuplicateModulesPlugin()`

1 comment on commit d2721e9

@github-actions
Copy link
Contributor

@github-actions github-actions bot commented on d2721e9 Jan 2, 2025

Choose a reason for hiding this comment

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

📝 Benchmark detail: Open

Name Base (2025-01-02 9a00d39) Current Change
10000_big_production-mode_disable-minimize + exec 37.3 s ± 234 ms 37.6 s ± 185 ms +0.64 %
10000_development-mode + exec 1.88 s ± 30 ms 1.83 s ± 22 ms -2.83 %
10000_development-mode_hmr + exec 680 ms ± 6.9 ms 688 ms ± 29 ms +1.28 %
10000_production-mode + exec 2.5 s ± 44 ms 2.47 s ± 21 ms -1.20 %
arco-pro_development-mode + exec 1.73 s ± 89 ms 1.75 s ± 68 ms +1.32 %
arco-pro_development-mode_hmr + exec 377 ms ± 2.7 ms 377 ms ± 1.5 ms -0.02 %
arco-pro_production-mode + exec 3.64 s ± 92 ms 3.53 s ± 114 ms -2.86 %
arco-pro_production-mode_generate-package-json-webpack-plugin + exec 3.67 s ± 155 ms 3.63 s ± 119 ms -0.99 %
arco-pro_production-mode_traverse-chunk-modules + exec 3.66 s ± 128 ms 3.59 s ± 105 ms -2.03 %
threejs_development-mode_10x + exec 1.52 s ± 22 ms 1.5 s ± 14 ms -1.35 %
threejs_development-mode_10x_hmr + exec 787 ms ± 34 ms 758 ms ± 15 ms -3.62 %
threejs_production-mode_10x + exec 5.37 s ± 95 ms 5.36 s ± 169 ms -0.16 %
10000_big_production-mode_disable-minimize + rss memory 9465 MiB ± 98.4 MiB 9520 MiB ± 38.1 MiB +0.59 %
10000_development-mode + rss memory 659 MiB ± 13.5 MiB 696 MiB ± 14.6 MiB +5.59 %
10000_development-mode_hmr + rss memory 1426 MiB ± 352 MiB 1509 MiB ± 319 MiB +5.78 %
10000_production-mode + rss memory 629 MiB ± 21.3 MiB 677 MiB ± 32.5 MiB +7.55 %
arco-pro_development-mode + rss memory 576 MiB ± 25.9 MiB 602 MiB ± 39.5 MiB +4.56 %
arco-pro_development-mode_hmr + rss memory 624 MiB ± 42 MiB 629 MiB ± 66 MiB +0.78 %
arco-pro_production-mode + rss memory 743 MiB ± 64.5 MiB 732 MiB ± 70.9 MiB -1.49 %
arco-pro_production-mode_generate-package-json-webpack-plugin + rss memory 743 MiB ± 39.9 MiB 752 MiB ± 55.4 MiB +1.22 %
arco-pro_production-mode_traverse-chunk-modules + rss memory 751 MiB ± 51.1 MiB 761 MiB ± 61 MiB +1.29 %
threejs_development-mode_10x + rss memory 613 MiB ± 23.4 MiB 632 MiB ± 29.8 MiB +3.16 %
threejs_development-mode_10x_hmr + rss memory 1175 MiB ± 68.7 MiB 1144 MiB ± 175 MiB -2.66 %
threejs_production-mode_10x + rss memory 857 MiB ± 44.9 MiB 906 MiB ± 38.1 MiB +5.70 %

Please sign in to comment.