fb-doc  0.4.0
FreeBASIC documentation tool
Highlighter Class Reference

Class to process the syntax highlighting. More...

Collaboration diagram for Highlighter:

Public Types

enum  WordTypes {
  FB_CODE, FB_KEYW, FB_KWTP, FB_KWFL,
  FB_PREP, FB_SYMB
}
 The high-lighting categories. More...
 

Public Member Functions

 Highlighter (BYVAL_AS_Parser_PTR)
 Constructor, executing the complete process. More...
 
SUB doDoxy (BYREF_AS_STRING)
 Procedure to control the repairing process. More...
 
SUB do_files ()
 Operate on all files. More...
 
SUB generate_all (BYVAL_AS_ZSTRING_PTR, BYVAL_AS_INTEGER)
 Emit source code with syntax highlighting. More...
 
FUNCTION_AS_STRING generate_code (BYVAL_AS_ZSTRING_PTR, BYVAL_AS_INTEGER, BYVAL_AS_INTEGER)
 highlight normal source code More...
 
FUNCTION_AS_ZSTRING_PTR word_type (BYREF_AS_STRING)
 Check type of word. More...
 
FUNCTION_AS_STRING searchPathNam (BYREF_AS_STRING)
 Search path and name of fb source. More...
 
FUNCTION_AS_STRING eol (BYVAL_AS_RepData_PTR, BYref_AS_INTEGER)
 The function called to end a line and start a new one. More...
 
FUNCTION_AS_STRING prepare (BYVAL_AS_Highlighter_PTR)
 The function called to extract links from original files. More...
 
FUNCTION_AS_STRING special_chars (BYVAL_AS_UBYTE_PTR, BYVAL_AS_INTEGER, BYVAL_AS_INTEGER)
 The function called for normal code to replace special characters. More...
 

Static Public Member Functions

static FUNCTION_AS_STRING prepare_tex (BYVAL_AS_Highlighter_PTR)
 Prepare a LaTeX file for syntax repairing. More...
 
static FUNCTION_AS_STRING prepare_xml (BYVAL_AS_Highlighter_PTR)
 Prepare a XML file for syntax repairing. More...
 
static FUNCTION_AS_STRING prepare_html (BYVAL_AS_Highlighter_PTR)
 Prepare a HTML file for syntax repairing. More...
 

Public Attributes

STRING FbPath
 The path to read FB code files from. More...
 
STRING FbFiles
 A list of all FB file names. More...
 
STRING InPath
 The path to read Doxygen files from. More...
 
STRING DoxyFiles
 A list of all Doxygen file names. More...
 
STRING HtmlPath
 The path for html files. More...
 
STRING HtmlSuff
 The filename suffix for html files. More...
 
STRING TexPath
 The path for LaTeX files. More...
 
STRING XmlPath
 The path for XML files. More...
 
STRING LastLine
 The last line read from the input file. More...
 
RepData_PTR Symbols
 A RepData class containing the list of linked symbols. More...
 
Parser_PTR Pars
 The parser to operate with. More...
 
ZSTRING_PTR FBDOC_MARK = "<!-- Syntax-highlighting by fb-doc -->"
 Text to mark the output. More...
 
ZSTRING_PTR KEYW_A = "<span class=""keyword"">"
 Code to start highlighting a keyword. More...
 
ZSTRING_PTR KWTP_A = "<span class=""keywordtype"">"
 Code to start highlighting a keywordtype. More...
 
ZSTRING_PTR KWFL_A = "<span class=""keywordflow"">"
 Code to start highlighting a flow keyword (not used yet) More...
 
ZSTRING_PTR PREP_A = "<span class=""preprocessor"">"
 Code to start highlighting a preprocessor statement. More...
 
ZSTRING_PTR CMNT_A = "<span class=""comment"">"
 Code to start highlighting a comment. More...
 
ZSTRING_PTR SPAN_E = "</span>"
 Code to end highlighting. More...
 
ZSTRING_PTR QUOT_A = "<span class=""stringliteral"">&quot;"
 Code to start highlighting a string literal. More...
 
ZSTRING_PTR QUOT_E = "&quot;</span>"
 Code to end highlighting a string literal. More...
 
INTEGER Ifnr
 The file number for input. More...
 
INTEGER LineNo
 The current line number. More...
 
union {
   class {
UBYTE GenHtm
 Flag for html output. More...
 
UBYTE GenTex
 Flag for LaTeX output. More...
 
UBYTE GenXml
 Flag for XML output. More...
 
   } 
 Individual flags for a single output format. More...
 
LONG GenAny
 Summary of all output flags. More...
 
}; 
 All flags for output formats in a UNION. More...
 

Detailed Description

Class to process the syntax highlighting.

The class is used to process the replacement of the Doxygen syntax highlighting for HTML, LaTeX and XML output. It contains members to

  • scan for the files (Doxygen outputs),
  • to read files and extract links,
  • copy context to new files (header and footer)
  • replace original file by fixed version.

Definition at line 44 of file fbdoc_emit_syntax.bi.

Member Enumeration Documentation

The high-lighting categories.

Enumerator
FB_CODE 

Normal code, no high-lighting.

FB_KEYW 

A keyword.

FB_KWTP 

A keyword type.

FB_KWFL 

A flow keyword (currently not used)

FB_PREP 

A preprocessor statement.

FB_SYMB 

A linked Symbol.

Definition at line 46 of file fbdoc_emit_syntax.bi.

Constructor & Destructor Documentation

Highlighter::Highlighter ( BYVAL_AS_Parser_PTR  P)

Constructor, executing the complete process.

Parameters
PThe parser for input

This constructor just connects to the parser in use and establishes itself as UserTok.

Definition at line 243 of file fbdoc_emit_syntax.bas.

Member Function Documentation

SUB Highlighter::doDoxy ( BYREF_AS_STRING  Fnam)

Procedure to control the repairing process.

Parameters
FnamThe path / file name of the Doxygen configuration file

This SUB controls the complete repairing process

  • load and parse Doxyfile for settings, paths and output types
  • scan FB directory for file names
  • scan output directories and
  • process source listing files.

Definition at line 260 of file fbdoc_emit_syntax.bas.

Here is the call graph for this function:

SUB Highlighter::do_files ( )

Operate on all files.

The procedure operates on all file names specified in DoxyFiles. It opens the input file, generated by Doxygen, writes a new file to copy the original context to (file start and end) and starts the emitter to replaces the source code section with advanced syntax highlighting.

Each file can only be fixed once (because the link texts from the original files are used and they change during the operation).

When done, the original file is killed and replaced by the new file, which is renamed to the original file name.

Definition at line 390 of file fbdoc_emit_syntax.bas.

FUNCTION_AS_STRING Highlighter::prepare_tex ( BYVAL_AS_Highlighter_PTR  Hgh)
static

Prepare a LaTeX file for syntax repairing.

Parameters
HghThe Highlighter to operate with
Returns
The file name of the FB source code

This function prepares a LaTeX file to replace the syntax highlighting. It reads the header from the original output and copies the context to the replacement file. The file name of the odiginal FB source is extracted from the header. Then the links from the original listing part are extracted in to the Highlighter::Symbols table.

Definition at line 1279 of file fbdoc_emit_syntax.bas.

Here is the caller graph for this function:

FUNCTION_AS_STRING Highlighter::prepare_xml ( BYVAL_AS_Highlighter_PTR  Hgh)
static

Prepare a XML file for syntax repairing.

Parameters
HghThe Highlighter to operate with
Returns
The file name of the FB source code

This function prepares a HTML file to replace the syntax highlighting. It reads the header from the original output and copies the context to the replacement file. The file name of the odiginal FB source is extracted from the header. Then the links from the original listing part are extracted in to the Highlighter::Symbols table.

Definition at line 1343 of file fbdoc_emit_syntax.bas.

Here is the caller graph for this function:

FUNCTION_AS_STRING Highlighter::prepare_html ( BYVAL_AS_Highlighter_PTR  Hgh)
static

Prepare a HTML file for syntax repairing.

Parameters
HghThe Highlighter to operate with
Returns
The file name of the FB source code

This function prepares a HTML file to replace the syntax highlighting. It reads the header from the original output and copies the context to the replacement file. The file name of the original FB source is extracted from the header. Then the links from the original listing part are extracted in to the Highlighter::Symbols table.

Definition at line 1236 of file fbdoc_emit_syntax.bas.

Here is the caller graph for this function:

SUB Highlighter::generate_all ( BYVAL_AS_ZSTRING_PTR  Buf,
BYVAL_AS_INTEGER  Stop_ 
)

Emit source code with syntax highlighting.

Parameters
BufThe buffer to read from
Stop_The position to stop at

This procedure parses a source code section, starting at Parser::SrcBgn up to the given parameter Stop_. It orperates on all kind of code (strings, comments and normal code). The output gets written to the Options::Ocha file.

Definition at line 450 of file fbdoc_emit_syntax.bas.

Here is the caller graph for this function:

FUNCTION_AS_STRING Highlighter::generate_code ( BYVAL_AS_ZSTRING_PTR  T,
BYVAL_AS_INTEGER  A,
BYVAL_AS_INTEGER  L 
)

highlight normal source code

Parameters
TThe input buffer from the parser
AThe start of the part to operate on (zero based)
LThe length of the part to operate on
Returns
Formated html code for the input context

This function highlights a piece of code. It doesn't handle comments nor string literals. In normal code it separates keywords, preprocessors and symbols and encovers the context by the matching tags. In the result special characters get replaced, like '&' by '&', '<' by '<', ... (special characters are different in HTML, LaTeX and XML output).

Definition at line 1134 of file fbdoc_emit_syntax.bas.

FUNCTION_AS_ZSTRING_PTR Highlighter::word_type ( BYREF_AS_STRING  W)

Check type of word.

Parameters
WThe word to check
Returns
The type of the word (first byte) & formated word

Check a word in the source context and return its type and a string in camel-case letters for formating in mixed cases. The first byte of this string is the word type (1 = keyword, 2 = preprocessor).

Definition at line 521 of file fbdoc_emit_syntax.bas.

FUNCTION_AS_STRING Highlighter::searchPathNam ( BYREF_AS_STRING  Nam)

Search path and name of fb source.

Parameters
NamThe name of the source file
Returns
The path and the file name of an FB source file (or empty string if not found)

This function prepends the path to a file name for a FB source file.

The original Doxygen output (HTM, TEX or XML) contains the name of the related source file, but it doesn't contain the path. This function searches the list of FB source files and returns the path (if any) and the file name.

Note
If there is no such name in the list, an empty string gets returned.
If there're multiple matches (several files with identical names in different folders), only the first match gets returned.

Definition at line 1211 of file fbdoc_emit_syntax.bas.

FUNCTION_AS_STRING Highlighter::eol ( BYVAL_AS_RepData_PTR  ,
BYref_AS_INTEGER   
)

The function called to end a line and start a new one.

FUNCTION_AS_STRING Highlighter::prepare ( BYVAL_AS_Highlighter_PTR  )

The function called to extract links from original files.

FUNCTION_AS_STRING Highlighter::special_chars ( BYVAL_AS_UBYTE_PTR  ,
BYVAL_AS_INTEGER  ,
BYVAL_AS_INTEGER   
)

The function called for normal code to replace special characters.

Member Data Documentation

STRING Highlighter::FbPath

The path to read FB code files from.

Definition at line 56 of file fbdoc_emit_syntax.bi.

STRING Highlighter::FbFiles

A list of all FB file names.

Definition at line 56 of file fbdoc_emit_syntax.bi.

STRING Highlighter::InPath

The path to read Doxygen files from.

Definition at line 56 of file fbdoc_emit_syntax.bi.

STRING Highlighter::DoxyFiles

A list of all Doxygen file names.

Definition at line 56 of file fbdoc_emit_syntax.bi.

STRING Highlighter::HtmlPath

The path for html files.

Definition at line 56 of file fbdoc_emit_syntax.bi.

STRING Highlighter::HtmlSuff

The filename suffix for html files.

Definition at line 56 of file fbdoc_emit_syntax.bi.

STRING Highlighter::TexPath

The path for LaTeX files.

Definition at line 56 of file fbdoc_emit_syntax.bi.

STRING Highlighter::XmlPath

The path for XML files.

Definition at line 56 of file fbdoc_emit_syntax.bi.

STRING Highlighter::LastLine

The last line read from the input file.

Definition at line 56 of file fbdoc_emit_syntax.bi.

RepData_PTR Highlighter::Symbols

A RepData class containing the list of linked symbols.

Definition at line 65 of file fbdoc_emit_syntax.bi.

Parser_PTR Highlighter::Pars

The parser to operate with.

Definition at line 66 of file fbdoc_emit_syntax.bi.

ZSTRING_PTR Highlighter::FBDOC_MARK = "<!-- Syntax-highlighting by fb-doc -->"

Text to mark the output.

Definition at line 68 of file fbdoc_emit_syntax.bi.

ZSTRING_PTR Highlighter::KEYW_A = "<span class=""keyword"">"

Code to start highlighting a keyword.

Definition at line 69 of file fbdoc_emit_syntax.bi.

ZSTRING_PTR Highlighter::KWTP_A = "<span class=""keywordtype"">"

Code to start highlighting a keywordtype.

Definition at line 70 of file fbdoc_emit_syntax.bi.

ZSTRING_PTR Highlighter::KWFL_A = "<span class=""keywordflow"">"

Code to start highlighting a flow keyword (not used yet)

Definition at line 71 of file fbdoc_emit_syntax.bi.

ZSTRING_PTR Highlighter::PREP_A = "<span class=""preprocessor"">"

Code to start highlighting a preprocessor statement.

Definition at line 72 of file fbdoc_emit_syntax.bi.

ZSTRING_PTR Highlighter::CMNT_A = "<span class=""comment"">"

Code to start highlighting a comment.

Definition at line 73 of file fbdoc_emit_syntax.bi.

ZSTRING_PTR Highlighter::SPAN_E = "</span>"

Code to end highlighting.

Definition at line 74 of file fbdoc_emit_syntax.bi.

ZSTRING_PTR Highlighter::QUOT_A = "<span class=""stringliteral"">&quot;"

Code to start highlighting a string literal.

Definition at line 75 of file fbdoc_emit_syntax.bi.

ZSTRING_PTR Highlighter::QUOT_E = "&quot;</span>"

Code to end highlighting a string literal.

Definition at line 76 of file fbdoc_emit_syntax.bi.

INTEGER Highlighter::Ifnr

The file number for input.

Definition at line 78 of file fbdoc_emit_syntax.bi.

INTEGER Highlighter::LineNo

The current line number.

Definition at line 78 of file fbdoc_emit_syntax.bi.

union { ... }

All flags for output formats in a UNION.


The documentation for this class was generated from the following files: