You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/src/modules/2-bundle/4-conventions/1-basic.md
+17-2Lines changed: 17 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -29,7 +29,7 @@ Neither default nor rest parameters are currently supported due to an [issue](ht
29
29
30
30
## 2. Cadet facing functions should not use array destructuring for parameters
31
31
32
-
Javascript allows us to pass destruct iterables directly within the function declaration:
32
+
Javascript allows us to destruct iterables directly within a function's parameters:
33
33
34
34
```ts
35
35
exportfunction foo([x, y]: [string, string]) {
@@ -124,7 +124,22 @@ Lists are actually introduced in Source 1, which would make the above function c
124
124
functionality specific to arrays, then consider using Source Lists instead.
125
125
:::
126
126
127
-
## 4. Making use of `js-slang/stdlib`
127
+
## 4. Semantic Versioning
128
+
129
+
[Semantic Versioning](https://semver.org) refers to a convention on how version numbers should be specified. In your bundle's `package.json`, a `version` field should
130
+
be specified:
131
+
132
+
```jsonc {3}
133
+
{
134
+
"name": "@sourceacademy/bundle-bundle0",
135
+
"version": "1.0.0"
136
+
}
137
+
```
138
+
139
+
This version number should follow the rules of semantic versioning. `js-slang` will use this version number to determine if it currently has the latest version of your bundle
140
+
compatible with its current version.
141
+
142
+
## 5. Making use of `js-slang/stdlib`
128
143
129
144
Bundles, where necessary, should use the implementations of libraries such as `list` or `stream` from the `js-slang` standard library:
Copy file name to clipboardExpand all lines: docs/src/modules/2-bundle/5-documentation/5-documentation.md
+78-56Lines changed: 78 additions & 56 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,7 +11,11 @@ By reading comments and type annotations, `typedoc` is able to generate both hum
11
11
12
12
## Writing Documentation
13
13
14
-
`typedoc` reads both Typescript type annotations, as well as [TSDOC](https://tsdoc.org) style comments. It will build documentation for all functions and constants exported by the particular module.
14
+
`typedoc` reads both Typescript type annotations, as well as [TSDOC](https://tsdoc.org) style comments. It will build documentation for all functions and constants exported by the particular bundle's entry point.
15
+
For example, since the `curve` bundle exports the `make_point` function, `typedoc` will generate documentation for it. However, there are many other functions that the bundle does not expose that won't have documentation generated.
16
+
17
+
Documentation should be written in [Markdown](https://www.markdownguide.org/getting-started/). That way, both IntelliSense and Typedoc will be able to process it. During documentation generation,
18
+
the markdown is converted to raw HTML.
15
19
16
20
::: details Type Aware annotations
17
21
[JSDoc](https://jsdoc.app) (and TSDoc) both support annotations that express type information directly like `@type` or annotations that can optionally contain type information like `@param` and `@returns`.
@@ -23,7 +27,9 @@ so as not to confuse Typedoc and ensure that the Typescript compiler is able to
23
27
If you do need to the type of an export to be documented differently from its type in Typescript source code, you can use a [type map](../7-type_map).
24
28
:::
25
29
26
-
Let us look at an example from the `curve` module.
30
+
Let us look at more examples from the `curve` module.
31
+
32
+
### Functions
27
33
28
34
```ts
29
35
// functions.ts
@@ -43,66 +49,21 @@ export function make_point(x: number, y: number): Point {
43
49
}
44
50
```
45
51
46
-
```ts
47
-
// index.ts
48
-
export { make_point } from'./functions.ts';
49
-
```
50
-
51
-
Since the `curve` bundle exports the `make_point` function, `typedoc` will generate documentation for it.
52
-
53
-
Documentation should be written in [Markdown](https://www.markdownguide.org/getting-started/). That way, both IntelliSense and Typedoc will be able to process it. During documentation generation,
54
-
the markdown is converted to raw HTML.
55
-
56
-
The following sections are conventions for writing documentation.
57
-
58
-
### Entry Point
59
-
60
-
At the entry point for each bundle, there should be a block comment that provides general information about the bundle.
61
-
62
-
This example is taken from the `repeat` bundle:
52
+
Notice that in the example above, each `@param` tag is followed directly by the name of the parameter its describing, which is then followed
53
+
by the description of the parameter itself.
63
54
55
+
Missing the documentation for a parameter is okay (not that you should), but trying to document a parameter that doesn't exist will cause a linting
56
+
error:
64
57
```ts
65
-
// repeat/src/index.ts
66
58
/**
67
-
* Test bundle for Source Academy modules repository
68
-
* @authorLoh Xian Ze, Bryan
69
-
* @authorTang Xin Kye, Marcus
70
-
* @modulerepeat
59
+
* Oops p1 isn't documented!
60
+
* @paramp3 This parameter doesn't exist and so this will cause a lint error!
This causes `type_map` to be removed from the documentation, even if it is exported from `rune/src/index.ts`.
101
-
102
-
> [!WARNING]
103
-
> Bundle `type_map`s are supposed to be internal implementation details hidden from users. If you forget to apply a `@hidden` tag to
104
-
> your bundle's type map export, the build tools will show a warning.
105
-
106
67
### Use of `@function`
107
68
108
69
Following v0.28, Typedoc only documents function-like types as functions if they are explicitly typed as functions (see the issue [here](https://github.com/TypeStrong/typedoc/issues/2881)).
@@ -168,6 +129,67 @@ The export will now be correctly recognized as a function:
168
129
169
130
There is no automatic way to make this distinction, so it is up to the bundle authors to make sure that this convention is adhered to.
170
131
132
+
### Variables/Constants
133
+
134
+
Constants can be documented in a similar fashion:
135
+
```ts
136
+
/**
137
+
* Represents the mathematical constant PI
138
+
*/
139
+
const PI:number=3.14159;
140
+
```
141
+
142
+
Also similar to function return types and parameters, because the types of variables is determined by the Typescript compiler, it is unnecessary
143
+
to use the `@type` tag here.
144
+
145
+
### Entry Point
146
+
147
+
At the entry point for each bundle, there should be a block comment that provides general information about the bundle.
148
+
149
+
This example is taken from the `repeat` bundle:
150
+
151
+
```ts
152
+
// repeat/src/index.ts
153
+
/**
154
+
* Test bundle for Source Academy modules repository
This causes `type_map` to be removed from the documentation, even if it is exported from `rune/src/index.ts`.
188
+
189
+
> [!WARNING]
190
+
> Bundle `type_map`s are supposed to be internal implementation details hidden from users. If you forget to apply a `@hidden` tag to
191
+
> your bundle's type map export, the build tools will show a warning.
192
+
171
193
### Other Tags
172
194
173
195
There are a variety of tags that Typedoc supports. This list can be found [here](https://typedoc.org/documents/Tags.html). When writing your documentation you should use these tags
0 commit comments