Skip to content

Commit 5b3b55b

Browse files
committed
docs: update docstring format and generator documentation for clarity
1 parent 40b6409 commit 5b3b55b

5 files changed

Lines changed: 13 additions & 9 deletions

File tree

docs/dev/docstrings.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ Locale dependent:
4747

4848
If omitted, the generator is assumed to be locale-independent.
4949

50-
!!! note title="Not entirely strict"
50+
!!! note "Not entirely strict"
5151
To be honest, if the line below Locale dependent is not exactly `yes` it's treated as `no`. But it's best to follow the format strictly to avoid confusion.
5252

5353
### `Args`

docs/dev/generators_registry.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ Generators must not use `**kwargs`. The DSL only supports positional and named a
4242
def my_gen(**kwargs) -> str: ...
4343
```
4444

45-
### `*args` and named parameters are mutually exclusive
45+
### `*args` and POSITIONAL_OR_KEYWORD parameters are mutually exclusive
4646

4747
A generator may use either `*args` (var positional) or POSITIONAL_OR_KEYWORD parameters — but not both simultaneously.
4848

@@ -60,8 +60,9 @@ def yet_another_gen(*args, extra: str = "") -> str: ...
6060
# Invalid — POSITIONAL_OR_KEYWORD params with *args (var positional)
6161
def invalid_gen(extra: str, *args) -> str: ...
6262

63-
# WHY ? Because the Semantic Validator for the DSL cannot currently handle this combination. It would require a more complex parsing logic to determine which arguments are meant for `*args` and which are actual positionals parameters, especially since the user can pass any number of values for `*args`. To keep things simple and unambiguous, we enforce this constraint.
6463
```
64+
WHY ? Because the Semantic Validator for the DSL cannot currently handle this combination. It would require a more complex parsing logic to determine which arguments are meant for `*args` and which are actual positionals parameters, especially since the user can pass any number of values for `*args`. To keep things simple and unambiguous, we enforce this constraint.
65+
6566

6667
!!! note "About union types"
6768
The current implementation of the docstring parser and the semantic validator does not support union types (e.g., `str | int`) in generator signatures. This will be updated in future updates. and no, even Any is not supported too.
@@ -72,12 +73,12 @@ def invalid_gen(extra: str, *args) -> str: ...
7273

7374
To add a new generator, simply define a function in any non-private module under `copia.generators` and ensure it follows the constraints outlined above. The function will be automatically registered and available for use in the DSL.
7475

75-
first check if the module you want to add the generator to already exists. If it does, add your function there. If not, create a new module and add your function there.
76+
- first check if the module you want to add the generator to already exists. If it does, add your function there. If not, create a new module and add your function there.
7677

77-
since the registry is built dynamically, you don't need to do anything else to make your generator available — just define it and it will be picked up when the module is imported.
78+
- since the registry is built dynamically, you don't need to do anything else to make your generator available — just define it and it will be picked up when the module is imported.
7879

79-
to ensure your generator is properly documented, follow the docstring format outlined in the [docstrings guide](./docstrings.md). This will help users understand how to use your generator and what it does.
80+
- to ensure your generator is properly documented, follow the docstring format outlined in the [docstrings guide](./docstrings.md). This will help users understand how to use your generator and what it does.
8081

81-
and to finish, simply run pytest tests/test_generators_discover.py to avoid any import warnings or errors related to your new generator. If you see an ImportWarning about overriding a generator, it means you have a naming conflict — either rename your generator or remove the conflicting one. If you see an error about `**kwargs` or invalid parameter combinations, adjust your function signature accordingly.
82+
- and to finish, simply run pytest tests/test_generators_discover.py to avoid any import warnings or errors related to your new generator. If you see an ImportWarning about overriding a generator, it means you have a naming conflict — either rename your generator or remove the conflicting one. If you see an error about `**kwargs` or invalid parameter combinations, adjust your function signature accordingly.
8283

8384
> just keep in mind, the function signature is a direct interface to users, so keep it simple and intuitive. Avoid complex parameter combinations that could confuse users or make the generator difficult to use in the DSL. The goal is to provide a clear and straightforward way for users to generate data without having to worry about the underlying implementation details.

docs/dev/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ This section documents the internals of Copia for contributors and developers wh
1010
- [Docstring format](docstrings.md) — the docstring convention Copia uses to generate documentation
1111
- [The dynamic generators system](generators_registry.md) — how generators are registered and what constraints apply
1212
- [The semantic validator](validator.md) — how Copia validates DSL calls against generator signatures
13-
- [How `ref` works](ref.md) — the internals of the `ref()` generator
13+
- [How `fetch` works](fetch.md) — the internals of the `fetch()` generator

docs/installation.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,12 @@ Copia requires **Python 3.13 or higher**.
2828

2929
=== "From source"
3030

31+
we recommend [uv](https://docs.astral.sh/uv/getting-started/installation/#standalone-installer) to download the repo from source
32+
3133
```bash
3234
git clone https://github.com/gitmobkab/copia
3335
cd copia
34-
pip install -e .
36+
uv sync --all-groups
3537
```
3638

3739
---

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ theme:
2626
- content.code.annotate
2727
- navigation.tabs
2828
- navigation.tabs.sticky
29+
- content.tooltips
2930

3031
hooks:
3132
- hooks/dsl_hook.py

0 commit comments

Comments
 (0)