Skip to content

Commit cf1dfdb

Browse files
committed
Clean Roots docs
1 parent 73678c5 commit cf1dfdb

39 files changed

Lines changed: 598 additions & 172 deletions

_auto_docs/rish/01-installation.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public partial class App : IApp
7979
// The internal Root element manages the application state
8080
private partial class Root : RishElement<NoProps, RootState>, IMountingListener
8181
{
82-
void IMountingListener.ComponentDidMount() {
82+
void IMountingListener.ElementDidMount() {
8383
if(StaticData.IsLoaded)
8484
{
8585
// If data is already ready, set progress immediately
@@ -90,7 +90,7 @@ public partial class App : IApp
9090
StaticData.OnLoadingProgress += SetLoadingProgress;
9191
}
9292
}
93-
void IMountingListener.ComponentWillUnmount() {
93+
void IMountingListener.ElementWillUnmount() {
9494
StaticData.OnLoadingProgress -= SetLoadingProgress;
9595
}
9696

_auto_docs/rish/03-visualelements.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,10 +155,10 @@ Rish provides interfaces to hook into the lifecycle of a `VisualElement`.
155155
Useful for initialization logic or event subscription.
156156

157157
{% highlight csharp %}
158-
void IMountingListener.ComponentDidMount() {
158+
void IMountingListener.ElementDidMount() {
159159
Debug.Log("Element added to the Visual Tree");
160160
}
161-
void IMountingListener.ComponentWillUnmount() {
161+
void IMountingListener.ElementWillUnmount() {
162162
Debug.Log("Element about to be removed");
163163
}
164164
{% endhighlight %}

_auto_docs/rish/04-rishelements.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: RishElements
33
slug: rishelements
44
sections:
55
- Inputs
6-
- DOMDescriptor
6+
- VisualAttributes
77
- Wrap VisualElements
88
- Callbacks
99
- UIToolkit Events
@@ -80,7 +80,7 @@ public struct FooProps {
8080
## Wrapping VisualElements
8181
A very common pattern is creating a `RishElement` that wraps a `VisualElement` (like a custom Card or Container) but allows the parent to style it.
8282

83-
Instead of passing every style property manually, you can use `DOMDescriptor`. This struct contains `name`, `className`, and `style`.
83+
Instead of passing every style property manually, you can use `VisualAttributes`. This struct contains `name`, `className`, and `style`.
8484

8585
{% highlight csharp %}
8686
private partial class Example : RishElement
@@ -109,8 +109,8 @@ private partial class AlertContainer : RishElement<AlertContainerProps>
109109

110110
[RishValueType]
111111
public struct AlertContainer {
112-
[DOMDescriptor]
113-
public DOMDescriptor descriptor;
112+
[Expand]
113+
public VisualAttributes descriptor;
114114
public Children children;
115115
}
116116
{% endhighlight %}
@@ -124,10 +124,10 @@ Implement `IMountingListener` to know when an element enters or leaves the tree.
124124
{% highlight csharp %}
125125
private partial class FooElement : RishElement, IMountingListener
126126
{
127-
void IMountingListener.ComponentDidMount() {
127+
void IMountingListener.ElementDidMount() {
128128
Debug.Log("Element mounted");
129129
}
130-
void IMountingListener.ComponentWillUnmount() {
130+
void IMountingListener.ElementWillUnmount() {
131131
Debug.Log("Element will be unmounted");
132132
}
133133

@@ -155,7 +155,7 @@ private partial class FooElement : RishElement, IManualState
155155
<div class="callout-block callout-block-warning">
156156
<div class="content">
157157
<h4 class="callout-title">Warning</h4>
158-
<p><code>IManualState.Restart</code> will be called right before the element gets reused from the Pool. Do not use <code>Restart</code> to unsubscribe from events or cancel actions. Use <code>ComponentWillUnmount</code> for that.</p>
158+
<p><code>IManualState.Restart</code> will be called right before the element gets reused from the Pool. Do not use <code>Restart</code> to unsubscribe from events or cancel actions. Use <code>ElementWillUnmount</code> for that.</p>
159159
</div>
160160
</div>
161161

@@ -170,10 +170,10 @@ If you implement `ICustomUnmountListener`:
170170
{% highlight csharp %}
171171
public partial class DelaySampleElement : RishElement, IMountingListener, ICustomUnmountListener
172172
{
173-
void IMountingListener.ComponentDidMount() {
173+
void IMountingListener.ElementDidMount() {
174174
Debug.Log("1. Element was added to the tree.");
175175
}
176-
void IMountingListener.ComponentWillUnmount() {
176+
void IMountingListener.ElementWillUnmount() {
177177
Debug.Log("4. Element is about to be removed from the tree.");
178178
}
179179

@@ -250,8 +250,8 @@ public partial class FooElement : RishElement<FooProps, FooState>, IPropsListene
250250

251251
[RishValueType]
252252
public struct FooProps {
253-
[DOMDescriptor]
254-
public DOMDescriptor descriptor; // descriptor can change and it won't trigger another setup
253+
[Expand]
254+
public VisualAttributes descriptor; // descriptor can change and it won't trigger another setup
255255

256256
public int id; // if id changes, Setup will be called
257257
}

_auto_docs/rish/05-data.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,10 @@ While we discourage using reference types in Props/State, you often need to inte
137137

138138
{% highlight csharp %}
139139
public partial class InventoryPocket : RishElement<InventoryPocketProps, InventoryPocketState>, IMountingListener, IPropsListener {
140-
void IMountingListener.ComponentDidMount() {
140+
void IMountingListener.ElementDidMount() {
141141
GameState.PlayerInventory.OnChange += Setup;
142142
}
143-
void IMountingListener.ComponentWillUnmount() {
143+
void IMountingListener.ElementWillUnmount() {
144144
GameState.PlayerInventory.OnChange -= Setup;
145145
}
146146

_auto_docs/rish/06-memory-management.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ You can leverage Rish's high-performance pooling system for your own data struct
122122

123123
To create a custom pooled type:
124124
1. **The Reference:** Create a class that implements `IManaged` (must have a parameterless constructor).
125-
2. **The Pointer:** Create a struct that implements `IReference`.
125+
2. **The Pointer:** Create a struct that implements `IPointer`.
126126

127127
Once implemented, Rish will automatically pool instances of your class and allow you to use them safely within Managed Contexts, just like native Rish types.
128128

_auto_docs/rish/08-rishenerator.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ public partial class Foo
102102
// ↑↑↑ Autogenerated ↑↑↑
103103
{% endhighlight %}
104104

105-
For Props using the `[DOMDescriptor]` attribute, the generator "flattens" the descriptor into `name`, `className`, and `style` arguments.
105+
For Props using the `[Expand]` attribute, the generator "flattens" the descriptor into `name`, `className`, and `style` arguments.
106106

107107
{% highlight csharp %}
108108
// ↓↓↓ User Code ↓↓↓
@@ -112,10 +112,10 @@ public partial class Foo : RishElement<FooProps>
112112
}
113113
[RishValueType]
114114
public struct FooProps {
115-
[DOMDescriptor]
116-
public DOMDescriptor descriptor;
117-
[DOMDescriptor]
118-
public DOMDescriptor secondDescriptor;
115+
[Expand]
116+
public VisualAttributes descriptor;
117+
[Expand]
118+
public VisualAttributes secondDescriptor;
119119

120120
public bool var1;
121121
}
@@ -131,11 +131,11 @@ public partial class Foo
131131
[RishUI.MemoryManagement.RequiresManagedContext]
132132
public static RishUI.Element Create(FooProps props) => Create(default(ulong), props);
133133
[RishUI.MemoryManagement.RequiresManagedContext]
134-
public static RishUI.Element Create(RishUI.Name name = default, RishUI.ClassName className = default, RishUI.Style style = default, RishUI.Name secondName = default, RishUI.ClassName secondClassName = default, RishUI.Style secondStyle = default, System.Boolean var1 = default) => Create(default(ulong), new FooProps { descriptor = new RishUI.DOMDescriptor {name = name, className = className, style = style }, secondDescriptor = new RishUI.DOMDescriptor {name = secondName, className = secondClassName, style = secondStyle }, var1 = var1 });
134+
public static RishUI.Element Create(RishUI.Name name = default, RishUI.ClassName className = default, RishUI.Style style = default, RishUI.Name secondName = default, RishUI.ClassName secondClassName = default, RishUI.Style secondStyle = default, System.Boolean var1 = default) => Create(default(ulong), new FooProps { descriptor = new RishUI.VisualAttributes {name = name, className = className, style = style }, secondDescriptor = new RishUI.VisualAttributes {name = secondName, className = secondClassName, style = secondStyle }, var1 = var1 });
135135
[RishUI.MemoryManagement.RequiresManagedContext]
136136
public static RishUI.Element Create(ulong key, FooProps props) => RishUI.Rish.Create<Foo, FooProps>(key, props);
137137
[RishUI.MemoryManagement.RequiresManagedContext]
138-
public static RishUI.Element Create(ulong key, RishUI.Name name = default, RishUI.ClassName className = default, RishUI.Style style = default, RishUI.Name secondName = default, RishUI.ClassName secondClassName = default, RishUI.Style secondStyle = default, System.Boolean var1 = default) => Create(key, new FooProps { descriptor = new RishUI.DOMDescriptor {name = name, className = className, style = style }, secondDescriptor = new RishUI.DOMDescriptor {name = secondName, className = secondClassName, style = secondStyle }, var1 = var1 });
138+
public static RishUI.Element Create(ulong key, RishUI.Name name = default, RishUI.ClassName className = default, RishUI.Style style = default, RishUI.Name secondName = default, RishUI.ClassName secondClassName = default, RishUI.Style secondStyle = default, System.Boolean var1 = default) => Create(key, new FooProps { descriptor = new RishUI.VisualAttributes {name = name, className = className, style = style }, secondDescriptor = new RishUI.VisualAttributes {name = secondName, className = secondClassName, style = secondStyle }, var1 = var1 });
139139
}
140140
// ↑↑↑ Autogenerated ↑↑↑
141141
{% endhighlight %}
@@ -164,20 +164,20 @@ public struct FooProps {
164164
public partial class Foo
165165
{
166166
[RishUI.MemoryManagement.RequiresManagedContext]
167-
public static RishUI.Element Create() => Create(default(ulong), default(RishUI.DOMDescriptor), default(FooProps), default(RishUI.Children));
167+
public static RishUI.Element Create() => Create(default(ulong), default(RishUI.VisualAttributes), default(FooProps), default(RishUI.Children));
168168
[RishUI.MemoryManagement.RequiresManagedContext]
169-
public static RishUI.Element Create(ulong key) => Create(key, default(RishUI.DOMDescriptor), default(FooProps), default(RishUI.Children));
169+
public static RishUI.Element Create(ulong key) => Create(key, default(RishUI.VisualAttributes), default(FooProps), default(RishUI.Children));
170170
[RishUI.MemoryManagement.RequiresManagedContext]
171-
public static RishUI.Element Create(RishUI.DOMDescriptor descriptor) => Create(default(ulong), descriptor, default(FooProps), default(RishUI.Children));
171+
public static RishUI.Element Create(RishUI.VisualAttributes descriptor) => Create(default(ulong), descriptor, default(FooProps), default(RishUI.Children));
172172
[RishUI.MemoryManagement.RequiresManagedContext]
173-
public static RishUI.Element Create(RishUI.Name name) => Create(default(ulong), new RishUI.DOMDescriptor { name = name }, default(FooProps), default(RishUI.Children));
173+
public static RishUI.Element Create(RishUI.Name name) => Create(default(ulong), new RishUI.VisualAttributes { name = name }, default(FooProps), default(RishUI.Children));
174174
[RishUI.MemoryManagement.RequiresManagedContext]
175-
public static RishUI.Element Create(RishUI.ClassName className) => Create(default(ulong), new RishUI.DOMDescriptor { className = className }, default(FooProps), default(RishUI.Children));
175+
public static RishUI.Element Create(RishUI.ClassName className) => Create(default(ulong), new RishUI.VisualAttributes { className = className }, default(FooProps), default(RishUI.Children));
176176
[RishUI.MemoryManagement.RequiresManagedContext]
177-
public static RishUI.Element Create(RishUI.Style style) => Create(default(ulong), new RishUI.DOMDescriptor { style = style }, default(FooProps), default(RishUI.Children));
177+
public static RishUI.Element Create(RishUI.Style style) => Create(default(ulong), new RishUI.VisualAttributes { style = style }, default(FooProps), default(RishUI.Children));
178178
// A lot more methods
179179
[RishUI.MemoryManagement.RequiresManagedContext]
180-
public static RishUI.Element Create(ulong key, RishUI.Name name, RishUI.ClassName className, RishUI.Style style, RishUI.Children children, System.Boolean var1 = default, System.Single var2 = default, System.Int32 var3 = default) => Create(key, new RishUI.DOMDescriptor { name = name, className = className, style = style }, new FooProps { var1 = var1, var2 = var2, var3 = var3 }, children);
180+
public static RishUI.Element Create(ulong key, RishUI.Name name, RishUI.ClassName className, RishUI.Style style, RishUI.Children children, System.Boolean var1 = default, System.Single var2 = default, System.Int32 var3 = default) => Create(key, new RishUI.VisualAttributes { name = name, className = className, style = style }, new FooProps { var1 = var1, var2 = var2, var3 = var3 }, children);
181181
}
182182
// ↑↑↑ Autogenerated ↑↑↑
183183
{% endhighlight %}
@@ -187,7 +187,7 @@ public partial class Foo
187187
<h4 class="callout-title"><i class="fa-solid fa-circle-info"></i>Reserved Keywords</h4>
188188
<ul>
189189
<li><code>key</code>: Always reserved for Element Keys.</li>
190-
<li><code>name</code>, <code>className</code> and <code>style</code>: Reserved in VisualElements and RishElements with expanded <code>DOMDescriptors</code>.</li>
190+
<li><code>name</code>, <code>className</code> and <code>style</code>: Reserved in VisualElements and RishElements with expanded <code>VisualAttributess</code>.</li>
191191
<li><code>children</code>: Reserved in VisualElements.</li>
192192
</ul>
193193
</div>

_auto_docs/rish/09-best-practices.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -181,12 +181,12 @@ Rishenerator automatically generates `SappyProps` (for callbacks) and `SappyStat
181181
{% highlight csharp %}
182182
public partial class CachedLambdasExample : RishElement<CachedLambdasExampleProps>, IMountingListener
183183
{
184-
void IMountingListener.ComponentDidMount()
184+
void IMountingListener.ElementDidMount()
185185
{
186186
// ✅ Every time the element is mounted, we are reusing the same instance generated by Rishenerator.
187187
VolumeLevel.OnChange += SappyState.SetVolume;
188188
}
189-
void IMountingListener.ComponentWillUnmount()
189+
void IMountingListener.ElementWillUnmount()
190190
{
191191
// ✅ Every time the element is unmounted, we are reusing the same instance generated by Rishenerator.
192192
VolumeLevel.OnChange -= SappyState.SetVolume;
@@ -397,8 +397,8 @@ When it comes to best practices styling VisualElements, UI Toolkit is king. You
397397
Interfaces are implemented explicitly.
398398

399399
{% highlight csharp %}
400-
void IMountingListener.ComponentDidMount() { }
401-
void IMountingListener.ComponentWillUnmount() { }
400+
void IMountingListener.ElementDidMount() { }
401+
void IMountingListener.ElementWillUnmount() { }
402402
{% endhighlight %}
403403

404404
You should not call any of these lifecycle methods manually and implementing them explicitly adds extra friction to prevent you from calling them by accident.

_config.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,11 @@ defaults:
5555
type: docs
5656
values:
5757
layout: docs
58+
icon-style: solid
5859
- scope:
5960
path: ""
6061
type: auto_docs
62+
icon-style: solid
6163
values:
6264
layout: docs
6365
- scope:

_docs/rish/3.0.0/01-installation.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public partial class App : IApp
8080
// The internal Root element manages the application state
8181
private partial class Root : RishElement<NoProps, RootState>, IMountingListener
8282
{
83-
void IMountingListener.ComponentDidMount() {
83+
void IMountingListener.ElementDidMount() {
8484
if(StaticData.IsLoaded)
8585
{
8686
// If data is already ready, set progress immediately
@@ -91,7 +91,7 @@ public partial class App : IApp
9191
StaticData.OnLoadingProgress += SetLoadingProgress;
9292
}
9393
}
94-
void IMountingListener.ComponentWillUnmount() {
94+
void IMountingListener.ElementWillUnmount() {
9595
StaticData.OnLoadingProgress -= SetLoadingProgress;
9696
}
9797

_docs/rish/3.0.0/03-visualelements.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,10 +155,10 @@ Rish provides interfaces to hook into the lifecycle of a `VisualElement`.
155155
Useful for initialization logic or event subscription.
156156

157157
{% highlight csharp %}
158-
void IMountingListener.ComponentDidMount() {
158+
void IMountingListener.ElementDidMount() {
159159
Debug.Log("Element added to the Visual Tree");
160160
}
161-
void IMountingListener.ComponentWillUnmount() {
161+
void IMountingListener.ElementWillUnmount() {
162162
Debug.Log("Element about to be removed");
163163
}
164164
{% endhighlight %}

0 commit comments

Comments
 (0)