Skip to content

Commit 6562fb1

Browse files
committed
proofed docs/client-dsl
1 parent 2413199 commit 6562fb1

19 files changed

+242
-73
lines changed

.rubocop.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,3 +151,7 @@ Layout/MultilineMethodCallIndentation:
151151
Exclude:
152152
- 'bin/yarn'
153153
- app/hyperstack/components
154+
155+
Lint/ConstantDefinitionInBlock:
156+
Exclude:
157+
- !ruby/regexp /_spec\.rb$/

docs/README.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ In the code above, if the `good_books` scope changed \(even on the server\), the
2525

2626
<img align="left" width="100" height="100" style="margin-right: 20px" src="https://github.com/hyperstack-org/hyperstack/blob/edge/docs/wip.png?raw=true">
2727

28-
While we have over 1000 specs passing, in 3 different configurations, and several large apps using Hyperstack, documentation is a lagging. If you see this icon it means we are working hard to
28+
While we have over 1000 specs passing in 3 different configurations, and several large apps using Hyperstack, documentation is lagging. If you see this icon it means we are working hard to
2929
get the docs up to the same state as the code.
3030

31-
Chapters without the work-in-progress flag, are still draft, and any issues are greatly appreciated, or better yet follow the `Edit on Github` link make your propsed corrections, and submit a pull request.
31+
Chapters without the work-in-progress flag are still draft, and any issues are greatly appreciated, or better yet follow the `Edit on Github` link, make your proposed corrections, and submit a pull request.
3232

3333
## Setup and installation
3434

@@ -46,7 +46,7 @@ Hyperstack is supported by a friendly, helpful community, both for users, and co
4646

4747
## Roadmap
4848

49-
We are currently driving towards our 1.0 release. Currently we are at 1.0.alpha1.5 release candidate. There is a list of 163 open issues including some bugs, many requested enhancements. The plan is to triage the issues, and do a weekly release until the issues are closed as deemed not needed for a 1.0 release.
49+
We are currently driving towards our 1.0 release. Currently we are at 1.0.alpha1.5 release candidate. There is a list of 163 open issues including some bugs, documentation issues and many requested enhancements. The plan is to triage the issues and do a weekly release until the issues are closed or deemed not needed for a 1.0 release.
5050

5151
Please consider contributing by grabbing a "good first issue", or just adding your thoughts, thumbs up, or down on any issues that interest you.
5252

@@ -55,8 +55,6 @@ Please consider contributing by grabbing a "good first issue", or just adding yo
5555
In general, if you would like to help in any way, please read the [CONTRIBUTING](https://github.com/hyperstack-org/hyperstack/blob/edge/CONTRIBUTING.md) file for suggestions.
5656
System setup for the development of Hyperstack itself is documented in this file.
5757

58-
More specifically, we have a [Feature Matrix](https://github.com/hyperstack-org/hyperstack/blob/edge/docs/feature_matrix.md) that needs to be filled with missing features. The idea is that you can check here what the implementation status is of a Ruby \(on Rails\) feature. And if you have the time and skill you're more then encouraged to implement or fix one or two. But if you're not in a position to contribute code, just expanding and maintaining this table would be excellent.
59-
6058
## Links
6159

6260
* Rubygems: [https://rubygems.org/profiles/hyperstack](https://rubygems.org/profiles/hyperstack)

docs/client-dsl/component-basics.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ end
3838

3939
To create a component instance, you reference its class name as a method call from another component. This creates a new instance, passes any parameters and proceeds with the component lifecycle.
4040

41-
> **[The actual type created is an Element read on for details...](/notes.html#component_instances)**
41+
> **[The actual type created is an Element read on for details...](notes.md#component-instances)**
4242
4343
```ruby
4444
class FirstComponent < HyperComponent
@@ -80,7 +80,7 @@ Components can receive new params, causing the component to update. **[More on
8080

8181
## Component State
8282

83-
Component also have *state*, which is stored in instance variables. You signal a state change using the `mutate` method. Component state is a fundamental concept covered **[here](state.md)**.
83+
Components also have *state*, which is stored in instance variables. You signal a state change using the `mutate` method. Component state is a fundamental concept covered **[here](state.md)**.
8484

8585

8686
## Life Cycle Callbacks
@@ -101,7 +101,7 @@ class Clock < HyperComponent
101101
end
102102
```
103103

104-
The complete list of life cycle methods and their syntax is discussed in detail in the **[Lifecycle Methods](/lifecycle-methods)** section.
104+
The complete list of life cycle methods and their syntax is discussed in detail in the **[Lifecycle Methods](lifecycle-methods.md)** section.
105105

106106
## Events, Event Handlers, and Component Callbacks
107107

docs/client-dsl/elements-and-rendering.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ The only major difference between the systems is that JSX compiles directly to R
1313
As each React element is generated it is stored by Hyperstack in a *rendering buffer*, and when the component finishes the rendering block, the buffer is returned as the result of the components render callback. If the expression has a child block (like `DIV { 'hello' }`) the block is passed to the `createElement` as a the child function the same
1414
as JSX would do.
1515

16-
When an expression like this is evaluated (**[see the full example in the section on params...](/params#named-child-components-as-params)**)
16+
When an expression like this is evaluated (**[see the full example in the section on params...](../params#named-child-components-as-params)**)
1717
```ruby
1818
Reveal(content: DIV { 'I came from the App' })
1919
```
2020
we need to *remove* the generated `DIV` element *out* of the rendering buffer before passing it to `Reveal`. This is done automatically by applying the `~` (remove) operator to the
2121
`DIV` as it is passed on.
2222

23-
In general will never have to manually use the remove (`~`) operator, as React's declarative nature makes storing elements for later use not as helpful in more
23+
In general you will never have to manually use the remove (`~`) operator, as React's declarative nature makes storing elements for later use not as necessary as in more
2424
procedural frameworks.
2525

2626
#### Creating Elements Programmatically

docs/client-dsl/events-and-callbacks.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,14 +115,14 @@ no reason not use the `on` method to attach handlers. Both will keep your code
115115
The notation `on(:click)` is short for passing a proc to a param named `on_click`. In general `on(:xxx)` will pass the
116116
given block as the `on_xxx` parameter in a Hyperstack component and `onXxx` in a JS component.
117117

118-
All the built-in events and many React libraries follow the `on_xxx` (or `onXxx` in JS.) However even if a library does not use
118+
All the built-in events and many React libraries follow the `on_xxx` (or `onXxx` in JS) convention. However even if a library does not use
119119
this convention you can still attach the handler using `on('<name-of-param>')`. Whatever string is inside the `<..>` brackets will
120120
be used as the param name.
121121

122122
Likewise the `fires` method is shorthand for creating a `Proc` param following the `on_xxx` naming convention:
123123

124124
`fires :foo` is short for
125-
`param :foo, type: Proc, alias: :foo!`
125+
`param :on_foo, type: Proc, alias: :foo!`
126126

127127
### The `Event` Object
128128

@@ -147,7 +147,7 @@ Besides the UI there are several other sources of events:
147147
The way you receive events from these sources depends on the event. Typically though the method will either take a block, or callback proc, or in many cases will return a Promise.
148148
Regardless the event handler will do one of three things: mutate some state within the component, fire an event to a higher level component, or update some shared store.
149149

150-
> For details on updating shared stores, which is often the best answer **[see the chapter on HyperState...](/hyper-state.md)**
150+
> For details on updating shared stores, which is often the best answer **[see the chapter on HyperState...](../hyper-state.md)**
151151
152152
You have seen the `every` method used to create events throughout this chapter, here is an example with an HTTP post (which returns a promise.)
153153

docs/client-dsl/javascript-components.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
Hyperstack gives you full access to the entire universe of JavaScript libraries and components directly within your Ruby code.
44

5-
Everything you can do in JavaScript is simple to do in Opal-Ruby; this includes passing parameters between Ruby and JavaScript and even passing Ruby methods as JavaScript callbacks. See the JavaScript section for more information.
5+
Everything you can do in JavaScript is simple to do in Opal-Ruby; this includes passing parameters between Ruby and JavaScript and even passing Ruby methods as JavaScript callbacks.
66

7-
> **[For more information on writing Javascript within your Ruby code...](/notes.md#Javascript)**
7+
> **[For more information on writing Javascript within your Ruby code...](notes.md#javascript)**
88
99
## Importing Javascript or React Libraries
1010

@@ -64,7 +64,7 @@ Libraries used often with Hyperstack projects:
6464

6565
### Making Custom Wrappers - WORK IN PROGRESS ...
6666

67-
Hyperstack will automatically import Javascript components and component libraries as discussed above. Sometimes for
67+
<img align="left" width="100" height="100" style="margin-right: 20px" src="https://github.com/hyperstack-org/hyperstack/blob/edge/docs/wip.png?raw=true"> Hyperstack will automatically import Javascript components and component libraries as discussed above. Sometimes for
6868
complex libraries that you will use a lot it is useful to add some syntactic sugar to the wrapper.
6969

7070
This can be done using the `imports` directive and the `Hyperstack::Component::NativeLibrary` superclass.
@@ -134,7 +134,7 @@ finally require it in your hyper_component.rb file:
134134

135135
require 'hyperstack/component/jquery'
136136
```
137-
You can access jQuery anywhere in your code using the `Element` or the `jQ` methods.
137+
You can access jQuery anywhere in your code using the `jQ` method.
138138
For details see https://github.com/opal/opal-jquery
139139

140140
> Note most of the time you will not need to manipulate the dom directly.

docs/client-dsl/lifecycle-methods.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ A component may define lifecycle methods for each phase of the components lifecy
1010
* `render` will be called again here
1111
* `after_update`
1212
* `before_unmount`
13-
* `rescues` The `rescues` callback is described **[here...](/error-recovery.md)**
13+
* `rescues` The `rescues` callback is described **[here...](error-recovery.md)**
1414

1515
All the Component Lifecycle methods (except `render`) may take a block or the name(s) of instance method(s) to be called. The `render` method always takes a block.
1616

@@ -21,7 +21,7 @@ class MyComponent < HyperComponent
2121
end
2222

2323
render do
24-
# return some elements
24+
# return some elements
2525
end
2626

2727
before_unmount :cleanup # call the cleanup method before unmounting

docs/client-dsl/methods.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ class. You may also use any other Ruby constructs such as method definition as
55
you would in any Ruby class.
66

77
**Interface Definition**
8-
These methods define the signature of the components params.
8+
These methods define the signature of the component's params.
99
+ `param(*args)` - specifies params and creates accessor methods
1010
+ `fires(name, alias: internal_name)` - specifies an event call-back
1111
+ `others(name)` accessor method that collects all params not otherwise specified
@@ -27,16 +27,16 @@ define multiple handlers for each callback.
2727
+ `rescues(*klasses_to_rescue, &block)`
2828

2929
**State Management**
30-
Each component instance has internal state represented by the contents of instance variables,
31-
changes to the state is signaled using the instance `mutate` method. The following methods
32-
define instance methods that access state with builtin calls to the mutate method.
30+
Each component instance has internal state represented by the contents of instance variables:
31+
changes to the state is signaled using the `mutate` method. The following methods
32+
define additional instance methods that access state with built-in calls to the mutate method.
3333
+ `mutator` defines an *instance* method with a built-in mutate.
3434
+ `state_reader` creates an *instance* state read only accessor method.
3535
+ `state_writer` creates an *instance* state write only accessor method.
3636
+ `state_accessor` creates *instance* reader and writer methods.
3737

3838
**Other Class Level Methods**
39-
+ `mounted_components` - returns array of all currently mounted components of this class and subclasses
39+
+ `mounted_components` - returns an array of all currently mounted components of this class and subclasses
4040
+ `force_update!` forces all components in this class and its subclasses to update
4141
+ `create_element(*params, &children)` - create an element from this class
4242
+ `insert_element(*params, &children)` - create and insert an element into the rendering buffer

docs/client-dsl/notes.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,3 +295,20 @@ You may also turn off the autoimport function if necessary in your `hyperstack.r
295295
# do not use the auto-import module
296296
Hyperstack.cancel_import 'hyperstack/component/auto-import'
297297
```
298+
299+
### The Enter Event
300+
```ruby
301+
class YouSaid < HyperComponent
302+
state_accessor :value
303+
render(DIV) do
304+
INPUT(value: value)
305+
.on(:enter) do
306+
alert "You said: #{value}"
307+
self.value = ""
308+
end
309+
.on(:change) do |e|
310+
self.value = e.target.value
311+
end
312+
end
313+
end
314+
```

docs/client-dsl/params.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ class App < HyperComponent
8484
end
8585
end
8686
```
87+
[see the spec...](https://github.com/hyperstack-org/hyperstack/blob/24131990ea1cdacfc9efc328d4994a7c2d86a0f4/docs/specs/spec/client-dsl/params_spec.rb#L4-L25)
8788

8889
`render` is used to render the child components. **[For details ...](component-details.md#rendering-children)**
8990

@@ -163,7 +164,7 @@ end
163164
Even though we have not gotten to event handlers yet, you can see what is going on: When we click the update button we call `force_update!`
164165
which will force the `App` component to rerender.
165166
> By the way `force_update!` is almost never used, but we are using it here
166-
just to make the example clear.)
167+
just to make the example clear. Its also one of the reasons this example gets into trouble. Read on!
167168

168169
Will `Comp2` rerender? No - because even though we are creating a new hash, the old hash and new hash are equal in value.
169170

@@ -194,5 +195,5 @@ So when we compare *old* verses *new* we are comparing the same object, so the v
194195

195196
That does not seem like a very happy ending, but the case we used was not very realistic. If you stick to passing simple scalars, or hashes and arrays
196197
whose values don't change after they have been passed, things will work fine. And for situations where you do need to store and
197-
manipulate complex data, you can use the **[the Hyperstack::Observable module](/hyper-state/README.md)** to build safe classes that don't
198+
manipulate complex data, you can use the **[the Hyperstack::Observable module](../hyper-state/README.md)** to build safe classes that don't
198199
have the problems seen above.

0 commit comments

Comments
 (0)