blueloveTH hai 1 ano
pai
achega
888abaa027

+ 2 - 11
docs/modules/array2d.md

@@ -5,15 +5,6 @@ label: array2d
 
 Efficient general-purpose 2D array.
 
-https://github.com/pocketpy/pocketpy/blob/main/include/typings/array2d.pyi
+#### Source code
 
-## Example
-
-```python
-from array2d import array2d
-
-a = array2d(3, 4, default=0)
-
-a[1, 2] = 5
-print(a[1, 2]) # 5
-```
+:::code source="../../include/typings/array2d.pyi" :::

+ 2 - 0
docs/modules/dataclasses.md

@@ -11,4 +11,6 @@ A decorator that is used to add special method to classes, including `__init__`,
 
 Convert a dataclass instance to a dictionary.
 
+#### Source code
 
+:::code source="../../python/dataclasses.py" :::

+ 0 - 42
docs/modules/io.md

@@ -1,42 +0,0 @@
----
-icon: package-dependencies
-label: io
----
-
-!!!
-This module is optional. Set `PK_ENABLE_OS` to `1` to enable it.
-!!!
-
-### `io.FileIO.read(size=-1) -> bytes | str`
-
-Read up to `size` bytes from the file. If `size` is negative or omitted, read until EOF.
-
-### `io.FileIO.write(data: bytes | str)`
-
-Write the given data to the file.
-
-### `io.FileIO.seek(offset, whence=0) -> int`
-
-Change the file position to the given offset. The `whence` argument is optional and defaults to `0` (absolute file positioning); other values are `1` (seek relative to the current position) and `2` (seek relative to the file's end).
-
-### `io.FileIO.tell() -> int`
-
-Return the current file position.
-
-### `io.FileIO.close()`
-
-Close the file.
-
-
-### `io.SEEK_SET`
-
-Seek from the beginning of the file.
-
-### `io.SEEK_CUR`
-
-Seek from the current position.
-
-### `io.SEEK_END`
-
-Seek from the end of the file.
-

+ 1 - 1
docs/modules/linalg.md

@@ -7,6 +7,6 @@ Provide `mat3x3`, `vec2`, `vec3` and `vec4` types.
 
 This classes adopt `torch`'s naming convention. Methods with `_` suffix will modify the instance itself.
 
-https://github.com/pocketpy/pocketpy/blob/main/include/typings/linalg.pyi
+#### Source code
 
 :::code source="../../include/typings/linalg.pyi" :::

+ 0 - 72
docs/modules/os.md

@@ -1,72 +0,0 @@
----
-icon: package-dependencies
-label: os
----
-
-!!!
-This module is optional. Set `PK_ENABLE_OS` to `1` to enable it.
-!!!
-
-### `os.getcwd()`
-
-Returns the current working directory.
-
-### `os.chdir(path: str)`
-
-Changes the current working directory to the given path.
-
-### `os.listdir(path: str)`
-
-Returns a list of files and directories in the given path.
-
-### `os.remove(path: str)`
-
-Removes the file at the given path.
-
-### `os.mkdir(path: str)`
-
-Creates a directory at the given path.
-
-### `os.rmdir(path: str)`
-
-Removes the directory at the given path.
-
-### `os.path.join(*paths: str)`
-
-Joins the given paths together.
-
-### `os.path.exists(path: str)`
-
-Check if the given path exists.
-
-### `os.path.basename(path: str)`
-
-Returns the basename of the given path.
-
-### `os.path.isdir(path: str)`
-
-Check if the given path is a directory.
-
-### `os.path.isfile(path: str)`
-
-Check if the given path is a file.
-
-### `os.path.abspath(path: str)`
-
-Returns the absolute path of the given path.
-
-
-## Other functions
-
-You can add other functions to `os` module via normal binding if you need them.
-For example, add `os.system`:
-
-```cpp
-PyVar mod = vm->_modules["os"];
-
-vm->bind(mod, "system(cmd: str) -> int", [](VM* vm, ArgsView args){
-    const char* cmd = py_cast<CString>(vm, args[0]);
-    int code = system(cmd);
-    return py_var(vm, code);
-});
-```

+ 10 - 0
docs/modules/textwrap.md

@@ -0,0 +1,10 @@
+---
+icon: package
+label: textwrap
+---
+
+Text wrapping and filling.
+
+#### Source code
+
+:::code source="../../python/textwrap.py" :::

+ 2 - 0
docs/modules/typing.md

@@ -5,4 +5,6 @@ label: typing
 
 Placeholder module for type hints.
 
+#### Source code
+
 :::code source="../../python/typing.py" :::

+ 0 - 0
python/textwrap.py