[squeak-dev] CustomHelpToOrg dev question.
gettimothy at zoho.com
Sat Sep 4 09:58:31 UTC 2021
>Using #, works, but it is quite suboptimal. It'll result in the creation
>of many intermediate objects and will result in quadratic runtime.
>An easy way to avoid that would be to write directly into the file stream,
>but Squeak's file streams are not write-buffered, so I advise against
>Instead, you should create an in-memory stream, and write data into that
>stream. Once done, write the contents of the stream into the file.
>| contents |
>contents := String streamContents: [ :stream |
> <write stuff to the stream here with #nextPut:, #nextPutAll:, etc> ].
>FileStream newFileNamed: <file name here> do: [ :file |
> file nextPutAll: contents ]
Thank you for the pointers.
Here is a stab at it with your recommendations:
|ios filename recurse break newline |
newline := (Character cr asString).
break:= newline, newline.
ios := String streamContents:[:stream|
stream nextPutAll: ( '* ', aCustomHelp name asString , newline).
recurse := [:help |
help pages do:[:each | | v |
each asString first isUppercase
stream nextPutAll: ( '* ' , each, break).
recurse value: (Smalltalk at: each)]
v := help perform: each.
stream nextPutAll: ( break, '** ' , (v title) , (Character cr asString), break , (v contents) ,break)]]].
recurse value: aCustomHelp
filename := ((aCustomHelp name asString), '.org').
StandardFileStream forceNewFileNamed: filename do: [ :file |
file nextPutAll: ios ].
DocCustomHelpToOrg toTestFile: PostgresV3Help.
The output is beautiful org mode content, but only for that superclass.
The Help System treats subclasses of a CustomHelp class as 'books'.
I am going to try to figure out how to do that next.
maybe a new method that calls this method.
anyhoo, thank you to all who responded, Much appreciated!
P.S. I am thinking a HelpTerseGuideNot with all the subjects in the terse guide expanded with examples of really cool code that is all over the mailing lists will be a nice feature. These examples here will definitely be on that book.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Squeak-dev