Interactive documentation

Started by cormullion, December 06, 2005, 02:33:48 AM

Previous topic - Next topic

cormullion

I've been spending a lot of time looking through the documentation, and I just wondered - has an interactive documentation tool been developed for newLISP? I'm thinking of a quick way of finding out the syntax of functions... I seem to remember some function in Common Lisp that did something similar...

HPW

#1
You may look here:



http://www.alh.net/newlisp/phpbb/viewtopic.php?t=782&highlight=doc">http://www.alh.net/newlisp/phpbb/viewto ... hlight=doc">http://www.alh.net/newlisp/phpbb/viewtopic.php?t=782&highlight=doc



http://www.alh.net/newlisp/phpbb/viewtopic.php?t=378">http://www.alh.net/newlisp/phpbb/viewtopic.php?t=378



(Of cource for your own code, not for native commands)
Hans-Peter

cormullion

#2
Yes, thanks - worth doing, although naturally I can understand all my own code... :-) :-) But I think it would be useful to have quick access to a syntax summary for native functions too...

HPW

#3
Quote
But I think it would be useful to have quick access to a syntax summary for native functions too...


You would need to hack the TK-Frontend of newlisp to be able to jump from a highlighted topic/command into the HTML doc and the command as a target. Similar to the index frame in the doc.
Hans-Peter

HPW

#4
Something like (for example setq):



file:///C:Programmenewlispnewlisp_manual.html#setq



Since the editor supports the selection for clipboard operation it should

be possible to take such string and makel a shell call with that manual-call.
Hans-Peter

cormullion

#5
That's a great idea! I've managed to get a similar effect when using my text editor (which has a "Find in reference" command for the selected word)...



If you're using BBEdit or TextWrangler on MacOS, type this command to customise the Find in reference command for newLISP:


defaults write com.barebones.bbedit Services:ADCReferenceSearchTemplate "file:///usr/share/newlisp/doc/newlisp_manual.html#%@"

and the relevant page will be displayed. The '%@' means the selected word, apparently. (Change 'bbedit' to 'textwrangler' if you're using the free version.)



I haven't even started to look at newlisp-tk yet ... So much to do :-)

HPW

#6
Similar is possible with Ultraedit on Windows.



But I am quite sure it could be done in newLISP-TK with TCL.



Lutz,



time for newLISP-TK 1.31 ??



;-)
Hans-Peter

Lutz

#7
Try this on OSX when running newLISP in a terminal window:



(define-macro (help func)
  (if (primitive? (eval func))
    (!  (format "open http://newlisp.org/newlisp_manual.html#%s" (name func)))
    (format "%s is not a built-in function" (name func))))

;; try

(help println) => pops up manual in your default browser and positions to 'println'

(help foo) => "foo is not a built-in function"


A similar thing is possible in Linux/UNIX or Win32 when replacing 'open' with the name of the browser application.



Lutz

Lutz

#8
if you have lynx installed on yur Linux/UNIX/OSX box you can use the following very fast method:



(define-macro (help func)
  (if (primitive? (eval func))
    (!  (format "lynx /usr/share/newlisp/doc/newlisp_manual.html#%s" (name func)))
    (format "%s is not a built-in function" (name func))))


I have this in my /usr/share/newlisp/init.lsp file. It is almost instantly because lynx ( a character based web growser) loads very fast.



Lutz

cormullion

#9
Thanks, Lutz. This is also very useful!

cormullion

#10
You certainly won't like this version I'm currently using:


(define-macro (?? func)
"(?? println) => displays syntax for func "
  (if (primitive? (eval func))
    (begin
    (set 'file (open "/usr/share/newlisp/doc/newlisp_manual.html" "read"))
(search file (string {<a NAME="} (name func) {">} ) )
(read-buffer file 'buff 500 )
(replace  "<.+>" buff "" 512 )
(replace ">" buff ">")
(replace "<" buff "<")
(println buff "...")
(close file))))


but it's so quick I can't help using it. It's wonderful how even a beginner like me can do this sort of thing in (new)LISP...

Lutz

#11
Actually I like it very much, fast and streight forward.



Lutz

Sammo

#12
Thanks, cormullion.



This is great! Because it's "nothing but newLisp," it works in Windows, too, with the obvious change.



-- Sam

cormullion

#13
:-) I discovered that it doesn't work with every single function. I think it should do a case-insensitive search...

HPW

#14
Quote
But I am quite sure it could be done in newLISP-TK with TCL.

time for newLISP-TK 1.31 ??


Take the newlisp-tk.tcl from 8.7.4 source.



Here we go:



Add a var to config vars (here windows version):

set Ide(HelpFile) "$env(PROGRAMFILES)/newlisp/newlisp_manual.html"


Add a proc:

proc CommandHelp { widget } {
global selectionBuff Ide
catch [set selectionBuff [selection get -displayof $widget ]]
exec $Ide(HelpProgram) $Ide(HelpFile)#$selectionBuff
}


Add a binding to the key-bindings:

bind $txt <F1> { CommandHelp %W }


Voila, highlight the keyword and press F1 and you get the doku.



time for newLISP-TK 1.31 ??



;-)
Hans-Peter