Skip to content

Commit 397f618

Browse files
committed
Add issues table to function page
1 parent 604d67e commit 397f618

File tree

3 files changed

+112
-87
lines changed

3 files changed

+112
-87
lines changed

web/src/pages/reference/[func].astro

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { Code } from '@astrojs/starlight/components';
99
import { MTA_CURRENT_VERSION } from '@src/content.constants';
1010
1111
import NoteBox from '@src/components/NoteBox.astro';
12-
import type { NotesType } from '@src/utils/types';
12+
import type { NotesType, IssuesTable } from '@src/utils/types';
1313
1414
import SeeAlsoSection from '@src/components/SeeAlsoSection.astro';
1515
import CodeExamplesSection from '@src/components/CodeExamplesSection.astro';
@@ -298,6 +298,26 @@ let funcSyntaxes = parseFunctionSyntaxes(func.id, func.data);
298298
<!-- Changelog -->
299299
<ChangelogList entries={changelogEntries} />
300300

301+
<!-- Issues -->
302+
{funcInfo.issues && funcInfo.issues.length > 0 && (
303+
<h4>Issues</h4>
304+
<table>
305+
<tbody>
306+
<tr>
307+
<th>ID</th>
308+
<th>Description</th>
309+
</tr>
310+
311+
{funcInfo.issues.map((issue) => (
312+
<tr>
313+
<td><a href={`https://github.com/multitheftauto/mtasa-blue/issues/${issue.id}`}>{issue.id}</a></td>
314+
<td>{issue.description}</td>
315+
</tr>
316+
))}
317+
</tbody>
318+
</table>
319+
)}
320+
301321
<SeeAlsoSection seeAlsoLinks={getSeeAlsoLinksForItem(func)} currentId={func.id} />
302322
</StarlightPage>
303323
</div>

web/src/utils/functions.ts

Lines changed: 1 addition & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,7 @@
11
import { getCollection } from 'astro:content';
22
import path from 'path';
33

4-
import type { FunctionType, NotesType } from './types';
5-
6-
type FunctionItem = Awaited<ReturnType<typeof getCollection>>[number];
7-
8-
type BaseOOP = {
9-
element: string;
10-
note?: string;
11-
};
12-
13-
// /!\ constructor is a reserved word in JS/TS, so we use constructorclass
14-
type MethodOOP = BaseOOP & {
15-
method: string;
16-
static: boolean;
17-
variable?: string;
18-
constructorclass?: never; // mutually exclusive with constructor
19-
};
20-
21-
type ConstructorOOP = BaseOOP & {
22-
constructorclass: string;
23-
method?: never; // mutually exclusive with method
24-
static?: never;
25-
variable?: never;
26-
};
27-
28-
export type OOPInfo = MethodOOP | ConstructorOOP;
29-
30-
export type FunctionInfo = {
31-
description: string;
32-
incomplete?: boolean;
33-
type: FunctionType;
34-
typePretty: string;
35-
pair?: string;
36-
preview_images?: string[];
37-
oop?: OOPInfo;
38-
notes?: NotesType;
39-
version?: VersionInfo
40-
};
41-
42-
type VersionInfo = {
43-
added?: string;
44-
updated?: string;
45-
removed?: string;
46-
};
47-
48-
type FunctionsByCategory = {
49-
[folder: string]: FunctionItem[];
50-
};
51-
type FunctionsByTypeByCategory = {
52-
[key in FunctionType]: FunctionsByCategory;
53-
};
54-
55-
56-
export type FunctionData = {
57-
shared?: any;
58-
client?: any;
59-
server?: any;
60-
};
4+
import type { FunctionData, FunctionInfo, FunctionsByCategory, FunctionsByTypeByCategory, FunctionType, Parameter, ReturnBlock, Syntax } from './types';
615

626
export const functionTypePrettyName = {
637
'client': 'Client-side',
@@ -75,34 +19,6 @@ function getFunctionTypePretty(data: FunctionData): string {
7519
return functionTypePrettyName[funcType];
7620
}
7721

78-
79-
type Parameter = {
80-
name: string;
81-
type: string;
82-
description: string;
83-
default?: string;
84-
templateList?: string;
85-
};
86-
87-
type ReturnValue = {
88-
type: string;
89-
name: string;
90-
templateList?: string;
91-
};
92-
93-
type ReturnBlock = {
94-
description?: string;
95-
values: ReturnValue[];
96-
};
97-
98-
type Syntax = {
99-
type: 'shared' | 'server' | 'client';
100-
parameters: Parameter[];
101-
returns: ReturnBlock | null;
102-
syntaxString: string;
103-
};
104-
105-
10622
// return_type func_name ( param1, param2, [ optional param1 ] )
10723
// e.g. bool setCursorPosition ( int cursorX, int cursorY )
10824
function buildSyntaxString(

web/src/utils/types.ts

Lines changed: 90 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,95 @@
1+
import type { getCollection } from "astro:content";
2+
13
export type FunctionType = 'shared' | 'client' | 'server';
24
export type NotesTypeType = 'info' | 'warning' | 'important' | 'tip' | 'needs_checking';
35
export type NotesType = {
46
type: NotesTypeType
57
content: string;
6-
}[];
8+
}[];
9+
10+
export type FunctionItem = Awaited<ReturnType<typeof getCollection>>[number];
11+
12+
export type BaseOOP = {
13+
element: string;
14+
note?: string;
15+
};
16+
17+
// /!\ constructor is a reserved word in JS/TS, so we use constructorclass
18+
export type MethodOOP = BaseOOP & {
19+
method: string;
20+
static: boolean;
21+
variable?: string;
22+
constructorclass?: never; // mutually exclusive with constructor
23+
};
24+
25+
export type ConstructorOOP = BaseOOP & {
26+
constructorclass: string;
27+
method?: never; // mutually exclusive with method
28+
static?: never;
29+
variable?: never;
30+
};
31+
32+
export type OOPInfo = MethodOOP | ConstructorOOP;
33+
34+
export type FunctionInfo = {
35+
description: string;
36+
incomplete?: boolean;
37+
type: FunctionType;
38+
typePretty: string;
39+
pair?: string;
40+
preview_images?: string[];
41+
oop?: OOPInfo;
42+
notes?: NotesType;
43+
version?: VersionInfo;
44+
issues?: IssuesTable;
45+
};
46+
47+
export type FunctionData = {
48+
shared?: any;
49+
client?: any;
50+
server?: any;
51+
};
52+
53+
export type VersionInfo = {
54+
added?: string;
55+
updated?: string;
56+
removed?: string;
57+
};
58+
59+
export type IssuesTable = {
60+
id: number|string
61+
description: string
62+
}[];
63+
64+
export type FunctionsByCategory = {
65+
[folder: string]: FunctionItem[];
66+
};
67+
export type FunctionsByTypeByCategory = {
68+
[key in FunctionType]: FunctionsByCategory;
69+
};
70+
71+
export type Parameter = {
72+
name: string;
73+
type: string;
74+
description: string;
75+
default?: string;
76+
templateList?: string;
77+
};
78+
79+
export type ReturnValue = {
80+
type: string;
81+
name: string;
82+
templateList?: string;
83+
};
84+
85+
export type ReturnBlock = {
86+
description?: string;
87+
values: ReturnValue[];
88+
};
89+
90+
export type Syntax = {
91+
type: 'shared' | 'server' | 'client';
92+
parameters: Parameter[];
93+
returns: ReturnBlock | null;
94+
syntaxString: string;
95+
};

0 commit comments

Comments
 (0)