The Trunk: HelpSystem-Core-mt.92.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

The Trunk: HelpSystem-Core-mt.92.mcz

commits-2
Marcel Taeumel uploaded a new version of HelpSystem-Core to project The Trunk:
http://source.squeak.org/trunk/HelpSystem-Core-mt.92.mcz

==================== Summary ====================

Name: HelpSystem-Core-mt.92
Author: mt
Time: 14 August 2016, 3:46:28.731622 pm
UUID: e4144644-912a-7d4f-aee5-d221d530a36c
Ancestors: HelpSystem-Core-mt.91

Small fix to normalize selectors (needed for release notes).

Is there a method to convert any string to a valid selector symbol?

=============== Diff against HelpSystem-Core-mt.91 ===============

Item was changed:
  ----- Method: HelpBrowser>>accept: (in category 'actions') -----
  accept: text
  "Accept edited text. Compile it into a HelpTopic"
 
  | code parent topicClass topicMethod topicMethodSelector normalizedText colorsToRemove |
  (self currentParentTopic isNil or: [self currentParentTopic isEditable not])
  ifTrue: [^ self inform: 'This help topic cannot be edited.'].
 
  self changed: #clearUserEdits.
 
  parent := self currentParentTopic.
  topicClass := parent helpClass.
  topicMethod := self currentTopic key.
+ topicMethodSelector := (topicMethod copyReplaceAll: '-' with: '') copyReplaceAll: '.' with: ''.
- topicMethodSelector := topicMethod copyReplaceAll: '-' with: ''.
  normalizedText := text.
 
  "Remove default colors for the sake of UI themes."
  colorsToRemove := {Color black. Color white}.
  normalizedText runs: (normalizedText runs collect: [:attributes | attributes reject: [:attribute |
  (((attribute respondsTo: #color) and: [colorsToRemove includes: attribute color])
  or: [attribute respondsTo: #font])]]).
 
  code := String streamContents:[:s|
  s nextPutAll: topicMethodSelector.
  s crtab; nextPutAll: '"This method was automatically generated. Edit it using:"'.
  s crtab; nextPutAll: '"', topicClass name,' edit: ', topicMethod storeString,'"'.
  s crtab; nextPutAll: '^(HelpTopic'.
  s crtab: 2; nextPutAll: 'title: ', currentTopic title storeString.
  s crtab: 2; nextPutAll: 'contents: '.
  s cr; nextPutAll: (String streamContents:[:c| c nextChunkPutWithStyle: normalizedText]) storeString.
  s nextPutAll:' readStream nextChunkText)'.
  s crtab: 3; nextPutAll: 'key: ', topicMethod storeString.
  ].
 
  topicClass class
  compile: code
  classified: ((topicClass class organization categoryOfElement: topicMethodSelector) ifNil:['pages']).
 
  parent refresh.
  parent == self rootTopic ifTrue: [self rootTopic: parent].
 
  self currentTopic: (parent subtopics detect: [:t | t key = topicMethod]).!