[squeak-dev] The Inbox: HelpSystem-Core-LM.141.mcz
commits at source.squeak.org
commits at source.squeak.org
Thu Jul 14 14:24:19 UTC 2022
A new version of HelpSystem-Core was added to project The Inbox:
http://source.squeak.org/inbox/HelpSystem-Core-LM.141.mcz
==================== Summary ====================
Name: HelpSystem-Core-LM.141
Author: LM
Time: 14 July 2022, 4:06:42.369386 pm
UUID: 887985cb-790f-4976-9514-be491a3167e9
Ancestors: HelpSystem-Core-mt.140
Allow HelpTopic instances to choose a custom Styler class used when styling their contents.
This is especially useful for Markdown support, which can then select a custom Markdown Styler.
=============== Diff against HelpSystem-Core-mt.140 ===============
Item was added:
+ ----- Method: AbstractHelpTopic>>stylerClass (in category 'tools') -----
+ stylerClass
+ "Subclasses may overwrite this and #usesCodeStyling to enable a styler of their own choosing."
+ ^ TextStyler for: #Smalltalk!
Item was changed:
----- Method: AbstractHelpTopic>>usesCodeStyling (in category 'testing') -----
usesCodeStyling
+ "do I need a styled (ie with Shout) browser page?
+ Overwrite #stylerClass to change the Styler used."
- "do I need a styled (ie with Shout) browser page?"
^false!
Item was changed:
----- Method: DirectoryBasedHelpTopic>>accept:for: (in category 'editing') -----
accept: newContents for: subtopic
+ subtopic contents: newContents.
- FileStream forceNewFileNamed: subtopic fileEntry fullName do: [:strm |
- strm nextChunkPutWithStyle: newContents].
^ true
!
Item was changed:
----- Method: DirectoryBasedHelpTopic>>subtopics (in category 'accessing') -----
subtopics
| directory |
subtopics ifNotNil: [^ subtopics].
self directoryEntry ifNil: [^ #()].
directory := self directoryEntry asFileDirectory.
^ subtopics := (directory entries
select: [:ea | ea isDirectory]
thenCollect: [:ea | DirectoryBasedHelpTopic new directoryEntry: ea]),
((directory fileNamesMatching: self filter)
+ collect: [:fileName | FileBasedHelpTopic for: (directory entryAt: fileName) withSorting: self sortBlock])!
- collect: [:fileName | FileBasedHelpTopic new
- fileEntry: (directory entryAt: fileName);
- sortBlock: self sortBlock])!
Item was changed:
AbstractHelpTopic subclass: #FileBasedHelpTopic
instanceVariableNames: 'contents fileEntry sortBlock'
classVariableNames: ''
poolDictionaries: ''
category: 'HelpSystem-Core-Model'!
+
+ !FileBasedHelpTopic commentStamp: 'LM 7/14/2022 15:34' prior: 0!
+ I am a help topic that represents a file on disk.
+
+ My content is loaded from the file. Saving modifications in the Help Browser will update the file on disk.
+ This is a great tool to sync external documentation with Squeak.
+
+ There also exists an API to support handling of different file extensions.
+ See the #classFor: implementation on the class side.!
Item was added:
+ ----- Method: FileBasedHelpTopic class>>classFor: (in category 'instance creation') -----
+ classFor: aDirectoryEntryFile
+
+ | subclasses |
+ subclasses := self allSubclasses select: [:clazz | clazz supportsEntry: aDirectoryEntryFile].
+ ^ subclasses ifEmpty: [self] ifNotEmpty: [subclasses first].!
Item was added:
+ ----- Method: FileBasedHelpTopic class>>for:withSorting: (in category 'instance creation') -----
+ for: aDirectoryEntryFile withSorting: aSortBlock
+
+ ^ (self classFor: aDirectoryEntryFile) new
+ fileEntry: aDirectoryEntryFile;
+ sortBlock: aSortBlock;
+ yourself!
Item was added:
+ ----- Method: FileBasedHelpTopic class>>supportsEntry: (in category 'instance creation') -----
+ supportsEntry: aDirectoryEntryFile
+
+ ^ self subclassResponsibility!
Item was changed:
----- Method: FileBasedHelpTopic>>accept:for: (in category 'editing') -----
accept: newContents for: subtopic
+ "FileBasedHelpTopics do not have subtopics. Saving is handled by the DirectoryBasedHelpTopic."
+ self shouldNotImplement.!
- FileStream forceNewFileNamed: self fileEntry fullName do: [:strm |
- strm nextChunkPutWithStyle: newContents].
- ^ true
- !
Item was changed:
----- Method: FileBasedHelpTopic>>contents (in category 'accessing') -----
contents
+ ^ contents ifNil: [contents := self readFileContents]!
- ^ contents ifNil: [
- [contents := fileEntry readStream nextChunkText withSqueakLineEndings]
- on: InvalidUTF8
- do: [:err | ('Invalid UTF8 contents!! Please check ', self fileEntry fullName) asText addAttribute: TextColor red]]!
Item was added:
+ ----- Method: FileBasedHelpTopic>>contents: (in category 'editing') -----
+ contents: newContents
+
+ self storeFileContents: newContents!
Item was added:
+ ----- Method: FileBasedHelpTopic>>readFileContents (in category 'File I/O') -----
+ readFileContents
+
+ ^ [fileEntry readStream nextChunkText withSqueakLineEndings]
+ on: InvalidUTF8
+ do: [:err | ('Invalid UTF8 contents!! Please check ', self fileEntry fullName) asText addAttribute: TextColor red].!
Item was added:
+ ----- Method: FileBasedHelpTopic>>storeFileContents: (in category 'File I/O') -----
+ storeFileContents: newContents
+
+ FileStream forceNewFileNamed: self fileEntry fullName do: [:stream |
+ stream nextChunkPutWithStyle: newContents]!
Item was added:
+ ----- Method: HelpBrowser>>aboutToStyle:requestor: (in category 'styling') -----
+ aboutToStyle: aStyler requestor: aView
+
+ self updateStyler: aStyler requestor: aView.
+
+ ^ self aboutToStyle: aStyler!
Item was changed:
----- Method: HelpBrowser>>buildContentsWith: (in category 'toolbuilder') -----
buildContentsWith: builder
^ builder pluggableTextSpec new
model: self;
getText: #topicContents;
setText: #accept:;
selection: #topicContentsSelection;
menu: #codePaneMenu:shifted:;
+ stylerClass: (TextStyler for: #Smalltalk);
frame: (LayoutFrame
fractions: (0.3 at 0.0 corner: 1 at 1)
offsets: (0@ builder inputFieldHeight corner: 0 at 0));
yourself!
Item was added:
+ ----- Method: HelpBrowser>>updateStyler:requestor: (in category 'as yet unclassified') -----
+ updateStyler: aStyler requestor: aView
+
+ self currentTopic ifNotNil: [:topic |
+ aStyler class ~= topic stylerClass
+ ifTrue: [aView styler: (topic stylerClass new view: aView)]].!
More information about the Squeak-dev
mailing list
|