Skip to content

Commit

Permalink
Merge pull request #2084 from umijs/feature/2.3.0
Browse files Browse the repository at this point in the history
chore: merge feature into master
  • Loading branch information
PeachScript committed Apr 26, 2024
2 parents e3ce9b4 + efc6e20 commit 8b1a512
Show file tree
Hide file tree
Showing 200 changed files with 52,927 additions and 4,410 deletions.
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/dist
/compiled
/theme-default
/suites/*/compiled
/suites/preset-vue/lib
6 changes: 6 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
module.exports = {
extends: require.resolve('@umijs/lint/dist/config/eslint'),
rules: {
'@typescript-eslint/no-unused-vars': [
'error',
{ ignoreRestSiblings: true },
],
},
};
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@
/target
/compiled/crates
.swc
/server
25 changes: 20 additions & 5 deletions assets-types/typings/atom/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import type { ObjectPropertySchema, PropertySchema } from './props';
import type {
FunctionArgSchema,
ObjectPropertySchema,
PropertySchema,
} from './props';

/**
* base atom asset
Expand Down Expand Up @@ -41,6 +45,20 @@ export interface AtomComponentAsset extends AtomBaseAsset {
* props definition of component
*/
propsConfig: ObjectPropertySchema;
/**
* slots definition of component
*/
slotsConfig?: ObjectPropertySchema;
/**
* events definition of component
*/
eventsConfig?: ObjectPropertySchema;
/**
* Whether it is methods and properties exposed by component instances,
* or common functional calls, such as Popup.open().
* Such imperative methods and properties should be classified under this configuration
*/
imperativeConfig?: ObjectPropertySchema;

/**
* available parent components of component
Expand Down Expand Up @@ -77,10 +95,7 @@ export interface AtomFunctionAsset extends AtomBaseAsset {
/**
* arguments of function
*/
arguments: {
key: string;
schema: PropertySchema;
}[];
arguments: FunctionArgSchema[];

/**
* return value of function
Expand Down
53 changes: 52 additions & 1 deletion assets-types/typings/atom/props/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,25 @@
import type { BuiltinTags } from './jsdoc';
import type { TypeMap } from './types';

export interface PropertySourceReference {
/**
* fileName of the source file
*/
fileName: string;
/**
* The one based number of the line that emitted the declaration
*/
line: number;
/**
* The index of the character that emitted the declaration
*/
character: number;
/**
* URL for displaying source file, usually the git repo file URL
*/
url?: string;
}

/**
* base props definition
*/
Expand All @@ -25,6 +44,10 @@ export interface BasePropertySchema<T extends keyof TypeMap = keyof TypeMap> {
* value type of prop
*/
type?: T;
/**
* the full name of the type
*/
className?: string;
/**
* const value of prop
*/
Expand All @@ -50,6 +73,10 @@ export interface BasePropertySchema<T extends keyof TypeMap = keyof TypeMap> {
* extra jsdoc tags
*/
tags?: BuiltinTags & Record<string, any>;
/**
* source of prop
*/
source?: PropertySourceReference[];
}

/**
Expand Down Expand Up @@ -115,13 +142,37 @@ export interface ObjectPropertySchema extends BasePropertySchema {
required?: string[];
}

export interface ReferencePropertySchema extends BasePropertySchema {
type: 'reference';
name: string;
typeParameters?: PropertySchema[];
externalUrl: string;
}

export interface FunctionArgSchema {
key: string;
schema: PropertySchema;
hasQuestionToken?: boolean;
}

export interface FunctionPropertySchema extends BasePropertySchema {
type: 'function';
signature: {
isAsync: boolean;
returnType: PropertySchema;
arguments: FunctionArgSchema[];
};
}

/**
* prop definition
*/
export type PropertySchema =
| BasePropertySchema
| ObjectPropertySchema
| ArrayPropertySchema
| FunctionPropertySchema
| StringPropertySchema
| NumberPropertySchema
| BooleanPropertySchema;
| BooleanPropertySchema
| ReferencePropertySchema;
4 changes: 4 additions & 0 deletions assets-types/typings/example.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ export interface ExampleBlockAsset extends ExampleBaseAsset {
value: string;
}
>;
/**
* Entry file name, you can find the relevant entry file content from `dependencies`
*/
entry?: string;
}

/**
Expand Down
2 changes: 2 additions & 0 deletions docs/config/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ export default () => '我会被编译,展示为组件';

`resolveFilter` 配置项用于跳过指定原子资产的解析以提升性能。部分组件属性或函数签名存在多层嵌套,甚至是循环引用时,会导致解析结果巨大,此时可以通过该配置项跳过解析。

上述配置是默认 React 解析器的配置, dumi 也提供方法覆盖原有解析器,具体可查看[API Table 支持](../plugin/techstack.md#api-table-支持)

### autoAlias

- 类型:`boolean`
Expand Down
63 changes: 63 additions & 0 deletions docs/guide/markdown.md
Original file line number Diff line number Diff line change
Expand Up @@ -237,3 +237,66 @@ features:
</li>
</ul>
</Tree>

## CodeGroup <Badge>2.3.0+</Badge>

需要将多代码块合并成一个分组进行展示时,可以使用 CodeGroup 语法,例如:

```jsx
/**
* inline: true
*/
import SourceCode from 'dumi/theme/builtins/SourceCode';
const content = `
:::code-group
\`\`\`bash [npm]
npm install -D dumi
\`\`\`
\`\`\`bash [yarn]
yarn add -D dumi
\`\`\`
\`\`\`bash [pnpm]
pnpm add -D dumi
\`\`\`
\`\`\`ts [.dumirc.ts] {3}
import { defineConfig } from 'dumi';
export default defineConfig({
// ...
});
\`\`\`
:::
`.trim();

export default () => <SourceCode lang="markdown">{content}</SourceCode>;
```

将会被渲染为:

:::code-group

```bash [npm]
npm install -D dumi
```

```bash [yarn]
yarn add -D dumi
```

```bash [pnpm]
pnpm add -D dumi
```

```ts [.dumirc.ts] {3}
import { defineConfig } from 'dumi';

export default defineConfig({
// ...
});
```

:::

0 comments on commit 8b1a512

Please sign in to comment.