Skip to content

Commit b0e067e

Browse files
committed
doc: misc doc additions
1 parent 16b1649 commit b0e067e

File tree

3 files changed

+121
-0
lines changed

3 files changed

+121
-0
lines changed

doc/uncategorized/README.md

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Uncategorized Documentation
2+
3+
Any document in this directory may be moved in the future to
4+
a more suitable location. This is a good place to put any
5+
documentation that needs to be written when it's unclear what
6+
the best place for it is. This is to avoid situations where
7+
documentation _doesn't_ get written simply because it's not clear
8+
where it belongs (something which the author of this very document
9+
has been guilty of at times).

doc/uncategorized/es6-note.md

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Notes about ES6 Class Syntax
2+
3+
## Document Meta
4+
5+
> **backend focus:** This documentation is more relevant to
6+
> Puter's backend than frontend, but is placed here because
7+
> it could apply to other areas in the future.
8+
9+
## Expressions as Methods
10+
11+
One important shortcoming in the ES6 class syntax to be aware of
12+
is that it discourages the use of expressions as methods.
13+
14+
For example:
15+
16+
```javascript
17+
class ExampleClass extends SomeBase {
18+
intuitive_method_definition () {}
19+
20+
constructor () {
21+
this.less_intuitive = some_expr();
22+
}
23+
}
24+
```
25+
26+
Even if it is known that the return type of `some_expr` is a function,
27+
it is still unclear whether it's being used as a callback or
28+
as a method without other context in the code, since this is
29+
how we typically assign instance members rather than methods.
30+
31+
We solve this in Puter's backend using a **trait** called
32+
[AssignableMethodsTrait](../../packages/backend/src/traits/AssignableMethodsTrait.js)
33+
which allows a static member called `METHODS` to contain
34+
method definitions.
35+
36+
### Uses for Expressions as Methods
37+
38+
#### Method Composition
39+
40+
Method Composition is the act of composing methods from other
41+
constituents. For example,
42+
[Sequence](../../packages/backend/src/codex/Sequence.js)
43+
allows composing a method from smaller functions, allowing
44+
easier definition of "in-betwewen-each" behaviors and ways
45+
to track which values from the arguments are actually read
46+
during a particular call.

doc/uncategorized/puter-mods.md

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# Puter Mods
2+
3+
## What is a Puter Mod?
4+
5+
Currently, the definition of a Puter mod is:
6+
7+
> A [Module](../../packages/backend/doc/contributors/modules.md)
8+
> which is exported by a package directory which itself exists
9+
> within a directory specified in the `mod_directories` array
10+
> in `config.json`.
11+
12+
## Enabling Puter Mods
13+
14+
### Step 1: Update Configuration
15+
16+
First update the configuration (usually at `./volatile/config.json`
17+
or `/var/puter/config.json`) to specify mod directories.
18+
19+
```json
20+
{
21+
"config_name": "example config",
22+
23+
"mod_directories": [
24+
"{source}/mods/mods_enabled"
25+
]
26+
27+
// ... other config options
28+
}
29+
```
30+
31+
The first path you'll want to add is
32+
`"{source}/mods/mods_enabled"`
33+
which adds all the mods included in Puter's official repository.
34+
You don't need to change `{source}` unless your entry javascript
35+
file is in a different location than the default.
36+
37+
If you want to enable all the mods, you can change the path above
38+
to `mods_available` instead and skip step 2 below.
39+
40+
### Step 2: Select Mods
41+
42+
To enable a Puter mod, create a symbolic link (AKA symlink) in
43+
`mods/mods_enabled`, pointing to
44+
a directory in `mods/mods_available`. This follows the same convention
45+
as managing sites/mods in Apache or Nginx servers.
46+
47+
For example to enable KDMOD (which you can read as "Kernel Dev" mod,
48+
or "the mod that GitHub user KernelDeimos created to help with testing")
49+
you would run this command:
50+
```sh
51+
ln -rs ./mods/mods_available/kdmod ./mods/mods_enabled/
52+
```
53+
54+
This will create a symlink at `./mods/mods_enabled/kdmod` pointing
55+
to the directory `./mods/mods_available/kdmod`.
56+
57+
> **note:** here are some helpful tips for the `ln` command:
58+
> - You can remember `ln`'s first argument is the unaffected
59+
> source file by remembering `cp` and `mv` are the same in
60+
> this way.
61+
> - If you don't add `-s` you get a hard link. You will rarely
62+
> find yourself needing to do that.
63+
> - The `-r` flag allows you to write both paths relative to
64+
> the directory from which you are calling the command, which
65+
> is sometimes more intuitive.
66+

0 commit comments

Comments
 (0)