MCPcopy Index your code
hub / github.com/alibaba/lowcode-engine / parse

Function parse

modules/material-parser/src/parse/js/index.ts:9–42  ·  view source on GitHub ↗
(filePath: string)

Source from the content-addressed store, hash-verified

7const reactDocs = require('react-docgen');
8
9export default function parse(filePath: string): IMaterialParsedModel[] {
10 if (!filePath) return [];
11 const fileContent = loadFile(filePath);
12 const result = reactDocs.parse(
13 fileContent,
14 (ast: any) => {
15 ast.__path = filePath;
16 return resolver(ast);
17 },
18 handlers,
19 {
20 filename: filePath,
21 },
22 );
23 const coms = result.reduce((res: any[], info: any) => {
24 if (!info || !info.props) return res;
25 const props = Object.keys(info.props).reduce((acc: any[], name) => {
26 try {
27 const item: any = transformItem(name, info.props[name]);
28 acc.push(item);
29 } catch (e) {
30 // TODO
31 }
32 return acc;
33 }, []);
34 res.push({
35 componentName: info.displayName,
36 props,
37 meta: info.meta || {},
38 });
39 return res;
40 }, []);
41 return coms;
42}

Callers 6

index.test.tsFile · 0.85
online.test.tsFile · 0.85
dynamic.test.tsFile · 0.85
index.tsFile · 0.85
parse-tsx.jsFile · 0.85
parse-jsx.jsFile · 0.85

Calls 5

loadFileFunction · 0.90
transformItemFunction · 0.90
parseMethod · 0.80
pushMethod · 0.80
reduceMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…