diff --git a/src/GToolkit-Documenter/GtDocumenter.class.st b/src/GToolkit-Documenter/GtDocumenter.class.st index de8e70c6..9337e8ac 100644 --- a/src/GToolkit-Documenter/GtDocumenter.class.st +++ b/src/GToolkit-Documenter/GtDocumenter.class.st @@ -30,6 +30,11 @@ GtDocumenter class >> forFile: aFileReference [ ^ self new fileReference: aFileReference; read ] +{ #category : #'instance creation' } +GtDocumenter class >> forPackage: anRPackage [ + ^ self new packageComment: anRPackage; read +] + { #category : #'instance creation' } GtDocumenter class >> forText: aStringOrText [ ^ self new text: aStringOrText @@ -408,6 +413,12 @@ GtDocumenter >> normalFontSize: aNumber [ self editorElement normalFontSize: aNumber. ] +{ #category : #'api - storage' } +GtDocumenter >> packageComment: anRPackage [ + self editorElement packageComment: anRPackage. + self updateTitleLabel. +] + { #category : #'api - ast' } GtDocumenter >> parse [ ^ self ast diff --git a/src/GToolkit-Documenter/GtDocumenterEditor.class.st b/src/GToolkit-Documenter/GtDocumenterEditor.class.st index f5ec4a26..9a94b2fc 100644 --- a/src/GToolkit-Documenter/GtDocumenterEditor.class.st +++ b/src/GToolkit-Documenter/GtDocumenterEditor.class.st @@ -133,6 +133,11 @@ GtDocumenterEditor >> normalFontSize: aNumber [ normalFontSizeModel normalFontSize: aNumber ] +{ #category : #'api - storage' } +GtDocumenterEditor >> packageComment: anRPackage [ + storageModel packageComment: anRPackage +] + { #category : #'api - storage' } GtDocumenterEditor >> read [ ^ storageModel read diff --git a/src/GToolkit-Documenter/GtDocumenterEditorStorageModel.class.st b/src/GToolkit-Documenter/GtDocumenterEditorStorageModel.class.st index f47434d5..c4e67710 100644 --- a/src/GToolkit-Documenter/GtDocumenterEditorStorageModel.class.st +++ b/src/GToolkit-Documenter/GtDocumenterEditorStorageModel.class.st @@ -79,6 +79,14 @@ GtDocumenterEditorStorageModel >> notifyStorageChanged [ storage: self storage) ] +{ #category : #'api - storage' } +GtDocumenterEditorStorageModel >> packageComment: anRPackage [ + self + assert: [ anRPackage notNil ] + description: [ 'Package to document must be non-nil' ]. + self storage: (GtStorageStrategy packageComment: anRPackage) +] + { #category : #'api - storage' } GtDocumenterEditorStorageModel >> read [ self widgetDo: [ :aDocumenter | diff --git a/src/GToolkit-Documenter/GtPackageCommentStrategy.class.st b/src/GToolkit-Documenter/GtPackageCommentStrategy.class.st new file mode 100644 index 00000000..1d7e716a --- /dev/null +++ b/src/GToolkit-Documenter/GtPackageCommentStrategy.class.st @@ -0,0 +1,77 @@ +Class { + #name : #GtPackageCommentStrategy, + #superclass : #GtStorageStrategy, + #instVars : [ + 'package' + ], + #category : #'GToolkit-Documenter-Storage' +} + +{ #category : #accessing } +GtPackageCommentStrategy >> basename [ + "Return a string representing the document filename" + + ^ self name, '.', GtFileUtilityConstants pillarExtension +] + +{ #category : #accessing } +GtPackageCommentStrategy >> comment [ + + ^ self packageToComment packageManifestOrNil + ifNil: [ '' ] + ifNotNil: [ :manifest | + manifest hasComment + ifTrue: [ manifest comment ] + ifFalse: [ '' ] ] +] + +{ #category : #accessing } +GtPackageCommentStrategy >> evaluationReceiver [ + "Return an object that is used as a receiver (self) in a codeblock (code snippet) evalution" + + ^ self packageToComment +] + +{ #category : #testing } +GtPackageCommentStrategy >> exists [ + + ^ true +] + +{ #category : #accessing } +GtPackageCommentStrategy >> name [ + "Return a string representing the stored document" + + ^ self packageToComment name +] + +{ #category : #accessing } +GtPackageCommentStrategy >> packageToComment [ + ^ package +] + +{ #category : #accessing } +GtPackageCommentStrategy >> packageToComment: anRPackage [ + self + assert: [ anRPackage notNil ] + description: [ 'Package to document must be non-nil' ]. + package := anRPackage +] + +{ #category : #actions } +GtPackageCommentStrategy >> read: aGt2Document [ + aGt2Document text: self comment +] + +{ #category : #accessing } +GtPackageCommentStrategy >> rootDirectory [ + + ^ FileSystem workingDirectory +] + +{ #category : #actions } +GtPackageCommentStrategy >> save: aGt2Document [ + self packageToComment packageManifest + comment: aGt2Document text asString + stamp: Author changeStamp +] diff --git a/src/GToolkit-Documenter/GtStorageStrategy.class.st b/src/GToolkit-Documenter/GtStorageStrategy.class.st index 99ff8258..0a7bb0f9 100644 --- a/src/GToolkit-Documenter/GtStorageStrategy.class.st +++ b/src/GToolkit-Documenter/GtStorageStrategy.class.st @@ -31,6 +31,16 @@ GtStorageStrategy class >> null [ ^ GtNoStorageStrategy uniqueInstance ] +{ #category : #factory } +GtStorageStrategy class >> packageComment [ + ^ GtPackageCommentStrategy new +] + +{ #category : #factory } +GtStorageStrategy class >> packageComment: anRPackage [ + ^ self packageComment packageToComment: anRPackage +] + { #category : #accessing } GtStorageStrategy >> basename [ "Return a string representing the document filename"