help-smalltalk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-smalltalk] Documentation syntax


From: Mike Anderson
Subject: Re: [Help-smalltalk] Documentation syntax
Date: Sat, 19 Aug 2006 15:46:30 +0000
User-agent: Mozilla Thunderbird 1.0.5 (X11/20050711)

Bram Neijt wrote:
> On 8/17/06, Stewart Stremler <address@hidden> wrote:
> 
>> Markup would be needed to un-select inappropriate links. If I have
>> a class named "Answer", it shouldn't be linked to everytime someone
>> writes "Answer the blah-blah-blah", as it would be unrelated, and
>> the resulting link would be confusing.
> 
> This is a problem I already noticed. Which would mean some kind of
> markup is needed. However, we could still use very simple markup, like
> brackets ("[]") to donate that that term is special (which would make
> it a link).

It's not a real problem. The potentically problematic words are, in
fact, "Set" and "File" (and one ungrammatical "Error"). If you didn't
make links when the word was the first word in the comments, then
they're all covered.

Mike

Object subclass: 'ThisScript'!

ThisScript methodsFor: 'everything'!

allBaseClasses
        ^Smalltalk select: [ :each | each isClass ]
!

extractComment: aMethodSourceString
        | s c |
        aMethodSourceString isNil ifTrue: [ ^'' ].
        s := aMethodSourceString readStream.
        s upTo: Character nl.
        s skipSeparators.
        s next = $" ifFalse: [ ^'' ].
        c := s upTo: $".
        [ s next = $" ]
                whileTrue:
                [ c := c, '"', s upTo: $" ].
        ^c
!

capsInComment: aComment
        ^aComment isNil
                ifTrue:
                        [ #() ]
                ifFalse:
                        [ aComment subStrings select:
                                [ :each | each first isUppercase ] ].
!

run
        | abc names capitalized |
        capitalized := Set new.
        abc := self allBaseClasses asSortedCollection: [ :a :b | a name < b 
name ].
        names := abc collect: [ :cls | cls name asString ].
        abc     do:
                [ :c |
                c selectors do:
                        [ :s | | comment ms caps |
                        ms := (c >> s) methodSourceString.
                        comment := self extractComment: ms.
                        caps := self capsInComment: comment.
                        capitalized addAll: caps.
                        caps := caps select: [ :each | names includes: each ].
                        caps notEmpty
                                ifTrue:
                                        [ Transcript nl; nl.
                                        Transcript << c name << ' >> '.
                                        Transcript << (c >> s) selector ; nl.
                                        Transcript << comment ; nl.
                                        caps
                                                do:     
                                                        [ :cap | Transcript << 
cap ]
                                                separatedBy:
                                                        [ Transcript << ' ' ]. 
]. ] ].
                                                        
        "Transcript << '*** All base classes ***' ; nl.
        abc
                do:     
                        [ :cls | Transcript << cls name ]
                separatedBy:
                        [ Transcript << ' ' ].
        Transcript nl.
        Transcript << '*** All caps ***' ; nl.
        capitalized asSortedCollection
                do:     
                        [ :cap | Transcript << cap ]
                separatedBy:
                        [ Transcript << ' ' ].
        Transcript nl.
        Transcript << '*** Intersection ***' ; nl.
        (capitalized & (abc collect: [ :each | each name asString ]) asSet)
                do:     
                        [ :cap | Transcript << cap ]
                separatedBy:
                        [ Transcript << ' ' ].
        Transcript nl."
!
!

ThisScript new run
!




reply via email to

[Prev in Thread] Current Thread [Next in Thread]