2017-07-03 22:12:09 +00:00
|
|
|
"
|
|
|
|
I model a documentation object for Grafoscopio.
|
|
|
|
Documents are stored in a fossil repository and have
|
|
|
|
relative paths to it.
|
|
|
|
"
|
|
|
|
Class {
|
|
|
|
#name : #GrafoscopioDocumentation,
|
|
|
|
#superclass : #Object,
|
|
|
|
#instVars : [
|
|
|
|
'repository',
|
|
|
|
'documents',
|
2017-07-04 14:24:31 +00:00
|
|
|
'localPlace',
|
|
|
|
'name'
|
2017-07-03 22:12:09 +00:00
|
|
|
],
|
|
|
|
#category : #'Grafoscopio-Utils'
|
|
|
|
}
|
|
|
|
|
2019-04-08 19:24:27 +00:00
|
|
|
{ #category : #updating }
|
|
|
|
GrafoscopioDocumentation class >> documents [
|
|
|
|
^ self newDefault documents
|
|
|
|
]
|
|
|
|
|
2017-07-07 19:58:39 +00:00
|
|
|
{ #category : #api }
|
|
|
|
GrafoscopioDocumentation class >> download: aFileName [
|
|
|
|
self newDefault download: aFileName
|
|
|
|
]
|
|
|
|
|
2017-07-06 21:23:22 +00:00
|
|
|
{ #category : #updating }
|
|
|
|
GrafoscopioDocumentation class >> listOutdatedDocs [
|
2017-07-06 22:04:55 +00:00
|
|
|
^ self newDefault listOutdatedDocs
|
2017-07-06 21:23:22 +00:00
|
|
|
]
|
|
|
|
|
2019-04-08 19:24:27 +00:00
|
|
|
{ #category : #updating }
|
|
|
|
GrafoscopioDocumentation class >> localPlace [
|
|
|
|
^ self newDefault localPlace
|
|
|
|
]
|
|
|
|
|
2017-07-06 22:04:55 +00:00
|
|
|
{ #category : #'instance creation' }
|
2017-07-06 18:12:08 +00:00
|
|
|
GrafoscopioDocumentation class >> newDefault [
|
|
|
|
^ self new
|
|
|
|
]
|
|
|
|
|
2017-07-06 21:23:22 +00:00
|
|
|
{ #category : #updating }
|
|
|
|
GrafoscopioDocumentation class >> update [
|
2017-07-07 19:58:39 +00:00
|
|
|
^ self newDefault update
|
2017-07-06 21:23:22 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
{ #category : #updating }
|
|
|
|
GrafoscopioDocumentation class >> updateAll [
|
2017-07-06 22:04:55 +00:00
|
|
|
{GrafoscopioDocs . DatavizDocs . OffshoreLeaksDocs} do: [ :docs | docs update ]
|
2017-07-06 21:23:22 +00:00
|
|
|
]
|
|
|
|
|
2017-07-03 22:12:09 +00:00
|
|
|
{ #category : #updating }
|
|
|
|
GrafoscopioDocumentation class >> updateAllUI [
|
|
|
|
"Updates documentation (manual, tutorials) from the official repository for a given documentation."
|
|
|
|
| update |
|
|
|
|
update := (UIManager default
|
|
|
|
confirm: 'Do you wish to update the documentation?'
|
|
|
|
label: 'Update documentation').
|
|
|
|
update
|
|
|
|
ifTrue: [ self updateAll ]
|
|
|
|
]
|
|
|
|
|
2017-07-07 19:58:39 +00:00
|
|
|
{ #category : #accessing }
|
|
|
|
GrafoscopioDocumentation >> addDocument: aFilePath [
|
|
|
|
"I add the document contained in aFilePath (a String) to the list of documents that belong
|
|
|
|
to this collection, taking care of avoiding repetitions"
|
|
|
|
|
|
|
|
(self documents includes: aFilePath) ifFalse: [ self documents add: aFilePath ]
|
|
|
|
]
|
|
|
|
|
2017-07-03 22:12:09 +00:00
|
|
|
{ #category : #accessing }
|
|
|
|
GrafoscopioDocumentation >> documents [
|
|
|
|
^ documents ifNil: [ documents := OrderedCollection new ]
|
|
|
|
]
|
|
|
|
|
|
|
|
{ #category : #accessing }
|
|
|
|
GrafoscopioDocumentation >> documents: anObject [
|
|
|
|
documents := anObject
|
|
|
|
]
|
|
|
|
|
2017-07-04 14:24:31 +00:00
|
|
|
{ #category : #updating }
|
|
|
|
GrafoscopioDocumentation >> download: fileNameWithRelativePath [
|
2019-04-08 20:37:40 +00:00
|
|
|
| fileName parentFolder sanitized lastVersion |
|
2017-07-04 14:24:31 +00:00
|
|
|
fileName := (fileNameWithRelativePath splitOn: $/) last.
|
2019-04-08 20:37:40 +00:00
|
|
|
sanitized := self repository sanitize: fileNameWithRelativePath.
|
|
|
|
lastVersion := self repository lastVersionPath: fileNameWithRelativePath.
|
2017-12-07 11:21:36 +00:00
|
|
|
parentFolder := GrafoscopioUtils
|
2019-04-08 20:37:40 +00:00
|
|
|
ensureCreateDirectory: sanitized into: self localPlace.
|
2017-07-06 21:23:22 +00:00
|
|
|
GrafoscopioUtils
|
2019-04-08 20:37:40 +00:00
|
|
|
downloadingFrom: self repository remote asString, lastVersion
|
2017-07-04 14:24:31 +00:00
|
|
|
withMessage: 'Downloading ', fileName
|
2017-12-07 11:21:36 +00:00
|
|
|
into: parentFolder
|
2017-07-04 14:24:31 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
{ #category : #updating }
|
|
|
|
GrafoscopioDocumentation >> isFileUpdatedFor: relativeFilePath [
|
|
|
|
"I compare if the local and remote copies of a relativeFilePath are updated for the current
|
|
|
|
documentation and return true if they are and false in any other case"
|
|
|
|
| localFile |
|
|
|
|
localFile := self localPlace / relativeFilePath.
|
|
|
|
localFile exists
|
|
|
|
ifFalse: [ ^ false ]
|
|
|
|
ifTrue: [
|
|
|
|
^ ExternalApp
|
|
|
|
compareHashFor: localFile
|
|
|
|
with: (self repository lastHashNumberFor: relativeFilePath) ]
|
|
|
|
]
|
|
|
|
|
2017-07-06 22:04:55 +00:00
|
|
|
{ #category : #updating }
|
|
|
|
GrafoscopioDocumentation >> listOutdatedDocs [
|
|
|
|
"I return the list of all documentent where the local copy and the remote copy doesn't match"
|
|
|
|
^ self documents reject: [ :doc | (self isFileUpdatedFor: doc) ]
|
|
|
|
]
|
|
|
|
|
2017-07-03 22:12:09 +00:00
|
|
|
{ #category : #accessing }
|
|
|
|
GrafoscopioDocumentation >> localPlace [
|
2017-07-07 19:58:39 +00:00
|
|
|
^ localPlace.
|
2017-07-04 14:24:31 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
{ #category : #accessing }
|
|
|
|
GrafoscopioDocumentation >> localPlace: aFileDirectory [
|
|
|
|
localPlace := aFileDirectory.
|
|
|
|
self localPlace exists ifFalse: [ self localPlace ensureCreateDirectory ].
|
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
{ #category : #accessing }
|
|
|
|
GrafoscopioDocumentation >> name [
|
|
|
|
^ name
|
|
|
|
]
|
|
|
|
|
|
|
|
{ #category : #accessing }
|
|
|
|
GrafoscopioDocumentation >> name: anObject [
|
|
|
|
name := anObject
|
2017-07-03 22:12:09 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
{ #category : #accessing }
|
2017-07-04 14:24:31 +00:00
|
|
|
GrafoscopioDocumentation >> openNotebookAt: index [
|
|
|
|
"I open a notebook included with the documentation, located at a given index (anInteger)"
|
|
|
|
| notebookTemp |
|
|
|
|
(index between: 1 and: self documents size)
|
|
|
|
ifFalse: [ ^ self ]
|
|
|
|
ifTrue: [
|
|
|
|
notebookTemp := (self localPlace fullName, '/', (self documents at: index)) asFileReference.
|
|
|
|
notebookTemp exists
|
|
|
|
ifTrue: [GrafoscopioNotebook new openFromFile: notebookTemp]
|
|
|
|
ifFalse: [ self updateUI ]]
|
2017-07-03 22:12:09 +00:00
|
|
|
]
|
|
|
|
|
2017-11-21 19:05:35 +00:00
|
|
|
{ #category : #updating }
|
|
|
|
GrafoscopioDocumentation >> registerIntoDockingBar [
|
|
|
|
"I detect if any of the documents that are part of my collection contains any metadata
|
|
|
|
indicating if they should be registered in the main docking bar, and in such case, I add them."
|
|
|
|
self documents
|
|
|
|
do: [ :doc | | metadata currentNotebook |
|
|
|
|
currentNotebook := GrafoscopioNotebook new loadFromFile: self localPlace / doc.
|
|
|
|
metadata := currentNotebook metadata.
|
|
|
|
metadata ifNotNil: [
|
|
|
|
metadata
|
|
|
|
at: 'showOnHelp'
|
|
|
|
ifPresent: [ GrafoscopioDockingBar addToHelpMenu: currentNotebook ] ] ]
|
|
|
|
]
|
|
|
|
|
2017-07-03 22:12:09 +00:00
|
|
|
{ #category : #accessing }
|
|
|
|
GrafoscopioDocumentation >> repository [
|
|
|
|
^ repository
|
|
|
|
]
|
|
|
|
|
|
|
|
{ #category : #accessing }
|
2017-07-07 19:58:39 +00:00
|
|
|
GrafoscopioDocumentation >> repository: aFossilRepo [
|
|
|
|
repository := aFossilRepo
|
2017-07-03 22:12:09 +00:00
|
|
|
]
|
2017-07-04 14:24:31 +00:00
|
|
|
|
|
|
|
{ #category : #updating }
|
|
|
|
GrafoscopioDocumentation >> update [
|
2017-07-06 22:04:55 +00:00
|
|
|
(self listOutdatedDocs)
|
2017-07-04 14:24:31 +00:00
|
|
|
ifEmpty: [
|
|
|
|
self inform: 'All documents in the ', self name,' collection are already updated'.
|
|
|
|
^ self ]
|
|
|
|
ifNotEmpty: [:outdatedDocs |
|
2017-11-28 21:20:57 +00:00
|
|
|
outdatedDocs do: [ :eachDoc | self download: eachDoc ].
|
2017-07-04 14:24:31 +00:00
|
|
|
self inform: 'Updating of ', self name,' documentation finished.' ]
|
|
|
|
]
|
|
|
|
|
2017-07-06 08:29:42 +00:00
|
|
|
{ #category : #updating }
|
|
|
|
GrafoscopioDocumentation >> updateDocsPlaceUI [
|
|
|
|
self current localPlace: (UIManager default chooseDirectory: 'Path to the documentation folder')
|
|
|
|
]
|
|
|
|
|
2017-07-04 14:24:31 +00:00
|
|
|
{ #category : #updating }
|
|
|
|
GrafoscopioDocumentation >> updateUI [
|
|
|
|
"Updates documentation (manual, tutorials) from the official repository for a given documentation."
|
|
|
|
| update |
|
|
|
|
update := (UIManager default
|
|
|
|
confirm: 'Do you wish to update the ', self name,' documentation?'
|
|
|
|
label: 'Update ', self name, ' documentation').
|
|
|
|
update ifTrue: [ self update ]
|
|
|
|
]
|