@@ -27,25 +27,30 @@ const funcType = funcInfo.type;
27
27
const funcPair = funcInfo .pair ;
28
28
const funcPath = path .dirname (func .filePath ?? " " );
29
29
30
- const { description, notes : funcNotes, examples : rawExamples } = funcInfo ;
31
-
32
- let processedExamples: any [] = [];
33
- if (Array .isArray (rawExamples ) && rawExamples .length > 0 ) {
34
- processedExamples = rawExamples .map ((example : any ) => {
35
- try {
36
- const exampleFilePath = path .resolve (funcPath , example .path );
37
- const luaCode = fs .readFileSync (exampleFilePath , " utf8" );
38
- return { ... example , luaCode };
39
- } catch (error ) {
40
- console .error (` Error reading example file ${example .path } at ${path .resolve (funcPath , example .path )}: ` , error );
41
- return { ... example , luaCode: ` Error loading example: ${example .path } ` };
42
- }
43
- });
30
+ // join shared, client and server examples (in func.data) if any
31
+ let funcExamples = [];
32
+ if (func .data .shared && func .data .shared .examples ) {
33
+ funcExamples = [... funcExamples , ... func .data .shared .examples ];
44
34
}
35
+ if (func .data .client && func .data .client .examples ) {
36
+ funcExamples = [... funcExamples , ... func .data .client .examples ];
37
+ }
38
+ if (func .data .server && func .data .server .examples ) {
39
+ funcExamples = [... funcExamples , ... func .data .server .examples ];
40
+ }
41
+ funcExamples = funcExamples .map ((example : any ) => {
42
+ try {
43
+ const luaCode = fs .readFileSync (path .resolve (` ${funcPath } ` , example .path ), " utf8" );
44
+ return { ... example , luaCode };
45
+ } catch (error ) {
46
+ console .error (` Error reading ${example .path }: ` , error );
47
+ return { ... example , luaCode: " Loading example error." };
48
+ }
49
+ });
45
50
46
51
let notesContent: NotesType = [];
47
- if (Array .isArray (funcNotes ) && funcNotes .length > 0 ) {
48
- notesContent = funcNotes ;
52
+ if (Array .isArray (funcInfo . notes ) && funcInfo . notes .length > 0 ) {
53
+ notesContent = funcInfo . notes ;
49
54
}
50
55
51
56
let funcSyntaxes = parseFunctionSyntaxes (func .id , func .data );
@@ -63,7 +68,7 @@ let funcSyntaxes = parseFunctionSyntaxes(func.id, func.data);
63
68
)}
64
69
65
70
<!-- Description -->
66
- { description && <Fragment set :html = { marked (description )} />}
71
+ { funcInfo . description && <Fragment set :html = { marked (funcInfo . description )} />}
67
72
68
73
<!-- Notes -->
69
74
{ notesContent .length > 0 && (
@@ -79,7 +84,8 @@ let funcSyntaxes = parseFunctionSyntaxes(func.id, func.data);
79
84
<!-- OOP Syntax -->
80
85
{ funcInfo .oop && (
81
86
<>
82
- <h3 >OOP Syntax <a class = " small-text" href = " /OOP_Introduction" >Help! I don't understand this!</a ></h3 >
87
+ <div class = " function-oop" >
88
+ <h4 >OOP Syntax <a class = " small-text" href = " /OOP_Introduction" >Help! I don't understand this!</a ></h4 >
83
89
<ul >
84
90
{ funcInfo .oop .method && (
85
91
<li >
@@ -105,17 +111,19 @@ let funcSyntaxes = parseFunctionSyntaxes(func.id, func.data);
105
111
<strong >Counterpart:</strong > <a href = { ` /${funcPair } ` } >{ funcPair } </a >
106
112
</li >
107
113
)}
114
+
108
115
</ul >
116
+ </div >
109
117
</>
110
118
)}
111
119
112
120
<!-- Syntaxes -->
113
121
{ funcSyntaxes .length > 0 && funcSyntaxes .map ((syntax : any ) => (
114
122
<div class = " function-syntax" >
115
123
{ funcType === syntax .type && (
116
- <h3 >Syntax</h3 >
124
+ <h4 >Syntax</h4 >
117
125
) || (
118
- <h3 >{ syntax .type .charAt (0 ).toUpperCase () + syntax .type .slice (1 )} Syntax</h3 >
126
+ <h4 >{ syntax .type .charAt (0 ).toUpperCase () + syntax .type .slice (1 )} Syntax</h4 >
119
127
)}
120
128
<Code code = { syntax .syntaxString } lang = " c" />
121
129
{ syntax .parameters .length > 0 && (
@@ -154,7 +162,7 @@ let funcSyntaxes = parseFunctionSyntaxes(func.id, func.data);
154
162
</>
155
163
)}
156
164
{ syntax .returns && (
157
- <h5 >Returns</h5 >
165
+ <h4 >Returns</h4 >
158
166
<ul >
159
167
{ syntax .returns .values .map ((ret : any ) => (
160
168
<li set :html = { " <strong>" + ret .type + " </strong>: " + renderInlineMarkdown (ret .name )} />
@@ -166,10 +174,10 @@ let funcSyntaxes = parseFunctionSyntaxes(func.id, func.data);
166
174
))}
167
175
168
176
<!-- Examples -->
169
- { processedExamples .length > 0 && (
177
+ { funcExamples .length > 0 && (
170
178
<div class = " examples-section" >
171
- <h3 >Code Examples</h3 >
172
- { processedExamples .map ((example : any ) => (
179
+ <h4 >Code Examples</h4 >
180
+ { funcExamples .map ((example : any ) => (
173
181
<div class = " function-example" >
174
182
<Fragment set :html = { marked (example .description )} />
175
183
<Code code = { example .luaCode } lang = " lua" />
0 commit comments