From 5d46ade4696abf7817ea38ae8b14fe2c19ea5e35 Mon Sep 17 00:00:00 2001 From: Luiz Rafael Culik Date: Wed, 22 Mar 2000 02:40:51 +0000 Subject: [PATCH] See changelog 20000321 21:10 --- harbour/include/hbdocdef.ch | 58 +++ harbour/utils/hbdoc/genhpc.prg | 2 - harbour/utils/hbdoc/genng.prg | 676 +++++++++++++++++++++++++++------ harbour/utils/hbdoc/genos2.prg | 497 ++++++++++++++++++++++-- harbour/utils/hbdoc/genrtf.prg | 507 +++++++++++++++++-------- harbour/utils/hbdoc/hbdoc.prg | 14 +- 6 files changed, 1433 insertions(+), 321 deletions(-) create mode 100644 harbour/include/hbdocdef.ch diff --git a/harbour/include/hbdocdef.ch b/harbour/include/hbdocdef.ch new file mode 100644 index 0000000000..7c6e7876a5 --- /dev/null +++ b/harbour/include/hbdocdef.ch @@ -0,0 +1,58 @@ +/* + * $Id$ + */ + +/* + * Harbour Project source code: + * Header file common definition of HBDOc + * + * Copyright 2000 Luiz Rafael Culik + * www - http://www.harbour-project.org + * + * This program 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 of the License, or + * (at your option) any later version, with one exception: + * + * The exception is that if you link the Harbour Runtime Library (HRL) + * and/or the Harbour Virtual Machine (HVM) with other files to produce + * an executable, this does not by itself cause the resulting executable + * to be covered by the GNU General Public License. Your use of that + * executable is in no way restricted on account of linking the HRL + * and/or HVM code into it. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * 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 (or visit + * their web site at http://www.gnu.org/). + * + */ +#ifndef _HBDOCDEF_CH_ +#define _HBDOCDEF_CH_ + +#define CRLF HB_OSNewLine() +// The delimiter +#define DELIM "$" // keyword delimiter + +#xtranslate UPPERLOWER() => (UPPER(SUBSTR(,1,1))+LOWER(SUBSTR(,2))) +#define D_NORMAL 1 +#define D_ARG 2 +#define D_SYNTAX 3 +#define D_IGNORE 4 +#define D_SEEALSO 5 +#define D_INCLUDE 6 +#define D_ONELINE 7 +#define D_STATUS 8 +#define D_DATALINK 10 +#define D_METHODLINK 11 +#define D_EXAMPLE 12 +#define D_DESCRIPTION 13 +#define D_RETURN 14 +#define D_COMPLIANCE 15 + +#endif diff --git a/harbour/utils/hbdoc/genhpc.prg b/harbour/utils/hbdoc/genhpc.prg index 2e1dc4d036..8388089fab 100644 --- a/harbour/utils/hbdoc/genhpc.prg +++ b/harbour/utils/hbdoc/genhpc.prg @@ -514,8 +514,6 @@ FUNCTION ProcessFiles() RETURN NIL -#undef CRLF -#define CRLF chr(13)+chr(10) *+±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±± *+ diff --git a/harbour/utils/hbdoc/genng.prg b/harbour/utils/hbdoc/genng.prg index e6fa66dad4..c1ccabbd66 100644 --- a/harbour/utils/hbdoc/genng.prg +++ b/harbour/utils/hbdoc/genng.prg @@ -34,14 +34,12 @@ * */ -#ifdef __HARBOUR__ - #define NANFOR -#endif #include "directry.ch" #include "fileio.ch" #include "inkey.ch" - +#include 'common.ch' +#include 'hbdocdef.ch' // output lines on the screen #define INFILELINE 10 @@ -50,16 +48,15 @@ #define ERRORLINE 20 #define LONGLINE 78 #define LONGONELINE 66 -#define CRLF HB_OSNewLine() -// The delimiter -#define DELIM "$" // keyword delimiter - -#xtranslate UPPERLOWER() => (UPPER(SUBSTR(,1,1))+LOWER(SUBSTR(,2))) MEMVAR aDirlist,aDocInfo STATIC aAlso -STATIC aTable := {} +STATIC aFiTable := {} +STATIC aSiTable := {} STATIC lIsTable :=.F. +STATIC nCommentLen +STATIC lEof +STATIC aColorTable:={{'aqua','1B'},{'black','10'},{'fuchia','1D'},{'grey','18'},{'green','12'},{'lime','1A'},{'maroon','16'},{'navy','19'},{'olive','12'},{'purple','15'},{'red','1C'},{'silver','17'},{'teal','13 '},{'white','1F'},{'yellow','1E'}} FUNCTION ProcessiNg() // @@ -78,25 +75,22 @@ FUNCTION ProcessiNg() // - // LOCAL variables: -#define D_NORMAL 1 -#define D_ARG 2 -#define D_SYNTAX 3 -#define D_IGNORE 4 -#define D_SEEALSO 5 -#define D_INCLUDE 6 -#define D_ONELINE 7 -#define D_STATUS 8 -#define D_EXAMPLE 9 LOCAL i LOCAL j - LOCAL nFiles := LEN( aDirList ) - LOCAL nCommentLen - LOCAL lEof + LOCAL nFiles := LEN( aDirList ) LOCAL lDoc + LOCAL cBuffer LOCAL nEnd LOCAL nCount ,nAlso + LOCAL lData := .F. + LOCAL lMethod := .F. + LOCAL CBUFFEND + LOCAL nPos,NPOSEND + LOCAL lIsDataLink := .F. + LOCAL lIsMethodLink := .F. + LOCAL cBar := "ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ" LOCAL nMode LOCAL cFuncName @@ -132,6 +126,21 @@ FUNCTION ProcessiNg() LOCAL cFiles := DELIM + 'FILES' + DELIM LOCAL cSubCode := DELIM + 'SUBCODE' + DELIM LOCAL cFunction := DELIM + 'FUNCTION' +DELIM + LOCAL cConstruct := DELIM + 'CONSTRUCTOR' + DELIM + LOCAL cDatalink := DELIM + 'DATALINK' + DELIM + LOCAL cDatanolink := DELIM + 'DATANOLINK' + DELIM + LOCAL cMethodslink := DELIM + 'METHODSLINK' + DELIM + LOCAL cMethodsNolink := DELIM + 'METHODSNOLINK' + DELIM + LOCAL cData := DELIM +"DATA"+ DELIM + LOCAL cMethod := DELIM +'METHOD' +DELIM + LOCAL cClassDoc := DELIM+ "CLASSDOC" + DELIM + + + lData := .F. + lMethod := .F. + lIsDataLink := .F. + lIsMethodLink := .F. + lPar := .T. // // Entry Point @@ -141,10 +150,13 @@ FUNCTION ProcessiNg() @ MODULELINE, 20 SAY "Documenting: " // loop through all of the files - FOR i := 1 TO nFiles + FOR i := 1 TO nFiles + afiTable:={} + asiTable:={} // Open file for input + nCommentLen := IIF( AT( ".ASM", UPPER( aDirList[ i, F_NAME ] ) ) > 0, 2, 3 ) nReadHandle := FT_FUSE( aDirList[ i, F_NAME ] ) @ INFILELINE, 33 CLEAR TO INFILELINE, MAXCOL() @@ -152,6 +164,7 @@ FUNCTION ProcessiNg() @ MODULELINE, 33 CLEAR TO LINELINE, MAXCOL() @ LINELINE, 27 SAY "Line:" + nLineCnt := 0 IF nReadHandle < 0 @@ -175,7 +188,7 @@ FUNCTION ProcessiNg() ENDIF // check to see if we are in doc mode or getting out of doc mode - IF AT( cDoc, cBuffer ) > 0 + IF AT( cDoc, cBuffer ) > 0 .or. AT( cClassDoc, cBuffer ) > 0 IF lDoc write_error( cDoc + " encountered during extraction of Doc" ; + " at line" + STR( nLinecnt, 5, 0 ),,,, aDirList[ i, F_NAME ] ) @@ -289,6 +302,24 @@ FUNCTION ProcessiNg() write_error( "Error creating",,,, cFileName + ".ngi" ) ENDIF // 2) Category + ELSEIF AT( cdata, cBuffer ) > 0 .OR. AT( cmethod, cBuffer ) > 0 + if AT( cdata, cBuffer ) > 0 + lData := .T. + lMethod := .F. + ELSEIF AT( cmethod, cBuffer ) > 0 + lMethod := .T. + lData:= .F. + ENDIF + cBuffer := ReadLN( @lEof ) + nLineCnt ++ + // Save the function name + cFuncName := UPPER( ALLTRIM( SUBSTR( cBuffer, nCommentLen ) ) ) + @ MODULELINE, 33 CLEAR TO MODULELINE, MAXCOL() + @ MODULELINE, 33 SAY cFuncName + + nMode := D_NORMAL + + ELSEIF AT( cCat, cBuffer ) > 0 cBuffer := ReadLN( @lEof ) nLineCnt ++ @@ -308,12 +339,17 @@ FUNCTION ProcessiNg() nMode := D_ONELINE // Now start writing out what we know + if lData + oNgi:WriteJumpTitle( left(cFilename,At('.',cFilename)-1)+ cFuncName, "Data "+cFuncName ) + Elseif lMethod + oNgi:WriteJumpTitle( left(cFilename,At('.',cFilename)-1)+cFuncName, "Method " +cFuncName ) + Else oNgi:WriteTitle( PAD( cFuncName, 21 ) + cOneLine, cFuncName ) oNgi:WritePar( cOneLine ) oNgi:WritePar( cBar ) // 4) all other stuff - + endif ELSE IF AT( cSyn, cBuffer ) > 0 @@ -322,6 +358,13 @@ FUNCTION ProcessiNg() nMode := D_SYNTAX lAddBlank := .T. + ELSEIF AT( cConstruct, cBuffer ) > 0 + + oNgi:WriteParBold( " Constructor syntax" ) + + nMode := D_SYNTAX + lAddBlank := .T. + ELSEIF AT( cArg, cBuffer ) > 0 @@ -349,25 +392,65 @@ FUNCTION ProcessiNg() oNgi:WriteParBold( " Description" ) - nMode := D_NORMAL + nMode := D_DESCRIPTION lAddBlank := .T. lPar := .T. + ELSEIF AT( cdatalink, cBuffer ) > 0 + IF !lBlankLine + oNgi:WritePar( "" ) //:endpar() + ENDIF + + oNgi:WriteParBold( " Data" ) + nMode := D_DATALINK + lAddBlank := .T. + + lIsDataLink := .T. + + ELSEIF AT( cDatanolink, cBuffer ) > 0 + if !lIsDataLink + oNgi:WriteParBold( " Data" ) + + endif + nMode := D_NORMAL + lAddBlank := .T. + + lPar:= .T. + ELSEIF AT( cMethodslink, cBuffer ) > 0 + + oNgi:WriteParBold( " Method" ) + nMode := D_METHODLINK + lAddBlank := .T. + + lIsMethodLink := .T. + + ELSEIF AT( cMethodsnolink, cBuffer ) > 0 + if !lIsMethodLink + oNgi:WriteParBold( " Methods" ) + endif + + nMode := D_NORMAL + lAddBlank := .T. + lPar:= .T. + + ELSEIF AT( cExam, cBuffer ) > 0 -// IF !lBlankLine + IF !lBlankLine // oNgi:WritePar( "" ) -// ENDIF oNgi:WriteParBold( " Examples" ) + ENDIF + nMode := D_EXAMPLE lAddBlank := .T. ELSEIF AT( cTest, cBuffer ) > 0 -// IF !lBlankLine -// oNgi:WritePar( "" ) -// ENDIF + IF !lBlankLine oNgi:WriteParBold( " Tests" ) + ENDIF + + nMode := D_NORMAL lAddBlank := .T. lPar:=.t. @@ -377,28 +460,27 @@ FUNCTION ProcessiNg() ELSEIF AT( cCompl, cBuffer ) > 0 -// IF !lBlankLine -// oNgi:WritePar( "" ) -// ENDIF - oNgi:WriteParBold( " Compliance" ) - nMode := D_NORMAL + IF !lBlankLine + oNgi:WriteParBold( " Compliance" ) + ENDIF + + nMode := D_COMPLIANCE lAddBlank := .T. lPar:=.t. ELSEIF AT( cPlat, cBuffer ) > 0 -// IF !lBlankLine -// oNgi:WritePar( "" ) -// ENDIF - oNgi:WriteParBold( " Platforms" ) + IF !lBlankLine + oNgi:WriteParBold( " Platforms" ) + ENDIF + nMode := D_NORMAL lAddBlank := .T. lPar:=.t. ELSEIF AT( cFiles, cBuffer ) > 0 -// IF !lBlankLine -// oNgi:WritePar( "" ) -// ENDIF - oNgi:WriteParBold( " Files" ) + IF !lBlankLine + oNgi:WriteParBold( " Files" ) + ENDIF nMode := D_NORMAL lAddBlank := .T. @@ -429,34 +511,45 @@ FUNCTION ProcessiNg() LONGLINE, aDirList[ i, F_NAME ] ) ENDIF lBlankLine := EMPTY( cBuffer ) -// IF lAddBlank -// oNgi:WritePar( "" ) -// lAddBlank := .F. -// ENDIF - oNgi:WritePar( Strtran(cBuffer," "," ") ) - + if AT("",cBuffer)>0 + nPos:=At("->",cBuffer) + if nPos>0 + nPosend:=AT("",cBuffer) + + cBuffend:=Substr(cBuffer,nPos+2,nPosend-2) + cBuffEnd:=Strtran(cBuffend,"","") + cBuffer:=SubStr(cBuffer,1,nPos+2) + + cBuffer:=cBuffer+' '+cBuffend+' ' + endif + Endif + procngdesc(cbuffer,oNgi,"Syntax") ELSEIF nMode = D_ARG IF LEN( cBuffer ) > LONGLINE write_error( "Arguments", cBuffer, nLineCnt, ; LONGLINE, aDirList[ i, F_NAME ] ) ENDIF lBlankLine := EMPTY( cBuffer ) -// IF lAddBlank -// oNgi:WritePar( "" ) -// lAddBlank := .F. -// ENDIF + IF lAddBlank + oNgi:WritePar( "" ) + lAddBlank := .F. + ENDIF - cBuffer := STRTRAN( cBuffer, "<", "^b<" ) - cBuffer := STRTRAN( cBuffer, ">", ">^b" ) - - oNgi:WritePar( Strtran(cBuffer," "," ") ) + procngdesc(cbuffer,oNgi,"Arguments") ELSEIF nMode = D_EXAMPLE IF LEN( cBuffer ) > LONGLINE write_error( "General", cBuffer, nLineCnt, ; LONGLINE, aDirList[ i, F_NAME ] ) ENDIF lBlankLine := EMPTY( cBuffer ) - oNgi:WritePar( StripNgControls(Strtran(cBuffer," "," ") ) ) + ProcNgDesc(cBuffer,oNgi,"Example") + ELSEIF nMode = D_DESCRIPTION + IF LEN( cBuffer ) > LONGLINE + write_error( "General", cBuffer, nLineCnt, ; + LONGLINE, aDirList[ i, F_NAME ] ) + ENDIF + lBlankLine := EMPTY( cBuffer ) + ProcNgDesc(cBuffer,oNgi,"Description") ELSEIF nMode = D_NORMAL IF LEN( cBuffer ) > LONGLINE @@ -464,24 +557,21 @@ FUNCTION ProcessiNg() LONGLINE, aDirList[ i, F_NAME ] ) ENDIF lBlankLine := EMPTY( cBuffer ) -// IF lAddBlank -// oNgi:WritePar( "" ) -// lAddBlank := .F. -// ENDIF - lPar:=ProcNgDesc(cBuffer,lBlankLine,oNgi,@lPar) + ProcNgDesc(cBuffer,oNgi) + ELSEIF nMode = D_COMPLIANCE + IF LEN( cBuffer ) > LONGLINE + write_error( "General", cBuffer, nLineCnt, ; + LONGLINE, aDirList[ i, F_NAME ] ) + ENDIF + lBlankLine := EMPTY( cBuffer ) + ProcNgDesc(cBuffer,oNgi,"Compliance") + ELSEIF nMode = D_SEEALSO IF .NOT. EMPTY( cBuffer ) cSeeAlso := ProcNgiAlso( StripFiles( ALLTRIM( cBuffer ) ) ) ENDIF ELSEIF nMode = D_INCLUDE // read next line - // IF .NOT. EMPTY( cBuffer ) -// IF !lBlankLine - // oNgi:WritePar( "" ) - // ENDIF - // oNgi:WritePar( " Header File: " ; - // + ALLTRIM( cBuffer ) ) - // ENDIF ELSEIF nMode = D_STATUS IF !EMPTY( cBuffer ) oNgi:WriteParBold( "Status" ) @@ -593,7 +683,7 @@ FUNCTION ProcNgiInput() IF UPPER( cSee ) == UPPER( cTs ) cTs := SUBSTR( cBuffer, 11 ) - aAlso := ProcNgiAlso2( cTs ) + aAlso := procngialso2( cTs ) cBuffer := '' ENDIF @@ -632,7 +722,7 @@ FUNCTION ProcNgiInput() IF UPPER( cSee ) == UPPER( cTs ) cTs := SUBSTR( cBuffer, 11 ) - aAlso := ProcNgiAlso2( cTs ) + aAlso := procngialso2( cTs ) cBuffer := '' ENDIF @@ -684,7 +774,7 @@ FUNCTION ProcNgiInput() IF UPPER( cSee ) == UPPER( cTs ) cTs := SUBSTR( cBuffer, 11 ) - aAlso := ProcNgiAlso2( cTs ) + aAlso := procngialso2( cTs ) cBuffer := '' ENDIF @@ -711,11 +801,11 @@ RETURN NIL *+±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±± *+ -*+ Function ProcNgiAlso2() +*+ Function procngialso2() *+ *+±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±± *+ -FUNCTION ProcNgiAlso2( cSeealso ) +FUNCTION procngialso2( cSeealso ) LOCAL nPos LOCAL aAlso:={} @@ -754,65 +844,405 @@ FUNCTION ProcStatusng( nWriteHandle, cBuffer ) RETURN nil + +Function GenNgTable(oNgi) +LOCAL y,nLen2,x,nMax,nSpace,lCar:=.f.,nMax2,nSpace2,nPos1,nPos2,LColor,npos +LOCAL aLensFItem:={} +LOCAL aLensSItem:={} + + FOR X:=1 to LEN(afitable) + if AT("^",afitable[x])>0 + aadd(aLenssItem,len(Substr(strtran(afitable[x],"^n",""),5))) + else + AADD(aLensFItem,Len(afiTable[x])) + endif + NEXT + FOR X:=1 to LEN(asiTable) + if AT("^",asitable[x])>0 + aadd(aLenssItem,len(Substr(strtran(asitable[x],"^n",""),5))) + else + AADD(aLensSItem,Len(asiTable[x])) + endif + NEXT + ASORT(aLensFItem,,,{|x,y| x > y}) + ASORT(aLensSItem,,,{|x,y| x > y}) + +nMax:=alenssitem[1] +nPos:=maxelem(asitable) + nPos1:=ascan(aLenssItem,{|x| x==nPos}) + oNgi:WritePar("") +// nMax2:=checkcar(aTable,1)+1 + nMax2:=alensfitem[1] + nPos:=maxelem(afitable) + nPos2:=ascan(alensfitem,{|x| x==nPos}) + + + oNgi:WritePar(" É"+REPL("Í",aLensFitem[nPos2]+2)+"Ë"+REPL("Í",alensSitem[nPos1]+2)+"»",.F.) //-4 + +FOR x:=1 to len(asitable) + nSpace:=nMax-Len(asitable[x]) + nSpace2:=nMax2-Len(afitable[x]) + oNgi:WriteParBox( " º "+ afiTable[x]+space(nSpace2)+ " º "+ IF(asiTable[x]=="|",Strtran(asiTable[x],"|"," "),asiTable[x]) +space(nspace)+" º"+HB_OsNEWLINE()) +Next + + + oNgi:WritePar(" È"+REPL("Í",aLensFitem[nPos2]+2)+"Ê"+REPL("Í",aLenssitem[npos1]+2)+"¼",.F.) // -4 + +oNgi:WritePar("") +afiTable:={} +asitable:={} +Return Nil + Function ProcNgTable(cBuffer) -Local nPos,cItem,cItem2,cItem3 +Local nPos,cItem,cItem2,cItem3,xtype,nColorpos,cColor + if AT("0 + nColorPos:=AT(":",cBuffer) + cColor:=SubStr(cBuffer,nColorpos+1) + nPos:=at(">",ccolor) + cColor:=substr(ccolor,1,nPos-1) + cBuffer:=strtran(cbuffer,"","") + cBuffer:=STRTRAn(cbuffer,"","") + cBuffer:=Strtran(cBuffer,ccolor,'') + nColorpos:=ASCAn(aColorTable,{|x,y| upper(x[1])==upper(ccolor)}) + cColor:=aColortable[nColorPos,2] + Endif cItem:=SubStr(cBuffer,1,22) + xtype=valtype(citem) cBuffer:=StrTran(cBuffer,cItem,Space(len(cItem))) nPos:=STRPos(cBuffer) IF nPos=23 cItem2:=SubStr(cBuffer,nPos) Endif - AADD(aTable,{ltrim(cItem),cItem2}) -Return Nil + AADD(afiTable,rtrim(ltrim(cItem))) + AADD(asiTable,cItem2) -Function GenNgTable(oRtf) - -LOCAL y,nLen2,x,nMax,nSpace -LOCAL aLensFItem:={} -LOCAL aLensSItem:={} - FOR X:=1 to LEN(aTable) - AADD(aLensFItem,Len(aTable[x,1])) - NEXT - FOR X:=1 to LEN(aTable) - AADD(aLensSItem,Len(aTable[x,2])) - NEXT - ASORT(aLensFItem,,,{|x,y| x < y}) - ASORT(aLensSItem,,,{|x,y| x > y}) - nMax:=aLensSItem[1]+1 -oRtf:WritePar(" É"+REPL("Í",aLensFitem[1])+"Ë"+REPL("Í",nMax)+"»",.f.) -FOR x:=1 to len(aTable) - nSpace:=nMax-Len(atable[x,2])-1 - oRtf:WriteParBox( " º"+ aTable[x,1]+ "º "+ IF(aTable[x,2]=="|",Strtran(aTable[x,2],"|"," "),aTable[x,2]) +space(nspace)+"º"+HB_OSNEWLINE()) -Next -oRtf:WritePar(" È"+REPL("Í",aLensFitem[1])+"Ê"+REPL("Í",nMax)+"¼",.f.) -oRtf:WritePar("") -aTable:={} -lIsTable:=.T. Return Nil +FUNCTION ProcNGDesc(cBuffer,oNgi,cStyle) +local cLine:='' +Local npos,CurPos:=0 +LOCAL nColorPos,ccolor:='',creturn:='',ncolorend,nIdentLevel +LOCAL lEndPar:= .F. + +LOCAL lEndFixed:=.F. +LOCAL lEndTable:=.F. +Default cStyle to "Default" -FUNCTION ProcNGDesc(cBuffer,lBlankLine,oRtf,lPar) - if lPar .and. !lBlankLine - if Strpos(cBuffer)=7 .or. Strpos(cBuffer)>=9 .or. Strpos(cBuffer)=5 - oRtf:WritePar(Strtran(cBuffer," "," ")) - lPar:=.T. + +if cStyle<>"Example" .and. at("",cBuffer)==0 .and. AT("",cBuffer)=0 + if AT("",cBuffer)>=0 .or. AT("",cBuffer)=0 .and. !empty(cbuffer) + If AT("",cBuffer)>0 .and. AT("",cBuffer)>0 + + if cStyle=="Arguments" + cBuffer:= strtran(cBuffer,"","") +// ? cBuffer + if at(") ",cBuffer)>0 + cBuffer:= strtran(cBuffer,") ",")") + elseif at("> ",cBuffer)>0 + cBuffer:= strtran(cBuffer,"> ",">") + endif + endif + + else + cBuffer:=FormatngBuff(cBuffer,cStyle,ongi) + endif +endif +endif + +if empty(cBuffer) +oNgi:WritePar("") +endif + +If AT('',cBuffer)>0 .and. AT('',cBuffer)>0 + cBuffer:=Strtran(cBuffer,'','') + cBuffer:=StrTran(cBuffer,'',' ^b') + cBuffer:=StrTran(cBuffer,'', '^n ') + cBuffer:=Strtran(cBuffer,'', '^n ') + cBuffer:=StrTran(cBuffer,'','') + cBuffer:=StrTran(cBuffer,'','') + cBuffer:=StrTran(cBuffer,'','') + cBuffer:=StrTran(cBuffer,'','') + + nColorPos:=at('0 + checkngcolor(@cbuffer,ncolorpos) + endif +// Alltrim(cBuffer) + If cStyle=="Description" .or. cStyle=="Compliance" + nIdentLevel:=6 + nPos:=0 + do while !lendPar + if nPos==0 + cLine:=SubStr(cBuffer,1,76) + nPos:=RAT(" ",cLine) + if nPos>0 + + cLine:=SubStr(cBuffer,1,nPos) endif - ENDIF - IF lBlankLine - lIsTable:=.F. - oRtf:WritePar("") - lPar:=.T. - ENDIF - IF StrPos(cBuffer)=8 - lIsTable:=.T. - ProcNgTable(cBuffer) - lPar:=.f. - ENDIF - IF !lIsTable .and. len(aTable)>0 - GenNgTable(oRtf) - lPar:=.T. - ENDIF -RETURN lPar + else + cLine:=space(nidentLevel)+SubStr(cBuffer,curPos,69) + + if AT('',cline)>0 + lEndPar:=.T. + cline:=strtran(cline," ","") + endif + nPos:=RAT(" ",cLine) + if nPos>0 + cLine:=space(nidentLevel)+ SubStr(cBuffer,curpos,nPos-nIdentlevel) + npos-=nIdentlevel + else + if cLine=="" + cLine:='' + endif + + endif + endif + if !empty(cline) + oNgi:WritePar(space(nidentLevel)+Alltrim(cline)) + endif + curPos:=Curpos+nPos + Enddo + + ELSEIf cStyle=="Arguments" + nIdentLevel:=18 + nPos:=0 + + do while !lendPar + if nPos==0 + cLine:=SubStr(cBuffer,1,76) + nPos:=RAT(" ",cLine) + if nPos>0 + + cLine:=SubStr(cBuffer,1,nPos) + endif + if !empty(cline) + oNgi:WritePar(cline) + endif + + else + cLine:=space(nidentLevel)+SubStr(cBuffer,curPos,58) //60 + + if AT('',cline)>0 + lEndPar:=.T. + cline:=strtran(cline," ","") + endif + nPos:=RAT(" ",cLine) + if nPos>0 + cLine:=space(nidentLevel)+ SubStr(cBuffer,curpos,nPos-nIdentlevel) + npos-=nIdentlevel + else + if cLine=="" + cLine:='' + endif + + endif + if !empty(cline) + oNgi:WritePar(space(nidentLevel)+Alltrim(cline)) + endif + + endif + curPos:=Curpos+nPos + Enddo + + + ELSEIf cStyle=="Syntax" + nIdentLevel:=6 + nPos:=0 + do while !lendPar + if nPos==0 + cLine:=SubStr(cBuffer,1,76) + nPos:=RAT(" ",cLine) + if nPos>0 + + cLine:=SubStr(cBuffer,1,nPos) + endif + + else + cLine:=space(nidentLevel)+SubStr(cBuffer,curPos,69) + + if AT('',cline)>0 + lEndPar:=.T. + cline:=strtran(cline," ","") + endif + nPos:=RAT(" ",cLine) + if nPos>0 + cLine:=space(nidentLevel)+ SubStr(cBuffer,curpos,nPos-nIdentlevel) + npos-=nIdentlevel + else + if cLine=="" + cLine:='' + endif + + endif + endif + if !empty(cline) + oNgi:WritePar(space(nidentLevel)+Alltrim(cline)) + endif + curPos:=Curpos+nPos + Enddo + + +Elseif cStyle=="Default" + nIdentLevel:=6 + nPos:=0 + do while !lendPar + if nPos==0 + cLine:=SubStr(cBuffer,1,76) + nPos:=RAT(" ",cLine) + if nPos>0 + cLine:=SubStr(cBuffer,1,nPos) + endif + + else + cLine:=space(nidentLevel)+SubStr(cBuffer,curPos,69) + nPos:=RAT(" ",cLine) + if AT('',cline)>0 + lEndPar:=.T. + cline:=strtran(cline,"","") + endif + if nPos>0 + cLine:=space(nidentLevel)+SubStr(cBuffer,curpos,nPos-nIdentlevel) + npos-=nIdentlevel + else + if cLine=="" + cLine:='' + endif + + endif + endif + if !empty(cline) + oNgi:WritePar(rtrim(cline)) + endif + curPos:=Curpos+nPos + Enddo +endif +endif +If AT('',cBuffer)>0 + do while !lendFixed + cLine := TRIM(SUBSTR( ReadLN( @lEof ), nCommentLen ) ) + if at("",cLine)>0 + lendfixed:=.t. + else + + oNgi:WritePar(cline) + endif + enddo +end +if AT('
',cBuffer)>0 + do while !lendTable + cLine := TRIM(SUBSTR( ReadLN( @lEof ), nCommentLen ) ) + if at("
",cLine)>0 + lendTable:=.t. + else + procngtable(cline) + endif + enddo +if lEndTable + GenNgTable(oNgi) +endif +endif +// If cStyle=="Description" .or. cStyle=="Compliance" + // oNgi:Writepar('') + // endif +return nil + + +func checkngcolor(cbuffer,ncolorpos) +local ncolorend,nreturn,cOldColorString,cReturn,ccolor + +do while at("0 + nColorPos:=AT("",ccolor) + ccolor:=substr(ccolor,1,nColorend-1) + cOldColorString:=Substr(cbuffer,ncolorpos) + nColorend:=AT(">",cOldColorString) + cOldColorString:=Substr(cOldColorString,1,nColorEnd) +nreturn:=ascan(acolortable,{|x,y| upper(x[1])==upper(ccolor)}) +if nreturn >0 + creturn:="^a"+acolortable[nreturn,2] +endif +cBuffer:=strtran(cBuffer,cOldColorString,cReturn) +enddo +return cbuffer + +func maxelem(a) +local nsize:=len(a) +local max:=0 +Local tam:=0 +local max2:=0 +LOCAL nPos:=1 +LOCAL cString +local ncount +for ncount:=1 to nsize + tam:=len(a[ncount]) + max:=if(tam>max,tam,max) +next +nPos:=ascan(a,{|x| Len(x)==max}) +return max + +function FormatNgBuff(cBuffer,cStyle,ongi) + +Local creturn:='' +local cline:='',coline:='' +local cBuffend:='' +local lendbuff:=.f. +local npos,nposend + creturn :=cBuffer+' ' + if at('',creturn)>0 .or. empty(cBuffer) + if empty(cbuffer) + creturn:='' + endif + return creturn + endif + if cStyle != "Syntax" .AND. cStyle !="Arguments" + do while !lendBuff + cLine := TRIM(SUBSTR( ReadLN( @lEof ), nCommentLen ) ) + if at('',cLine)>0 .or. empty(cline) + lendBuff:=.t. + endif + cReturn+=alltrim(cLine)+ ' ' + enddo + cReturn:=''+creturn+' ' + elseif cStyle=='Syntax' + nPos:=At("-->",cBuffer) + if nPos>0 + cBuffend:=Substr(cReturn,nPos+3) + cReturn:=SubStr(cReturn,1,nPos+3) + cReturn:=cReturn+''+cBuffend+' ' + creturn:=''+creturn+' ' + ELSE + cReturn:=''+cReturn+' ' + ENDIF + ELSEIF cStyle=='Arguments' + nPos:=0 + if at("",cReturn)>0 + cReturn:=STRTRAN(cReturn,"","") + cReturn:=STRTRAN(cReturn,"","") + cReturn:=alltrim(cReturn) + nPos:=AT(" ",cReturn) + cOLine:=left(cReturn,nPos-1) + cReturn:=STRTRAN(cReturn,coLine,"") + cReturn:=STRTRAN(cReturn,">","> ") + cReturn:=STRTRAN(cReturn," <"," <") + + endif + DO WHILE !lEndBuff + cLine := TRIM(SUBSTR( ReadLN( @lEof ), nCommentLen ) ) + IF AT('',cLine)>0 .OR. EMPTY(cLine) + lEndBuff:=.t. + ENDIF + cReturn+=alltrim(cLine)+ ' ' + enddo + cReturn:=' '+cOLine+' '+cReturn+'' + ENDIF + +// endif +return creturn + + + diff --git a/harbour/utils/hbdoc/genos2.prg b/harbour/utils/hbdoc/genos2.prg index d54b914996..c793863444 100644 --- a/harbour/utils/hbdoc/genos2.prg +++ b/harbour/utils/hbdoc/genos2.prg @@ -40,7 +40,8 @@ #include "directry.ch" #include "fileio.ch" #include "inkey.ch" - +#include "hbdocdef.ch" +#include 'common.ch' // output lines on the screen #define INFILELINE 10 @@ -49,14 +50,13 @@ #define ERRORLINE 20 #define LONGLINE 100 #define LONGONELINE 86 -#define CRLF HB_OSNewLine() -// The delimiter -#define DELIM "$" // keyword delimiter - -#xtranslate UPPERLOWER() => (UPPER(SUBSTR(,1,1))+LOWER(SUBSTR(,2))) MEMVAR aDirlist,aDocInfo STATIC aAlso - +STATIC nCommentLen +STATIC lEof +STATIC aFiTable := {} +STATIC lIsTable :=.F. +STATIC aColorTable:={{'aqua',''},{'black',''},{'fuchia',''},{'grey',''},{'green',''},{'lime',''},{'maroon',''},{'navy',''},{'olive',''},{'purple',''},{'red',''},{'silver',''},{'teal',''},{'white',''},{'yellow',''}} FUNCTION ProcessOs2() // @@ -75,19 +75,11 @@ FUNCTION ProcessOs2() // - // LOCAL variables: -#define D_NORMAL 1 -#define D_ARG 2 -#define D_SYNTAX 3 -#define D_IGNORE 4 -#define D_SEEALSO 5 -#define D_INCLUDE 6 -#define D_ONELINE 7 -#define D_STATUS 8 LOCAL i LOCAL j LOCAL nFiles - LOCAL nCommentLen - LOCAL lEof +// LOCAL nCommentLen +// LOCAL lEof LOCAL lDoc LOCAL cBuffer LOCAL nEnd @@ -95,6 +87,7 @@ FUNCTION ProcessOs2() LOCAL cBar := "ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ" LOCAL nMode + local cname LOCAL cFuncName LOCAL cOneLine LOCAL cCategory @@ -104,6 +97,12 @@ FUNCTION ProcessOs2() LOCAL cTemp LOCAL cChar LOCAL oOs2 + LOCAL lData := .F. + LOCAL lMethod := .F. + LOCAL nPos,nEpos,nPosend,cBuffEnd + LOCAL lIsDataLink := .F. + LOCAL lIsMethodLink := .F. + LOCAL lBlankLine := .F. // Blank line encountered and sent out LOCAL lAddBlank := .F. // Need to add a blank line if next line is not blank LOCAL nReadHandle @@ -127,6 +126,20 @@ FUNCTION ProcessOs2() LOCAL cFiles := DELIM + 'FILES' + DELIM LOCAL cSubCode := DELIM + 'SUBCODE' + DELIM LOCAL cFunction := DELIM + 'FUNCTION' +DELIM + LOCAL cConstruct := DELIM + 'CONSTRUCTOR' + DELIM + LOCAL cDatalink := DELIM + 'DATALINK' + DELIM + LOCAL cDatanolink := DELIM + 'DATANOLINK' + DELIM + LOCAL cMethodslink := DELIM + 'METHODSLINK' + DELIM + LOCAL cMethodsNolink := DELIM + 'METHODSNOLINK' + DELIM + LOCAL cData := DELIM +"DATA"+ DELIM + LOCAL cMethod := DELIM +'METHOD' +DELIM + LOCAL cClassDoc := DELIM+ "CLASSDOC" + DELIM + LOCAL cTable := DELIM +"TABLE" + DELIM + + lData := .F. + lMethod := .F. + lIsDataLink := .F. + lIsMethodLink := .F. nFiles := LEN( aDirList ) @@ -172,7 +185,7 @@ FUNCTION ProcessOs2() ENDIF // check to see if we are in doc mode or getting out of doc mode - IF AT( cDoc, cBuffer ) > 0 + IF AT( cDoc, cBuffer ) > 0 .or. AT( cClassDoc, cBuffer ) > 0 IF lDoc write_error( cDoc + " encountered during extraction of Doc" ; + " at line" + STR( nLinecnt, 5, 0 ),,,, aDirList[ i, F_NAME ] ) @@ -201,6 +214,9 @@ FUNCTION ProcessOs2() AADD( aDocInfo, { cCategory, cFuncName, cOneLine, cFileName } ) // Now close down this little piece lDoc := .F. + if lData .or. lmethod + oos2:writeText(':efn.') + endif IF .NOT. EMPTY( cSeeAlso ) oOs2:WritePar( ".br" + CRLF + "See Also:" ) FOR nAlso := 1 TO LEN( aAlso ) @@ -281,7 +297,25 @@ FUNCTION ProcessOs2() ? "Error creating", cFileName, ".ipf" write_error( "Error creating",,,, cFileName + ".ipf" ) ENDIF + ELSEIF AT( cdata, cBuffer ) > 0 .OR. AT( cmethod, cBuffer ) > 0 + if AT( cdata, cBuffer ) > 0 + lData := .T. + lMethod := .F. + ELSEIF AT( cmethod, cBuffer ) > 0 + lMethod := .T. + lData:= .F. + ENDIF + cBuffer := ReadLN( @lEof ) + nLineCnt ++ + // Save the function name + cFuncName := UPPER( ALLTRIM( SUBSTR( cBuffer, nCommentLen ) ) ) + @ MODULELINE, 33 CLEAR TO MODULELINE, MAXCOL() + @ MODULELINE, 33 SAY cFuncName + + nMode := D_NORMAL + // 2) Category + ELSEIF AT( cCat, cBuffer ) > 0 cBuffer := ReadLN( @lEof ) nLineCnt ++ @@ -301,8 +335,16 @@ FUNCTION ProcessOs2() nMode := D_ONELINE // Now start writing out what we know + if lData + oOs2:WriteJumpTitle( left(cFilename,At('.',cFilename)-1)+ cFuncName, "Data "+cFuncName ) + Elseif lMethod + oOs2:WriteJumpTitle( left(cFilename,At('.',cFilename)-1)+cFuncName, "Method " +cFuncName ) + Else + oOs2:WriteTitle( PAD( cFuncName, 21 ), cFuncName ) oOs2:WriteParBold( cOneLine ) + + Endif // 4) all other stuff ELSE @@ -314,6 +356,15 @@ FUNCTION ProcessOs2() nMode := D_SYNTAX lAddBlank := .T. + ELSEIF AT( cConstruct, cBuffer ) > 0 + + oOs2:WriteParBold( " Constructor syntax" ) + + nMode := D_SYNTAX + lAddBlank := .T. + + + ELSEIF AT( cArg, cBuffer ) > 0 IF !lBlankLine @@ -333,7 +384,7 @@ FUNCTION ProcessOs2() oOs2:WriteParBold( " Returns" ) - nMode := D_ARG + nMode := D_RETURN lAddBlank := .T. ELSEIF AT( cDesc, cBuffer ) > 0 @@ -343,9 +394,46 @@ FUNCTION ProcessOs2() ENDIF oOs2:WriteParBold( " Description" ) + nMode := D_DESCRIPTION + lAddBlank := .T. + ELSEIF AT( cdatalink, cBuffer ) > 0 + IF !lBlankLine + oOs2:WritePar( "" ) //:endpar() + ENDIF + + oOs2:WriteParBold( " Data" ) + nMode := D_DATALINK + lAddBlank := .T. + + lIsDataLink := .T. + + ELSEIF AT( cDatanolink, cBuffer ) > 0 + if !lIsDataLink + oOs2:WriteParBold( " Data" ) + + endif nMode := D_NORMAL lAddBlank := .T. + + ELSEIF AT( cMethodslink, cBuffer ) > 0 + + oOs2:WriteParBold( " Method" ) + nMode := D_METHODLINK + lAddBlank := .T. + + lIsMethodLink := .T. + + ELSEIF AT( cMethodsnolink, cBuffer ) > 0 + if !lIsMethodLink + oOs2:WriteParBold( " Methods" ) + endif + + nMode := D_NORMAL + lAddBlank := .T. + + + ELSEIF AT( cExam, cBuffer ) > 0 IF !lBlankLine @@ -374,7 +462,7 @@ FUNCTION ProcessOs2() oOs2:WritePar( "" ) ENDIF oOs2:WriteParBold( " Compliance" ) - nMode := D_NORMAL + nMode := D_COMPLIANCE lAddBlank := .T. ELSEIF AT( cPlat, cBuffer ) > 0 @@ -419,37 +507,72 @@ FUNCTION ProcessOs2() LONGLINE, aDirList[ i, F_NAME ] ) ENDIF lBlankLine := EMPTY( cBuffer ) - IF lAddBlank - oOs2:WritePar( "" ) - lAddBlank := .F. + if At("",cBuffer)>0 + nPos:=At("->",cBuffer) + if nPos>0 + nPosend:=AT("",cBuffer) + + cBuffend:=Substr(cBuffer,nPos+2,nPosend-2) + cBuffEnd:=Strtran(cBuffend,"","") + cBuffer:=SubStr(cBuffer,1,nPos+2) + + cBuffer:=cBuffer+''+cBuffend+' ' + endif + endif + procos2desc(cbuffer,oOs2,"Syntax") + + ELSEIF nMode = D_RETURN + + IF LEN( cBuffer ) > LONGLINE + write_error( "Arguments", cBuffer, nLineCnt, ; + LONGLINE, aDirList[ i, F_NAME ] ) ENDIF - /* nNonBlank:=FirstNB(cBuffer) - cBuffer=STUFF(cBuffer,nNonBlank,0,"^a1f ")*/ - oOs2:WritePar( cBuffer ) + lBlankLine := EMPTY( cBuffer ) + + procos2desc(cbuffer,oOs2,"Arguments") + + + ELSEIF nMode = D_ARG IF LEN( cBuffer ) > LONGLINE write_error( "Arguments", cBuffer, nLineCnt, ; LONGLINE, aDirList[ i, F_NAME ] ) ENDIF lBlankLine := EMPTY( cBuffer ) - IF lAddBlank - oOs2:WritePar( "" ) - lAddBlank := .F. - ENDIF - cBuffer := STRTRAN( cBuffer, "<", "<", 1 ) - cBuffer := STRTRAN( cBuffer, ">", ">", 1 ) - oOs2:WritePar( StripNgControls( cBuffer ) ) + procos2desc(cbuffer,oOs2,"Arguments") ELSEIF nMode = D_NORMAL + IF LEN( cBuffer ) > LONGLINE + write_error( "General", cBuffer, nLineCnt, ; + LONGLINE, aDirList[ i, F_NAME ] ) + ENDIF + lBlankLine := EMPTY( cBuffer ) + procos2desc(cBuffer,oOs2) + ELSEIF nMode = D_DATALINK IF LEN( cBuffer ) > LONGLINE write_error( "General", cBuffer, nLineCnt, ; LONGLINE, aDirList[ i, F_NAME ] ) ENDIF lBlankLine := EMPTY( cBuffer ) IF lAddBlank - oOs2:WritePar( "" ) lAddBlank := .F. ENDIF - oOs2:WritePar( StripNgControls( cBuffer ) ) + cTemp:=Substr(cBuffer,1,AT(":",cBuffer)-1) + cBuffer:=Substr(cBuffer,AT(":",cBuffer)+1) + oOs2:WriteJumpLink(Left(cfilename,At('.',cFilename)-1)+alltrim(cTemp),cBuffer) + ELSEIF nMode = D_METHODLINK + IF LEN( cBuffer ) > LONGLINE + write_error( "General", cBuffer, nLineCnt, ; + LONGLINE, aDirList[ i, F_NAME ] ) + ENDIF + lBlankLine := EMPTY( cBuffer ) + IF lAddBlank + lAddBlank := .F. + ENDIF + cTemp:=Substr(cBuffer,1,AT("()",cBuffer)+1) + cName:=Substr(cBuffer,1,AT("()",cBuffer)-1) + cBuffer:=Substr(cBuffer,AT("()",cBuffer)+2) + oOs2:WriteJumpLink(Left(cfilename,At('.',cFilename)-1)+alltrim(cTemp) ,cTemp,cBuffer) + ELSEIF nMode = D_SEEALSO IF .NOT. EMPTY( cBuffer ) cSeeAlso := ProcOs2Also( StripFiles( ALLTRIM( cBuffer ) ) ) @@ -460,9 +583,39 @@ FUNCTION ProcessOs2() IF !lBlankLine oOs2:WritePar( "" ) ENDIF - oOs2:WritePar( " Header File: " ; - + ALLTRIM( cBuffer ) ) ENDIF + ELSEIF nMode = D_COMPLIANCE + IF LEN( cBuffer ) > LONGLINE + write_error( "General", cBuffer, nLineCnt, ; + LONGLINE, aDirList[ i, F_NAME ] ) + ENDIF + lBlankLine := EMPTY( cBuffer ) + procos2desc(cBuffer,oOs2,"Compliance") + + + ELSEIF nMode = D_DESCRIPTION + IF LEN( cBuffer ) > LONGLINE + write_error( "General", cBuffer, nLineCnt, ; + LONGLINE, aDirList[ i, F_NAME ] ) + ENDIF + lBlankLine := EMPTY( cBuffer ) + procos2desc(cBuffer,oOs2,"Description") + + + ELSEIF nMode = D_EXAMPLE + IF LEN( cBuffer ) > LONGLINE + write_error( "General", cBuffer, nLineCnt, ; + LONGLINE, aDirList[ i, F_NAME ] ) + ENDIF + lBlankLine := EMPTY( cBuffer ) + + IF lAddBlank + oOs2:WritePar( "" ) //:endpar() + lAddBlank := .F. + ENDIF + + procos2desc(cBuffer,oOs2,"Example") + ELSEIF nMode = D_STATUS IF !EMPTY( cBuffer ) oOs2:WriteParBold( "Status" ) @@ -515,3 +668,273 @@ FUNCTION ProcOs2Also( cSeealso ) aAlso := {} aAlso := ListAsArray2( cSeealso, "," ) RETURN aAlso + +FUNCTION Formatos2Buff(cBuffer,cStyle,ongi) + +LOCAL cReturn:='' +LOCAL cLine:='' +LOCAL cBuffend:='' +LOCAL cEnd,cStart ,coline:='' +LOCAL lEndBuff:=.f. +LOCAL nPos,nPosEnd + cReturn :=cBuffer+' ' + IF AT('',cReturn)>0 .OR. EMPTY(cBuffer) + IF EMPTY(cbuffer) + cReturn:='' + ENDIF + Return cReturn + ENDIF + IF cStyle != "Syntax" .AND. cStyle !="Arguments" + DO WHILE !lEndBuff + cLine := TRIM(SUBSTR( ReadLN( @lEof ), nCommentLen ) ) + IF AT('',cLine)>0 .OR. EMPTY(cLine) + lEndBuff:=.t. + ENDIF + cReturn+=alltrim(cLine)+ ' ' + enddo + cReturn:=''+cReturn+' ' + ELSEIF cStyle=='Syntax' + nPos:=AT("-->",cBuffer) + + IF nPos>0 + cBuffend:=Substr(cReturn,nPos+3) + cReturn:=SubStr(cReturn,1,nPos+3) + cReturn:=cReturn+''+cBuffend+' ' + cReturn:=''+cReturn+' ' + ELSE + cReturn:=''+cReturn+' ' + ENDIF + ELSEIF cStyle=='Arguments' + nPos:=0 + if at("",cReturn)>0 + cReturn:=STRTRAN(cReturn,"","") + cReturn:=STRTRAN(cReturn,"","") + cReturn:=alltrim(cReturn) + nPos:=AT(" ",cReturn) + cOLine:=left(cReturn,nPos-1) + cReturn:=STRTRAN(cReturn,coLine,"") + cReturn:=STRTRAN(cReturn,">","> ") + cReturn:=STRTRAN(cReturn," <"," <") + + endif + DO WHILE !lEndBuff + cLine := TRIM(SUBSTR( ReadLN( @lEof ), nCommentLen ) ) + IF AT('',cLine)>0 .OR. EMPTY(cLine) + lEndBuff:=.t. + ENDIF + cReturn+=alltrim(cLine)+ ' ' + enddo + cReturn:=' '+cOLine+' '+cReturn+'' + + ENDIF +Return cReturn + +func checkos2color(cbuffer,ncolorpos) +LOCAL ncolorend,nreturn,cOldColorString,cReturn,ccolor + +do while at("0 + nColorPos:=AT("",ccolor) + ccolor:=substr(ccolor,1,nColorend-1) + cOldColorString:=Substr(cbuffer,ncolorpos) + nColorend:=AT(">",cOldColorString) + cOldColorString:=Substr(cOldColorString,1,nColorEnd) +nreturn:=ascan(acolortable,{|x,y| upper(x[1])==upper(ccolor)}) +if nreturn >0 + creturn:=+acolortable[nreturn,2] +endif +cBuffer:=strtran(cBuffer,cOldColorString,cReturn) +enddo +return cbuffer + +Function ProcOs2Table(cBuffer) + +LOCAL nPos,cItem,cItem2,cItem3,xtype,nColorpos,cColor + if AT("0 + nColorPos:=AT(":",cBuffer) + cColor:=SubStr(cBuffer,nColorpos+1) + nPos:=at(">",ccolor) + cColor:=substr(ccolor,1,nPos-1) + cBuffer:=strtran(cbuffer,"","") + cBuffer:=STRTRAn(cbuffer,"","") + cBuffer:=Strtran(cBuffer,ccolor,'') + nColorpos:=ASCAn(aColorTable,{|x,y| upper(x[1])==upper(ccolor)}) + cColor:=aColortable[nColorPos,2] + Endif + cItem:=cBuffer + AADD(afiTable,cItem) + + +Return Nil + + +func maxos2elem(a) +LOCAL nsize:=len(a) +LOCAL max:=0 +LOCAL tam:=0,max2:=0 +LOCAL nPos:=1 +LOCAL cString +LOCAL ncount +for ncount:=1 to nsize + tam:=len(a[ncount]) + max:=if(tam>max,tam,max) +next +nPos:=ascan(a,{|x| Len(x)==max}) +return max + + +Function Genos2Table(oOs2) +LOCAL y,nLen2,x,nMax,nSpace,lCar:=.f.,nMax2,nSpace2,nPos1,nPos2,LColor,nPos +LOCAL aLensFItem:={} +LOCAL aLensSItem:={} + + FOR X:=1 to LEN(afitable) + AADD(aLensFItem,Len(afiTable[x])) + + NEXT + ASORT(aLensFItem,,,{|x,y| x > y}) + + + + oOs2:WritePar("") +// nMax2:=checkcar(aTable,1)+1 + nMax2:=alensfitem[1] + nPos:=maxrtfelem(afitable) + nPos2:=ascan(alensfitem,{|x| x==nPos}) + +oOs2:WriteText(':cgraphic.') +oOs2:WritePar(" "+repl('Í',80)) +FOR x:=1 to len(afiTable) + oOs2:WritePar(IF(at("|",afiTable[x])>0,Strtran(afiTable[x],"|"," "),afiTable[x])) +Next +oOs2:WritePar(" "+repl('Í',80)) +oOs2:WriteText(':ecgraphic.') + oOs2:WritePar("") +afiTable:={} + +Return Nil + + +FUNCTION Procos2Desc(cBuffer,oOs2,cStyle) +LOCAL cLine:='' +LOCAL npos,CurPos:=0 +LOCAL nColorPos,ccolor:='',creturn:='',ncolorend,NIDENTLEVEL +LOCAL lEndPar:= .F. + +LOCAL lEndFixed:=.F. +LOCAL lEndTable:=.F. +default cStyle to "Default" + +if cStyle<>"Example" .and. at("",cBuffer)==0 .and. AT("",cBuffer)=0 + if AT("",cBuffer)>=0 .or. AT("",cBuffer)=0 .and. !empty(cbuffer) + If AT("",cBuffer)>0 .and. AT("",cBuffer)>0 + + if cStyle=="Arguments" + cBuffer:= strtran(cBuffer,"","") +// ? cBuffer + if at(") ",cBuffer)>0 + cBuffer:= strtran(cBuffer,") ",")") + elseif at("> ",cBuffer)>0 + cBuffer:= strtran(cBuffer,"> ",">") + endif + endif + + else + cBuffer:=Formatos2Buff(cBuffer,cStyle,oOs2) + endif +endif +endif + + +If AT('',cBuffer)>0 .and. AT('',cBuffer)>0 + cBuffer:=Strtran(cBuffer,'','') + cBuffer:=StrTran(cBuffer,'',':hp2. ') + cBuffer:=StrTran(cBuffer,'',':ehp2 ') + cBuffer:=StrTran(cBuffer,'',':hp3. ') + cBuffer:=StrTran(cBuffer,'',':ehb3 ') + cBuffer:=StrTran(cBuffer,'',':hp1 ') + cBuffer:=StrTran(cBuffer,'',':ehp1 ') + cBuffer:=Strtran(cBuffer,'','') + nColorPos:=at('0 + checkos2color(@cbuffer,ncolorpos) + endif + + If cStyle=="Description" .or. cStyle=="Compliance" + nIdentLevel:=6 + nPos:=0 + if AT('',cBuffer)>0 + cBuffer:=strtran(cBuffer,"","") + endif + if !empty(cBuffer) + cBuffer:=SUBSTR(cBuffer,2) + oOs2:WritePar(cBuffer) + endif + + ELSEIf cStyle=="Arguments" + + if AT('',cBuffer)>0 + cBuffer:=strtran(cBuffer,"","") + endif + if !empty(cBuffer) + cBuffer:=SUBSTR(cBuffer,2) + oOs2:writeText(cBuffer) + endif + + ELSEIf cStyle=="Syntax" + if AT('',cBuffer)>0 + cBuffer:=strtran(cBuffer,"","") + endif + if !empty(cBuffer) + cBuffer:=SUBSTR(cBuffer,2) + oOs2:WritePar(cBuffer) + endif + +Elseif cStyle=="Default" + if AT('',cBuffer)>0 + cBuffer:=strtran(cBuffer,"","") + endif + if !empty(cBuffer) + cBuffer:=SUBSTR(cBuffer,2) + oOs2:WritePar(cBuffer) + endif + + +endif +endif +If AT('',cBuffer)>0 + do while !lendFixed + cBuffer := TRIM(SUBSTR( ReadLN( @lEof ), nCommentLen ) ) + if at("",cBuffer)>0 + lendfixed:=.t. + else + + oOs2:WritePar(cBuffer) + endif + enddo +end +if AT('
',cBuffer)>0 + do while !lendTable + cBuffer := TRIM(SUBSTR( ReadLN( @lEof ), nCommentLen ) ) + if at("
",cBuffer)>0 + lendTable:=.t. + else + procos2table(cBuffer) + endif + enddo + if lEndTable + Genos2Table(oOs2) + endif +endif +if empty(cBuffer) +oOs2:WritePar("") +endif + +// If cStyle=="Description" .or. cStyle=="Compliance" +// oOs2:Writepar('') +// endif + +return nil + diff --git a/harbour/utils/hbdoc/genrtf.prg b/harbour/utils/hbdoc/genrtf.prg index b460d411cd..047b127e02 100644 --- a/harbour/utils/hbdoc/genrtf.prg +++ b/harbour/utils/hbdoc/genrtf.prg @@ -41,7 +41,8 @@ #include "directry.ch" #include "fileio.ch" #include "inkey.ch" - +#include 'hbdocdef.ch' +#include 'common.ch' // output lines on the screen #define INFILELINE 10 @@ -50,15 +51,14 @@ #define ERRORLINE 20 #define LONGLINE 100 #define LONGONELINE 86 -#define CRLF HB_OSNewLine() -// The delimiter -#define DELIM "$" // keyword delimiter - -#xtranslate UPPERLOWER() => (UPPER(SUBSTR(,1,1))+LOWER(SUBSTR(,2))) -MEMVAR aDirList,aDocInfo -STATIC aTable := {} +MEMVAR aDirList,aDocinfo +STATIC aFiTable := {} STATIC lIsTable :=.F. -Static myh +STATIC nCommentLen +STATIC lEof + +STATIC aColorTable:={{'aqua','\cf2 '},{'black','\cf1 '},{'fuchia','\cf3 '},{'grey','\cf4 '},{'green','\cf5 '},{'lime','\cf6 '},{'maroon','\cf7 '},{'navy','\cf8 '},{'olive','\cf9 '},{'purple','\cf10 '},{'red','\cf11 '},{'silver','\cf12 '},{'teal','\cf13 '},{'white','\cf14 '},{'yellow','\cf15 '}} + FUNCTION ProcessRtf() // @@ -76,22 +76,10 @@ FUNCTION ProcessRtf() // - // LOCAL variables: -#define D_NORMAL 1 -#define D_ARG 2 -#define D_SYNTAX 3 -#define D_IGNORE 4 -#define D_SEEALSO 5 -#define D_INCLUDE 6 -#define D_ONELINE 7 -#define D_STATUS 8 -#define D_DATALINK 10 -#define D_METHODLINK 11 -#define D_EXAMPLE 12 + LOCAL i LOCAL j - LOCAL nFiles := LEN( aDirList ) - LOCAL nCommentLen - LOCAL lEof + LOCAL nFiles := LEN( aDirList ) LOCAL lDoc LOCAL cBuffer LOCAL nEnd @@ -99,7 +87,7 @@ FUNCTION ProcessRtf() LOCAL xAddBlank LOCAL nNumTopics :=0 LOCAL nCurTopics :=1 - LOCAL cBar := "ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ" + LOCAL cBar := " "+ repl(')',80) LOCAL nMode LOCAL cFuncName LOCAL cOneLine @@ -120,7 +108,7 @@ FUNCTION ProcessRtf() LOCAL lPar LOCAL lWrite :=.f. LOCAL lWasLine := .F. - LOCAL nPos,nEpos + LOCAL nPos,nEpos,nPosend,cBuffEnd LOCAL lIsDataLink := .F. LOCAL lIsMethodLink := .F. LOCAL cName @@ -158,7 +146,7 @@ FUNCTION ProcessRtf() lMethod := .F. lIsDataLink := .F. lIsMethodLink := .F. - myh:=fcreate('error.txt') + lWrite:=.f. cTempx:='' // @@ -358,20 +346,30 @@ FUNCTION ProcessRtf() Else oRtf:WriteTitle( PAD( cFuncName, 21 ), cFuncName ) oRtf:WriteParBold( cOneLine,.t. ) - oRtf:WriteParBold( cBar,.t. ) + oRtf:WriteParBox( cBar ) ENDIF // 4) all other stuff ELSE IF AT( cSyn, cBuffer ) > 0 + IF !lBlankLine + + oRtf:WritePar( "" ) + + ENDIF oRtf:WriteParBold( " Syntax" ) - + oRtf:WritePar('') //:endpar() nMode := D_SYNTAX - +// oRtf:WritePar('') //:endpar() lAddBlank := .T. ELSEIF AT( cConstruct, cBuffer ) > 0 + IF !lBlankLine + + oRtf:WritePar( "" ) + + ENDIF oRtf:WriteParBold( " Constructor syntax" ) @@ -384,10 +382,11 @@ FUNCTION ProcessRtf() IF !lBlankLine - oRtf:WriteParBold( " Arguments" ) + oRtf:WritePar( "" ) ENDIF - + oRtf:WriteParBold( " Arguments" ) + oRtf:WritePar('') //:endpar() nMode := D_ARG lAddBlank := .T. lPar:=.t. @@ -398,15 +397,15 @@ FUNCTION ProcessRtf() ENDIF oRtf:WriteParBold( " Returns" ) - - nMode := D_ARG + oRtf:WritePar( "" ) //:endpar() + nMode := D_RETURN lAddBlank := .T. lPar:=.t. ELSEIF AT( cDesc, cBuffer ) > 0 oRtf:WritePar('') //:endpar() oRtf:WriteParBold( " Description" ) oRtf:WritePar('') //:endpar() - nMode := D_NORMAL + nMode := D_DESCRIPTION lAddBlank := .T. lPar:= .T. ELSEIF AT( cTable, cBuffer ) > 0 @@ -432,7 +431,7 @@ FUNCTION ProcessRtf() endif nMode := D_NORMAL lAddBlank := .T. -// lEndDatalink:=.T. + lPar:= .T. ELSEIF AT( cMethodslink, cBuffer ) > 0 @@ -488,7 +487,7 @@ FUNCTION ProcessRtf() oRtf:WritePar('') //:endpar() ENDIF - nMode := D_NORMAL + nMode := D_COMPLIANCE lAddBlank := .T. lPar:= .T. ELSEIF AT( cPlat, cBuffer ) > 0 @@ -544,58 +543,39 @@ FUNCTION ProcessRtf() LONGLINE, aDirList[ i, F_NAME ] ) ENDIF lBlankLine := EMPTY( cBuffer ) - IF lAddBlank - oRtf:WritePar( "" ) //:endpar() - lAddBlank := .F. - ENDIF - /* nNonBlank:=FirstNB(cBuffer) - cBuffer=STUFF(cBuffer,nNonBlank,0,"^a1f ")*/ - oRtf:WritePar( cBuffer ) //:endpar() - oRtf:WritePar("") //:endpar() + if At("",cBuffer)>0 + nPos:=At("->",cBuffer) + if nPos>0 + nPosend:=AT("",cBuffer) + + cBuffend:=Substr(cBuffer,nPos+2,nPosend-2) + cBuffEnd:=Strtran(cBuffend,"","") + cBuffer:=SubStr(cBuffer,1,nPos+2) + + cBuffer:=cBuffer+''+cBuffend+' ' + endif + endif + procrtfdesc(cbuffer,oRtf,"Syntax") +// oRtf:WritePar('') //:endpar() + ELSEIF nMode = D_RETURN - ELSEIF nMode = D_ARG IF LEN( cBuffer ) > LONGLINE write_error( "Arguments", cBuffer, nLineCnt, ; LONGLINE, aDirList[ i, F_NAME ] ) ENDIF lBlankLine := EMPTY( cBuffer ) - IF lAddBlank - oRtf:WritePar( "" ) //:endpar() - lAddBlank := .F. + procrtfdesc(cbuffer,oRtf,"Arguments") + + ELSEIF nMode = D_ARG + + IF LEN( cBuffer ) > LONGLINE + write_error( "Arguments", cBuffer, nLineCnt, ; + LONGLINE, aDirList[ i, F_NAME ] ) ENDIF - IF AT("_SET_",cBuffer)>0 - nPos:=AT("_SET_",cBuffer) - if nPos<23 - oRtf:WritePar("\line "+cBuffer+ " \line ") - Else - oRtf:WriteParText( " "+ ALLTRIM(cBuffer) +" ") - endif - ELSEIF AT("<",cBuffer)> 0 - nPos := AT("<",cBuffer) - if nPos>0 .and. nPos<12 - nEpos:=AT(">",cBuffer) - oRtf:WriteParBoldText( substr(cBuffer,1,nEpos ),substr(cBuffer,nEpos+1)+" ") - else - oRtf:WriteParText( " "+ ALLTRIM(cBuffer) ) - endif - ELSEIF AT("()",Cbuffer)>0 - nPos:=AT("()",Cbuffer) - nEpos:=AT(")",cBuffer) - if nPos>0 .and. nPos<22 - oRtf:WriteParBoldText( substr(cBuffer,1,nEpos ),substr(cBuffer,nEpos+1)+" ") - ELSE - oRtf:WriteParText( " "+ ALLTRIM(cBuffer) +" ") - Endif - ELSEIF at("===",cBuffer)>0 .or. at("---",cBuffer)>0 - oRtf:WritePar(cBuffer+" ") - ELSEIF !lBlankline - oRtf:WriteParText( ALLTRIM(cBuffer) +" " ) - ELSE - //ortf:endpar() - ortf:writepar('') //:endpar() + lBlankLine := EMPTY( cBuffer ) - ENDIF + procrtfdesc(cbuffer,oRtf,"Arguments") ELSEIF nMode = D_DATALINK IF LEN( cBuffer ) > LONGLINE write_error( "General", cBuffer, nLineCnt, ; @@ -628,8 +608,24 @@ FUNCTION ProcessRtf() LONGLINE, aDirList[ i, F_NAME ] ) ENDIF lBlankLine := EMPTY( cBuffer ) + procrtfdesc(cBuffer,oRtf) + ELSEIF nMode = D_COMPLIANCE + IF LEN( cBuffer ) > LONGLINE + write_error( "General", cBuffer, nLineCnt, ; + LONGLINE, aDirList[ i, F_NAME ] ) + ENDIF + lBlankLine := EMPTY( cBuffer ) + procrtfdesc(cBuffer,oRtf,"Compliance") - ProcRtfDesc(cBuffer,lBlankLine,oRtf,@lPar) + + ELSEIF nMode = D_DESCRIPTION + IF LEN( cBuffer ) > LONGLINE + write_error( "General", cBuffer, nLineCnt, ; + LONGLINE, aDirList[ i, F_NAME ] ) + ENDIF + lBlankLine := EMPTY( cBuffer ) + procrtfdesc(cBuffer,oRtf,"Description") + ELSEIF nMode = D_EXAMPLE IF LEN( cBuffer ) > LONGLINE @@ -642,8 +638,8 @@ FUNCTION ProcessRtf() oRtf:WritePar( "" ) //:endpar() lAddBlank := .F. ENDIF - oRtf:WriteParNoIndent( cBuffer ) //:endpar() + procrtfdesc(cBuffer,oRtf,"Example") ELSEIF nMode = D_SEEALSO IF .NOT. EMPTY( cBuffer ) cSeeAlso := StripFiles( ALLTRIM( cBuffer ) ) @@ -665,7 +661,7 @@ FUNCTION ProcessRtf() oRtf:WritePar("") //:endpar() xAddBlank:=.T. ENDIF - ProcStatusRtf( oRtf, cBuffer ) + procrtfstatus( oRtf, cBuffer ) ELSE // unknown data from somewhere @@ -687,7 +683,7 @@ FUNCTION ProcessRtf() FT_FUSE() NEXT ortf:close() - fclose(myh) + RETURN NIL FUNCTION ProcRtfAlso( nWriteHandle, cSeeAlso ) @@ -755,7 +751,7 @@ FUNCTION ProcRtfAlso( nWriteHandle, cSeeAlso ) ENDDO RETURN nil -FUNCTION ProcStatusRTF( nWriteHandle, cBuffer ) +FUNCTION procrtfstatus( nWriteHandle, cBuffer ) IF LEN( ALLTRIM(cBuffer) ) >1 nWriteHandle:WritePar( cBuffer ) //:endpar() ELSEIF SUBSTR( ALLTRIM( cBuffer ), 1 ) == "R" @@ -766,40 +762,225 @@ FUNCTION ProcStatusRTF( nWriteHandle, cBuffer ) nWriteHandle:WritePar( " Not Started" ) //:endpar() ENDIF RETURN nil -/* -func filesize(cfile) - - nretval := fseek(cfile,0,2) - +FUNCTION ProcRTFDesc(cBuffer,oRtf,cStyle) +LOCAL cLine:='' +LOCAL npos,CurPos:=0 +LOCAL nColorPos,ccolor:='',creturn:='',ncolorend,NIDENTLEVEL +LOCAL lEndPar:= .F. -return nretval -*/ -FUNCTION ProcRtfDesc(cBuffer,lBlankLine,oRtf,lPar) - cBuffer:=StrTran(cBuffer,"\","\\") - IF StrPos(cBuffer)=8 - lIsTable:=.T. - ProcRtfTable(cBuffer) - lPar:=.f. - ELSEIF !lIsTable .and. len(aTable)>0 - GenRtfTable(oRtf) - ELSEIF lPar - oRtf:WritePar(cBuffer+" ") - lPar:=.F. - ELSEIF AT("==",cBuffer)>0 .or. at("--",cBuffer)>0 - lPar:=.T. - oRtf:WritePar(cBuffer+" ") - ELSEIF lBlankLine - lIsTable:=.F. - oRtf:WritePar("") - lPar:=.T. - ELSE - oRtf:WriteParText(" "+alltrim(cBuffer)) - ENDIF +LOCAL lEndFixed:=.F. +LOCAL lEndTable:=.F. +default cStyle to "Default" -RETURN lPar +if cStyle<>"Example" .and. at("",cBuffer)==0 .and. AT("",cBuffer)=0 + if AT("",cBuffer)>=0 .or. AT("",cBuffer)=0 .and. !empty(cbuffer) + If AT("",cBuffer)>0 .and. AT("",cBuffer)>0 + + if cStyle=="Arguments" + cBuffer:= strtran(cBuffer,"","") +// ? cBuffer + if at(") ",cBuffer)>0 + cBuffer:= strtran(cBuffer,") ",")") + elseif at("> ",cBuffer)>0 + cBuffer:= strtran(cBuffer,"> ",">") + endif + endif + + else + cBuffer:=FormatrtfBuff(cBuffer,cStyle,ortf) + endif +endif +endif + +If AT('',cBuffer)>0 .and. AT('',cBuffer)>0 + cBuffer:=Strtran(cBuffer,'','') + cBuffer:=StrTran(cBuffer,'','\b ') + cBuffer:=StrTran(cBuffer,'','\b0 ') + cBuffer:=StrTran(cBuffer,'','\b\i ') + cBuffer:=StrTran(cBuffer,'','\b0\i0 ') + cBuffer:=StrTran(cBuffer,'','\i ') + cBuffer:=StrTran(cBuffer,'','\i0 ') + cBuffer:=Strtran(cBuffer,'','\cf1 ') + nColorPos:=at('0 + checkrtfcolor(@cbuffer,ncolorpos) + endif + + If cStyle=="Description" .or. cStyle=="Compliance" + nIdentLevel:=6 + nPos:=0 + if AT('',cBuffer)>0 + cBuffer:=strtran(cBuffer,"","") + endif + if !empty(cBuffer) + cBuffer:=SUBSTR(cBuffer,2) + oRtf:WritePar(cBuffer,'\fi-710\li710 ') + endif + + ELSEIf cStyle=="Arguments" + + if AT('',cBuffer)>0 + cBuffer:=strtran(cBuffer,"","") + endif + if !empty(cBuffer) + cBuffer:=SUBSTR(cBuffer,2) + oRtf:WritePar(cBuffer,'\fi-2272\li2272 ') + endif + + ELSEIf cStyle=="Syntax" + if AT('',cBuffer)>0 + cBuffer:=strtran(cBuffer,"","") + endif + if !empty(cBuffer) + cBuffer:=SUBSTR(cBuffer,2) + oRtf:WritePar(cBuffer,'\fi-710\li710 ') + endif + +Elseif cStyle=="Default" + if AT('',cBuffer)>0 + cBuffer:=strtran(cBuffer,"","") + endif + if !empty(cBuffer) + cBuffer:=SUBSTR(cBuffer,2) + oRtf:WritePar(cBuffer,'\fi-710\li710 ') + endif + + +endif +endif +If AT('',cBuffer)>0 + do while !lendFixed + cBuffer := TRIM(SUBSTR( ReadLN( @lEof ), nCommentLen ) ) + if at("",cBuffer)>0 + lendfixed:=.t. + else + + oRtf:WritePar(cBuffer) + endif + enddo +end +if AT('
',cBuffer)>0 + do while !lendTable + cBuffer := TRIM(SUBSTR( ReadLN( @lEof ), nCommentLen ) ) + if at("
",cBuffer)>0 + lendTable:=.t. + else + procrtftable(cBuffer) + endif + enddo + if lEndTable + GenrtfTable(oRtf) + endif +endif +if empty(cBuffer) +oRtf:WritePar("") +endif + +// If cStyle=="Description" .or. cStyle=="Compliance" +// oRtf:Writepar('') +// endif + +return nil + + +Function ProcRtfTable(cBuffer) + +LOCAL nPos,cItem,cItem2,cItem3,xtype,nColorpos,cColor + if AT("0 + nColorPos:=AT(":",cBuffer) + cColor:=SubStr(cBuffer,nColorpos+1) + nPos:=at(">",ccolor) + cColor:=substr(ccolor,1,nPos-1) + + cBuffer:=strtran(cbuffer,"","\cf1") + cBuffer:=STRTRAn(cbuffer,"","") + cBuffer:=Strtran(cBuffer,ccolor,'') + nColorpos:=ASCAn(aColorTable,{|x,y| upper(x[1])==upper(ccolor)}) + cColor:=aColortable[nColorPos,2] + Endif + cItem:=cBuffer + if ccolor<>NIL + AADD(afiTable,ccolor+cItem) + else + AADD(afiTable,cItem) + endif + +Return Nil + +Function GenRtfTable(oRtf) +LOCAL y,nLen2,x,nMax,nSpace,lCar:=.f.,nMax2,nSpace2,nPos1,nPos2,LColor,nPos +LOCAL aLensFItem:={} +LOCAL aLensSItem:={} + + FOR X:=1 to LEN(afitable) + if AT("\cf",afitable[x])>0 + aadd(aLensfItem,len(Substr(strtran(afitable[x],"\cf1",""),at(" ",afitable[x])))) + else + AADD(aLensFItem,Len(afiTable[x])) + endif + NEXT + ASORT(aLensFItem,,,{|x,y| x > y}) + + + + oRtf:WritePar("") +// nMax2:=checkcar(aTable,1)+1 + nMax2:=alensfitem[1] + nPos:=maxrtfelem(afitable) + nPos2:=ascan(alensfitem,{|x| x==nPos}) + + +oRtf:WriteParBox(" "+repl('4',80)) +FOR x:=1 to len(afiTable) + ortf:WritePar(IF(at("|",afiTable[x])>0,Strtran(afiTable[x],"|"," "),afiTable[x]),'\fi-710\li710') +Next +oRtf:WriteParBox(" "+repl('4',80)) + oRtf:WritePar("") +afiTable:={} + +Return Nil + +func checkrtfcolor(cbuffer,ncolorpos) +LOCAL ncolorend,nreturn,cOldColorString,cReturn,ccolor + +do while at("0 + nColorPos:=AT("",ccolor) + ccolor:=substr(ccolor,1,nColorend-1) + cOldColorString:=Substr(cbuffer,ncolorpos) + nColorend:=AT(">",cOldColorString) + cOldColorString:=Substr(cOldColorString,1,nColorEnd) +nreturn:=ascan(acolortable,{|x,y| upper(x[1])==upper(ccolor)}) +if nreturn >0 + creturn:="\cf"+acolortable[nreturn,2] +endif +cBuffer:=strtran(cBuffer,cOldColorString,cReturn) +enddo +return cbuffer +func maxrtfelem(a) +LOCAL nsize:=len(a) +LOCAL max:=0 +LOCAL tam:=0,max2:=0 +LOCAL nPos:=1 +LOCAL cString +LOCAL ncount +for ncount:=1 to nsize + if AT("\cf",a[ncount])>0 + cString:=Substr(strtran(a[ncount],"\cf1",""),6) + tam:=len(cString) + else + tam:=len(a[ncount]) + endif + max:=if(tam>max,tam,max) +next +nPos:=ascan(a,{|x| Len(x)==max}) +return max FUNCTION StrPos(cBuffer) LOCAL nPos,x,cChar +default nPos to 0 FOR x:=1 to LEN(cBuffer) cChar:=SubStr(cBuffer,x,1) if cChar>=chr(64) .and. cChar <=Chr(90) .or. cChar>=chr(97) ; @@ -809,50 +990,76 @@ LOCAL nPos,x,cChar cchar==chr(asc('.')) .or. cchar==chr(asc('*')) .or. ; cchar==chr(asc('#')) .or. cchar==chr(asc('"')) .or. ; cchar==chr(asc('/')) .or. cchar==chr(asc("@")) ; - .or. cchar==chr(asc("=")) + .or. cchar==chr(asc("=")) .or. cchar==chr(asc('Ä')) ; + .or. cchar==chr(asc('?')) .or. cchar==chr(asc('!')) ; + .or. cchar==chr(asc("<")) .or. cchar==chr(asc('>')) ; + .or. cchar==chr(asc('!')) .or. cchar==chr(asc('+')) + nPos=x + Exit ENDIF NEXT -return nPos -Function ProcRtfTable(cBuffer) +Return nPos +FUNCTION FormatrtfBuff(cBuffer,cStyle,ongi) -Local nPos,cItem,cItem2,cItem3 +LOCAL cReturn:='' +LOCAL cLine:='' +LOCAL cBuffend:='' +LOCAL cEnd,cStart ,coline:='' +LOCAL lEndBuff:=.f. +LOCAL nPos,nPosEnd + cReturn :=cBuffer+' ' + IF AT('',cReturn)>0 .OR. EMPTY(cBuffer) + IF EMPTY(cbuffer) + cReturn:='' + ENDIF + Return cReturn + ENDIF + IF cStyle != "Syntax" .AND. cStyle !="Arguments" + DO WHILE !lEndBuff + cLine := TRIM(SUBSTR( ReadLN( @lEof ), nCommentLen ) ) + IF AT('',cLine)>0 .OR. EMPTY(cLine) + lEndBuff:=.t. + ENDIF + cReturn+=alltrim(cLine)+ ' ' + enddo + cReturn:=''+cReturn+' ' + ELSEIF cStyle=='Syntax' + nPos:=AT("-->",cBuffer) - cItem:=SubStr(cBuffer,1,22) - fwrite(myh,citem+hb_osnewline()) - cBuffer:=StrTran(cBuffer,cItem,Space(len(cItem))) - nPos:=STRPos(cBuffer) - IF nPos=23 - cItem2:=SubStr(cBuffer,nPos) - Endif - fwrite(myh,citem2+hb_osnewline()) - AADD(aTable,{ltrim(cItem),cItem2}) -Return Nil + IF nPos>0 + cBuffend:=Substr(cReturn,nPos+3) + cReturn:=SubStr(cReturn,1,nPos+3) + cReturn:=cReturn+''+cBuffend+' ' + cReturn:=''+cReturn+' ' + ELSE + cReturn:=''+cReturn+' ' + ENDIF + ELSEIF cStyle=='Arguments' + nPos:=0 + if at("",cReturn)>0 + cReturn:=STRTRAN(cReturn,"","") + cReturn:=STRTRAN(cReturn,"","") + cReturn:=alltrim(cReturn) + nPos:=AT(" ",cReturn) + cOLine:=left(cReturn,nPos-1) + cReturn:=STRTRAN(cReturn,coLine,"") + cReturn:=STRTRAN(cReturn,">",">
") + cReturn:=STRTRAN(cReturn," <"," <") -Function GenRtfTable(oRtf) + endif + DO WHILE !lEndBuff + cLine := TRIM(SUBSTR( ReadLN( @lEof ), nCommentLen ) ) + IF AT('',cLine)>0 .OR. EMPTY(cLine) + lEndBuff:=.t. + ENDIF + cReturn+=alltrim(cLine)+ ' ' + enddo + cReturn:=' '+cOLine+' '+cReturn+'' -LOCAL y,nLen2,x,nMax,nSpace -LOCAL aLensFItem:={} -LOCAL aLensSItem:={} - FOR X:=1 to LEN(aTable) - AADD(aLensFItem,Len(aTable[x,1])) - NEXT - FOR X:=1 to LEN(aTable) - AADD(aLensSItem,Len(aTable[x,2])) - NEXT - ASORT(aLensFItem,,,{|x,y| x < y}) - ASORT(aLensSItem,,,{|x,y| x > y}) - nMax:=aLensSItem[1]+1 -oRtf:WriteParBox(" 6"+REPL("4",aLensFitem[1]+1)+"="+REPL("4",nMax)+"7") -FOR x:=1 to len(aTable) - nSpace:=nMax-Len(atable[x,2])-1 - oRtf:WriteParText( "\par"+HB_OSNEWLINE()+"\pard\f14\fs20"+" 5"+" \cf1\f8\fs20\b0\i0 "+ aTable[x,1]+"\f14\fs20 " + "5 "+"\cf1\f8\fs20\b0\i0 "+ aTable[x,2] +space(nspace)+"\f14\fs20 5" +HB_OSNEWLINE(),.F.) -Next -oRtf:WriteParBox(" 9"+REPL("4",aLensFitem[1]+1)+";"+REPL("4",nMax)+"8") -oRtf:WritePar("") -aTable:={} -lIsTable:=.T. -Return Nil + ENDIF +Return cReturn +*/ diff --git a/harbour/utils/hbdoc/hbdoc.prg b/harbour/utils/hbdoc/hbdoc.prg index 15a1a39550..ec33f5bdf1 100644 --- a/harbour/utils/hbdoc/hbdoc.prg +++ b/harbour/utils/hbdoc/hbdoc.prg @@ -87,7 +87,7 @@ * * V1.07 * Added back the "<" and ">" symbols - * Fixed the links on the Harbour.htm file + * Fixed the links on the Harbour.htm file * Fixed the help text when hbdoc is called with out any parameter */ @@ -98,7 +98,7 @@ #include "directry.ch" #include "fileio.ch" #include "inkey.ch" - +#include 'hbdocdef.ch' // output lines on the screen #define INFILELINE 10 @@ -107,11 +107,8 @@ #define ERRORLINE 20 #define LONGLINE 78 #define LONGONELINE 66 -#define CRLF HB_OSNewLine() -// The delimiter -#define DELIM "$" // keyword delimiter -#xtranslate UPPERLOWER() => (UPPER(SUBSTR(,1,1))+LOWER(SUBSTR(,2))) +// The delimiter memvar aDirList memvar aDocInfo memvar aLinkInfo @@ -178,7 +175,7 @@ FUNCTION MAIN( cFlags, cLinkName, cAtFile ) // Entry Point // - + mHIDE() // Delete log file if present IF FILE( "hbdocerr.log" ) @@ -531,7 +528,6 @@ FUNCTION MAIN( cFlags, cLinkName, cAtFile ) ? 'ngxl harbour.lnk' ? 'del ngi\*.*' ? 'del *.ngo' - ? 'del *.txt' ENDIF @ INFILELINE, 0 CLEAR TO INFILELINE, MAXCOL() @@ -625,7 +621,7 @@ FUNCTION MAIN( cFlags, cLinkName, cAtFile ) SET CONSOLE ON SET ALTERNATE OFF SET ALTERNATE TO - + mShow() @ MAXROW(), 0 SAY "Execute ASSEMBL.BAT to compile and link Guides" // Return to caller