diff --git a/harbour/ChangeLog b/harbour/ChangeLog index d11cea808d..3fca1e644b 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -16,6 +16,66 @@ The license applies to all entries newer than 2009-04-28. */ +2010-07-12 18:44 UTC+0200 Viktor Szakats (harbour.01 syenar.hu) + * include/hbextern.ch + * src/rtl/Makefile + + src/rtl/hbdoc.prg + + Added __HBDOC_LOADDIR() internal RTL function to read + NFDOC formatted documentation source directories into + memory. The result will be a list of hashes which contain + the raw content of doc files. The function does format + validation (but not content) and add all agreed-on metadata + to the hashes. + It's a start and I hope others can join to create new + layers of function for below functionality: + - doc content validation + - pre-formatting + - output generators + The goal is to avoid local solutions and standardize + the format. + + + tests/hbdoctst.prg + + Added small test app which will find and parse all + documentation inside the Harbour source tree and + save them in .hbd (serialized doc hash) format. + Such .hdb files can be generated by the build process + in the future, so tools like HBIDE can use the content + to display intellisense or built-in help. + ; TODO: HBQT doc/html should be removed as it's + hbdoc tools' job to convert HBDOC source + format to html or whatever else format needed. + + * harbour.spec + * debian/rules + - doc/man + + src/pp/hbpp.1 + + src/main/harbour.1 + + utils/hbmk2/hbmk2.1 + + utils/hbtest/hbtest.1 + + utils/hbrun/hbrun.1 + * Moved man doc files to their own component dirs. + + * doc/Makefile + * doc/en/Makefile + + doc/clipper.txt + - doc/en/clipper.txt + * Moved non-NFDOC formatted doc file to doc dir. + + * doc/en/Makefile + ! Fixed missing 1stread.txt + + * doc/en/hb_apigt.txt + * doc/en/hbinet.txt + * doc/en/tbrowse.txt + * doc/en/hb_apifs.txt + ! Fixed NFDOC non-standard entries. + + * bin/hbxpatch.hbs + ! Fixed detecting dirs. (could cause errors only in rare cases) + + * contrib/hbdoc2/tmplates.prg + * Formatting. + 2010-07-12 09:06 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com) * contrib/hbide/idesources.prg ! Fixed: "Save As..." had gone disabled with another fix. diff --git a/harbour/bin/hbxpatch.hbs b/harbour/bin/hbxpatch.hbs index fa16029fb6..50d71430e6 100755 --- a/harbour/bin/hbxpatch.hbs +++ b/harbour/bin/hbxpatch.hbs @@ -592,10 +592,10 @@ STATIC FUNCTION WalkAndFind( cTop, cLookFor ) cTop += iif( Right( cTop, 1 ) $ "/\", "", hb_ps() ) aDir := Directory( cTop + hb_osFileMask(), "D" ) - ASORT( aDir,,, { |aLeft| !( aLeft[ F_ATTR ] $ "D" ) } ) /* Files first */ + ASORT( aDir,,, { |aLeft| !( "D" $ aLeft[ F_ATTR ] ) } ) /* Files first */ FOR EACH aDirEntry IN aDir - IF !( aDirEntry[ F_ATTR ] == "D" ) + IF !( "D" $ aDirEntry[ F_ATTR ] ) IF aDirEntry[ F_NAME ] == cLookFor cRetVal := cTop EXIT diff --git a/harbour/contrib/hbdoc2/tmplates.prg b/harbour/contrib/hbdoc2/tmplates.prg index 93c6f06909..6d7bfc7836 100644 --- a/harbour/contrib/hbdoc2/tmplates.prg +++ b/harbour/contrib/hbdoc2/tmplates.prg @@ -109,16 +109,16 @@ EXPORTED: // this is best viewed with a fixed-width font // the columns of this array correspond to the elements of Fields CLASSDATA Templates AS ARRAY INIT { ; - { "Template" , { S, T, x+U, x, O, x+U, x+U, x+U, x+U, x+U, x+U, x+U, x+U, x+U, x +U, x +U, x+U, x+U, x+U, x+U, x+U, E } }, ; + { "Template" , { S, T, x+U, x, O , x+U, x+U, x+U, x+U, x+U, x+U, x+U, x+U, x+U, x +U, x +U, x+U, x+U, x+U, x+U, x+U, E } }, ; { "Document" , { S, T, R+U, R, O+U, O+U, x+U, x+U, x+U, R+U, x+U, x+U, x+U, x+U, x +U, x +U, x+U, x+U, O+U, O+U, O+U, E } }, ; - { "Function" , { S, T, R+U, R, R, O+U, O+U, O+U, O+U, O+U, x+U, x+U, x+U, x+U, P+O+U, P+O+U, O+U, O+U, O+U, O+U, O+U, E } }, ; - { "C Function" , { S, T, R+U, R, R, O+U, O+U, O+U, O+U, O+U, x+U, x+U, x+U, x+U, P+O+U, P+O+U, O+U, O+U, O+U, O+U, O+U, E } }, ; - { "Procedure" , { S, T, R+U, R, R, O+U, O+U, O+U, x, O+U, x+U, x+U, x+U, x+U, P+O+U, P+O+U, O+U, O+U, O+U, O+U, O+U, E } }, ; - { "Command" , { S, T, R+U, R, R, O+U, R+U, R+U, x+U, R+U, x+U, x+U, x+U, x+U, P+O+U, P+O+U, O+U, O+U, O+U, O+U, O+U, E } }, ; - { "Class" , { S, T, R+U, R, R, O+U, R+U, R+U, R+U, R+U, O+U, O+U, O+U, O+U, P+O+U, P+O+U, O+U, O+U, O+U, O+U, O+U, E } }, ; - { "Class method" , { S, T, R+U, R, R, O+U, R+U, R+U, R+U, R+U, x+U, x+U, x+U, x+U, P+O+U, x +U, x+U, x+U, x+U, x+U, O+U, E } }, ; - { "Class data" , { S, T, R+U, R, R, O+U, R+U, x+U, x+U, R+U, x+U, x+U, x+U, x+U, P+O+U, x +U, x+U, x+U, x+U, x+U, O+U, E } }, ; - { "Run time error", { S, T, R+U, R, x, O+U, x+U, x+U, x+U, R+U, x+U, x+U, x+U, x+U, P+O+U, x +U, x+U, O+U, x+U, x+U, O+U, E } }, ; + { "Function" , { S, T, R+U, R, R , O+U, O+U, O+U, O+U, O+U, x+U, x+U, x+U, x+U, P+O+U, P+O+U, O+U, O+U, O+U, O+U, O+U, E } }, ; + { "C Function" , { S, T, R+U, R, R , O+U, O+U, O+U, O+U, O+U, x+U, x+U, x+U, x+U, P+O+U, P+O+U, O+U, O+U, O+U, O+U, O+U, E } }, ; + { "Procedure" , { S, T, R+U, R, R , O+U, O+U, O+U, x, O+U, x+U, x+U, x+U, x+U, P+O+U, P+O+U, O+U, O+U, O+U, O+U, O+U, E } }, ; + { "Command" , { S, T, R+U, R, R , O+U, R+U, R+U, x+U, R+U, x+U, x+U, x+U, x+U, P+O+U, P+O+U, O+U, O+U, O+U, O+U, O+U, E } }, ; + { "Class" , { S, T, R+U, R, R , O+U, R+U, R+U, R+U, R+U, O+U, O+U, O+U, O+U, P+O+U, P+O+U, O+U, O+U, O+U, O+U, O+U, E } }, ; + { "Class method" , { S, T, R+U, R, R , O+U, R+U, R+U, R+U, R+U, x+U, x+U, x+U, x+U, P+O+U, x +U, x+U, x+U, x+U, x+U, O+U, E } }, ; + { "Class data" , { S, T, R+U, R, R , O+U, R+U, x+U, x+U, R+U, x+U, x+U, x+U, x+U, P+O+U, x +U, x+U, x+U, x+U, x+U, O+U, E } }, ; + { "Run time error", { S, T, R+U, R, x , O+U, x+U, x+U, x+U, R+U, x+U, x+U, x+U, x+U, P+O+U, x +U, x+U, O+U, x+U, x+U, O+U, E } }, ; } #undef S diff --git a/harbour/debian/rules b/harbour/debian/rules index 13471e8eb8..9d81912e1a 100755 --- a/harbour/debian/rules +++ b/harbour/debian/rules @@ -67,7 +67,7 @@ binary-arch: build install dh_installdocs dh_installexamples # dh_install - dh_installman doc/man/harbour.1 doc/man/hbmk2.1 doc/man/hbpp.1 doc/man/hbrun.1 doc/man/hbtest.1 + dh_installman src/main/harbour.1 src/pp/hbpp.1 utils/hbmk2/hbmk2.1 utils/hbrun/hbrun.1 utils/hbtest/hbtest.1 dh_link dh_strip dh_compress diff --git a/harbour/doc/Makefile b/harbour/doc/Makefile index 51e5f548f6..5659f877c0 100644 --- a/harbour/doc/Makefile +++ b/harbour/doc/Makefile @@ -7,6 +7,7 @@ ROOT := ../ DOC_FILES := \ c_std.txt \ class_tp.txt \ + clipper.txt \ cmdline.txt \ cmpopt.txt \ codebloc.txt \ diff --git a/harbour/doc/en/clipper.txt b/harbour/doc/clipper.txt similarity index 99% rename from harbour/doc/en/clipper.txt rename to harbour/doc/clipper.txt index 1b6d6412e3..b235f971a5 100644 --- a/harbour/doc/en/clipper.txt +++ b/harbour/doc/clipper.txt @@ -1,4 +1,6 @@ -$Id$ +/* + * $Id$ + */ This document attempts to describe the features separating Harbour from CA-Cl*pper. diff --git a/harbour/doc/en/Makefile b/harbour/doc/en/Makefile index 680ce7ce26..7e99b1ad48 100644 --- a/harbour/doc/en/Makefile +++ b/harbour/doc/en/Makefile @@ -7,10 +7,10 @@ ROOT := ../../ DOC_SUBDIR := /en DOC_FILES := \ + 1stread.txt \ array.txt \ binnum.txt \ browse.txt \ - clipper.txt \ cmdline.txt \ command.txt \ compiler.txt \ diff --git a/harbour/doc/en/hb_apifs.txt b/harbour/doc/en/hb_apifs.txt index baf4f7cf35..94b868a4a5 100644 --- a/harbour/doc/en/hb_apifs.txt +++ b/harbour/doc/en/hb_apifs.txt @@ -22,7 +22,7 @@ * hb_fsChDir() * $CATEGORY$ * C level API - * $SUBCATEGORY$ + * $SUBCATEGORY$ * FileSys * $ONELINER$ * Change working directory diff --git a/harbour/doc/en/hb_apigt.txt b/harbour/doc/en/hb_apigt.txt index 408ad739e3..dfc7bfdea9 100644 --- a/harbour/doc/en/hb_apigt.txt +++ b/harbour/doc/en/hb_apigt.txt @@ -4188,7 +4188,7 @@ * hb_mouseSetBounds() * $CATEGORY$ * C level API - * $SUBCATEGORY$ + * $SUBCATEGORY$ * Terminal * $ONELINER$ * diff --git a/harbour/doc/en/hbinet.txt b/harbour/doc/en/hbinet.txt index 6f235c366f..1e37250c6a 100644 --- a/harbour/doc/en/hbinet.txt +++ b/harbour/doc/en/hbinet.txt @@ -283,42 +283,6 @@ * $END$ */ -/* $no-DOC$ - * $TEMPLATE$ - * Function - * $NAME$ - * HB_INETSTATUSDESC - * $CATEGORY$ - * API - * $SUBCATEGORY$ - * INET - * $ONELINER$ - * ? (note: this function is not active in hbinet.c) - * $SYNTAX$ - * HB_INETSTATUSDESC( ) - * $ARGUMENTS$ - * a socket previously created / opened - * $RETURNS$ - * - * $DESCRIPTION$ - * - * $EXAMPLES$ - * - * $TESTS$ - * - * $STATUS$ - * - * $COMPLIANCE$ - * H - * $PLATFORMS$ - * - * $FILES$ - * - * $SEEALSO$ - * - * $END$ - */ - /* $DOC$ * $TEMPLATE$ * Function diff --git a/harbour/doc/en/tbrowse.txt b/harbour/doc/en/tbrowse.txt index da1ec5c6e2..dfd8a6a5a3 100644 --- a/harbour/doc/en/tbrowse.txt +++ b/harbour/doc/en/tbrowse.txt @@ -2,7 +2,9 @@ * $Id$ */ -/* $CLASSDOC$ +/* $DOC$ + * $TEMPLATE$ + * Class * $NAME$ * TBROWSENew() * $CATEGORY$ @@ -186,7 +188,9 @@ */ -/* $CLASSDOC$ +/* $DOC$ + * $TEMPLATE$ + * Class * $METHOD$ * SetKey() * $CATEGORY$ @@ -248,7 +252,9 @@ * $END$ */ -/* $CLASSDOC$ +/* $DOC$ + * $TEMPLATE$ + * Class * $METHOD$ * Applykey() * $CATEGORY$ @@ -282,7 +288,9 @@ * $END$ */ -/* $CLASSDOC$ +/* $DOC$ + * $TEMPLATE$ + * Class * $METHOD$ * AddColumn() * $CATEGORY$ diff --git a/harbour/harbour.spec b/harbour/harbour.spec index c96304cb6d..ed6a6aa0b9 100644 --- a/harbour/harbour.spec +++ b/harbour/harbour.spec @@ -423,7 +423,11 @@ rm -f $HB_INST_PKGPREF$HB_LIB_INSTALL/libpng.a rm -f $HB_INST_PKGPREF$HB_LIB_INSTALL/libsqlite3.a mkdir -p $HB_INST_PKGPREF%{_mandir}/man1 -install -m644 doc/man/*.1* $HB_INST_PKGPREF%{_mandir}/man1/ +install -m644 src/main/*.1* $HB_INST_PKGPREF%{_mandir}/man1/ +install -m644 src/pp/*.1* $HB_INST_PKGPREF%{_mandir}/man1/ +install -m644 utils/hbmk2/*.1* $HB_INST_PKGPREF%{_mandir}/man1/ +install -m644 utils/hbrun/*.1* $HB_INST_PKGPREF%{_mandir}/man1/ +install -m644 utils/hbtest/*.1* $HB_INST_PKGPREF%{_mandir}/man1/ mkdir -p $HB_INST_PKGPREF$HB_ETC_INSTALL install -m644 src/rtl/gtcrs/hb-charmap.def $HB_INST_PKGPREF$HB_ETC_INSTALL/hb-charmap.def diff --git a/harbour/include/hbextern.ch b/harbour/include/hbextern.ch index 020af90f35..37cd32bb18 100644 --- a/harbour/include/hbextern.ch +++ b/harbour/include/hbextern.ch @@ -550,6 +550,8 @@ EXTERNAL __MVXRELEASE EXTERNAL __EINSTVAR52 EXTERNAL __EINSTVAR53 +EXTERNAL __HBDOC_LOADDIR + /* i18n */ EXTERNAL HB_I18N_GETTEXT EXTERNAL HB_I18N_GETTEXT_STRICT diff --git a/harbour/doc/man/harbour.1 b/harbour/src/main/harbour.1 similarity index 100% rename from harbour/doc/man/harbour.1 rename to harbour/src/main/harbour.1 diff --git a/harbour/doc/man/hbpp.1 b/harbour/src/pp/hbpp.1 similarity index 100% rename from harbour/doc/man/hbpp.1 rename to harbour/src/pp/hbpp.1 diff --git a/harbour/src/rtl/Makefile b/harbour/src/rtl/Makefile index fc15444a7c..d4918725f6 100644 --- a/harbour/src/rtl/Makefile +++ b/harbour/src/rtl/Makefile @@ -222,6 +222,7 @@ PRG_SOURCES := \ getsys53.prg \ getsyshb.prg \ gui.prg \ + hbdoc.prg \ hbi18n2.prg \ hbini.prg \ input.prg \ diff --git a/harbour/src/rtl/hbdoc.prg b/harbour/src/rtl/hbdoc.prg new file mode 100644 index 0000000000..cfffa77c45 --- /dev/null +++ b/harbour/src/rtl/hbdoc.prg @@ -0,0 +1,209 @@ +/* + * $Id$ + */ + +/* + * Harbour Project source code: + * NFDOC reader + * + * Copyright 2010 Viktor Szakats (harbour.01 syenar.hu) + * www - http://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, or (at your option) + * any later version. + * + * 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 software; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/). + * + * As a special exception, the Harbour Project gives permission for + * additional uses of the text contained in its release of Harbour. + * + * The exception is that, if you link the Harbour libraries 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 Harbour library code into it. + * + * This exception does not however invalidate any other reasons why + * the executable file might be covered by the GNU General Public License. + * + * This exception applies only to the code released by the Harbour + * Project under the name Harbour. If you copy code from other + * Harbour Project or Free Software Foundation releases into a copy of + * Harbour, as the General Public License permits, the exception does + * not apply to the code that you add in this way. To avoid misleading + * anyone as to the status of such modified files, you must delete + * this exception notice from them. + * + * If you write modifications of your own for Harbour, it is your choice + * whether to permit this exception to apply to your modifications. + * If you do not wish that, delete this exception notice. + * + */ + +#include "common.ch" +#include "directry.ch" + +#define _HBDOC_SRC_SUBDIR "doc" +#define _HBDOC_SRC_EXT ".txt" + +#define _HBDOC_ADD_MSG( a, m ) IF ISARRAY( a ); AAdd( a, m ); ENDIF + +FUNCTION __hbdoc_LoadDir( cDir, cName, aErrMsg ) + LOCAL hMeta + LOCAL nCount + LOCAL aFile + LOCAL aEntry + + IF ISCHARACTER( cDir ) + + cDir := DirAddPathSep( cDir ) + + IF hb_DirExists( cDir + _HBDOC_SRC_SUBDIR ) + + aEntry := {} + hMeta := { => } + + IF ISCHARACTER( cName ) + hMeta[ "_COMPONENT" ] := cName + ENDIF + + nCount := 0 + FOR EACH aFile IN Directory( cDir + _HBDOC_SRC_SUBDIR + hb_ps() + hb_osFileMask(), "D" ) + IF "D" $ aFile[ F_ATTR ] .AND. ; + !( aFile[ F_NAME ] == "." ) .AND. ; + !( aFile[ F_NAME ] == ".." ) + + __hbdoc__read_langdir( aEntry, cDir + _HBDOC_SRC_SUBDIR + hb_ps() + aFile[ F_NAME ], hMeta, aErrMsg ) + ++nCount + ENDIF + NEXT + + IF nCount == 0 + _HBDOC_ADD_MSG( aErrMsg, hb_StrFormat( "Warning: Component (%1$s) has no language subdirs", cDir ) ) + ENDIF + ENDIF + ENDIF + + RETURN aEntry + +STATIC PROCEDURE __hbdoc__read_langdir( aEntry, cDir, hMeta, aErrMsg ) + LOCAL aFile + LOCAL nCount + + nCount := 0 + FOR EACH aFile IN Directory( cDir + hb_ps() + "*" + _HBDOC_SRC_EXT ) + hMeta[ "_LANG" ] := aFile[ F_NAME ] + __hbdoc__read_file( aEntry, cDir + hb_ps() + aFile[ F_NAME ], hMeta, aErrMsg ) + ++nCount + NEXT + + IF nCount == 0 + _HBDOC_ADD_MSG( aErrMsg, hb_StrFormat( "Warning: Component (%1$s) has no documentation files", cDir ) ) + ENDIF + + RETURN + +STATIC PROCEDURE __hbdoc__read_file( aEntry, cFileName, hMeta, aErrMsg ) + LOCAL cFile := MemoRead( cFileName ) + LOCAL hEntry := NIL + LOCAL cLine + LOCAL cSection + LOCAL tmp + LOCAL nLine + + LOCAL cDefTemplate + + LOCAL aFilenameTemplateMap := {; + "FUNCTION" => "func_" ,; + "C FUNCTION" => "cfunc_" ,; + "CLASS" => "class_" ,; + "COMMAND" => "cmd_" ,; + "PP" => "pp_" } + + /* Preselect the default template based on source filename */ + FOR EACH tmp IN aFilenameTemplateMap + IF Lower( Left( cFileName, Len( tmp ) ) ) == tmp + cDefTemplate := tmp:__enumKey() + ENDIF + NEXT + + cFile := StrTran( cFile, Chr( 13 ) ) + cFile := StrTran( cFile, Chr( 9 ), " " ) + + nLine := 0 + FOR EACH cLine IN hb_ATokens( cFile, Chr( 10 ) ) + + cLine := SubStr( cLine, 4 ) + ++nLine + + SWITCH AllTrim( cLine ) + CASE "$DOC$" + IF hEntry != NIL + _HBDOC_ADD_MSG( aErrMsg, hb_StrFormat( "Warning: %1$s: %2$s: $DOC$ without $END$", cFileName, hb_ntos( nLine ) ) ) + ELSEIF ! Empty( hEntry ) + AAdd( aEntry, hEntry ) + ENDIF + hEntry := { => } + IF hb_isHash( hMeta ) + hMeta[ "_DOCSOURCE" ] := cFileName + IF cDefTemplate != NIL + hMeta[ "TEMPLATE" ] := cDefTemplate + ENDIF + FOR EACH tmp IN hMeta + hEntry[ tmp:__enumKey() ] := tmp + NEXT + ENDIF + EXIT + CASE "$END$" + IF hEntry == NIL + _HBDOC_ADD_MSG( aErrMsg, hb_StrFormat( "Warning: %1$s: %2$s: $END$ without $DOC$", cFileName, hb_ntos( nLine ) ) ) + ELSEIF ! Empty( hEntry ) + AAdd( aEntry, hEntry ) + ENDIF + hEntry := NIL + EXIT + OTHERWISE + IF hEntry == NIL + /* Ignore line outside entry. Don't warn, this is normal. */ + ELSEIF Left( LTrim( cLine ), 1 ) == "$" .AND. Right( RTrim( cLine ), 1 ) == "$" + cLine := AllTrim( cLine ) + cSection := SubStr( cLine, 2, Len( cLine ) - 2 ) + IF cSection $ hEntry + _HBDOC_ADD_MSG( aErrMsg, hb_StrFormat( "Warning: %1$s: %2$s: Duplicate sections inside the same entry", cFileName, hb_ntos( nLine ) ) ) + ELSE + hEntry[ cSection ] := "" + ENDIF + ELSEIF ! Empty( cSection ) + IF ! Empty( hEntry[ cSection ] ) + hEntry[ cSection ] += hb_eol() + ENDIF + hEntry[ cSection ] += cLine + ELSEIF ! Empty( cLine ) + _HBDOC_ADD_MSG( aErrMsg, hb_StrFormat( "Warning: %1$s: %2$s: Content outside section", cFileName, hb_ntos( nLine ) ) ) + ENDIF + ENDSWITCH + NEXT + + IF hEntry != NIL + _HBDOC_ADD_MSG( aErrMsg, hb_StrFormat( "Warning: %1$s: %2$s: $DOC$ without $END$", cFileName, hb_ntos( nLine ) ) ) + ENDIF + + RETURN + +STATIC FUNCTION DirAddPathSep( cDir ) + + IF ! Empty( cDir ) .AND. !( Right( cDir, 1 ) == hb_ps() ) + cDir += hb_ps() + ENDIF + + RETURN cDir diff --git a/harbour/tests/hbdoctst.prg b/harbour/tests/hbdoctst.prg new file mode 100644 index 0000000000..6bbc7561e2 --- /dev/null +++ b/harbour/tests/hbdoctst.prg @@ -0,0 +1,118 @@ +/* + * $Id$ + */ + +/* + * HBDOC reader test + * + * Copyright 2010 Viktor Szakats (harbour.01 syenar.hu) + * www - http://harbour-project.org + * + */ + +#include "common.ch" + +#define _HBDOC_HBD_EXT ".hbd" + +PROCEDURE Main( cRoot ) + LOCAL aEntry + LOCAL cName + + LOCAL aDir + LOCAL cDir + + LOCAL aFile + + LOCAL aErrMsg + LOCAL tmp + + IF ! ISCHARACTER( cRoot ) + /* Detect Harbour root */ + cRoot := "." + hb_ps() + DO WHILE hb_DirExists( cRoot + ".." ) + IF hb_FileExists( cRoot + "INSTALL" ) .AND. ; + hb_FileExists( cRoot + "COPYING" ) .AND. ; + hb_DirExists( cRoot + "config" ) + EXIT + ENDIF + cRoot += ".." + hb_ps() + ENDDO + ELSE + cDir := DirAddPathSep( cDir ) + ENDIF + + OutStd( "Root: " + cRoot + hb_eol() ) + + 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 + + cName := DirGetName( cDir ) + IF Empty( cName ) + cName := "harbour" + ENDIF + + aErrMsg := {} + + aEntry := __hbdoc_LoadDir( cDir, cName, aErrMsg ) + + /* TODO: apply code formatting, NFDOC 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 + OutStd( tmp + hb_eol() ) + NEXT + + IF ! Empty( aEntry ) + OutStd( hb_MemoWrit( cName + _HBDOC_HBD_EXT, hb_serialize( aEntry ) ), cName, Len( aEntry ), hb_eol() ) + ENDIF + NEXT + + RETURN + +STATIC FUNCTION DirGetName( cDir ) + LOCAL cName + + cDir := DirDelPathSep( cDir ) + + hb_FNameSplit( cDir,, @cName ) + + IF Empty( cName ) .OR. cName == "." .OR. cName == ".." + RETURN "" + ENDIF + + RETURN cName + +STATIC FUNCTION DirDelPathSep( cDir ) + + IF Empty( hb_osDriveSeparator() ) + DO WHILE Len( cDir ) > 1 .AND. Right( cDir, 1 ) == hb_ps() + cDir := hb_StrShrink( cDir, 1 ) + ENDDO + ELSE + DO WHILE Len( cDir ) > 1 .AND. Right( cDir, 1 ) == hb_ps() .AND. ; + !( Right( cDir, 2 ) == hb_osDriveSeparator() + hb_ps() ) + cDir := hb_StrShrink( cDir, 1 ) + ENDDO + ENDIF + + RETURN cDir + +STATIC FUNCTION DirAddPathSep( cDir ) + + IF ! Empty( cDir ) .AND. !( Right( cDir, 1 ) == hb_ps() ) + cDir += hb_ps() + ENDIF + + RETURN cDir diff --git a/harbour/doc/man/hbmk2.1 b/harbour/utils/hbmk2/hbmk2.1 similarity index 100% rename from harbour/doc/man/hbmk2.1 rename to harbour/utils/hbmk2/hbmk2.1 diff --git a/harbour/doc/man/hbrun.1 b/harbour/utils/hbrun/hbrun.1 similarity index 100% rename from harbour/doc/man/hbrun.1 rename to harbour/utils/hbrun/hbrun.1 diff --git a/harbour/doc/man/hbtest.1 b/harbour/utils/hbtest/hbtest.1 similarity index 100% rename from harbour/doc/man/hbtest.1 rename to harbour/utils/hbtest/hbtest.1