mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-20 11:30:18 +00:00
update docs
This commit is contained in:
parent
51b14d3526
commit
888abaa027
@ -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" :::
|
@ -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" :::
|
@ -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.
|
||||
|
@ -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" :::
|
@ -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
docs/modules/textwrap.md
Normal file
10
docs/modules/textwrap.md
Normal file
@ -0,0 +1,10 @@
|
||||
---
|
||||
icon: package
|
||||
label: textwrap
|
||||
---
|
||||
|
||||
Text wrapping and filling.
|
||||
|
||||
#### Source code
|
||||
|
||||
:::code source="../../python/textwrap.py" :::
|
@ -5,4 +5,6 @@ label: typing
|
||||
|
||||
Placeholder module for type hints.
|
||||
|
||||
#### Source code
|
||||
|
||||
:::code source="../../python/typing.py" :::
|
0
python/textwrap.py
Normal file
0
python/textwrap.py
Normal file
Loading…
x
Reference in New Issue
Block a user