Skip to content

Commit 2b3e30b

Browse files
authored
Merge pull request GaijinEntertainment#2081 from GaijinEntertainment/doc-cleanup
Doc cleanup
2 parents 32894cf + 49315c4 commit 2b3e30b

143 files changed

Lines changed: 5432 additions & 979 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/copilot-instructions.md

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,15 @@ All code examples and documentation MUST use gen2 syntax (add `options gen2` at
4848
- **Braces** on all blocks — no indentation-based blocks: `def foo() { ... }`, `if (x) { ... }`
4949
- **Construction:** `new Type(field=val)` — NOT `new [[Type() field=val]]`
5050
- **Enum access:** `EnumName.EnumValue` with dot — NOT `EnumName EnumValue` without
51-
- **Array literals:** `[1, 2, 3]` (commas, square brackets) — NOT `[[int 1; 2; 3]]`
51+
- **Array literals:** `[1, 2, 3]` (commas, square brackets) — NOT `[[int 1; 2; 3]]`. Note: this creates a **dynamic** `array<int>` — use `fixed_array(1, 2, 3)` for fixed-size arrays
5252
- **Struct init:** `Foo(a=1, b=2)` — NOT `[[Foo() a=1, b=2]]`
5353
- **No `[[ ]]` for `new`**`new` always uses parentheses: `new Foo(x=1)`
5454
- **Table literals:** `{ "k" => v, "k2" => v2 }` (single braces, commas) — NOT `{{ "k" => v; "k2" => v2 }}`
5555
- **Named arguments:** `foo([name = value])` with square brackets — NOT `foo(name=value)`
5656
- **Block arguments with `<|`:** use `$()` or `@()` prefix: `defer() <| $() { ... }` — NOT `defer <| { ... }` (bare `{ }` creates a table literal)
5757
- **Lambda:** `@(args) { body }` or `@@(args) { body }` (no-capture)
58+
- **Generator:** `$() { yield value; }` or `$ { yield value; }` — both are valid gen2 syntax
59+
- **Tuple `=>` operator:** `a => b` creates a `tuple<auto;auto>` — useful in LINQ, table construction, and ad-hoc pairs
5860
- **Bitfield variables** need explicit type for `.field` access and printing: `var f : MyBitfield`
5961
- **Bitfield dot access:** read with `f.flag` (returns bool), write with `f.flag = true/false`
6062
- **`typeinfo`** special syntax: `typeinfo enum_length(type<MyEnum>)` — NOT `typeinfo(enum_length type<MyEnum>)`
@@ -110,6 +112,10 @@ All code examples and documentation MUST use gen2 syntax (add `options gen2` at
110112
- When calling `apply_template`, always capture the return value: `unsafe { expr <- apply_template(expr) <| ... }` — discarding the return loses the expression data
111113
- Iterator comprehension: `[iterator for(x in src); expression]` — semicolon separates generator from body
112114
- `to_array` (from `daslib/builtin`) converts any iterator to an array
115+
- Lambdas CAN be stored in arrays: `var fns : array<lambda<(x:int):int>>` + `fns |> emplace() <| @(x : int) : int { return x * 2; }` — move semantics, not copy
116+
- Blocks CANNOT be stored in containers, returned from functions, or captured — use lambdas or function pointers for those use cases
117+
- `match`, `multi_match`, `static_match` macros (from `daslib/match.das`) handle side effects automatically — do NOT add `[sideeffects]` annotations to functions that only use match
118+
- `[export] def main()` returns `void` — do NOT `return true` or return other values from main
113119

114120
## Key Directories
115121

@@ -175,6 +181,45 @@ When editing RST files in `doc/source/reference/language/`:
175181
- Use `:ref:` cross-references to link between pages (labels: `_structs`, `_classes`, `_functions`, `_statements`, `_expressions`, `_arrays`, `_tables`, `_iterators`, `_generators`, `_lambdas`, `_blocks`, `_tuples`, `_variants`, `_bitfields`, `_aliases`, `_modules`, `_options`, `_unsafe`, `_enumerations`, `_generic_programming`, `_pattern-matching`, `_comprehensions`, `_string_builder`, `_macros`, `_reification`, `_finalizers`, `_clone`, `_temporary`, `_move_copy_clone`, `_annotations`, `_program_structure`, `_type_conversions`, `_contexts`, `_locks`, `_datatypes_and_values`)
176182
- Verify examples compile: `bin/Release/daslang.exe example.das`
177183

184+
### RST table rules
185+
186+
RST uses two table formats — **grid tables** and **simple tables**. Both are fragile:
187+
188+
- **Grid tables** (`+---+---+`): Every row line must be exactly the same width as every separator line. Off-by-one spaces cause Sphinx errors.
189+
- **Simple tables** (`=== ===`): The `=` separator defines column widths. Content in non-last columns must NOT extend past its column's `=` boundary. Headers must start at or after the column's start position (not in the gap). The gap between columns must be at least 2 spaces.
190+
- After creating or editing any RST table, verify the file with a Sphinx build (see below).
191+
192+
### Documentation workflow (REQUIRED)
193+
194+
After creating or modifying any RST files, stdlib documentation, or `daslib/*.das` module doc-comments:
195+
196+
1. **Regenerate stdlib docs** (if `daslib/*.das` files or `doc/reflections/das2rst.das` were changed):
197+
```
198+
bin/Release/daslang.exe doc/reflections/das2rst.das
199+
```
200+
201+
2. **Clean Sphinx build** — MUST delete cache; cached builds hide errors:
202+
```
203+
cd doc
204+
Remove-Item -Recurse -Force sphinx-build # delete doctree cache
205+
Remove-Item -Recurse -Force ../site/doc # delete HTML output
206+
sphinx-build -b html -d sphinx-build source ../site/doc
207+
```
208+
On Linux/Mac:
209+
```
210+
cd doc
211+
rm -rf sphinx-build ../site/doc
212+
sphinx-build -b html -d sphinx-build source ../site/doc
213+
```
214+
215+
3. **Verify no new errors or warnings**: Check the build output for `ERROR` and `WARNING`. The build must introduce **no new** Sphinx errors or warnings compared to the baseline.
216+
217+
**When to run the workflow:**
218+
- New or modified RST files (language docs, tutorials, stdlib docs)
219+
- New or modified `//!` doc-comments in `daslib/*.das` files
220+
- Changes to `doc/reflections/das2rst.das` or `doc/reflections/rst.das`
221+
- New public functions added to any `daslib/*.das` module (also update `group_by_regex` in `das2rst.das`)
222+
178223
### Tutorial RST conventions
179224

180225
Tutorial RST files live in `doc/source/reference/tutorials/` with companion `.das` files in `tutorials/language/`.

CLAUDE.md

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,15 @@ All code examples and documentation MUST use gen2 syntax (add `options gen2` at
4848
- **Braces** on all blocks — no indentation-based blocks: `def foo() { ... }`, `if (x) { ... }`
4949
- **Construction:** `new Type(field=val)` — NOT `new [[Type() field=val]]`
5050
- **Enum access:** `EnumName.EnumValue` with dot — NOT `EnumName EnumValue` without
51-
- **Array literals:** `[1, 2, 3]` (commas, square brackets) — NOT `[[int 1; 2; 3]]`
51+
- **Array literals:** `[1, 2, 3]` (commas, square brackets) — NOT `[[int 1; 2; 3]]`. Note: this creates a **dynamic** `array<int>` — use `fixed_array(1, 2, 3)` for fixed-size arrays
5252
- **Struct init:** `Foo(a=1, b=2)` — NOT `[[Foo() a=1, b=2]]`
5353
- **No `[[ ]]` for `new`**`new` always uses parentheses: `new Foo(x=1)`
5454
- **Table literals:** `{ "k" => v, "k2" => v2 }` (single braces, commas) — NOT `{{ "k" => v; "k2" => v2 }}`
5555
- **Named arguments:** `foo([name = value])` with square brackets — NOT `foo(name=value)`
5656
- **Block arguments with `<|`:** use `$()` or `@()` prefix: `defer() <| $() { ... }` — NOT `defer <| { ... }` (bare `{ }` creates a table literal)
5757
- **Lambda:** `@(args) { body }` or `@@(args) { body }` (no-capture)
58+
- **Generator:** `$() { yield value; }` or `$ { yield value; }` — both are valid gen2 syntax
59+
- **Tuple `=>` operator:** `a => b` creates a `tuple<auto;auto>` — useful in LINQ, table construction, and ad-hoc pairs
5860
- **Bitfield variables** need explicit type for `.field` access and printing: `var f : MyBitfield`
5961
- **Bitfield dot access:** read with `f.flag` (returns bool), write with `f.flag = true/false`
6062
- **`typeinfo`** special syntax: `typeinfo enum_length(type<MyEnum>)` — NOT `typeinfo(enum_length type<MyEnum>)`
@@ -110,6 +112,10 @@ All code examples and documentation MUST use gen2 syntax (add `options gen2` at
110112
- When calling `apply_template`, always capture the return value: `unsafe { expr <- apply_template(expr) <| ... }` — discarding the return loses the expression data
111113
- Iterator comprehension: `[iterator for(x in src); expression]` — semicolon separates generator from body
112114
- `to_array` (from `daslib/builtin`) converts any iterator to an array
115+
- Lambdas CAN be stored in arrays: `var fns : array<lambda<(x:int):int>>` + `fns |> emplace() <| @(x : int) : int { return x * 2; }` — move semantics, not copy
116+
- Blocks CANNOT be stored in containers, returned from functions, or captured — use lambdas or function pointers for those use cases
117+
- `match`, `multi_match`, `static_match` macros (from `daslib/match.das`) handle side effects automatically — do NOT add `[sideeffects]` annotations to functions that only use match
118+
- `[export] def main()` returns `void` — do NOT `return true` or return other values from main
113119

114120
## Key Directories
115121

@@ -175,6 +181,45 @@ When editing RST files in `doc/source/reference/language/`:
175181
- Use `:ref:` cross-references to link between pages (labels: `_structs`, `_classes`, `_functions`, `_statements`, `_expressions`, `_arrays`, `_tables`, `_iterators`, `_generators`, `_lambdas`, `_blocks`, `_tuples`, `_variants`, `_bitfields`, `_aliases`, `_modules`, `_options`, `_unsafe`, `_enumerations`, `_generic_programming`, `_pattern-matching`, `_comprehensions`, `_string_builder`, `_macros`, `_reification`, `_finalizers`, `_clone`, `_temporary`, `_move_copy_clone`, `_annotations`, `_program_structure`, `_type_conversions`, `_contexts`, `_locks`, `_datatypes_and_values`)
176182
- Verify examples compile: `bin/Release/daslang.exe example.das`
177183

184+
### RST table rules
185+
186+
RST uses two table formats — **grid tables** and **simple tables**. Both are fragile:
187+
188+
- **Grid tables** (`+---+---+`): Every row line must be exactly the same width as every separator line. Off-by-one spaces cause Sphinx errors.
189+
- **Simple tables** (`=== ===`): The `=` separator defines column widths. Content in non-last columns must NOT extend past its column's `=` boundary. Headers must start at or after the column's start position (not in the gap). The gap between columns must be at least 2 spaces.
190+
- After creating or editing any RST table, verify the file with a Sphinx build (see below).
191+
192+
### Documentation workflow (REQUIRED)
193+
194+
After creating or modifying any RST files, stdlib documentation, or `daslib/*.das` module doc-comments:
195+
196+
1. **Regenerate stdlib docs** (if `daslib/*.das` files or `doc/reflections/das2rst.das` were changed):
197+
```
198+
bin/Release/daslang.exe doc/reflections/das2rst.das
199+
```
200+
201+
2. **Clean Sphinx build** — MUST delete cache; cached builds hide errors:
202+
```
203+
cd doc
204+
Remove-Item -Recurse -Force sphinx-build # delete doctree cache
205+
Remove-Item -Recurse -Force ../site/doc # delete HTML output
206+
sphinx-build -b html -d sphinx-build source ../site/doc
207+
```
208+
On Linux/Mac:
209+
```
210+
cd doc
211+
rm -rf sphinx-build ../site/doc
212+
sphinx-build -b html -d sphinx-build source ../site/doc
213+
```
214+
215+
3. **Verify no new errors or warnings**: Check the build output for `ERROR` and `WARNING`. The build must introduce **no new** Sphinx errors or warnings compared to the baseline.
216+
217+
**When to run the workflow:**
218+
- New or modified RST files (language docs, tutorials, stdlib docs)
219+
- New or modified `//!` doc-comments in `daslib/*.das` files
220+
- Changes to `doc/reflections/das2rst.das` or `doc/reflections/rst.das`
221+
- New public functions added to any `daslib/*.das` module (also update `group_by_regex` in `das2rst.das`)
222+
178223
### Tutorial RST conventions
179224

180225
Tutorial RST files live in `doc/source/reference/tutorials/` with companion `.das` files in `tutorials/language/`.

daslib/apply_in_context.das

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,12 @@ class AppendCondAnnotation : AstFunctionAnnotation {
2929
//! If specified context is not installed, panic is called.
3030
//!
3131
//! For example::
32-
//! [apply_in_context(opengl_cache)]
33-
//! def public cache_font(name:string implicit) : Font?
34-
//! ...
35-
//! ...
36-
//! let font = cache_font("Arial") // call invoked in the "opengl_cache" debug agent context
32+
//!
33+
//! [apply_in_context(opengl_cache)]
34+
//! def public cache_font(name:string implicit) : Font?
35+
//! ...
36+
//! ...
37+
//! let font = cache_font("Arial") // call invoked in the "opengl_cache" debug agent context
3738
def override patch(var func : FunctionPtr; var group : ModuleGroup; args, progArgs : AnnotationArgumentList; var errors : das_string; var astChanged : bool&) : bool {
3839

3940
for (ann in func.annotations) {

daslib/array_boost.das

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ def private array_helper(arr : auto implicit ==const; a : auto(TT)) : array<TT -
4646
def public temp_array(var arr : auto implicit ==const) {
4747
//! Creates temporary array from the given object.
4848
//! Important requirements are:
49+
//!
4950
//! * object memory is linear
5051
//! * each element follows the next one directly, with the stride equal to size of the element
5152
//! * object memory does not change within the lifetime of the returned array
@@ -58,6 +59,7 @@ def public temp_array(var arr : auto implicit ==const) {
5859
def public temp_array(arr : auto implicit ==const) {
5960
//! Creates temporary array from the given object.
6061
//! Important requirements are:
62+
//!
6163
//! * object memory is linear
6264
//! * each element follows the next one directly, with the stride equal to size of the element
6365
//! * object memory does not change within the lifetime of the returned array
@@ -76,6 +78,7 @@ def empty(v : auto(VecT)) {
7678
def public temp_array(var data : auto? ==const; lenA : int; a : auto(TT)) : array<TT -const -#> {
7779
//! creates a temporary array from the given data pointer and length
7880
//! Important requirements are:
81+
//!
7982
//! * data pointer is valid and points to a memory block of at least lenA elements
8083
//! * each element follows the next one directly, with the stride equal to size of the element
8184
//! * data memory does not change within the lifetime of the returned array
@@ -92,6 +95,7 @@ def public temp_array(var data : auto? ==const; lenA : int; a : auto(TT)) : arra
9295
def public temp_array(data : auto? ==const; lenA : int; a : auto(TT)) : array<TT -const -#> const {
9396
//! creates a temporary array from the given data pointer and length
9497
//! Important requirements are:
98+
//!
9599
//! * data pointer is valid and points to a memory block of at least lenA elements
96100
//! * each element follows the next one directly, with the stride equal to size of the element
97101
//! * data memory does not change within the lifetime of the returned array

daslib/decs_boost.das

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -267,9 +267,11 @@ enum private DecsQueryType {
267267

268268
[call_macro(name="query")]
269269
class DecsQueryMacro : AstCallMacro {
270-
//! This macro implements 'query` functionality. There are 2 types of queries:
271-
//! * query(...) - returns a list of entities matching the query
272-
//! * query(eid) - returns a single entity matching the eid
270+
//! This macro implements `query` functionality. There are 2 types of queries:
271+
//!
272+
//! * query(...) - returns a list of entities matching the query
273+
//! * query(eid) - returns a single entity matching the eid
274+
//!
273275
//! For example::
274276
//!
275277
//! query() <| $ ( eid:EntityId; pos, vel : float3 )
@@ -280,6 +282,7 @@ class DecsQueryMacro : AstCallMacro {
280282
//!
281283
//! query(kaboom) <| $ ( var pos:float3&; vel:float3; col:uint=13u )
282284
//! pos += vel
285+
//!
283286
//! The query above will add the velocity to the position of an entity with eid kaboom.
284287
//!
285288
//! Query can have `REQUIRE` and `REQUIRE_NOT` clauses::
@@ -302,7 +305,7 @@ class DecsQueryMacro : AstCallMacro {
302305
//!
303306
//! In the example above structure q : Particle does not exist as a variable. Instead it is expanded into accessing individual components of the entity.
304307
//! REQURE section of the query is automatically filled with all components of the template.
305-
//! If template prefix is not specified, prefix is taken from the name of the template (would be "Particle_").
308+
//! If template prefix is not specified, prefix is taken from the name of the template (would be ``Particle_``).
306309
//! Specifying empty prefix `[decs_template(prefix)]` will result in no prefix being added.
307310
//!
308311
//! Note: apart from tagging structure as a template, the macro also generates `apply_decs_template` and `remove_decs_template` functions.
@@ -477,10 +480,12 @@ class DecsQueryMacro : AstCallMacro {
477480

478481
[call_macro(name="find_query")]
479482
class DecsFindQueryMacro : DecsQueryMacro {
480-
//! This macro implements 'find_query` functionality.
483+
//! This macro implements `find_query` functionality.
481484
//! It is similar to `query` in most ways, with the main differences being:
482-
//! * there is no eid-based find query
483-
//! * the find_query stops once the first match is found
485+
//!
486+
//! * there is no eid-based find query
487+
//! * the find_query stops once the first match is found
488+
//!
484489
//! For example::
485490
//!
486491
//! let found = find_query <| $ ( pos,dim:float3; obstacle:Obstacle )
@@ -500,7 +505,7 @@ class DecsFindQueryMacro : DecsQueryMacro {
500505

501506
[function_macro(name="decs")]
502507
class DecsEcsMacro : AstFunctionAnnotation {
503-
//! This macro converts a function into a DECS pass stage query. Possible arguments are `stage`, 'REQUIRE', and `REQUIRE_NOT`.
508+
//! This macro converts a function into a DECS pass stage query. Possible arguments are `stage`, `REQUIRE`, and `REQUIRE_NOT`.
504509
//! It has all other properties of a `query` (like ability to operate on templates). For example::
505510
//!
506511
//! [decs(stage=update_ai, REQUIRE=ai_turret)]
@@ -587,12 +592,15 @@ class DecsEcsMacro : AstFunctionAnnotation {
587592
[call_macro(name="from_decs")]
588593
class FromDecsMacro : AstCallMacro {
589594
//! This macro converts a DECS query into an iterator<tuple<...>>. For example::
595+
//!
590596
//! let it = from_decs($(index:int; text:string){})
591597
//! for (item in it) {
592598
//! // process item
593599
//! print("Entity {item.index}: {item.text}\n")
594600
//! }
601+
//!
595602
//! Internally it generates the following code::
603+
//!
596604
//! let it = invoke($() {
597605
//! var res : array<tuple<int,string>>
598606
//! query($(index:int; text:string) {

daslib/json_boost.das

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -214,12 +214,13 @@ class private BetterJsonMacro : AstVariantMacro {
214214
[reader_macro(name="json")]
215215
class private JsonReader : AstReaderMacro {
216216
//! This macro implements embedding of the JSON object into the program::
217-
//! var jsv = %json~
218-
//! {
219-
//! "name": "main_window",
220-
//! "value": 500,
221-
//! "size": [1,2,3]
222-
//! } %%
217+
//!
218+
//! var jsv = %json~
219+
//! {
220+
//! "name": "main_window",
221+
//! "value": 500,
222+
//! "size": [1,2,3]
223+
//! } %%
223224
def override accept(prog : ProgramPtr; mod : Module?; var expr : ExprReader?; ch : int; info : LineInfo) : bool {
224225
//! Implement the accept method to read until '%%' is found.
225226
append(expr.sequence, ch)

0 commit comments

Comments
 (0)