Files
harbour-core/tests/hbdoc.prg
Viktor Szakats 58faf91453 2016-01-14 19:17 UTC+0100 Viktor Szakats (vszakats users.noreply.github.com)
* *
    % remove brandings and homepage [1] from copyright header. Pass 1 - using script.
      [1] nobody has access to it anymore AFAIK - and it's also just
          a redirect since long
    ! update url in copyright header
    ; this should make the diff between 3.4 and 3.2 easier to manage
2016-01-14 19:18:17 +01:00

96 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