Skip to content

Commit a942aa0

Browse files
committed
Making settings fro settings file available.
Making the settings from the doxygen settings / configuration file directly available inside the documentation.
1 parent 7664493 commit a942aa0

File tree

7 files changed

+159
-0
lines changed

7 files changed

+159
-0
lines changed

doc/commands.doc

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ documentation:
7878
\refitem cmddontinclude \\dontinclude
7979
\refitem cmddot \\dot
8080
\refitem cmddotfile \\dotfile
81+
\refitem cmddoxysetting \\doxysetting
8182
\refitem cmde \\e
8283
\refitem cmdelse \\else
8384
\refitem cmdelseif \\elseif
@@ -3136,6 +3137,21 @@ class Receiver
31363137
\ref image_sizeindicator "Size indication" with the
31373138
\ref cmdimage "\\image" command.
31383139

3140+
<hr>
3141+
\section cmddoxysetting \\doxysetting <setting>
3142+
3143+
\addindex \\doxysetting
3144+
Dispays the value of the setting of `<setting>` as used in the doxygen
3145+
configuration file for this doxygen run.
3146+
3147+
\par Example:
3148+
When creating this manual the following:
3149+
\verbatim
3150+
... Project name = \doxysetting PROJECT_NAME ...
3151+
\endverbatim
3152+
gives:<br>
3153+
... Project name = \doxysetting PROJECT_NAME ...
3154+
31393155
<hr>
31403156
\section cmde \\e <word>
31413157

src/cmdmapper.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ CommandMap cmdMap[] =
4242
{ "date", CMD_DATE },
4343
{ "dontinclude", CMD_DONTINCLUDE },
4444
{ "dotfile", CMD_DOTFILE },
45+
{ "doxysetting", CMD_DOXYSETTING },
4546
{ "e", CMD_EMPHASIS },
4647
{ "em", CMD_EMPHASIS },
4748
{ "endcode", CMD_ENDCODE },

src/cmdmapper.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ enum CommandType
143143
CMD_MANINCLUDE = 114,
144144
CMD_XMLINCLUDE = 115,
145145
CMD_ILINE = 116,
146+
CMD_DOXYSETTING = 117,
146147
};
147148

148149
enum HtmlTagType

src/docparser.cpp

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@
5151
#include "emoji.h"
5252
#include "fileinfo.h"
5353
#include "dir.h"
54+
#include "configimpl.h"
55+
#include "configoptions.h"
5456

5557
#define TK_COMMAND_CHAR(token) ((token)==TK_COMMAND_AT ? "@" : "\\")
5658

@@ -4791,6 +4793,107 @@ void DocPara::handleCite()
47914793
m_parser.tokenizer.setStatePara();
47924794
}
47934795

4796+
void DocPara::handleDoxySetting()
4797+
{
4798+
// get the argument of the cite command.
4799+
int tok=m_parser.tokenizer.lex();
4800+
if (tok!=TK_WHITESPACE)
4801+
{
4802+
warn_doc_error(m_parser.context.fileName,m_parser.tokenizer.getLineNr(),"expected whitespace after \\%s command",
4803+
qPrint("doxysetting"));
4804+
return;
4805+
}
4806+
m_parser.tokenizer.setStateDoxySetting();
4807+
tok=m_parser.tokenizer.lex();
4808+
if (tok==0)
4809+
{
4810+
warn_doc_error(m_parser.context.fileName,m_parser.tokenizer.getLineNr(),"unexpected end of comment block while parsing the "
4811+
"argument of command %s\n", qPrint("doxysetting"));
4812+
return;
4813+
}
4814+
else if (tok!=TK_WORD && tok!=TK_LNKWORD)
4815+
{
4816+
warn_doc_error(m_parser.context.fileName,m_parser.tokenizer.getLineNr(),"unexpected token %s as the argument of %s",
4817+
DocTokenizer::tokToString(tok),qPrint("doxysetting"));
4818+
return;
4819+
}
4820+
ConfigOption * opt = ConfigImpl::instance()->get(m_parser.context.token->name);
4821+
if (opt)
4822+
{
4823+
switch (opt->kind())
4824+
{
4825+
case ConfigOption::O_Bool:
4826+
m_children.push_back(std::make_unique<DocWord>(m_parser,this,*(dynamic_cast<ConfigBool*>(opt)->valueStringRef())));
4827+
break;
4828+
case ConfigOption::O_String:
4829+
m_children.push_back(std::make_unique<DocWord>(m_parser,this,*(dynamic_cast<ConfigString*>(opt)->valueRef())));
4830+
break;
4831+
case ConfigOption::O_Enum:
4832+
m_children.push_back(std::make_unique<DocWord>(m_parser,this,*(dynamic_cast<ConfigEnum*>(opt)->valueRef())));
4833+
break;
4834+
case ConfigOption::O_Int:
4835+
m_children.push_back(std::make_unique<DocWord>(m_parser,this,*(dynamic_cast<ConfigInt*>(opt)->valueStringRef())));
4836+
break;
4837+
case ConfigOption::O_List:
4838+
{
4839+
StringVector *lst = dynamic_cast<ConfigList*>(opt)->valueRef();
4840+
if (!lst->empty())
4841+
{
4842+
std::string lstFormat = theTranslator->trWriteList(lst->size()).str();
4843+
static const reg::Ex marker(R"(@(\d+))");
4844+
reg::Iterator it(lstFormat,marker);
4845+
reg::Iterator end;
4846+
size_t index=0;
4847+
QCString newList;
4848+
// now replace all markers with the real text
4849+
for ( ; it!=end ; ++it)
4850+
{
4851+
const auto &match = *it;
4852+
size_t newIndex = match.position();
4853+
size_t matchLen = match.length();
4854+
newList += lstFormat.substr(index,newIndex-index);
4855+
unsigned long entryIndex = std::stoul(match[1].str());
4856+
if (entryIndex<(unsigned long)lst->size())
4857+
{
4858+
newList += lst->at(entryIndex);
4859+
}
4860+
index=newIndex+matchLen;
4861+
}
4862+
m_children.push_back(std::make_unique<DocWord>(m_parser,this,newList));
4863+
}
4864+
}
4865+
break;
4866+
case ConfigOption::O_Obsolete:
4867+
warn(m_parser.context.fileName,m_parser.tokenizer.getLineNr(), "Obsolete setting for '\\doxysetting': '%s'",
4868+
qPrint(m_parser.context.token->name));
4869+
m_children.push_back(std::make_unique<DocWord>(m_parser,this,m_parser.context.token->name + " (obsolete)"));
4870+
break;
4871+
case ConfigOption::O_Disabled:
4872+
warn(m_parser.context.fileName,m_parser.tokenizer.getLineNr(),
4873+
"Disabled setting (i.e. not supported in this doxygen executable) for '\\doxysetting': '%s'",
4874+
qPrint(m_parser.context.token->name));
4875+
m_children.push_back(std::make_unique<DocWord>(m_parser,this,m_parser.context.token->name + " (Disabled)"));
4876+
break;
4877+
default:
4878+
break;
4879+
}
4880+
}
4881+
else
4882+
{
4883+
warn(m_parser.context.fileName,m_parser.tokenizer.getLineNr(), "Unknown setting for '\\doxysetting': '%s'",
4884+
qPrint(m_parser.context.token->name));
4885+
m_children.push_back(std::make_unique<DocWord>(m_parser,this,m_parser.context.token->name));
4886+
}
4887+
#if 0
4888+
m_parser.context.token->sectionId = m_parser.context.token->name;
4889+
m_children.push_back(
4890+
std::make_unique<DocCite>(
4891+
m_parser,this,m_parser.context.token->name,m_parser.context.context));
4892+
4893+
#endif
4894+
m_parser.tokenizer.setStatePara();
4895+
}
4896+
47944897
void DocPara::handleEmoji()
47954898
{
47964899
// get the argument of the emoji command.
@@ -5877,6 +5980,9 @@ int DocPara::handleCommand(const QCString &cmdName, const int tok)
58775980
case CMD_CITE:
58785981
handleCite();
58795982
break;
5983+
case CMD_DOXYSETTING:
5984+
handleDoxySetting();
5985+
break;
58805986
case CMD_EMOJI:
58815987
handleEmoji();
58825988
break;

src/docparser.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1202,6 +1202,7 @@ class DocPara : public CompAccept<DocPara>
12021202
void handleInclude(const QCString &cmdName,DocInclude::Type t);
12031203
void handleLink(const QCString &cmdName,bool isJavaLink);
12041204
void handleCite();
1205+
void handleDoxySetting();
12051206
void handleEmoji();
12061207
void handleRef(const QCString &cmdName);
12071208
void handleSection(const QCString &cmdName);

src/doctokenizer.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ class DocTokenizer
158158
void setStatePattern();
159159
void setStateLink();
160160
void setStateCite();
161+
void setStateDoxySetting();
161162
void setStateRef();
162163
void setStateInternalRef();
163164
void setStateText();

src/doctokenizer.l

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,7 @@ PHPTYPE [\\:a-z_A-Z0-9\x80-\xFF\-]+
236236
CITESCHAR [a-z_A-Z0-9\x80-\xFF\-\?]
237237
CITEECHAR [a-z_A-Z0-9\x80-\xFF\-\+:\/\?]
238238
CITEID {CITESCHAR}{CITEECHAR}*("."{CITESCHAR}{CITEECHAR}*)*|"\""{CITESCHAR}{CITEECHAR}*("."{CITESCHAR}{CITEECHAR}*)*"\""
239+
DOXYSET [a-z_A-Z][a-z_A-Z0-9]*
239240
MAILADDR ("mailto:")?[a-z_A-Z0-9.+-]+"@"[a-z_A-Z0-9-]+("."[a-z_A-Z0-9\-]+)+[a-z_A-Z0-9\-]+
240241
MAILWS [\t a-z_A-Z0-9+-]
241242
MAILADDR2 {MAILWS}+{BLANK}+("at"|"AT"|"_at_"|"_AT_"){BLANK}+{MAILWS}+("dot"|"DOT"|"_dot_"|"_DOT_"){BLANK}+{MAILWS}+
@@ -343,6 +344,7 @@ LINENR {BLANK}*[1-9][0-9]*
343344
%x St_Pattern
344345
%x St_Link
345346
%x St_Cite
347+
%x St_DoxySetting
346348
%x St_Ref
347349
%x St_Ref2
348350
%x St_IntRef
@@ -1019,6 +1021,30 @@ LINENR {BLANK}*[1-9][0-9]*
10191021
unput(*yytext);
10201022
return 0;
10211023
}
1024+
<St_DoxySetting>{DOXYSET} { // label to cite
1025+
if (yytext[0] =='"')
1026+
{
1027+
yyextra->token->name=yytext+1;
1028+
yyextra->token->name=yyextra->token->name.left(static_cast<uint>(yyleng)-2);
1029+
}
1030+
else
1031+
{
1032+
yyextra->token->name=yytext;
1033+
}
1034+
return TK_WORD;
1035+
}
1036+
<St_DoxySetting>{BLANK} { // white space
1037+
unput(' ');
1038+
return 0;
1039+
}
1040+
<St_DoxySetting>(\n|"\\ilinebr") { // new line
1041+
unput_string(yytext,yyleng);
1042+
return 0;
1043+
}
1044+
<St_DoxySetting>. { // any other character
1045+
unput(*yytext);
1046+
return 0;
1047+
}
10221048
<St_Ref>{REFWORD_NOCV}/{BLANK}("const")[a-z_A-Z0-9] { // see bug776988
10231049
yyextra->token->name=yytext;
10241050
return TK_WORD;
@@ -1820,6 +1846,13 @@ void DocTokenizer::setStateCite()
18201846
BEGIN(St_Cite);
18211847
}
18221848

1849+
void DocTokenizer::setStateDoxySetting()
1850+
{
1851+
yyscan_t yyscanner = p->yyscanner;
1852+
struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
1853+
BEGIN(St_DoxySetting);
1854+
}
1855+
18231856
void DocTokenizer::setStateRef()
18241857
{
18251858
yyscan_t yyscanner = p->yyscanner;

0 commit comments

Comments
 (0)