@@ -27,25 +27,30 @@ const funcType = funcInfo.type;
2727const funcPair = funcInfo .pair ;
2828const funcPath = path .dirname (func .filePath ?? " " );
2929
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 ];
4434}
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+ });
4550
4651let 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 ;
4954}
5055
5156let funcSyntaxes = parseFunctionSyntaxes (func .id , func .data );
@@ -63,7 +68,7 @@ let funcSyntaxes = parseFunctionSyntaxes(func.id, func.data);
6368 )}
6469
6570 <!-- Description -->
66- { description && <Fragment set :html = { marked (description )} />}
71+ { funcInfo . description && <Fragment set :html = { marked (funcInfo . description )} />}
6772
6873 <!-- Notes -->
6974 { notesContent .length > 0 && (
@@ -79,7 +84,8 @@ let funcSyntaxes = parseFunctionSyntaxes(func.id, func.data);
7984 <!-- OOP Syntax -->
8085 { funcInfo .oop && (
8186 <>
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 >
8389 <ul >
8490 { funcInfo .oop .method && (
8591 <li >
@@ -105,17 +111,19 @@ let funcSyntaxes = parseFunctionSyntaxes(func.id, func.data);
105111 <strong >Counterpart:</strong > <a href = { ` /${funcPair } ` } >{ funcPair } </a >
106112 </li >
107113 )}
114+
108115 </ul >
116+ </div >
109117 </>
110118 )}
111119
112120 <!-- Syntaxes -->
113121 { funcSyntaxes .length > 0 && funcSyntaxes .map ((syntax : any ) => (
114122 <div class = " function-syntax" >
115123 { funcType === syntax .type && (
116- <h3 >Syntax</h3 >
124+ <h4 >Syntax</h4 >
117125 ) || (
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 >
119127 )}
120128 <Code code = { syntax .syntaxString } lang = " c" />
121129 { syntax .parameters .length > 0 && (
@@ -154,7 +162,7 @@ let funcSyntaxes = parseFunctionSyntaxes(func.id, func.data);
154162 </>
155163 )}
156164 { syntax .returns && (
157- <h5 >Returns</h5 >
165+ <h4 >Returns</h4 >
158166 <ul >
159167 { syntax .returns .values .map ((ret : any ) => (
160168 <li set :html = { " <strong>" + ret .type + " </strong>: " + renderInlineMarkdown (ret .name )} />
@@ -166,10 +174,10 @@ let funcSyntaxes = parseFunctionSyntaxes(func.id, func.data);
166174 ))}
167175
168176 <!-- Examples -->
169- { processedExamples .length > 0 && (
177+ { funcExamples .length > 0 && (
170178 <div class = " examples-section" >
171- <h3 >Code Examples</h3 >
172- { processedExamples .map ((example : any ) => (
179+ <h4 >Code Examples</h4 >
180+ { funcExamples .map ((example : any ) => (
173181 <div class = " function-example" >
174182 <Fragment set :html = { marked (example .description )} />
175183 <Code code = { example .luaCode } lang = " lua" />
0 commit comments