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