1
1
---
2
2
import StarlightPage from ' @astrojs/starlight/components/StarlightPage.astro' ;
3
3
import { getCollection } from ' astro:content' ;
4
- import { getFunctionInfo } from ' @src/utils/functions' ;
4
+ import { getFunctionInfo , parseFunctionSyntaxes } from ' @src/utils/functions' ;
5
+ import { renderInlineMarkdown } from ' @src/utils/general' ;
5
6
import { marked } from ' marked' ;
6
7
import fs from " fs" ;
7
8
import path from " path" ;
@@ -47,6 +48,7 @@ if (Array.isArray(funcNotes) && funcNotes.length > 0) {
47
48
notesContent = funcNotes ;
48
49
}
49
50
51
+ let funcSyntaxes = parseFunctionSyntaxes (func .id , func .data );
50
52
---
51
53
52
54
<div class ={ " show-type-badge-" + funcType } >
@@ -64,22 +66,111 @@ if (Array.isArray(funcNotes) && funcNotes.length > 0) {
64
66
{ description && <Fragment set :html = { marked (description )} />}
65
67
66
68
<!-- Notes -->
67
- <div class =" notes-section" >
68
- { notesContent .map ((note ) => (
69
- <NoteBox type = { note .type } >
70
- <Fragment set :html = { marked (note .content )} />
71
- </NoteBox >
72
- ))}
73
- </div >
69
+ { notesContent .length > 0 && (
70
+ <div class = " notes-section" >
71
+ { notesContent .map ((note ) => (
72
+ <NoteBox type = { note .type } >
73
+ <Fragment set :html = { marked (note .content )} />
74
+ </NoteBox >
75
+ ))}
76
+ </div >
77
+ )}
78
+
79
+ <!-- OOP Syntax -->
80
+ { funcInfo .oop && (
81
+ <>
82
+ <h5 >OOP Syntax <a class = " small-text" href = " /OOP_Introduction" >Help! I don't understand this!</a ></h5 >
83
+ <ul >
84
+ { funcInfo .oop .method && (
85
+ <li >
86
+ <strong >Method:</strong >{ ' ' }
87
+ <a href = { ` /${funcInfo .oop .entity } ` } >{ funcInfo .oop .entity } </a >{ funcInfo .oop .static ? ' .' : ' :' } { funcInfo .oop .method } (...)
88
+ </li >
89
+ )}
90
+
91
+ { funcInfo .oop .variable && (
92
+ <li >
93
+ <strong >Variable:</strong > .{ funcInfo .oop .variable }
94
+ </li >
95
+ )}
96
+
97
+ { funcInfo .oop .constructorclass && (
98
+ <li >
99
+ <strong >Constructor:</strong > { funcInfo .oop .constructorclass } (...)
100
+ </li >
101
+ )}
102
+
103
+ { funcPair && (
104
+ <li >
105
+ <strong >Counterpart:</strong > <a href = { ` /${funcPair } ` } >{ funcPair } </a >
106
+ </li >
107
+ )}
108
+ </ul >
109
+ </>
110
+ )}
111
+
112
+ <!-- Syntaxes -->
113
+ { funcSyntaxes .length > 0 && funcSyntaxes .map ((syntax : any ) => (
114
+ <div class = " function-syntax" >
115
+ { funcType === syntax .type && (
116
+ <h3 >Syntax</h3 >
117
+ ) || (
118
+ <h3 >{ syntax .type .charAt (0 ).toUpperCase () + syntax .type .slice (1 )} Syntax</h3 >
119
+ )}
120
+ <Code code = { syntax .syntaxString } lang = " c" />
121
+ { syntax .parameters .length > 0 && (
122
+ <>
123
+ { syntax .parameters .some ((param : any ) => ! param .default ) && (
124
+ <>
125
+ <h5 >Required Arguments</h5 >
126
+ <ul >
127
+ { syntax .parameters
128
+ .filter ((param : any ) => ! param .default )
129
+ .map ((param : any ) => (
130
+ <li
131
+ set :html = { ` <strong>${param .name }</strong>: ${renderInlineMarkdown (param .description )} ` }
132
+ />
133
+ ))}
134
+ </ul >
135
+ </>
136
+ )}
137
+
138
+ { syntax .parameters .some ((param : any ) => param .default ) && (
139
+ <>
140
+ <h5 >Optional Arguments</h5 >
141
+ <ul >
142
+ { syntax .parameters
143
+ .filter ((param : any ) => param .default )
144
+ .map ((param : any ) => (
145
+ <li
146
+ set :html = { ` <strong>${param .name }</strong>: ${renderInlineMarkdown (param .description )} ` }
147
+ />
148
+ ))}
149
+ </ul >
150
+ </>
151
+ )}
152
+ </>
153
+ )}
154
+ { syntax .returns && (
155
+ <h5 >Returns</h5 >
156
+ <ul >
157
+ { syntax .returns .values .map ((ret : any ) => (
158
+ <li set :html = { " <strong>" + ret .type + " </strong>: " + renderInlineMarkdown (ret .name )} />
159
+ ))}
160
+ </ul >
161
+ <Fragment set :html = { marked (syntax .returns .description )} />
162
+ )}
163
+ </div >
164
+ ))}
74
165
75
166
<!-- Examples -->
76
167
{ processedExamples .length > 0 && (
77
168
<div class = " examples-section" >
78
- <h3 >Exemplos </h3 >
169
+ <h3 >Code Examples </h3 >
79
170
{ processedExamples .map ((example : any ) => (
80
171
<div class = " function-example" >
81
172
<Fragment set :html = { marked (example .description )} />
82
- <Code code = { example .luaCode } lang = " lua" title = { path . basename ( example . path ) } />
173
+ <Code code = { example .luaCode } lang = " lua" />
83
174
</div >
84
175
))}
85
176
</div >
0 commit comments