Browse Source

Fixes in class docs.

Herbert Vojčík 7 years ago
parent
commit
99b49f8c78
2 changed files with 20 additions and 10 deletions
  1. 1 1
      src/Silk.js
  2. 19 9
      src/Silk.st

+ 1 - 1
src/Silk.js

@@ -8,7 +8,7 @@ $core.packages["Silk"].transport = {"type":"amd","amdNamespace":"silk"};
 
 $core.addClass('Silk', $globals.Domite, [], 'Silk');
 //>>excludeStart("ide", pragmas.excludeIdeData);
-$globals.Silk.comment="I am adding convenience APIs to my subclass, `Domite`.\x0a\x0a##Rendering\x0a\x0a - `aSilk << anObject` uses double-dispatch via `renderOnSilk:`. This allows creating widgets (no formal superclass, anything with `renderOnSilk:` is a widget), as well as incorporating magic on other objects:\x0a   - blocks: `aSilk << aBlock` runs the block, passing aSilk as a parameter.\x0a   - associations: `aSilk << (key -> value)` set attribute key to value.\x0a\x0aIt is good to note that rendering collection has magic\x0aof its own built-in in general: if you `stream << aCollection`, its items are `<<`'d in sequence.\x0aSo, de facto, array are deeply flattened\x0awhen putting on a stream via `<<`.\x0a\x0a##Convenience\x0a\x0a - `aCssSelectorString asSilk` returns Silk wrapping an element at a selector.\x0a - `anObject inSilk` returns anObject rendered in a document fragment.\x0a\x0a##Element creation\x0a\x0aThese messages use DNU to dynamically create\x0aelements with any (letters-and-numbers) tag name,\x0aNext samples show this on an example of `<div>`.\x0a\x0a - `Silk DIV` is shortcut for `Silk newElement: 'div'`.\x0a - `aSilk DIV` is shortcut for `[ |tmp| tmp := Silk DIV. aSilk << tmp. tmp] value`. IOW, it not just creates the element and returns it, but also puts in on aSilk.\x0a - `aSilk DIV: anObject` is shortcut for `aSilk DIV << anObject; yourself`. IOW, it not just creates and insert the element, but puts a content into it.\x0a\x0a##Conclusions\x0a\x0aTaken all this together, one can do pretty neat constructs:\x0a\x0a```\x0a  aSilk P: { 'id'->'mission'. 'We are the champions.' }\x0a```\x0a\x0aadds `<p id=\x22mission\x22>We are the champions.</p>` into `aSilk`.";
+$globals.Silk.comment="I am subclass of `Domite` with more convenient high-level API.\x0a\x0a##Rendering\x0a\x0a - `aSilk << anObject` uses double-dispatch via `renderOnSilk:`.\x0aThis allows to create widgets\x0a(no formal superclass, anything with `renderOnSilk:` is a widget),\x0aas well as incorporating magic on certain types of objects:\x0a   - blocks: `aSilk << aBlock` runs the block, passing aSilk as a parameter.\x0a   - associations: `aSilk << (key -> value)` set attribute key to value.\x0a\x0aWorthful to note is, rendering a collection has its magic\x0aalready built-in (via `putOn:`) -- if you `stream << aCollection`,\x0aits items are `<<`'d in sequence.\x0aSo, de facto, arrays are deeply flattened when put on a stream via `<<`.\x0a\x0a##Convenience\x0a\x0a - `aCssSelectorString asSilk` returns Silk wrapping an element at a selector.\x0a - `anObject inSilk` returns anObject rendered in a document fragment.\x0a\x0a##Element creation\x0a\x0aThese messages use DNU to dynamically create\x0aelements with any (letters-and-numbers) tag name,\x0aNext samples show this on an example of `<div>`.\x0a\x0a - `Silk DIV` is shortcut for `Silk newElement: 'div'`.\x0a - `aSilk DIV` is shortcut for\x0a`[ |tmp| tmp := Silk DIV. aSilk << tmp. tmp] value`.\x0aIOW, it not just creates the element and returns it,\x0abut also puts in on aSilk.\x0a - `aSilk DIV: anObject` is shortcut for\x0a`aSilk DIV << anObject; yourself`.\x0aIOW, it not just creates and inserts the element,\x0abut puts a content into it.\x0a\x0a##Conclusions\x0a\x0aTaken all this together, one can do pretty neat constructs:\x0a\x0a```\x0a  aSilk P: { 'id'->'mission'. 'We are the champions.' }\x0a```\x0a\x0aadds `<p id=\x22mission\x22>We are the champions.</p>` into `aSilk`\x0aand returns the Silk-wrapped `<p>` with insertion cursor at the end.";
 //>>excludeEnd("ide");
 $core.addMethod(
 $core.method({

+ 19 - 9
src/Silk.st

@@ -3,18 +3,21 @@ Domite subclass: #Silk
 	instanceVariableNames: ''
 	package: 'Silk'!
 !Silk commentStamp!
-I am adding convenience APIs to my subclass, `Domite`.
+I am subclass of `Domite` with more convenient high-level API.
 
 ##Rendering
 
- - `aSilk << anObject` uses double-dispatch via `renderOnSilk:`. This allows creating widgets (no formal superclass, anything with `renderOnSilk:` is a widget), as well as incorporating magic on other objects:
+ - `aSilk << anObject` uses double-dispatch via `renderOnSilk:`.
+This allows to create widgets
+(no formal superclass, anything with `renderOnSilk:` is a widget),
+as well as incorporating magic on certain types of objects:
    - blocks: `aSilk << aBlock` runs the block, passing aSilk as a parameter.
    - associations: `aSilk << (key -> value)` set attribute key to value.
 
-It is good to note that rendering collection has magic
-of its own built-in in general: if you `stream << aCollection`, its items are `<<`'d in sequence.
-So, de facto, array are deeply flattened
-when putting on a stream via `<<`.
+Worthful to note is, rendering a collection has its magic
+already built-in (via `putOn:`) -- if you `stream << aCollection`,
+its items are `<<`'d in sequence.
+So, de facto, arrays are deeply flattened when put on a stream via `<<`.
 
 ##Convenience
 
@@ -28,8 +31,14 @@ elements with any (letters-and-numbers) tag name,
 Next samples show this on an example of `<div>`.
 
  - `Silk DIV` is shortcut for `Silk newElement: 'div'`.
- - `aSilk DIV` is shortcut for `[ |tmp| tmp := Silk DIV. aSilk << tmp. tmp] value`. IOW, it not just creates the element and returns it, but also puts in on aSilk.
- - `aSilk DIV: anObject` is shortcut for `aSilk DIV << anObject; yourself`. IOW, it not just creates and insert the element, but puts a content into it.
+ - `aSilk DIV` is shortcut for
+`[ |tmp| tmp := Silk DIV. aSilk << tmp. tmp] value`.
+IOW, it not just creates the element and returns it,
+but also puts in on aSilk.
+ - `aSilk DIV: anObject` is shortcut for
+`aSilk DIV << anObject; yourself`.
+IOW, it not just creates and inserts the element,
+but puts a content into it.
 
 ##Conclusions
 
@@ -39,7 +48,8 @@ Taken all this together, one can do pretty neat constructs:
   aSilk P: { 'id'->'mission'. 'We are the champions.' }
 ```
 
-adds `<p id="mission">We are the champions.</p>` into `aSilk`.!
+adds `<p id="mission">We are the champions.</p>` into `aSilk`
+and returns the Silk-wrapped `<p>` with insertion cursor at the end.!
 
 !Silk methodsFor: 'writing'!