NumeRe v1.1.4
NumeRe: Framework für Numerische Rechnungen
documentation.cpp File Reference
#include <vector>
#include <map>
#include <fstream>
#include "documentation.hpp"
#include "../../kernel.hpp"
#include "../datamanagement/database.hpp"
#include "../ui/error.hpp"
#include "../utils/tools.hpp"
#include "../../syntax.hpp"
Include dependency graph for documentation.cpp:

Go to the source code of this file.

Macros

#define FILE_CODEBLOCK_START   "<div class=\"sites-codeblock sites-codesnippet-block\"><CODE><span style=\"color:#00008B;\">\n"
 
#define FILE_CODEBLOCK_END   "</span></CODE></div>\n"
 
#define VIEWER_CODEBLOCK_START   "<center><table border=\"0\" cellspacing=\"0\" bgcolor=\"#F2F2F2\" width=\"94%\">\n<tbody><tr><td>\n<CODE><span style=\"color:#00008B;\">\n"
 
#define VIEWER_CODEBLOCK_END   "\n</span></CODE></td></tr></tbody></table></center>\n"
 

Functions

static bool isValue (const std::string &sExpr, size_t nPos, size_t nLength)
 Static helper function for doc_ReplaceExprContentForHTML to determine literal values in expressions. More...
 
static bool isOperator (const std::string &sExpr, size_t nPos, size_t nLength)
 Static helper function for doc_ReplaceExprContentForHTML to determine operators in expressions. More...
 
static bool isFunction (const std::string &sExpr, size_t nPos, size_t nLength)
 Static helper function for doc_ReplaceExprContentForHTML to determine functions in expressions. More...
 
static void doc_ReplaceExprContentForHTML (std::string &sExpr, Settings &_option)
 This function replaces tokens in <expr>-tags to improve the readability of mathematical code. More...
 
static void doc_ReplaceTokensForHTML (std::string &sDocParagraph, bool generateFile, Settings &_option)
 Searches for defined XML tokens in the passed string and replaces them with the plain HTML counterpart. More...
 
void doc_Help (const std::string &__sTopic, Settings &_option)
 This function shows the content of a documentation article based upon the passed topic. The content is displayed in terminal or in an external window (depending on the settings) or directly written to an HTML file (depending on an additional parameter). More...
 
static std::string createCssString (int style, const Settings &_option)
 This static function creates the CSS string for the span element containing the lexed symbol. The passed style is mapped to the settings, so that the syntax colours are somewhat similar to the ones selected by the user. More...
 
static std::string applySyntaxHighlighting (const std::string &sCodeString, const Settings &_option)
 This static function lexes the passed code string usign a static instance of the NumeReSyntax class. More...
 
static std::string getHighlightedCode (std::string sCode, bool verbatim, Settings &_option)
 Returns the final HTML string containing the already lexed and highlighted code. More...
 
static std::string formatCodeBlock (std::string sCode, bool generateFile, bool verbatim, Settings &_option)
 Returns the final HTML string containing the lexed and highlighted code and embeds that into the code block environment. More...
 
std::string doc_HelpAsHTML (const std::string &__sTopic, bool generateFile, Settings &_option)
 This function returns the documentation article for the selected topic as an HTML std::string. This std::string either may be used to create a corresponding file or it may be displayed in the documentation viewer. More...
 
void doc_SearchFct (const std::string &sToLookFor, Settings &_option)
 This function provides the logic for searching for entries in the keywords database. More...
 

Macro Definition Documentation

◆ FILE_CODEBLOCK_END

#define FILE_CODEBLOCK_END   "</span></CODE></div>\n"

Definition at line 889 of file documentation.cpp.

◆ FILE_CODEBLOCK_START

#define FILE_CODEBLOCK_START   "<div class=\"sites-codeblock sites-codesnippet-block\"><CODE><span style=\"color:#00008B;\">\n"

Definition at line 888 of file documentation.cpp.

◆ VIEWER_CODEBLOCK_END

#define VIEWER_CODEBLOCK_END   "\n</span></CODE></td></tr></tbody></table></center>\n"

Definition at line 892 of file documentation.cpp.

◆ VIEWER_CODEBLOCK_START

#define VIEWER_CODEBLOCK_START   "<center><table border=\"0\" cellspacing=\"0\" bgcolor=\"#F2F2F2\" width=\"94%\">\n<tbody><tr><td>\n<CODE><span style=\"color:#00008B;\">\n"

Definition at line 891 of file documentation.cpp.

Function Documentation

◆ applySyntaxHighlighting()

static std::string applySyntaxHighlighting ( const std::string &  sCodeString,
const Settings _option 
)
static

This static function lexes the passed code string usign a static instance of the NumeReSyntax class.

Parameters
sCodeStringconst std::string&
_optionconst Settings&
Returns
std::string

Definition at line 797 of file documentation.cpp.

References createCssString(), Settings::getExePath(), NumeReKernel::getInstance(), NumeReKernel::getPluginCommands(), NumeReSyntax::highlightLine(), replaceAll(), and NumeReSyntax::SYNTAX_OPERATOR.

Referenced by getHighlightedCode().

Here is the call graph for this function:

◆ createCssString()

static std::string createCssString ( int  style,
const Settings _option 
)
static

This static function creates the CSS string for the span element containing the lexed symbol. The passed style is mapped to the settings, so that the syntax colours are somewhat similar to the ones selected by the user.

Parameters
styleint
_optionconst Settings&
Returns
std::string

Definition at line 718 of file documentation.cpp.

References Settings::getSetting(), replaceAll(), SETTING_S_ST_COMMAND, SETTING_S_ST_COMMENT, SETTING_S_ST_CONSTANT, SETTING_S_ST_FUNCTION, SETTING_S_ST_METHODS, SETTING_S_ST_NUMBER, SETTING_S_ST_OPERATOR, SETTING_S_ST_OPTION, SETTING_S_ST_PROCEDURE, SETTING_S_ST_SPECIALVAL, SETTING_S_ST_STRING, SettingsValue::stringval(), NumeReSyntax::SYNTAX_COMMAND, NumeReSyntax::SYNTAX_COMMENT, NumeReSyntax::SYNTAX_CONSTANT, NumeReSyntax::SYNTAX_FUNCTION, NumeReSyntax::SYNTAX_METHODS, NumeReSyntax::SYNTAX_NUMBER, NumeReSyntax::SYNTAX_OPERATOR, NumeReSyntax::SYNTAX_OPTION, NumeReSyntax::SYNTAX_PROCEDURE, NumeReSyntax::SYNTAX_SPECIALVAL, and NumeReSyntax::SYNTAX_STRING.

Referenced by applySyntaxHighlighting().

Here is the call graph for this function:

◆ doc_Help()

void doc_Help ( const std::string &  __sTopic,
Settings _option 
)

This function shows the content of a documentation article based upon the passed topic. The content is displayed in terminal or in an external window (depending on the settings) or directly written to an HTML file (depending on an additional parameter).

Parameters
__sTopicconst std::string&
_optionSettings&
Returns
void

Definition at line 302 of file documentation.cpp.

References _lang, SyntaxError::CANNOT_GENERATE_FILE, FileSystem::declareFileType(), doc_HelpAsHTML(), eraseToken(), findParameter(), Language::get(), Documentation::getHelpArticle(), Documentation::getHelpArticleID(), Documentation::getHelpArticleTitle(), Documentation::getHelpIdxKey(), SyntaxError::invalid_position, LineBreak(), make_hline(), NumeReKernel::print(), NumeReKernel::setDocumentation(), StripSpaces(), toLowerCase(), and FileSystem::ValidizeAndPrepareName().

Referenced by cmd_datagrid(), cmd_define(), cmd_diff(), cmd_edit(), cmd_eval(), cmd_extrema(), cmd_find(), cmd_fit(), cmd_get(), cmd_help(), cmd_ifndefined(), cmd_load(), cmd_new(), cmd_odesolve(), cmd_plotting(), cmd_pulse(), cmd_read(), cmd_redefine(), cmd_set(), cmd_spline(), cmd_stfa(), cmd_taylor(), cmd_undefine(), cmd_warn(), cmd_window(), cmd_write(), and cmd_zeroes().

Here is the call graph for this function:

◆ doc_HelpAsHTML()

std::string doc_HelpAsHTML ( const std::string &  __sTopic,
bool  generateFile,
Settings _option 
)

This function returns the documentation article for the selected topic as an HTML std::string. This std::string either may be used to create a corresponding file or it may be displayed in the documentation viewer.

Parameters
__sTopicconst std::string&
generateFilebool
_optionSettings&
Returns
std::string

Definition at line 932 of file documentation.cpp.

References _lang, doc_ReplaceExprContentForHTML(), doc_ReplaceTokensForHTML(), FILE_CODEBLOCK_END, FILE_CODEBLOCK_START, formatCodeBlock(), Language::get(), Documentation::getArgAtPos(), Documentation::getHelpArticle(), getHighlightedCode(), StripSpaces(), toUpperCase(), VIEWER_CODEBLOCK_END, and VIEWER_CODEBLOCK_START.

Referenced by doc_Help(), and NumeReKernel::getDocumentation().

Here is the call graph for this function:

◆ doc_ReplaceExprContentForHTML()

static void doc_ReplaceExprContentForHTML ( std::string &  sExpr,
Settings _option 
)
static

This function replaces tokens in <expr>-tags to improve the readability of mathematical code.

Parameters
sExprstd::string&
_optionSettings&
Returns
void

Definition at line 92 of file documentation.cpp.

References getMatchingParenthesis(), isFunction(), isOperator(), isValue(), and NumeRe::DataBase::size().

Referenced by doc_HelpAsHTML(), and doc_ReplaceTokensForHTML().

Here is the call graph for this function:

◆ doc_ReplaceTokensForHTML()

static void doc_ReplaceTokensForHTML ( std::string &  sDocParagraph,
bool  generateFile,
Settings _option 
)
static

Searches for defined XML tokens in the passed string and replaces them with the plain HTML counterpart.

Parameters
sDocParagraphstd::string&
generateFilebool
_optionSettings&
Returns
void

Definition at line 201 of file documentation.cpp.

References doc_ReplaceExprContentForHTML(), Documentation::getArgAtPos(), Settings::getExePath(), NumeReKernel::getFileSystem(), NumeReKernel::getInstance(), Settings::getLoadPath(), Settings::getPlotPath(), Settings::getProcPath(), Settings::getSavePath(), Settings::getScriptPath(), replacePathSeparator(), and FileSystem::ValidFileName().

Referenced by doc_HelpAsHTML(), and formatCodeBlock().

Here is the call graph for this function:

◆ doc_SearchFct()

void doc_SearchFct ( const std::string &  sToLookFor,
Settings _option 
)

This function provides the logic for searching for entries in the keywords database.

Parameters
sToLookForconst std::string&
_optionSettings&
Returns
void

Definition at line 1352 of file documentation.cpp.

References _lang, NumeRe::DataBase::addData(), fileExists(), NumeRe::DataBase::findRecordsUsingRelevance(), Language::get(), NumeRe::DataBase::getElement(), Settings::getExePath(), intCast(), make_hline(), NumeReKernel::print(), NumeReKernel::printPreFmt(), replacePathSeparator(), NumeRe::DataBase::size(), sVersion, NumeReKernel::toggleTableStatus(), toString(), toSystemCodePage(), toUpperCase(), Settings::useCustomLangFiles(), and FileSystem::ValidFileName().

Referenced by cmd_find().

Here is the call graph for this function:

◆ formatCodeBlock()

static std::string formatCodeBlock ( std::string  sCode,
bool  generateFile,
bool  verbatim,
Settings _option 
)
static

Returns the final HTML string containing the lexed and highlighted code and embeds that into the code block environment.

Parameters
sCodestd::string
generateFilebool
verbatimbool
_optionSettings&
Returns
std::string

Definition at line 907 of file documentation.cpp.

References doc_ReplaceTokensForHTML(), FILE_CODEBLOCK_END, FILE_CODEBLOCK_START, getHighlightedCode(), VIEWER_CODEBLOCK_END, and VIEWER_CODEBLOCK_START.

Referenced by doc_HelpAsHTML().

Here is the call graph for this function:

◆ getHighlightedCode()

static std::string getHighlightedCode ( std::string  sCode,
bool  verbatim,
Settings _option 
)
static

Returns the final HTML string containing the already lexed and highlighted code.

Parameters
sCodestd::string
verbatimbool
_optionSettings&
Returns
std::string

Definition at line 863 of file documentation.cpp.

References applySyntaxHighlighting(), and replaceAll().

Referenced by doc_HelpAsHTML(), and formatCodeBlock().

Here is the call graph for this function:

◆ isFunction()

static bool isFunction ( const std::string &  sExpr,
size_t  nPos,
size_t  nLength 
)
static

Static helper function for doc_ReplaceExprContentForHTML to determine functions in expressions.

Parameters
sExprconst std::string&
nPossize_t
nLengthsize_t
Returns
bool

Definition at line 76 of file documentation.cpp.

Referenced by doc_ReplaceExprContentForHTML().

◆ isOperator()

static bool isOperator ( const std::string &  sExpr,
size_t  nPos,
size_t  nLength 
)
static

Static helper function for doc_ReplaceExprContentForHTML to determine operators in expressions.

Parameters
sExprconst std::string&
nPossize_t
nLengthsize_t
Returns
bool

Definition at line 59 of file documentation.cpp.

Referenced by doc_ReplaceExprContentForHTML().

◆ isValue()

static bool isValue ( const std::string &  sExpr,
size_t  nPos,
size_t  nLength 
)
static

Static helper function for doc_ReplaceExprContentForHTML to determine literal values in expressions.

Parameters
sExprconst std::string&
nPossize_t
nLengthsize_t
Returns
bool

Definition at line 42 of file documentation.cpp.

Referenced by doc_ReplaceExprContentForHTML().