Neville Holmes and his correspondent, Walter Spunde wanted a simple means of
including documentation and accessing it. Brian Schott supported using the
Note function.
This provides a very tidy way of including comments and information relevant
to using functions from a script. It may not have the tacit form which
Neville and Walter use widely.
I use a function help to find the script in which a function is defined,
strip out anything other than the notes, and display them. I find it very
helpful. I am sure it could be tidied up in the manner of scriptdoc.
Writing to a temporary file is unnecessary but was a quick solution.
The script follows and another script with two illustrations.
===========================================
load 'validate'
Note 'help v monadic'
help name_as_string
returns all Note information from the script in
which the entity name_as_string was defined.
Because 'Note' occurs as a noun in the function
below part of the definition is copied to the
displayed file. This minor incovenience will only
occur if 'Note' is a part of a definition.
Example
help 'help'
)
help =: 3 : 0
if. -. isboxed y do. y =. <y end.
z =. 'm' fread fn =. (4!:4 y) {4!:3 ''
beg =. I. +./"1 'Note' E."_ 1 z NB. part defn included
fin =. I. ')' = {."1 z
grp =. <./ @ (>~#])
ints =. beg,. beg grp"0 _ fin
hlines =. [: < {.+ [: i.[: >: [: -/ |.
hinfo =.(> (,&.>/) hlines"1 ints){z
(, ((>fn),' ',hinfo,.CR),.LF) fwrite k =. jpath,'~temp\zzzhelpinfo.txt'
open k
)
====================================================
NB. Brief example script
a =: 'This' [ Note 'a'
What we are doing here is inserting
a multiline comment
It could easily describe the noun
just constructed. Note it displays the commands
as well as the comment.
)
shift =: verb define
4+y
)
Note 'shift v'
This verb shifts the values
of its numeric argument
)
===================================================
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm