2016-10-21 07:54 UTC+0200 Viktor Szakats (vszakats users.noreply.github.com)

* extras/hbdoc/_genbase.prg
  * extras/hbdoc/_genhtml.prg
  * extras/hbdoc/_gentxt.prg
  * extras/hbdoc/_genxml.prg
  * extras/hbdoc/_tmplate.prg
  * extras/hbdoc/hbdoc.ch
  * extras/hbdoc/hbdoc.css
  * extras/hbdoc/hbdoc.hbp
  * extras/hbdoc/hbdoc.prg
    ! fix linter problems in generated html
    * html5/css cleanups
    * use VF IO
    ! fix double close in hbdoc
    ! fix file handle leak in hbdoc
    * use Class(y) syntax in class definitions
    * remove internal file references
    % use hb_AScanI()
    ! use hb_ATokens() instead of hand-rolled line splitting,
      making this code EOL agnostic
    % use hb_cwd(), hb_FName*(), hb_DirSep*() (also fixes potential portability issues)
    * cleanups/opts
    * cleaned doc tags
    % force disable LTO at link-time
    ! typo in comment
    ; notice that you can regenerate the docs
      for the Harbour website (https://harbour.github.io/doc/)
      using this command:
         extras/hbdoc$ hbmk2 hbdoc -run -runflag=-format=html -runflag=-output-single
      or in this fork, using this command:
         extras/hbdoc$ hbmk2 hbdoc -run
    ; for NF doc parsing I created an internal API long ago
      (it is used by HBIDE f.e.):
         hbmk2 -find __hbdoc_
      usage examples in Harbour:
         grep -R __hbdoc_ *
    % optimized string handling / temp variable usage, IFs cleaned
    % enabled -kmo build options
    % cleaned header inclusion
    % reworked to not use PUBLIC vars at all
    % avoided some more macro expansions
    % converted a public var to hb_StrReplace() with hash
    * minor cleanups and optimizations
    * use PROTECTED obj vars
    % use SWITCH
    % merged some nested branches
    * use #if 0 for commented code
    % cleaned some array declarations
    % use hb_FNameExt()
    * avoid one macro expansion
    + added -run flags to regenarate docs for Harbour website
    * cleaned .AND./.OR. ambiguity
    % converted PUBLIC var to STATIC
    ; Above patches come from 3.4 fork commits below:
      2016-09-20 02:31 UTC+0200 Viktor Szakats (vszakats users.noreply.github.com)
      2016-09-19 18:51 UTC+0200 Viktor Szakats (vszakats users.noreply.github.com)
      2016-09-19 18:03 UTC+0200 Viktor Szakats (vszakats users.noreply.github.com)
      2015-07-18 17:57 UTC+0200 Viktor Szakats (vszakats users.noreply.github.com)
      2015-06-28 11:27 UTC+0200 Viktor Szakats (vszakats users.noreply.github.com)
      2015-06-05 20:47 UTC+0200 Viktor Szakats (vszakats users.noreply.github.com)
      2015-03-17 13:54 UTC+0100 Viktor Szakats (vszakats users.noreply.github.com)
      2014-12-13 03:15 UTC+0100 Viktor Szakats (vszakats users.noreply.github.com)
      2014-07-15 23:04 UTC+0200 Viktor Szakats (vszakats users.noreply.github.com)
      2014-06-21 12:46 UTC+0200 Viktor Szakats (vszakats users.noreply.github.com)
      2014-06-20 15:38 UTC+0200 Viktor Szakats (vszakats users.noreply.github.com)
      2014-02-12 01:58 UTC+0100 Viktor Szakáts (vszakats users.noreply.github.com)
      2014-02-03 21:07 UTC+0100 Viktor Szakáts (vszakats users.noreply.github.com)
      2014-02-03 19:19 UTC+0100 Viktor Szakáts (vszakats users.noreply.github.com)
      2014-02-03 18:37 UTC+0100 Viktor Szakáts (vszakats users.noreply.github.com)
      2014-02-03 18:22 UTC+0100 Viktor Szakáts (vszakats users.noreply.github.com)
      2014-02-03 17:45 UTC+0100 Viktor Szakáts (vszakats users.noreply.github.com)
    ; plus various minor maintenance updates from multiple other commits
This commit is contained in:
Viktor Szakats
2016-10-21 08:05:04 +02:00
parent bd2e492cca
commit da5de0c27b
10 changed files with 918 additions and 930 deletions

View File

@@ -1,11 +1,8 @@
/*
* Document generator base class
*
* Copyright 2009 April White <april users.sourceforge.net>
*
* Portions of this project are based on hbdoc
* Copyright 1999-2003 Luiz Rafael Culik <culikr@uol.com.br>
* <TODO: list gen... methods used>
* Copyright 2009 April White <bright.tigra gmail.com>
* Copyright 1999-2003 Luiz Rafael Culik <culikr@uol.com.br> (Portions of this project are based on hbdoc)
*
* 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
@@ -49,63 +46,63 @@
*/
#include "hbclass.ch"
#include "hbdoc.ch"
#define DOCUMENT_ 1
#define INDEX_ 2
#include "fileio.ch"
#define DOCUMENT_ 1
#define INDEX_ 2
CREATE CLASS TPLGenerate
EXPORTED:
// ~ PROTECTED:
VAR nHandle AS NUMERIC
VAR cFolder AS STRING
METHOD NewIndex( cDir, cFilename, cTitle, cExtension )
METHOD NewDocument( cDir, cFilename, cTitle, cExtension )
METHOD AddEntry( oEntry ) INLINE HB_SYMBOL_UNUSED( oEntry ), NIL
METHOD AddReference( oEntry ) INLINE HB_SYMBOL_UNUSED( oEntry ), NIL
METHOD BeginSection( cSection, cFilename ) INLINE HB_SYMBOL_UNUSED( cSection ), HB_SYMBOL_UNUSED( cFilename ), ::Depth++
METHOD EndSection( cSection, cFilename ) INLINE HB_SYMBOL_UNUSED( cSection ), HB_SYMBOL_UNUSED( cFilename ), ::Depth--
METHOD Generate() INLINE NIL
METHOD IsIndex() INLINE ::nType == INDEX_
PROTECTED:
METHOD New( cDir, cFilename, cTitle, cExtension, nType ) HIDDEN
VAR nType AS INTEGER
VAR Depth AS INTEGER INIT 0
VAR hFile
VAR cDir AS STRING
VAR cFilename AS STRING
VAR cTitle AS STRING
VAR cExtension AS STRING
METHOD NewIndex( cFolder, cFilename, cTitle, cExtension )
METHOD NewDocument( cFolder, cFilename, cTitle, cExtension )
METHOD AddEntry( oEntry ) INLINE HB_SYMBOL_UNUSED( oEntry ), NIL
METHOD AddReference( oEntry ) INLINE HB_SYMBOL_UNUSED( oEntry ), NIL
METHOD BeginSection( cSection, cFilename ) INLINE HB_SYMBOL_UNUSED( cSection ), HB_SYMBOL_UNUSED( cFilename ), ::Depth++
METHOD EndSection( cSection, cFilename ) INLINE HB_SYMBOL_UNUSED( cSection ), HB_SYMBOL_UNUSED( cFilename ), ::Depth--
METHOD Generate() INLINE NIL
METHOD IsIndex() INLINE ( ::nType == INDEX_ )
PROTECTED:
METHOD New( cFolder, cFilename, cTitle, cExtension, nType ) HIDDEN
VAR nType AS INTEGER
VAR Depth AS INTEGER INIT 0
ENDCLASS
METHOD NewIndex( cFolder, cFilename, cTitle, cExtension ) CLASS TPLGenerate
METHOD NewIndex( cDir, cFilename, cTitle, cExtension ) CLASS TPLGenerate
self:New( cFolder, cFilename, cTitle, cExtension, INDEX_ )
::New( cDir, cFilename, cTitle, cExtension, INDEX_ )
RETURN self
METHOD NewDocument( cFolder, cFilename, cTitle, cExtension ) CLASS TPLGenerate
METHOD NewDocument( cDir, cFilename, cTitle, cExtension ) CLASS TPLGenerate
self:New( cFolder, cFilename, cTitle, cExtension, DOCUMENT_ )
::New( cDir, cFilename, cTitle, cExtension, DOCUMENT_ )
RETURN self
METHOD New( cFolder, cFilename, cTitle, cExtension, nType ) CLASS TPLGenerate
METHOD New( cDir, cFilename, cTitle, cExtension, nType ) CLASS TPLGenerate
::nHandle := 0
::cFolder := cFolder
::cDir := cDir
::cFilename := cFilename
::cTitle := cTitle
::cExtension := cExtension
::nType := nType
IF ! hb_DirExists( ::cFolder )
OutStd( hb_eol() + "Creating folder '" + ::cFolder + "'" )
hb_DirCreate( ::cFolder )
IF ! hb_vfDirExists( ::cDir )
OutStd( hb_eol() + "Creating directory", "'" + ::cDir + "'" )
hb_vfDirMake( ::cDir )
ENDIF
::nHandle := FCreate( ::cFolder + hb_ps() + ::cFilename + ::cExtension )
::hFile := hb_vfOpen( ::cDir + hb_ps() + ::cFilename + ::cExtension, FO_CREAT + FO_TRUNC + FO_WRITE )
RETURN self

View File

@@ -1,10 +1,8 @@
/*
* Document generator - HTML output
*
* Copyright 2009 April White <april users.sourceforge.net>
*
* Portions of this project are based on hbdoc
* Copyright 1999-2003 Luiz Rafael Culik <culikr@uol.com.br>
* Copyright 2009 April White <bright.tigra gmail.com>
* Copyright 1999-2003 Luiz Rafael Culik <culikr@uol.com.br> (Portions of this project are based on hbdoc)
*
* 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
@@ -48,36 +46,35 @@
*/
#include "hbclass.ch"
#include "hbdoc.ch"
#ifdef __PLATFORM__DOS
# define EXTENSION ".htm"
#define EXTENSION ".htm"
#else
# define EXTENSION ".html"
#define EXTENSION ".html"
#endif
#define STYLEFILE "hbdoc.css"
CREATE CLASS GenerateHTML2 FROM GenerateHTML
CREATE CLASS GenerateHTML2 INHERIT GenerateHTML
METHOD NewIndex( cFolder, cFilename, cTitle )
METHOD NewDocument( cFolder, cFilename, cTitle )
METHOD NewIndex( cDir, cFilename, cTitle )
METHOD NewDocument( cDir, cFilename, cTitle )
ENDCLASS
METHOD NewDocument( cFolder, cFilename, cTitle ) CLASS GenerateHTML2
METHOD NewDocument( cDir, cFilename, cTitle ) CLASS GenerateHTML2
::super:NewDocument( cFolder, cFilename, cTitle, EXTENSION )
::super:NewDocument( cDir, cFilename, cTitle, EXTENSION )
RETURN self
METHOD NewIndex( cFolder, cFilename, cTitle ) CLASS GenerateHTML2
METHOD NewIndex( cDir, cFilename, cTitle ) CLASS GenerateHTML2
::super:NewIndex( cFolder, cFilename, cTitle, EXTENSION )
::super:NewIndex( cDir, cFilename, cTitle, EXTENSION )
RETURN self
CREATE CLASS GenerateHTML FROM TPLGenerate
CREATE CLASS GenerateHTML INHERIT TPLGenerate
HIDDEN:
METHOD RecreateStyleDocument( cStyleFile )
@@ -85,77 +82,74 @@ CREATE CLASS GenerateHTML FROM TPLGenerate
METHOD Tagged( cText, cTag, ... )
METHOD CloseTag( cText )
METHOD Append( cText, cFormat )
METHOD Newline() INLINE FWrite( ::nHandle, "<br />" + hb_eol() ), self
METHOD Newline() INLINE hb_vfWrite( ::hFile, "<br>" + hb_eol() ), self
CLASS VAR lCreateStyleDocument AS LOGICAL INIT .T.
VAR TargetFilename AS STRING INIT ""
EXPORTED:
METHOD NewFile() HIDDEN
METHOD NewIndex( cFolder, cFilename, cTitle )
METHOD NewDocument( cFolder, cFilename, cTitle )
METHOD NewIndex( cDir, cFilename, cTitle )
METHOD NewDocument( cDir, cFilename, cTitle )
METHOD AddEntry( oEntry )
METHOD AddReference( oEntry, cReference, cSubReference )
METHOD BeginSection( cSection, cFilename )
METHOD EndSection( cSection, cFilename )
METHOD Generate()
METHOD WriteEntry( cField, oEntry, lPreformatted, nIndent ) HIDDEN
METHOD WriteEntry( cField, oEntry, lPreformatted ) HIDDEN
ENDCLASS
METHOD NewFile() CLASS GenerateHTML
FWrite( ::nHandle, "<!DOCTYPE html>" + hb_eol() )
hb_vfWrite( ::hFile, "<!DOCTYPE html>" + hb_eol() )
::OpenTag( "html", "xmlns", "http://www.w3.org/1999/xhtml", "lang", "en" )
::OpenTag( "head" )
::OpenTag( "html", "lang", "en" )
::Append( ::cTitle /* + iif( Empty( ::cDescription ), "", " - " + ::cDescription ) */, "title" )
::OpenTag( "meta", "http-equiv", "content-type", "content", "text/html; charset=UTF-8" )
::CloseTag( "meta" )
::OpenTag( "meta", "name", "generator", "content", "Harbour examples/hbdoc" )
::CloseTag( "meta" )
::OpenTag( "meta", "name", "keywords", "content", "Harbour project, Clipper, xBase, database, Free Software, GNU, compiler, cross platform, 32-bit, FiveWin" )
::CloseTag( "meta" )
::OpenTag( "meta", "charset", "utf-8" )
::OpenTag( "meta", "name", "generator", "content", "hbdoc" )
::OpenTag( "meta", "name", "keywords", "content", "Harbour, Clipper, xBase, database, Free Software, GPL, compiler, cross platform, 32-bit, 64-bit" )
IF ::lCreateStyleDocument
::lCreateStyleDocument := .F.
::RecreateStyleDocument( STYLEFILE )
ENDIF
::OpenTag( "link", "rel", "stylesheet", "type", "text/css", "href", STYLEFILE )
::CloseTag( "link" )
::CloseTag( "head" )
::OpenTag( "body" )
::Append( ::cTitle /* + iif( Empty( ::cDescription ), "", " - " + ::cDescription ) */, "title" )
::OpenTag( "link", "rel", "stylesheet", "href", STYLEFILE )
::Append( ::cTitle, "h1" )
RETURN self
METHOD NewDocument( cFolder, cFilename, cTitle ) CLASS GenerateHTML
METHOD NewDocument( cDir, cFilename, cTitle ) CLASS GenerateHTML
::super:NewDocument( cFolder, cFilename, cTitle, EXTENSION )
::super:NewDocument( cDir, cFilename, cTitle, EXTENSION )
::NewFile()
RETURN self
METHOD NewIndex( cFolder, cFilename, cTitle ) CLASS GenerateHTML
METHOD NewIndex( cDir, cFilename, cTitle ) CLASS GenerateHTML
::super:NewIndex( cFolder, cFilename, cTitle, EXTENSION )
::super:NewIndex( cDir, cFilename, cTitle, EXTENSION )
::NewFile()
RETURN self
METHOD BeginSection( cSection, cFilename ) CLASS GenerateHTML
cSection := SymbolToHTMLID( cSection )
IF ::IsIndex()
IF cFilename == ::cFilename
::OpenTag( "div", "id", cSection ):Append( cSection, "h" + hb_ntos( ::Depth + 2 ) ):CloseTag( "div" )// :Newline()
::OpenTag( "div", "id", cSection ):Append( cSection, "h" + hb_ntos( ::Depth + 2 ) ):CloseTag( "div" )
ELSE
::OpenTag( "a", "href", cFilename + ::cExtension + "#" + cSection ):Append( cSection, "h" + hb_ntos( ::Depth + 2 ) ):CloseTag( "a" )// :Newline()
::OpenTag( "a", "href", cFilename + ::cExtension + "#" + cSection ):Append( cSection, "h" + hb_ntos( ::Depth + 2 ) ):CloseTag( "a" )
ENDIF
ELSE
::OpenTag( "div", "id", cSection ):Append( cSection, "h" + hb_ntos( ::Depth + 2 ) ):CloseTag( "div" )// :Newline()
::OpenTag( "div", "id", cSection ):Append( cSection, "h" + hb_ntos( ::Depth + 2 ) ):CloseTag( "div" )
ENDIF
::TargetFilename := cFilename
::Depth++
@@ -175,10 +169,10 @@ METHOD AddReference( oEntry, cReference, cSubReference ) CLASS GenerateHTML
IF HB_ISOBJECT( oEntry ) .AND. oEntry:ClassName() == "ENTRY"
::OpenTag( "a", "href", ::TargetFilename + ::cExtension + "#" + oEntry:Filename ):Append( oEntry:Name ):CloseTag( "a" ):Append( oEntry:OneLiner ):Newline()
ELSE
IF cSubReference == NIL
::OpenTag( "a", "href", cReference + ::cExtension /* + "#" + oEntry:Filename */ ):Append( oEntry ):CloseTag( "a" ):Newline()
ELSE
IF HB_ISSTRING( cSubReference )
::OpenTag( "a", "href", cReference + ::cExtension + "#" + cSubReference ):Append( oEntry ):CloseTag( "a" ):Newline()
ELSE
::OpenTag( "a", "href", cReference + ::cExtension /* + "#" + oEntry:Filename */ ):Append( oEntry ):CloseTag( "a" ):Newline()
ENDIF
ENDIF
@@ -186,63 +180,58 @@ METHOD AddReference( oEntry, cReference, cSubReference ) CLASS GenerateHTML
METHOD AddEntry( oEntry ) CLASS GenerateHTML
LOCAL idx
LOCAL item
FOR idx := 1 TO Len( oEntry:Fields )
IF oEntry:Fields[ idx ][ 1 ] == "NAME"
::OpenTag( "div", "id", oEntry:filename ):OpenTag( "h4" ):Append( oEntry:Name ):CloseTag( "h4" ):CloseTag( "div" )
ELSEIF oEntry:IsField( oEntry:Fields[ idx ][ 1 ] ) .AND. oEntry:IsOutput( oEntry:Fields[ idx ][ 1 ] ) .AND. Len( oEntry:&( oEntry:Fields[ idx ][ 1 ] ) ) > 0
::WriteEntry( oEntry:Fields[ idx ][ 1 ], oEntry, oEntry:IsPreformatted( oEntry:Fields[ idx ][ 1 ] ) )
FOR EACH item IN oEntry:Fields
IF item[ 1 ] == "NAME"
::OpenTag( "div", "id", SymbolToHTMLID( oEntry:filename ) ):OpenTag( "h4" ):Append( oEntry:Name ):CloseTag( "h4" ):CloseTag( "div" )
ELSEIF oEntry:IsField( item[ 1 ] ) .AND. oEntry:IsOutput( item[ 1 ] ) .AND. Len( oEntry:&( item[ 1 ] ) ) > 0
::WriteEntry( item[ 1 ], oEntry, oEntry:IsPreformatted( item[ 1 ] ) )
ENDIF
NEXT
RETURN self
METHOD Generate() CLASS GenerateHTML
IF ! Empty( ::nHandle )
::CloseTag( "body" )
::CloseTag( "html" )
FClose( ::nHandle )
::nHandle := 0
ENDIF
RETURN self
METHOD PROCEDURE WriteEntry( cField, oEntry, lPreformatted, nIndent ) CLASS GenerateHTML
METHOD PROCEDURE WriteEntry( cField, oEntry, lPreformatted ) CLASS GenerateHTML
LOCAL cCaption := oEntry:FieldName( cField )
LOCAL cEntry := oEntry:&( cField )
// TODO: change this to search the CSS document itself
/* TODO: change this to search the CSS document itself */
LOCAL cTagClass := iif( Lower( cField ) + "|" $ "name|oneliner|examples|tests|", Lower( cField ), "itemtext" )
IF ! Empty( cEntry )
hb_default( @cCaption, "" )
hb_default( @nIndent, 0 )
// ~ hb_default( @lPreformatted, .F. )
// ~ hb_default( @cTagClass, "itemtext" )
#if 0
hb_default( @lPreformatted, .F. )
hb_default( @cTagClass, "itemtext" )
#endif
IF Len( cCaption ) > 0 /* .AND. nIndent > 0 */
hb_default( @cCaption, "" )
IF ! HB_ISNULL( cCaption )
::Tagged( cCaption, "div", "class", "itemtitle" )
ENDIF
IF lPreformatted
::OpenTag( "pre", iif( cTagClass != NIL, "class", ), cTagClass )
DO WHILE Len( cEntry ) > 0
::OpenTag( "pre", "class", cTagClass )
DO WHILE ! HB_ISNULL( cEntry )
IF Lower( cField ) + "|" $ "examples|tests|"
::Append( SubStr( Parse( @cEntry, hb_eol() ), 5 ), "" )
ELSE
::Append( Indent( Parse( @cEntry, hb_eol() ), 0, , .T. ), "" )
ENDIF
// ~ IF Len( cEntry ) > 0 .AND. ! lPreformatted
// ~ FWrite( ::nHandle, hb_eol() )
// ~ ENDIF
#if 0
IF ! HB_ISNULL( cEntry ) .AND. ! lPreformatted
hb_vfWrite( ::hFile, hb_eol() )
ENDIF
#endif
ENDDO
::CloseTag( "pre" )
ELSE
DO WHILE Len( cEntry ) > 0
DO WHILE ! HB_ISNULL( cEntry )
::OpenTag( "div", "class", cTagClass )
::Append( Indent( Parse( @cEntry, hb_eol() ), 0, 70 ), "" ):Newline()
::CloseTag( "div" )
@@ -250,72 +239,69 @@ METHOD PROCEDURE WriteEntry( cField, oEntry, lPreformatted, nIndent ) CLASS Gene
ENDIF
ENDIF
RETURN
METHOD OpenTag( cText, ... ) CLASS GenerateHTML
LOCAL aArgs := hb_AParams()
LOCAL cTag := cText
LOCAL idx
FOR idx := 2 TO Len( aArgs ) STEP 2
cTag += " " + aArgs[ idx ] + "=" + '"' + aArgs[ idx + 1 ] + '"'
cText += " " + aArgs[ idx ] + "=" + '"' + aArgs[ idx + 1 ] + '"'
NEXT
FWrite( ::nHandle, "<" + cTag + ">" + hb_eol() )
hb_vfWrite( ::hFile, "<" + cText + ">" + hb_eol() )
RETURN self
METHOD Tagged( cText, cTag, ... ) CLASS GenerateHTML
LOCAL aArgs := hb_AParams()
LOCAL cResult := "<" + cTag
LOCAL cResult := ""
LOCAL idx
FOR idx := 3 TO Len( aArgs ) STEP 2
cResult += " " + aArgs[ idx ] + "=" + '"' + aArgs[ idx + 1 ] + '"'
NEXT
FWrite( ::nHandle, cResult + ">" + cText + "</" + cTag + ">" + /* "4" + */ hb_eol() )
hb_vfWrite( ::hFile, "<" + cTag + cResult + ">" + cText + "</" + cTag + ">" + hb_eol() )
RETURN self
METHOD CloseTag( cText ) CLASS GenerateHTML
FWrite( ::nHandle, "</" + cText + ">" + hb_eol() )
hb_vfWrite( ::hFile, "</" + cText + ">" + hb_eol() )
IF cText == "html"
FClose( ::nHandle )
::nHandle := 0
hb_vfClose( ::hFile )
::hFile := NIL
ENDIF
RETURN self
METHOD Append( cText, cFormat ) CLASS GenerateHTML
LOCAL cResult := cText
LOCAL aFormat
LOCAL idx
IF Len( cResult ) > 0
IF ! HB_ISNULL( cText )
hb_default( @cFormat, "" )
cText := hb_StrReplace( cText, { ;
"&" => "&amp;", ;
'"' => "&quot;", ;
"<" => "&lt;", ;
">" => "&gt;" } )
aFormat := p_aConversionList
FOR idx := 1 TO Len( aFormat ) STEP 2
cResult := StrTran( cResult, aFormat[ idx ], "&" + aFormat[ idx + 1 ] + ";" )
NEXT
aFormat := hb_ATokens( cFormat, "," )
FOR idx := Len( aFormat ) TO 1 STEP -1
IF ! Empty( aFormat[ idx ] )
cResult := "<" + aFormat[ idx ] + ">" + cResult + "</" + aFormat[ idx ] + ">"
FOR EACH idx IN hb_ATokens( hb_defaultValue( cFormat, "" ), "," ) DESCEND
IF ! Empty( idx )
cText := "<" + idx + ">" + cText + "</" + idx + ">"
ENDIF
NEXT
DO WHILE Right( cResult, Len( hb_eol() ) ) == hb_eol()
cResult := Left( cResult, Len( cResult ) - Len( hb_eol() ) )
DO WHILE Right( cText, Len( hb_eol() ) ) == hb_eol()
cText := hb_StrShrink( cText, Len( hb_eol() ) )
ENDDO
FWrite( ::nHandle, cResult + hb_eol() )
hb_vfWrite( ::hFile, cText + hb_eol() )
ENDIF
@@ -327,8 +313,11 @@ METHOD RecreateStyleDocument( cStyleFile ) CLASS GenerateHTML
#pragma __streaminclude "hbdoc.css" | cString := %s
IF ! hb_MemoWrit( ::cFolder + hb_ps() + cStyleFile, cString )
// TODO: raise an error, could not create style file
IF ! hb_MemoWrit( ::cDir + hb_ps() + cStyleFile, cString )
/* TODO: raise an error, could not create style file */
ENDIF
RETURN self
STATIC FUNCTION SymbolToHTMLID( cID )
RETURN Lower( hb_StrReplace( cID, "_ ", "--" ) )

View File

@@ -1,11 +1,8 @@
/*
* Document generator - text output
*
* Copyright 2009 April White <april users.sourceforge.net>
*
* Portions of this project are based on hbdoc
* Copyright 1999-2003 Luiz Rafael Culik <culikr@uol.com.br>
* <TODO: list gen... methods used>
* Copyright 2009 April White <bright.tigra gmail.com>
* Copyright 1999-2003 Luiz Rafael Culik <culikr@uol.com.br> (Portions of this project are based on hbdoc)
*
* 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
@@ -49,30 +46,29 @@
*/
#include "hbclass.ch"
#include "hbdoc.ch"
CREATE CLASS GenerateAscii FROM GenerateText
CREATE CLASS GenerateAscii INHERIT GenerateText
METHOD NewIndex( cFolder, cFilename, cTitle, cDescription )
METHOD NewDocument( cFolder, cFilename, cTitle, cDescription )
METHOD NewIndex( cDir, cFilename, cTitle, cDescription )
METHOD NewDocument( cDir, cFilename, cTitle, cDescription )
ENDCLASS
METHOD NewDocument( cFolder, cFilename, cTitle, cDescription ) CLASS GenerateAscii
METHOD NewDocument( cDir, cFilename, cTitle, cDescription ) CLASS GenerateAscii
::lContinuous := .T.
::super:NewDocument( cFolder, cFilename, cTitle, cDescription )
::super:NewDocument( cDir, cFilename, cTitle, cDescription )
RETURN self
METHOD NewIndex( cFolder, cFilename, cTitle, cDescription ) CLASS GenerateAscii
METHOD NewIndex( cDir, cFilename, cTitle, cDescription ) CLASS GenerateAscii
::lContinuous := .T.
::super:NewIndex( cFolder, cFilename, cTitle, cDescription )
::super:NewIndex( cDir, cFilename, cTitle, cDescription )
RETURN self
CREATE CLASS GenerateText FROM TPLGenerate
CREATE CLASS GenerateText INHERIT TPLGenerate
HIDDEN:
@@ -80,28 +76,30 @@ CREATE CLASS GenerateText FROM TPLGenerate
VAR lContinuous AS LOGICAL INIT .F.
EXPORTED:
METHOD NewIndex( cFolder, cFilename, cTitle )
METHOD NewDocument( cFolder, cFilename, cTitle )
METHOD NewIndex( cDir, cFilename, cTitle )
METHOD NewDocument( cDir, cFilename, cTitle )
METHOD AddEntry( oEntry )
METHOD AddIndex( oEntry ) HIDDEN
METHOD BeginSection( cSection, cFilename )
// ~ METHOD EndSection( cSection, cFilename ) // will use inherited method
#if 0
METHOD EndSection( cSection, cFilename ) /* will use inherited method */
#endif
METHOD Generate()
METHOD WriteEntry( cCaption, cEntry, lPreformatted ) HIDDEN
ENDCLASS
METHOD NewDocument( cFolder, cFilename, cTitle ) CLASS GenerateText
METHOD NewDocument( cDir, cFilename, cTitle ) CLASS GenerateText
::super:NewDocument( cFolder, cFilename, cTitle, ".txt" )
::super:NewDocument( cDir, cFilename, cTitle, ".txt" )
::WriteEntry( "", cTitle + hb_eol(), .F. )
RETURN self
METHOD NewIndex( cFolder, cFilename, cTitle ) CLASS GenerateText
METHOD NewIndex( cDir, cFilename, cTitle ) CLASS GenerateText
::super:NewIndex( cFolder, cFilename, cTitle, ".txt" )
::super:NewIndex( cDir, cFilename, cTitle, ".txt" )
::WriteEntry( "", cTitle + hb_eol(), .F. )
RETURN self
@@ -125,19 +123,19 @@ METHOD AddIndex( oEntry ) CLASS GenerateText
METHOD AddEntry( oEntry ) CLASS GenerateText
LOCAL idx
LOCAL item
IF self:IsIndex()
self:AddIndex( oEntry )
IF ::IsIndex()
::AddIndex( oEntry )
ELSE
FOR idx := 1 TO Len( oEntry:Fields )
IF oEntry:IsField( oEntry:Fields[ idx ][ 1 ] ) .AND. oEntry:IsOutput( oEntry:Fields[ idx ][ 1 ] ) .AND. Len( oEntry:&( oEntry:Fields[ idx ][ 1 ] ) ) > 0
::WriteEntry( oEntry:FieldName( oEntry:Fields[ idx ][ 1 ] ), oEntry:&( oEntry:Fields[ idx ][ 1 ] ), oEntry:IsPreformatted( oEntry:Fields[ idx ][ 1 ] ) )
FOR EACH item IN oEntry:Fields
IF oEntry:IsField( item[ 1 ] ) .AND. oEntry:IsOutput( item[ 1 ] ) .AND. Len( oEntry:&( item[ 1 ] ) ) > 0
::WriteEntry( oEntry:FieldName( item[ 1 ] ), oEntry:&( item[ 1 ] ), oEntry:IsPreformatted( item[ 1 ] ) )
ENDIF
NEXT
IF ! ::lContinuous
FWrite( ::nHandle, hb_BChar( 12 ) + hb_eol() )
hb_vfWrite( ::hFile, hb_BChar( 12 ) + hb_eol() )
ENDIF
ENDIF
@@ -148,27 +146,25 @@ METHOD PROCEDURE WriteEntry( cCaption, cEntry, lPreformatted ) CLASS GenerateTex
LOCAL nIndent
IF ! Empty( cEntry )
nIndent := iif( Len( cCaption ) > 0, 6, 0 )
IF Len( cCaption ) > 0 .AND. nIndent > 0
FWrite( ::nHandle, Space( ::Depth * 6 ) + cCaption + ": " + hb_eol() )
nIndent := iif( HB_ISNULL( cCaption ), 0, 6 )
IF ! HB_ISNULL( cCaption ) .AND. nIndent > 0
hb_vfWrite( ::hFile, Space( ::Depth * 6 ) + cCaption + ": " + hb_eol() )
ENDIF
nIndent += ::Depth * 6
DO WHILE Len( cEntry ) > 0
FWrite( ::nHandle, Indent( Parse( @cEntry, hb_eol() ), nIndent, 70, lPreformatted ) )
DO WHILE ! HB_ISNULL( cEntry )
hb_vfWrite( ::hFile, Indent( Parse( @cEntry, hb_eol() ), nIndent, 70, lPreformatted ) )
ENDDO
ENDIF
METHOD Generate() CLASS GenerateText
IF ::IsIndex()
IF ! ::lContinuous
FWrite( ::nHandle, hb_BChar( 12 ) + hb_eol() )
ENDIF
IF ::IsIndex() .AND. ! ::lContinuous
hb_vfWrite( ::hFile, hb_BChar( 12 ) + hb_eol() )
ENDIF
IF ! Empty( ::nHandle )
FClose( ::nHandle )
::nHandle := 0
IF ::hFile != NIL
hb_vfClose( ::hFile )
::hFile := NIL
ENDIF
RETURN self

View File

@@ -1,11 +1,8 @@
/*
* Document generator - XML output
*
* Copyright 2009 April White <april users.sourceforge.net>
*
* Portions of this project are based on hbdoc
* Copyright 1999-2003 Luiz Rafael Culik <culikr@uol.com.br>
* <TODO: list gen... methods used>
* Copyright 2009 April White <bright.tigra gmail.com>
* Copyright 1999-2003 Luiz Rafael Culik <culikr@uol.com.br> (Portions of this project are based on hbdoc)
*
* 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
@@ -49,17 +46,16 @@
*/
#include "hbclass.ch"
#include "hbdoc.ch"
CREATE CLASS GenerateXML FROM TPLGenerate
CREATE CLASS GenerateXML INHERIT TPLGenerate
HIDDEN:
PROTECTED:
EXPORTED:
METHOD NewIndex( cFolder, cFilename, cTitle )
METHOD NewDocument( cFolder, cFilename, cTitle )
METHOD NewIndex( cDir, cFilename, cTitle )
METHOD NewDocument( cDir, cFilename, cTitle )
METHOD AddEntry( oEntry )
METHOD AddIndex( oEntry ) HIDDEN
METHOD BeginSection( cSection, cFilename )
@@ -70,28 +66,28 @@ CREATE CLASS GenerateXML FROM TPLGenerate
ENDCLASS
METHOD NewDocument( cFolder, cFilename, cTitle ) CLASS GenerateXML
METHOD NewDocument( cDir, cFilename, cTitle ) CLASS GenerateXML
::super:NewDocument( cFolder, cFilename, cTitle, ".xml" )
FWrite( ::nHandle, '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>' + hb_eol() )
FWrite( ::nHandle, '<HarbourReference>' + hb_eol() )
::super:NewDocument( cDir, cFilename, cTitle, ".xml" )
hb_vfWrite( ::hFile, '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>' + hb_eol() )
hb_vfWrite( ::hFile, '<HarbourReference>' + hb_eol() )
RETURN self
METHOD NewIndex( cFolder, cFilename, cTitle ) CLASS GenerateXML
METHOD NewIndex( cDir, cFilename, cTitle ) CLASS GenerateXML
::super:NewIndex( cFolder, cFilename, cTitle, ".xml" )
FWrite( ::nHandle, '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>' + hb_eol() )
FWrite( ::nHandle, '<HarbourReference>' + hb_eol() )
::super:NewIndex( cDir, cFilename, cTitle, ".xml" )
hb_vfWrite( ::hFile, '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>' + hb_eol() )
hb_vfWrite( ::hFile, '<HarbourReference>' + hb_eol() )
RETURN self
METHOD BeginSection( cSection, cFilename ) CLASS GenerateXML
IF ::Depth == 0
FWrite( ::nHandle, Replicate( Chr( 9 ), ::Depth ) + '<Section name="' + cSection + '" file="' + cFilename + ::cExtension + '">' + hb_eol() )
hb_vfWrite( ::hFile, Replicate( Chr( 9 ), ::Depth ) + '<Section name="' + cSection + '" file="' + cFilename + ::cExtension + '">' + hb_eol() )
ELSE
FWrite( ::nHandle, Replicate( Chr( 9 ), ::Depth ) + '<Section name="' + cSection + '">' + hb_eol() )
hb_vfWrite( ::hFile, Replicate( Chr( 9 ), ::Depth ) + '<Section name="' + cSection + '">' + hb_eol() )
ENDIF
::Depth++
@@ -102,7 +98,7 @@ METHOD EndSection( cSection, cFilename ) CLASS GenerateXML
HB_SYMBOL_UNUSED( cSection )
HB_SYMBOL_UNUSED( cFilename )
::Depth--
FWrite( ::nHandle, Replicate( Chr( 9 ), ::Depth ) + '</Section>' + hb_eol() )
hb_vfWrite( ::hFile, Replicate( Chr( 9 ), ::Depth ) + '</Section>' + hb_eol() )
RETURN self
@@ -114,51 +110,48 @@ METHOD AddIndex( oEntry ) CLASS GenerateXML
METHOD AddEntry( oEntry ) CLASS GenerateXML
LOCAL idx
LOCAL item
IF self:IsIndex()
self:AddIndex( oEntry )
IF ::IsIndex()
::AddIndex( oEntry )
ELSE
FWrite( ::nHandle, '<Entry>' + hb_eol() )
hb_vfWrite( ::hFile, '<Entry>' + hb_eol() )
::Depth++
FOR idx := 1 TO Len( oEntry:Fields )
::WriteEntry( oEntry:Fields[ idx ][ 1 ], oEntry:&( oEntry:Fields[ idx ][ 1 ] ), oEntry:IsPreformatted( oEntry:Fields[ idx ][ 1 ] ) )
FOR EACH item IN oEntry:Fields
::WriteEntry( item[ 1 ], oEntry:&( item[ 1 ] ), oEntry:IsPreformatted( item[ 1 ] ) )
NEXT
::Depth--
FWrite( ::nHandle, '</Entry>' + hb_eol() )
hb_vfWrite( ::hFile, '</Entry>' + hb_eol() )
ENDIF
RETURN self
METHOD Generate() CLASS GenerateXML
FWrite( ::nHandle, '</HarbourReference>' + hb_eol() )
hb_vfWrite( ::hFile, '</HarbourReference>' + hb_eol() )
IF ::IsIndex()
ENDIF
IF ! Empty( ::nHandle )
FClose( ::nHandle )
::nHandle := 0
IF ::hFile != NIL
hb_vfClose( ::hFile )
::hFile := NIL
ENDIF
RETURN self
METHOD PROCEDURE WriteEntry( cCaption, cEntry, lPreformatted ) CLASS GenerateXML
LOCAL cResult
LOCAL idx
IF ! Empty( cEntry )
cResult := iif( hb_eol() $ cEntry, hb_eol() + cEntry, cEntry )
FOR idx := 1 TO Len( p_aConversionList ) STEP 2
cResult := StrTran( cResult, p_aConversionList[ idx ], "&" + p_aConversionList[ idx + 1 ] + ";" )
NEXT
cEntry := cResult
FWrite( ::nHandle, Replicate( Chr( 9 ), ::Depth ) + "<" + cCaption + iif( lPreformatted, ' preformatted="yes"', "" ) + ">" )
FWrite( ::nHandle, cEntry )
FWrite( ::nHandle, /* Replicate( Chr( 9 ), ::Depth ) + */ "</" + cCaption + ">" + hb_eol() )
IF hb_eol() $ cEntry
cEntry := hb_eol() + cEntry
ENDIF
hb_vfWrite( ::hFile, Replicate( Chr( 9 ), ::Depth ) + "<" + cCaption + iif( lPreformatted, ' preformatted="yes"', "" ) + ">" )
hb_vfWrite( ::hFile, hb_StrReplace( cEntry, { ;
"&" => "&amp;", ;
'"' => "&quot;", ;
"<" => "&lt;", ;
">" => "&gt;" } ) )
hb_vfWrite( ::hFile, /* Replicate( Chr( 9 ), ::Depth ) + */ "</" + cCaption + ">" + hb_eol() )
ENDIF
RETURN

View File

@@ -1,10 +1,8 @@
/*
* Document generator, templates
*
* Copyright 2009 April White <april users.sourceforge.net>
*
* Portions of this project are based on hbdoc
* Copyright 1999-2003 Luiz Rafael Culik <culikr@uol.com.br>
* Copyright 2009 April White <bright.tigra gmail.com>
* Copyright 1999-2003 Luiz Rafael Culik <culikr@uol.com.br> (Portions of this project are based on hbdoc)
*
* 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
@@ -62,24 +60,23 @@ CREATE CLASS Entry
{ "NAME", "" }, ;
{ "CATEGORY", "Category" }, ;
{ "SUBCATEGORY", "Sub category" }, ;
{ "ONELINER", "" },;
{ "SYNTAX", "Syntax" },;
{ "ARGUMENTS", "Argument(s)" },;
{ "RETURNS", "Returns" },;
{ "DESCRIPTION", "Description" },;
{ "DATALINK", "Data link" },;
{ "DATANOLINK", "Data no link" },;
{ "METHODSLINK", "Methods link" },;
{ "METHODSNOLINK","Methods no link" },;
{ "EXAMPLES", "Example(s)" },;
{ "TESTS", "Test(s)" },;
{ "STATUS", "Status" },; /* p_aStatus is the constraint list */
{ "COMPLIANCE", "Compliance" },; /* p_aCompliance is the constraint list */
{ "PLATFORMS", "Platform(s)" },; /* p_aPlatforms is the constraint list */
{ "FILES", "File(s)" },;
{ "ONELINER", "" }, ;
{ "SYNTAX", "Syntax" }, ;
{ "ARGUMENTS", "Argument(s)" }, ;
{ "RETURNS", "Returns" }, ;
{ "DESCRIPTION", "Description" }, ;
{ "DATALINK", "Data link" }, ;
{ "DATANOLINK", "Data no link" }, ;
{ "METHODSLINK", "Methods link" }, ;
{ "METHODSNOLINK","Methods no link" }, ;
{ "EXAMPLES", "Example(s)" }, ;
{ "TESTS", "Test(s)" }, ;
{ "STATUS", "Status" }, ; /* ::hConstraint[ "status" ] is the constraint list */
{ "COMPLIANCE", "Compliance" }, ; /* ::hConstraint[ "compliance" ] is the constraint list */
{ "PLATFORMS", "Platform(s)" }, ; /* ::hConstraint[ "platforms" ] is the constraint list */
{ "FILES", "File(s)" }, ;
{ "SEEALSO", "See also" }, ;
{ "END", "End" } ;
}
{ "END", "End" } }
#define _S TPL_START
#define _E TPL_END
@@ -89,8 +86,7 @@ CREATE CLASS Entry
#define _P TPL_PREFORMATTED
#define _U TPL_OUTPUT
// this is best viewed with a fixed-width font
// the columns of this array correspond to the elements of Fields
/* the columns of this array correspond to the elements of Fields */
CLASS VAR Templates AS ARRAY INIT { ;
{ "Template" , { _S, _T, 0+_U, 0, _O , 0+_U, 0+_U, 0+_U, 0+_U, 0+_U, 0+_U, 0+_U, 0+_U, 0+_U, 0 +_U, 0 +_U, 0+_U, 0+_U, 0+_U, 0+_U, 0+_U, _E } }, ;
{ "Document" , { _S, _T, _R+_U, _R, _O+_U, _O+_U, 0+_U, 0+_U, 0+_U, _R+_U, 0+_U, 0+_U, 0+_U, 0+_U, 0 +_U, 0 +_U, 0+_U, 0+_U, _O+_U, _O+_U, _O+_U, _E } }, ;
@@ -101,10 +97,9 @@ CREATE CLASS Entry
{ "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, 0+_U, 0+_U, 0+_U, 0+_U, _P+_O+_U, 0 +_U, 0+_U, 0+_U, 0+_U, 0+_U, _O+_U, _E } }, ;
{ "Class data" , { _S, _T, _R+_U, _R, _R , _O+_U, _R+_U, 0+_U, 0+_U, _R+_U, 0+_U, 0+_U, 0+_U, 0+_U, _P+_O+_U, 0 +_U, 0+_U, 0+_U, 0+_U, 0+_U, _O+_U, _E } }, ;
{ "Run time error", { _S, _T, _R+_U, _R, 0 , _O+_U, 0+_U, 0+_U, 0+_U, _R+_U, 0+_U, 0+_U, 0+_U, 0+_U, _P+_O+_U, 0 +_U, 0+_U, _O+_U, 0+_U, 0+_U, _O+_U, _E } }, ;
}
{ "Run time error", { _S, _T, _R+_U, _R, 0 , _O+_U, 0+_U, 0+_U, 0+_U, _R+_U, 0+_U, 0+_U, 0+_U, 0+_U, _P+_O+_U, 0 +_U, 0+_U, _O+_U, 0+_U, 0+_U, _O+_U, _E } } }
METHOD New( cType ) CONSTRUCTOR
METHOD New( cType, hConstraint ) CONSTRUCTOR
METHOD IsField( c, nType )
METHOD IsTemplate( cType )
METHOD SetTemplate( cTemplate )
@@ -124,18 +119,22 @@ CREATE CLASS Entry
VAR sourcefile_ AS STRING
VAR sourcefileversion_ AS STRING
VAR uid_ AS STRING
VAR hConstraint AS HASH
CLASS VAR uid__ AS INTEGER INIT 0
ENDCLASS
METHOD New( cType ) CLASS Entry
METHOD New( cType, hConstraint ) CLASS Entry
::hConstraint := hConstraint
::uid_ := hb_ntos( ++::uid__ )
IF ! __objHasData( self, self:Fields[ 1 ][ 1 ] )
AEval( self:Fields, {| a | __objAddData( self, a[ 1 ] ) } )
IF ! __objHasData( self, ::Fields[ 1 ][ 1 ] )
AEval( ::Fields, {| a | __objAddData( self, a[ 1 ] ) } )
ENDIF
IF cType != NIL
self:Group := self:Templates[ AScan( self:Templates, {| a | Upper( a[ 1 ] ) == Upper( cType ) } ) ][ 2 ]
IF HB_ISSTRING( cType )
::Group := ::Templates[ AScan( ::Templates, {| a | Upper( a[ 1 ] ) == Upper( cType ) } ) ][ 2 ]
ENDIF
RETURN self
@@ -145,10 +144,10 @@ METHOD IsField( c, nType ) CLASS Entry
LOCAL idx
LOCAL lResult
IF ( lResult := ( idx := AScan( self:Fields, {| a | Upper( a[ 1 ] ) == Upper( c ) } ) ) > 0 )
IF self:Group[ idx ] == 0
IF ( lResult := ( idx := AScan( ::Fields, {| a | Upper( a[ 1 ] ) == Upper( c ) } ) ) > 0 )
IF ::Group[ idx ] == 0
lResult := .F.
ELSEIF nType != NIL .AND. hb_bitAnd( self:Group[ idx ], nType ) != nType
ELSEIF HB_ISNUMERIC( nType ) .AND. hb_bitAnd( ::Group[ idx ], nType ) != nType
lResult := .F.
ENDIF
ENDIF
@@ -156,19 +155,19 @@ METHOD IsField( c, nType ) CLASS Entry
RETURN lResult
METHOD IsTemplate( cType ) CLASS Entry
RETURN AScan( self:Templates, {| a | Upper( a[ 1 ] ) == Upper( cType ) } ) > 0
RETURN AScan( ::Templates, {| a | Upper( a[ 1 ] ) == Upper( cType ) } ) > 0
METHOD SetTemplate( cTemplate ) CLASS Entry
LOCAL aData := Array( Len( self:Fields ) )
LOCAL aData := Array( Len( ::Fields ) )
LOCAL idx
self:Group := self:Templates[ AScan( self:Templates, {| a | Upper( a[ 1 ] ) == Upper( cTemplate ) } ) ][ 2 ]
::Group := ::Templates[ AScan( ::Templates, {| a | Upper( a[ 1 ] ) == Upper( cTemplate ) } ) ][ 2 ]
FOR idx := 1 TO Len( aData )
IF self:Fields[ idx ][ 1 ] == "TEMPLATE"
aData[ idx ] := { self:Fields[ idx ][ 1 ], cTemplate }
IF ::Fields[ idx ][ 1 ] == "TEMPLATE"
aData[ idx ] := { ::Fields[ idx ][ 1 ], cTemplate }
ELSE
aData[ idx ] := { self:Fields[ idx ][ 1 ], iif( self:Group[ idx ] == TPL_REQUIRED, NIL, "" ) }
aData[ idx ] := { ::Fields[ idx ][ 1 ], iif( ::Group[ idx ] == TPL_REQUIRED, NIL, "" ) }
ENDIF
NEXT
__objSetValueList( self, aData )
@@ -178,14 +177,14 @@ METHOD SetTemplate( cTemplate ) CLASS Entry
METHOD IsConstraint( cSectionName, cSection ) CLASS Entry
LOCAL lResult
LOCAL idx := AScan( self:Fields, {| a | a[ 1 ] == cSectionName } )
LOCAL idx := AScan( ::Fields, {| a | a[ 1 ] == cSectionName } )
IF hb_bitAnd( self:Group[ idx ], hb_bitAnd( TPL_REQUIRED, TPL_OPTIONAL ) ) == 0
IF hb_bitAnd( ::Group[ idx ], hb_bitAnd( TPL_REQUIRED, TPL_OPTIONAL ) ) == 0
lResult := .T.
ELSEIF Type( "p_a" + cSectionName ) == "A"
ELSEIF cSectionName $ ::hConstraint
lResult := ;
hb_AScan( &( "p_a" + cSectionName ), cSection, , , .T. ) .OR. ;
hb_AScan( &( "p_a" + cSectionName ), Parse( cSection, "," ), , , .T. )
hb_AScan( ::hConstraint[ cSectionName ], cSection, , , .T. ) .OR. ;
hb_AScan( ::hConstraint[ cSectionName ], Parse( cSection, "," ), , , .T. )
ELSE
lResult := .T.
ENDIF
@@ -199,9 +198,9 @@ METHOD IsComplete( cIncompleteFielsList ) CLASS Entry
cIncompleteFielsList := ""
FOR idx := 1 TO Len( self:Fields )
IF hb_bitAnd( self:Group[ idx ], TPL_REQUIRED ) != 0 .AND. Empty( self:&( self:Fields[ idx ][ 1 ] ) )
cIncompleteFielsList += "," + self:Fields[ idx ][ 1 ]
FOR idx := 1 TO Len( ::Fields )
IF hb_bitAnd( ::Group[ idx ], TPL_REQUIRED ) != 0 .AND. Empty( ::&( ::Fields[ idx ][ 1 ] ) )
cIncompleteFielsList += "," + ::Fields[ idx ][ 1 ]
lResult := .F.
ENDIF
NEXT
@@ -211,209 +210,23 @@ METHOD IsComplete( cIncompleteFielsList ) CLASS Entry
RETURN lResult
METHOD IsPreformatted( cField ) CLASS Entry
RETURN hb_bitAnd( self:Group[ AScan( self:Fields, {| a | a[ 1 ] == cField } ) ], TPL_PREFORMATTED ) != 0
RETURN hb_bitAnd( ::Group[ AScan( ::Fields, {| a | a[ 1 ] == cField } ) ], TPL_PREFORMATTED ) != 0
METHOD IsRequired( cField ) CLASS Entry
RETURN hb_bitAnd( self:Group[ AScan( self:Fields, {| a | a[ 1 ] == cField } ) ], TPL_REQUIRED ) != 0
RETURN hb_bitAnd( ::Group[ AScan( ::Fields, {| a | a[ 1 ] == cField } ) ], TPL_REQUIRED ) != 0
METHOD IsOptional( cField ) CLASS Entry
RETURN hb_bitAnd( self:Group[ AScan( self:Fields, {| a | a[ 1 ] == cField } ) ], TPL_OPTIONAL ) != 0
RETURN hb_bitAnd( ::Group[ AScan( ::Fields, {| a | a[ 1 ] == cField } ) ], TPL_OPTIONAL ) != 0
METHOD IsOutput( cField ) CLASS Entry
RETURN hb_bitAnd( self:Group[ AScan( self:Fields, {| a | a[ 1 ] == cField } ) ], TPL_OUTPUT ) != 0
RETURN hb_bitAnd( ::Group[ AScan( ::Fields, {| a | a[ 1 ] == cField } ) ], TPL_OUTPUT ) != 0
METHOD FieldName( cField ) CLASS Entry
RETURN self:Fields[ AScan( self:Fields, {| a | a[ 1 ] == cField } ) ][ 2 ]
RETURN ::Fields[ AScan( ::Fields, {| a | a[ 1 ] == cField } ) ][ 2 ]
METHOD CategoryIndex( cCategory ) CLASS Entry
RETURN AScan( p_aCategories, {| a | HB_ISARRAY( a ) .AND. Len( a ) >= 1 .AND. a[ 1 ] == cCategory } )
RETURN AScan( ::hConstraint[ "categories" ], {| a | HB_ISARRAY( a ) .AND. Len( a ) >= 1 .AND. a[ 1 ] == cCategory } )
METHOD SubcategoryIndex( cCategory, cSubcategory ) CLASS Entry
RETURN ::CategoryIndex( cCategory ) >= 1 .AND. ;
hb_AScan( p_aCategories[ ::CategoryIndex( cCategory ) ][ 2 ], cSubcategory, , , .T. )
PROCEDURE init_Templates()
LOCAL idx
LOCAL aSubCategories := { ;
"Application", ;
"Array", ;
"Classes", ;
"Conversion", ;
"Database", ;
"Date/Time", ;
"Environment", ;
"Error", ;
"Events", ;
"Execute and execution", ; /* replace w/ "Environment"? */
"Extend", ;
"FileSys", ;
"Fixed memory", ;
"Garbage collector", ;
"Hash table", ;
"Idle states", ;
"INET", ;
"Internal", ;
"Item", ;
"Language and Nation", ;
"Legacy", ;
"Macro", ;
"Math", ;
"Objects", ;
"Printer", ;
"RDD", ;
"Strings", ;
"Terminal", ;
"Undocumented", ;
"User interface", ;
"Variable management", ;
"Virtual machine", ;
}
PUBLIC p_aCategories := { ;
{ "Document", { "License", "Compiler", "" } }, ;
{ "API", AClone( aSubCategories ) }, ;
{ "C level API", AClone( aSubCategories ) }, ;
{ "C level API compatability", AClone( aSubCategories ) }, ;
{ "Class", { ;
"", ;
"Access", ;
"Assign", ;
"Constructor", ;
"Data", ;
"Definition", ;
"Destructor", ;
"Method", ;
"Var", ;
} }, ;
{ "Command", AClone( aSubCategories ) }, ;
/* { "Compile time errors", { {} } }, */ ;
{ "Run time errors", { "" } }, ;
}
FOR idx := 1 TO Len( p_aCategories )
IF ! Empty( p_aCategories[ idx ] )
AAdd( p_aCategories[ idx ], Array( Len( p_aCategories[ idx ][ 2 ] ) ) ) // holder array of sub-category entries
AAdd( p_aCategories[ idx ], "" ) // holder for sub-category file name
ENDIF
NEXT
PUBLIC p_aCompliance := { ;
{ "", "" }, ;
{ "C", "This is CA-Cl*pper v5.2 compliant" }, ;
{ "C(array)", "This is CA-Cl*pper v5.2 compliant except that arrays in Harbour can have an unlimited number of elements" }, ;
{ "C(menu)", "This is CA-Cl*pper v5.2 compliant except that menus (internally arrays) in Harbour can have an unlimited number of elements" }, ;
{ "C(arrayblock)", "Codeblock calling frequency and order differs from CA-Cl*pper, since Harbour uses a different (faster) sorting algorithm (quicksort)" }, ;
{ "C52S", "? verbage: This is an CA-Cl*pper v5.2 compliant and is only visible if source was compiled with the HB_C52_STRICT flag" }, ;
{ "C52U", "This is an undocumented CA-Cl*pper v5.2 function and is only visible if source was compiled with the HB_C52_UNDOC flag" }, ;
{ "C53", "This is CA-Cl*pper v5.3 compliant and is only visible if source was compiled with the HB_COMPAT_C53 flag" }, ;
{ "H", "This is Harbour specific" }, ;
{ "NA", "Not applicable" } ;
}
PUBLIC p_aPlatforms := { ;
{ "", "" }, ;
{ "All", "This is available on all platforms" }, ;
{ "All(GT)", "This part of the GT API and supported only by some platforms." }, ;
{ "All(LFN)", "This is available on all platforms." + hb_eol() + ;
"If long file names are available Harbour will use/display the first 15 characters " +;
"else Harbour will use/display a 8.3 file name consistent with CA-Cl*pper" }, ;
{ "Linux(GT)", "Under Linux the number of columns avaliable depends of the current Terminal screen size." }, ;
{ "OS2(GT)", "Under OS/2 the number of columns avaliable depends of the current Terminal screen size." }, ;
{ "Win(GT)", "Under Windows, the return value of MaxRow() function is only affected if called after an SetMode() function" }, ;
{ "BSD", "This is available on the BSD platform" }, ;
{ "DARWIN", "This is available on the Darwin platform" }, ;
{ "DOS", "This is available on the MS-DOS platform" }, ;
{ "HPUX", "This is available on the HPUX platform" }, ;
{ "LINUX", "This is available on the Linux platform" }, ;
{ "OS2", "This is available on the OS/2 platform" }, ;
{ "SUNOS", "This is available on the SunOS platform" }, ;
{ "Unix", "This is available on the Unix platform(s)" }, ;
{ "Win", "This is available on the Windows platform(s)" }, ;
{ "WinCE", "This is available on the Windows CE platform" } ;
}
PUBLIC p_aStatus := { ;
{ "", "" }, ;
{ "R", "Ready" }, ;
{ "S", "Started" }, ;
{ "N", "Not started" } ;
}
PUBLIC p_aConversionList := { ;
"&", "amp", ;
'"', "quot", ;
"<", "lt", ;
">", "gt" ;
}
RETURN
PROCEDURE ShowTemplatesHelp( cTemplate, cDelimiter )
LOCAL o := Entry():New()
LOCAL idxTemplates, nFrom := 1, nTo := Len( o:Templates )
LOCAL idx
IF ! Empty( cTemplate ) .AND. !( cTemplate == "Template" )
IF o:IsTemplate( cTemplate )
nFrom := nTo := AScan( o:Templates, {| a | Upper( a[ 1 ] ) == Upper( cTemplate ) } )
ELSE
ShowHelp( "Unknown template '" + cTemplate + "'" )
RETURN
ENDIF
ENDIF
FOR idxTemplates := nFrom TO nTo
IF ! Empty( o:Templates[ idxTemplates ] ) .AND. ;
! Empty( o:Templates[ idxTemplates ][ 1 ] ) .AND. ;
!( o:Templates[ idxTemplates ][ 1 ] == "Template" )
#if 0
IF nFrom != nTo
ShowSubHelp( o:Templates[ idxTemplates ][ 1 ], 1, 0 )
ENDIF
#endif
o:SetTemplate( o:Templates[ idxTemplates ][ 1 ] )
FOR idx := 1 TO Len( o:Fields )
IF o:Group[ idx ] != 0
ShowSubHelp( iif( idx == 1, "/", " " ) + "* " + cDelimiter + o:Fields[ idx ][ 1 ] + cDelimiter, 1, 0 )
IF o:Fields[ idx ][ 1 ] == "TEMPLATE"
ShowSubHelp( " * " + o:Template, 1, 0 )
ELSEIF o:Group[ idx ] != TPL_START .AND. o:Group[ idx ] != TPL_END .AND. .T.
ShowSubHelp( " * " + iif( o:IsRequired( o:Fields[ idx ][ 1 ] ), "<required>", "<optional>" ), 1, 0 )
ENDIF
ENDIF
NEXT
ShowSubHelp( " */", 1, 0 )
ShowSubHelp( "", 1, 0 )
ENDIF
NEXT
RETURN
PROCEDURE ShowComplianceHelp()
LOCAL idx
FOR idx := 1 TO Len( p_aCompliance )
ShowSubHelp( p_aCompliance[ idx ][ 1 ], 1, 0, idx )
ShowSubHelp( Decode( "COMPLIANCE", NIL, p_aCompliance[ idx ][ 1 ] ), 1, 6, idx )
ShowSubHelp( "", 1, 0 )
NEXT
RETURN
PROCEDURE ShowPlatformsHelp
LOCAL idx
FOR idx := 1 TO Len( p_aPlatforms )
ShowSubHelp( p_aPlatforms[ idx ][ 1 ], 1, 0, idx )
ShowSubHelp( Decode( "PLATFORMS", NIL, p_aPlatforms[ idx ][ 1 ] ), 1, 6, idx )
ShowSubHelp( "", 1, 0 )
NEXT
RETURN
hb_AScan( ::hConstraint[ "categories" ][ ::CategoryIndex( cCategory ) ][ 2 ], cSubcategory, , , .T. )

View File

@@ -1,10 +1,8 @@
/*
* Document generator include file
*
* Copyright 2009 April White <april users.sourceforge.net>
*
* Portions of this project are based on hbdoc
* Copyright 1999-2003 Luiz Rafael Culik <culikr@uol.com.br>
* Copyright 2009 April White <bright.tigra gmail.com>
* Copyright 1999-2003 Luiz Rafael Culik <culikr@uol.com.br> (Portions of this project are based on hbdoc)
*
* 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
@@ -50,16 +48,10 @@
#ifndef HBDOC_CH_
#define HBDOC_CH_
MEMVAR p_aCategories
MEMVAR p_aCompliance
MEMVAR p_aPlatforms
MEMVAR p_aStatus
MEMVAR p_aConversionList
// Template definitions
#define TPL_START 1
#define TPL_END 2
#define TPL_REQUIRED 4 // intentially has a 'required' and 'optional' flag
#define TPL_REQUIRED 4 // intentionally has a 'required' and 'optional' flag
#define TPL_OPTIONAL 8
#define TPL_PREFORMATTED 16
#define TPL_CONSTRAINTLIST 32

View File

@@ -1,44 +1,40 @@
/* Harbour Documentation Stylesheet */
@charset "utf-8";
body {
font-size: 14px;
font-family: arial;
line-height: 18px;
font-family: Arial, sans-serif;
font-size: 14px;
line-height: 18px;
}
.name {
margin-left: 0;
padding-top: 0;
padding-bottom: 4px;
font-weight: bold;
font-size: 18px;
font-size: 18px;
font-weight: bold;
margin-left: 0;
padding-top: 0;
padding-bottom: 4px;
}
.oneliner {
margin-bottom: 12px;
font-style: italic;
font-style: italic;
margin-bottom: 12px;
}
.itemtitle {
margin-left: 0;
padding-top: 0;
padding-bottom: 4px;
font-weight: bold;
font-weight: bold;
margin-left: 0;
padding-top: 0;
padding-bottom: 4px;
}
.itemtext {
margin-left: 10px;
padding-bottom: 4px;
margin-left: 10px;
padding-bottom: 4px;
}
.examples {
margin-left: 10px;
padding-bottom: 4px;
margin-left: 10px;
padding-bottom: 4px;
}
.tests {
margin-left: 10px;
padding-bottom: 4px;
margin-left: 10px;
padding-bottom: 4px;
}

View File

@@ -1,5 +1,4 @@
-w3 -es2
-l
-w3 -es2 -kmo -l
-o${hb_name}
@@ -17,3 +16,10 @@ _tmplate.prg
# NOTE: hbdoc doesn't work from other locations than
# the current one, so we don't install it yet.
# $hb_pkg_install.hbm
# default -run params useful to update the online docs
# on the Harbour website
-runflag=-format=html
-runflag=-output-single
{allgcc}-ldflag=-fno-lto

File diff suppressed because it is too large Load Diff