22#include "../utils/tinyxml2.h"
23#include "../utils/tools.hpp"
73 keyWords.push_back(iter->
GetText());
92 std::string sCombinedArticle;
94 for (
const auto& text : vArticleContents)
96 sCombinedArticle += text;
101 sCombinedArticle.erase(0, sCombinedArticle.find(
"<article "));
102 sCombinedArticle.erase(sCombinedArticle.find(
"</article>")+10);
111 for (
size_t i = 0; i < vArticleContents.size(); i++)
113 if (vArticleContents[i].find(
"<contents>") != std::string::npos)
115 if (vArticleContents[i].substr(vArticleContents[i].find(
"<contents>")+10).length())
116 m_contents.push_back(vArticleContents[i].substr(vArticleContents[i].find(
"<contents>")+10));
118 for (
size_t j = i+1; j < vArticleContents.size(); j++)
120 if (vArticleContents[j].find(
"</contents>") != std::string::npos)
122 if (vArticleContents[j].find(
"</contents>"))
123 m_contents.push_back(vArticleContents[j].substr(0, vArticleContents[j].find(
"</contents>")));
149 std::vector<std::string> vTagStack;
152 for (
size_t i = 0; i < sText.length(); i++)
157 std::string tag = sText.substr(i, sText.find(
'>', i) + 1 - i);
158 std::string tagVal = tag.substr(tag.find_first_not_of(
"</ "));
159 tagVal.erase(tagVal.find_first_of(
" />"));
162 if (tag.find(
"/>") != std::string::npos)
166 if (tag.substr(0, 2) ==
"</")
169 if (vTagStack.size() && tagVal == vTagStack.back())
171 vTagStack.pop_back();
174 else if (!vTagStack.size())
181 vTagStack.push_back(tagVal);
207 sFormat +=
"\t\t<keyword>" + keyw +
"</keyword>\n";
212 sFormat +=
"\t</keywords>\n\t<contents>\n";
214 int indentationLevel = 0;
221 if (indLevelDiff < 0)
222 indentationLevel += indLevelDiff;
225 indentationLevel =
std::max(0, indentationLevel);
227 sFormat.append(indentationLevel+2,
'\t');
228 sFormat += text +
"\n";
230 if (indLevelDiff > 0)
231 indentationLevel += indLevelDiff;
234 return sFormat +
"\t</contents>\n</article>";
263 parse(vFileContents,
"");
277 std::vector<std::string> vFileContents;
278 std::ifstream file(sFileName);
285 vFileContents.push_back(
"");
286 std::getline(file, vFileContents.back());
290 return vFileContents;
306 for (
size_t i = 0; i < vFileContents.size(); i++)
309 if (vFileContents[i].find(
"<article ") != std::string::npos)
312 for (
size_t j = i; j < vFileContents.size(); j++)
314 if (vFileContents[j].find(
"</article>") != std::string::npos
315 && (j > i || vFileContents[i].find(
"<article ") < vFileContents[j].find(
"</article>")))
345 file << article.format() << std::endl;
void parse(const std::vector< std::string > &vFileContents, const std::string &sFileName)
Parse the documentation file into single articles. Only complete <article>..</article> sections are p...
void print(const std::string &sFileName)
Print the documentation file to the specified file.
std::vector< DocumentationArticle > m_articles
std::vector< std::string > loadFromFile(const std::string &sFileName)
Load the documentation file contents from the specified file.
DocumentationFile(const std::string &sFileName)
Create a DocumentationFile from the an actual file.
Common exception class for all exceptions thrown in NumeRe.
@ HLPIDX_ENTRY_IS_MISSING
INSERT HERE.
static size_t invalid_position
const char * ErrorStr() const
XMLError Parse(const char *xml, size_t nBytes=static_cast< size_t >(-1))
const char * GetText() const
const char * Attribute(const char *name, const char *value=0) const
const XMLElement * NextSiblingElement(const char *name=0) const
Get the next (right) sibling element of this node, with an optionally supplied name.
const XMLElement * FirstChildElement(const char *name=0) const
static int indentationLevelDiff(const std::string &sText)
Calculate the indentation level difference from the passed line.
static void parseHeader(const std::string &sCombinedArticle, DocumentationEntry &docEntry, std::vector< std::string > &keyWords)
Parse the documentation article header into the DocumentationEntry structure and the list of keywords...
CONSTCD11 std::enable_if<!std::chrono::treat_as_floating_point< T >::value, T >::type trunc(T t) NOEXCEPT
void StripSpaces(std::string &)
Removes leading and trailing white spaces and tabulator characters.
This structure defines a single article in a documentation file.
DocumentationEntry m_docEntry
std::vector< std::string > m_keywords
std::string format()
Format the documentation article into a single string, which then can be printed to a file.
DocumentationArticle(const std::vector< std::string > &vArticleContents, const std::string &sFileName)
Create a DocumentationArticle structure from the selected part of the documentation file containing e...
std::vector< std::string > m_contents
This structure defines a single entry in the documentation index.