online help
Posted: Thu Oct 13, 2011 8:06 am
Does newlisp have online function's document in REPL like clojure's (doc map) or (find-doc "map")
Friends and Fans of newLISP
http://www.newlispfanclub.alh.net/forum/
http://www.newlispfanclub.alh.net/forum/viewtopic.php?f=15&t=3956
Code: Select all
(define-macro (?? func-name)
(let ((func-name (string func-name)))
(set 'f (read-file {/usr/share/doc/newlisp/newlisp_manual.html}))
(when (and
(starts-with func-name "[a-z]" 0)
(set 'html-text (find-all (string "<h4>syntax(.*?)" func-name "(.*?)</h4>") f)))
(set 'html-text (join html-text "\n"))
(replace "<.*?>" html-text "" 0)
(replace "<" html-text "<")
(replace ">" html-text ">")
(replace "&" html-text "&"))
(silent (println html-text))))
Code: Select all
(define-macro (doc func-name)
(let ((func-name (string func-name)))
(set 'f (read-file {/e:/newlisp/newlisp_manual.html}))
(set 'r (regex (string "<a name=\"" func-name "\"></a>") f))
(set 'n0 (r 1))
(set 'n1 ((regex "<a name=" f 0 (+ n0 (r 2))) 1))
(set 'html-text (slice f n0 (- n1 n0)))
(replace "<.*?>" html-text "" 0)
(replace "<" html-text "<")
(replace ">" html-text ">")
(replace "&" html-text "&")
(replace " " html-text " ")
(replace "&mdash" html-text "...")
(replace "\n\n+" html-text "\n\n" 1)
(replace "^\n+|\n+$" html-text "" 1)
(println "--------------------------")
(println html-text)
(println "--------------------------")
'end))
Code: Select all
(replace "→" html-text { ->})
Code: Select all
(replace "?" func-name "p")
Code: Select all
MAIN:/Users/lutz> help append
syntax: (append list-1 [list-2 ... ])
syntax: (append array-1 [array-2 ... ])
syntax: (append str-1 [str-2 ... ])
syntax: (append-file str-filename str-buffer)
MAIN:/Users/lutz> help fil
syntax: (file-info str-name [int-index [bool-flag]])
syntax: (file? str-path-name [bool])
syntax: (filter exp-predicate exp-list)
MAIN:/Users/lutz> (set 'x 123)
123
MAIN:/Users/lutz> x
123
MAIN:/Users/lutz> ls *.lsp
plot.lsp spawn.lsp
MAIN:/Users/lutz>