Files
harbour-core/tests/hbdoc.prg
Viktor Szakats 03ac58b17b 2017-09-08 18:22 UTC Viktor Szakats (vszakats users.noreply.github.com)
* bin/commit.hb
  * config/detect.mk
  * config/detfun.mk
  * config/detplat.mk
  * config/dir.mk
  * config/dirsh.mk
  * config/global.mk
  * config/globsh.mk
  * config/instsh.mk
  * config/lang.hb
  * config/lang2po.hb
  * config/po2lang.hb
  * config/postinst.hb
  * contrib/hbexpat/tests/tohash.prg
  * contrib/hbformat/utils/hbformat.ini
  * contrib/hbmisc/hbedit.prg
  * contrib/hbmxml/tests/testmxml.prg
  * contrib/hbnetio/utils/hbnetio/_console.prg
  * contrib/hbnetio/utils/hbnetio/_winsvc.prg
  * contrib/hbnetio/utils/hbnetio/hbnetio.prg
  * contrib/hbnetio/utils/hbnetio/netiomgm.hb
  * contrib/hbwin/tests/ole.prg
  * contrib/hbwin/tests/oletst2.js
  * contrib/hbwin/tests/oletst2.vbs
  * contrib/hbxpp/doc/en/binnumx.txt
  * contrib/hbxpp/doc/en/dbcmdx.txt
  * contrib/xhb/htmutil.prg
  * contrib/xhb/tfile.prg
  * contrib/xhb/tframe.prg
  * contrib/xhb/thtm.prg
  * ChangeLog.txt
  * debian/copyright
  * doc/class_tp.txt
  * doc/hdr_tpl.txt
  * doc/xhb-diff.txt
  * LICENSE.txt
  * package/harbour-wce.spec.in
  * package/harbour-win.spec.in
  * package/harbour.spec
  * package/mpkg_rpm_wce.sh
  * package/mpkg_rpm_win.sh
  * package/mpkg_rpm.sh
  * package/mpkg_src.sh
  * package/mpkg_ver.sh
  * src/rtl/achoice.prg
  * src/rtl/getsys53.prg
  * src/rtl/tgetlist.prg
  * src/rtl/tlabel.prg
  * src/rtl/tmenusys.prg
  * tests/hbdoc.prg
  * tests/langmsg.prg
  * tests/rto_get.prg
  * tests/rto_tb.prg
  + doc/en/ati.txt
  + doc/en/dirdrive.txt
  + doc/en/hashfunc.txt
  + doc/en/hbtoken.txt
  + doc/en/left.txt
  + doc/en/proc.txt
  + doc/en/strtran.txt
  + doc/en/transfrm.txt
  + doc/en/typefile.txt
  * doc/en/*
    * more partial sync with 3.4 fork
2017-09-08 18:25:11 +00:00

95 lines
2.1 KiB
Plaintext

/*
* HBDOC reader test
*
* Copyright 2010 Viktor Szakats (vszakats.net/harbour)
*/
#include "directry.ch"
#include "simpleio.ch"
PROCEDURE Main( cRoot )
LOCAL aEntry
LOCAL cName
LOCAL aDir
LOCAL cDir
LOCAL aFile
LOCAL tModified
LOCAL aErrMsg
LOCAL tmp
IF ! HB_ISSTRING( cRoot )
/* Detect Harbour root */
cRoot := "." + hb_ps()
DO WHILE hb_DirExists( cRoot + ".." )
IF hb_FileExists( cRoot + "README.md" ) .AND. ;
hb_FileExists( cRoot + "COPYING.txt" ) .AND. ;
hb_DirExists( cRoot + "config" )
EXIT
ENDIF
cRoot += ".." + hb_ps()
ENDDO
ELSE
cDir := hb_DirSepAdd( cDir )
ENDIF
? "Root: " + cRoot
aDir := { cRoot }
FOR EACH aFile IN Directory( cRoot + "contrib" + hb_ps() + hb_osFileMask(), "D" )
IF "D" $ aFile[ F_ATTR ] .AND. ;
!( aFile[ F_NAME ] == "." ) .AND. ;
!( aFile[ F_NAME ] == ".." )
AAdd( aDir, cRoot + "contrib" + hb_ps() + aFile[ F_NAME ] )
ENDIF
NEXT
FOR EACH cDir IN aDir
IF ! Empty( tModified := __hbdoc_DirLastModified( cDir ) )
cName := DirGetName( cDir )
IF Empty( cName )
cName := "harbour"
ENDIF
aErrMsg := {}
aEntry := __hbdoc_LoadDir( cDir, cName, aErrMsg )
/* TODO: apply code formatting, HBDOC section and content validation here.
It's also possible to create output generators at this point.
These generators should simply parse the list of entry hashes
and spit out output in selected end-user format, like .html
or .pdf */
FOR EACH tmp IN aErrMsg
? tmp
NEXT
IF ! Empty( aEntry )
? __hbdoc_SaveHBD( cName, aEntry ), cName, Len( aEntry ), tModified
ENDIF
ENDIF
NEXT
RETURN
STATIC FUNCTION DirGetName( cDir )
LOCAL cName
cDir := hb_DirSepDel( cDir )
hb_FNameSplit( cDir,, @cName )
IF Empty( cName ) .OR. cName == "." .OR. cName == ".."
RETURN ""
ENDIF
RETURN cName