2
#include "cbcolourmanager.h"
7
m_Description(_T("**description**")),
8
m_Brief(_T("**brief**"))
18
wxString DocBlock::GetDescription()
20
if (m_DocMap.count(m_Description) == 1)
21
return m_DocMap[m_Description];
26
bool DocBlock::HasDescription()
28
return (m_DocMap.count(m_Description) == 1);
31
void DocBlock::AddDescription(const wxString &descr)
33
m_DocMap[m_Description] = descr;
36
wxString DocBlock::GetBrief()
38
if (m_DocMap.count(m_Brief) == 1)
39
return m_DocMap[m_Brief];
44
bool DocBlock::HasBrief()
46
return (m_DocMap.count(m_Brief) == 1);
49
int DocBlock::GetParamCount()
52
for (std::map<wxString,wxString>::iterator it = m_DocMap.begin(); it != m_DocMap.end(); ++it)
54
if (!it->first.IsSameAs(m_Description) && !it->first.IsSameAs(m_Brief))
60
wxString DocBlock::GetValue(wxString& key)
62
if (m_DocMap.count(key) == 1)
68
void DocBlock::AddBrief(const wxString &bline)
70
m_DocMap[_T("**brief**")] = bline;
73
void DocBlock::AddParam(const wxString &name, const wxString &descr)
75
m_DocMap[name.Lower()] = descr;
78
void DocBlock::Clear()
83
//*****************************************
86
static const wxString br = _T("<br>");
87
static const wxString sep = _T(" ");
88
static const wxString b1 = _T("<b>");
89
static const wxString b0 = _T("</b>");
91
static const wxString a1 = _T("<a>");
92
static const wxString a0 = _T("</a>");
94
static const wxString i1 = _T("<i>");
95
static const wxString i0 = _T("</i>");
97
static const wxString pre1 = _T("<pre>");
98
static const wxString pre0 = _T("</pre>");
100
static const wxString nbsp(_T(" "));
101
static const wxString tab = nbsp + nbsp + nbsp;
103
static const wxString commandTag = _T("cmd=");
106
wxString HtmlDoc::GenerateHtmlDoc(TokenFlat* token, int token_idx, bool& hasDoc)
108
//http://docs.wxwidgets.org/2.8/wx_wxhtml.html#htmltagssupported
109
using namespace HTMLTags;
111
ColourManager *colours = Manager::Get()->GetColourManager();
113
wxString html = _T("<html><body bgcolor=\"");
114
html += colours->GetColour(wxT("cc_docs_back")).GetAsString(wxC2S_HTML_SYNTAX) + _T("\" text=\"");
115
html += colours->GetColour(wxT("cc_docs_fore")).GetAsString(wxC2S_HTML_SYNTAX) + _T("\" link=\"");
116
html += colours->GetColour(wxT("cc_docs_link")).GetAsString(wxC2S_HTML_SYNTAX) + _T("\">");
118
html += _T("<a name=\"top\"></a>");
121
if (!token || token->m_DisplayName.IsEmpty())
122
return wxEmptyString;
125
if (!token->m_ParentDisplayName.IsEmpty())
128
if (token->m_ParentTokenKind == tkModule)
129
html += _T("module: ") + b1 + token->m_ParentDisplayName + b0 + br;
135
//add scope and name:
136
switch (token->m_TokenKind)
139
html += token->m_PartFirst + _T(" function ") + b1 + token->m_DisplayName + b0;
140
html += token->m_Args;
141
html += sep + token->m_PartLast;
146
html += _T("subroutine ") + b1 + token->m_DisplayName + b0;
147
html += sep + token->m_Args;
149
if (token->m_ParentTokenKind == tkFile)
150
moreInfo = _T("global");
151
else if (token->m_TokenAccess == taPrivate)
152
moreInfo = _T("private");
156
html += token->m_TypeDefinition + _T(" :: ") + b1 + token->m_DisplayName + b0 + token->m_Args + br;
157
moreInfo = token->GetTokenKindString();
161
html += token->m_TypeDefinition + nbsp + b1 + token->m_DisplayName + b0 + br;
162
if (token->m_TypeDefinition.IsEmpty())
163
moreInfo = _T("interface");
165
moreInfo = _T("generic interface");
169
html += b1 + token->m_DisplayName + b0 + br;
170
moreInfo = token->GetTokenKindString();
174
if (!moreInfo.IsEmpty())
175
html += i1 + _T("<font color=\"green\" size=3>") + _T("(") +
176
moreInfo +_T(")") + _T("</font>") + i0 + br;
178
if (!token->m_DocString.IsEmpty())
180
const wxString brsep = _T("@brief_end@");
181
size_t brf = token->m_DocString.find(brsep);
183
if (brf != wxString::npos)
190
html += br + i1 + b1 + _T("Brief:") + b0 + i0 + br;
191
html += tab + token->m_DocString.substr(0,brf) + br;
195
if (bre_idx < token->m_DocString.size())
197
html += br + i1 + b1 + _T("Description:") + b0 + i0 + br;
198
html += tab + token->m_DocString.substr(bre_idx) + br;
203
//add go to declaration
204
html += br + br + _T("<a href=\"") + commandTag + _T("goto") + wxString::Format(_T("%i"), token_idx)
205
+ _T("\">") + _T("Open declaration") + _T("</a>") + br + br;
207
// Append 'close' link:
208
html += _T("<a href=\"") + commandTag + _T("close")
209
+ _T("\">") + _T("close") + _T("</a>"),
211
html += _T("</body></html>");
217
wxString HtmlDoc::OnDocumentationLink(wxHtmlLinkEvent &event, bool &dismissPopup, bool &isGoto, long int &tokenIdx)
219
using namespace HTMLTags;
221
const wxString& href = event.GetLinkInfo().GetHref();
225
dismissPopup = false;
228
if (!href.StartsWith(commandTag, &args))
229
return wxEmptyString;
231
if (args.StartsWith(_T("goto"), &tidx_str))
233
if(tidx_str.ToLong(&tokenIdx))
239
else if (args.StartsWith(_T("close")))
242
return wxEmptyString;
245
wxString HtmlDoc::GetDocForTooltip(TokenFlat* token)
247
return HtmlDoc::GetDocShort(token->m_DocString);
250
wxString HtmlDoc::GetDocShort(const wxString& tokDoc)
253
if (!tokDoc.IsEmpty())
255
const wxString brsep = _T("@brief_end@");
256
size_t brf = tokDoc.find(brsep);
258
if (brf != wxString::npos)
265
doc = tokDoc.substr(0,brf);
267
else if (bre_idx < tokDoc.size())
269
doc = tokDoc.substr(bre_idx);
270
if (doc.size() > 80) // limit length of doc
271
doc = doc.substr(0,80) + _T("...");