最近写了一个newlisp_armory库,用来实现一些newlisp自身不支持的操做。好比跨windows和ubuntu的目录拷贝功能等。git
本身用的时候,发现没有API reference文档参考,很不方便。因而学习了如何用注释生成文档。github
在Ubuntu环境下,首先要下载newlispdoc程序的源码:http://newlisp.org/syntax.cgi?code/newlispdoc.txtubuntu
将文件重命名为newlispdoc,添加执行权限,复制到/usr/bin目录下。windows
也可直接从个人github项目中得到:https://github.com/csfreebird/newlisp_armory.gitapp
而后注意注释的写法,下面是个例子:less
;; file.lsp ;; @module file ;; @description file module provides some file operations on both Ubuntu and Windows ;; @location file.lsp ;; @version 1.0 ;; @author Dean Chen ;; @example ;; (let ((test-dir1 (append (real-path) file:file-seperator "a")) (test-dir2 (append (real-path) file:file-seperator "b"))) ;; (make-dir test-dir1) ;; (make-dir test-dir2) ;; (if (directory? test-dir1) ;; (begin ;; (unless (catch (file:copy-folder test-dir1 test-dir2) 'result) ;; (println (append "catch error: " result)) ;; (println "test copy-folder failed")) ;; (file:remove-folder test-dir1) ;; (file:remove-folder test-dir2)))) (context 'file) ;; @syntax (file:init) ;; @throw Throw error if environment variable NEWLISP_ARMORY_HOME does not exist or is invalid ;; @throw Throw error if OS is not Windows or UBuntu ;; @note init function will be called automatically when loading file.lsp module, don't call it manually (define (init) (unless (env "NEWLISP_ARMORY_HOME") (throw-error "NEWLISP_ARMORY_HOME does not exist")) (unless (file? (env "NEWLISP_ARMORY_HOME")) (throw-error "NEWLISP_ARMORY_HOME points to a non-existing file")) (unless (directory? (env "NEWLISP_ARMORY_HOME")) (throw-error "NEWLISP_ARMORY_HOME points to a file instead of directory")) (set 'file-folder (append (env "NEWLISP_ARMORY_HOME") "/codes/file")) (if (= ostype "Linux") (load (append file-folder "/file_ubuntu.lsp")) (= ostype "Win32") (load (append file-folder "/file_win.lsp")) (throw-error (append "file tool doesn't support this OS for now, ostype:" ostype)) ))
如今运行命令产生doc:ide
newlispdoc file.lsp
因为我还有几个支持不一样平台的文件,file_ubuntu.lsp和file.win.lsp,彷佛newlispdoc没有这么智能。所以我将file_ubuntu.lsp的注释复制到file.lsp中,不复制源代码。学习
也可以生成。this
下面的截图展现了个人doc:code
点击连接后,进入详细页面: