浏览代码

MethodCategory and PluggableExporter have comments

Herbert Vojčík 10 年之前
父节点
当前提交
c7ae012c96
共有 2 个文件被更改,包括 35 次插入0 次删除
  1. 2 0
      js/Importer-Exporter.js
  2. 33 0
      st/Importer-Exporter.st

+ 2 - 0
js/Importer-Exporter.js

@@ -860,6 +860,7 @@ smalltalk.Importer);
 
 
 smalltalk.addClass('MethodCategory', smalltalk.Object, ['methods', 'name', 'theClass'], 'Importer-Exporter');
+smalltalk.MethodCategory.comment="I am an abstraction for a method category in a class / metaclass.\x0a\x0aI know of my class, name and methods.\x0aI am used when exporting a package.";
 smalltalk.addMethod(
 smalltalk.method({
 selector: "methods",
@@ -1436,6 +1437,7 @@ smalltalk.LegacyPackageHandler.klass);
 
 
 smalltalk.addClass('PluggableExporter', smalltalk.Object, ['recipe'], 'Importer-Exporter');
+smalltalk.PluggableExporter.comment="I am an engine for exporting structured data on a Stream.\x0a\x0aMy instances are created using\x0a  PluggableExporter newUsing: recipe,\x0awhere recipe is structured description of the exporting algorithm,\x0a\x0aThen actual exporting is done using\x0a  aPluggableExporter export: data usingRecipe: recipe on: stream\x0a\x0aRecipe is an array, which can contain two kinds of elements:\x0a - an assocation where key is the receiver and value is two-arg selector\x0a    In this case, `receiver perform: selector withArguments: { data. stream }` is called.\x0a\x09This essentially defines one step of export process.\x0a\x09The key (eg. receiver) is presumed to be some kind of 'repository' of the exporting methods\x0a\x09that just format appropriate aspect of data into a stream; like a class or a singleton,\x0a\x09so you can make the recipe itself decoupled from data.\x0a - a subarray (sa), where first element is special and the rest is recursive recipe\x0a    `sa first` must be an association similar to one above,\x0a\x09with key being the 'repository' receiver, but value is one-arg selector.\x0a\x09In this case, `receiver perform: selector withArguments: { data }` should create a collection.\x0a\x09Then, the sub-recipe (`sa allButFirst`) is applied to every element of a collection, eg.\x0a\x09  collection do: [ :each | self export: each using: sa allButFirst on: stream ]\x0a  \x0aI am used to export amber packages, so I have convenience method\x0aexportPackage: aPackage on: aStream\x0awhich exports aPackage using recipe you passed on newUsing:\x0a(it is otherwise no special, so it may be renamed to export:on:)";
 smalltalk.addMethod(
 smalltalk.method({
 selector: "export:usingRecipe:on:",

+ 33 - 0
st/Importer-Exporter.st

@@ -425,6 +425,11 @@ import: aStream
 Object subclass: #MethodCategory
 	instanceVariableNames: 'methods name theClass'
 	package: 'Importer-Exporter'!
+!MethodCategory commentStamp!
+I am an abstraction for a method category in a class / metaclass.
+
+I know of my class, name and methods.
+I am used when exporting a package.!
 
 !MethodCategory methodsFor: 'accessing'!
 
@@ -636,6 +641,34 @@ loadPackages: aCollection prefix: aString
 Object subclass: #PluggableExporter
 	instanceVariableNames: 'recipe'
 	package: 'Importer-Exporter'!
+!PluggableExporter commentStamp!
+I am an engine for exporting structured data on a Stream.
+
+My instances are created using
+  PluggableExporter newUsing: recipe,
+where recipe is structured description of the exporting algorithm,
+
+Then actual exporting is done using
+  aPluggableExporter export: data usingRecipe: recipe on: stream
+
+Recipe is an array, which can contain two kinds of elements:
+ - an assocation where key is the receiver and value is two-arg selector
+    In this case, `receiver perform: selector withArguments: { data. stream }` is called.
+	This essentially defines one step of export process.
+	The key (eg. receiver) is presumed to be some kind of 'repository' of the exporting methods
+	that just format appropriate aspect of data into a stream; like a class or a singleton,
+	so you can make the recipe itself decoupled from data.
+ - a subarray (sa), where first element is special and the rest is recursive recipe
+    `sa first` must be an association similar to one above,
+	with key being the 'repository' receiver, but value is one-arg selector.
+	In this case, `receiver perform: selector withArguments: { data }` should create a collection.
+	Then, the sub-recipe (`sa allButFirst`) is applied to every element of a collection, eg.
+	  collection do: [ :each | self export: each using: sa allButFirst on: stream ]
+  
+I am used to export amber packages, so I have convenience method
+exportPackage: aPackage on: aStream
+which exports aPackage using recipe you passed on newUsing:
+(it is otherwise no special, so it may be renamed to export:on:)!
 
 !PluggableExporter methodsFor: 'accessing'!