--- gforth/doc/makedoc.fs 1997/05/21 20:40:04 1.1 +++ gforth/doc/makedoc.fs 2007/12/31 18:40:25 1.13 @@ -1,12 +1,12 @@ \ create a documentation file -\ Copyright (C) 1995 Free Software Foundation, Inc. +\ Copyright (C) 1995,1999,2000,2003,2004,2007 Free Software Foundation, Inc. \ This file is part of Gforth. \ Gforth is free software; you can redistribute it and/or \ modify it under the terms of the GNU General Public License -\ as published by the Free Software Foundation; either version 2 +\ as published by the Free Software Foundation, either version 3 \ of the License, or (at your option) any later version. \ This program is distributed in the hope that it will be useful, @@ -15,19 +15,18 @@ \ GNU General Public License for more details. \ You should have received a copy of the GNU General Public License -\ along with this program; if not, write to the Free Software -\ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +\ along with this program. If not, see http://www.gnu.org/licenses/. \ the stack effect of loading this file is: ( addr u -- ) \ it takes the name of the doc-file to be generated. \ the forth source must have the following format: -\ .... name ( stack-effect ) \ wordset [pronounciation] +\ .... name ( stack-effect ) \ [prefix-] wordset [pronounciation] \ \G description ... -\ The output is a Forth source file that looks like this: -\ doc-entry name stack-effect ) wordset [pronountiation] +\ The output is a file of entries that look like this: +\ make-doc [--prefix]-entry name stack-effect ) wordset [pronounciation] \ description \ \ (i.e., the entry is terminated by an empty line or the end-of-file) @@ -57,24 +56,53 @@ r/w create-file throw value doc-file-id s" \ automatically generated by makedoc.fs" doc-file-id write-line throw +: >fileCR ( c-addr u -- ) + doc-file-id write-line throw ; +: >file ( c-addr u -- ) + doc-file-id write-file throw ; + : \G ( -- ) - source >in @ /string doc-file-id write-line throw + source >in @ /string >fileCR source >in ! drop ; immediate : put-doc-entry ( -- ) - locals-list @ 0= \ not in a colon def, i.e., not a local name - last @ 0<> and \ not an anonymous (i.e. noname) header + dpp @ normal-dp = \ not defining locals + latest 0<> and \ not an anonymous (i.e. noname) header if - s" " doc-file-id write-line throw - s" make-doc " doc-file-id write-file throw - last @ name>string doc-file-id write-file throw - >in @ - [char] ( parse 2drop - [char] ) parse doc-file-id write-file throw - s" )" doc-file-id write-file throw + s" " >fileCR + s" make-doc " >file + >in @ >r + parse-name 2dup s" (" str= if + 2drop ') parse + else + 2dup s" {" str= if + 2drop '} parse + else \ no stack comment or locals + 2drop + r@ >in ! \ restore "\" + s" unknown " \ default stack comment + endif + endif [char] \ parse 2drop + >in @ + bl word dup c@ + IF + dup count 1- chars + c@ [char] - = + IF + s" --" >file + count >file drop + ELSE + drop >in ! + THEN + ELSE + drop >in ! + THEN + latest name>string >file + s" " >file + >file + s" )" >file POSTPONE \g - >in ! + r> >in ! endif ; : (doc-header) ( -- )