summaryrefslogtreecommitdiffstats
path: root/tools/qdoc3
diff options
context:
space:
mode:
authorMartin Smith <martin.smith@nokia.com>2011-01-19 12:58:48 (GMT)
committerMartin Smith <martin.smith@nokia.com>2011-01-19 12:58:48 (GMT)
commitebaf3a991d0ef0533c829305ae1968bed41e2773 (patch)
tree0da2ef1bd95affd9794452121839ac190f71cc3b /tools/qdoc3
parent74f63cebc430ef6634917577783dafeed9a233d5 (diff)
downloadQt-ebaf3a991d0ef0533c829305ae1968bed41e2773.zip
Qt-ebaf3a991d0ef0533c829305ae1968bed41e2773.tar.gz
Qt-ebaf3a991d0ef0533c829305ae1968bed41e2773.tar.bz2
qdoc: Fixed some validation errors in the DITA files
11 instances of raw-html remain.
Diffstat (limited to 'tools/qdoc3')
-rw-r--r--tools/qdoc3/ditaxmlgenerator.cpp83
-rw-r--r--tools/qdoc3/ditaxmlgenerator.h3
-rw-r--r--tools/qdoc3/doc.cpp35
-rw-r--r--tools/qdoc3/htmlgenerator.cpp20
4 files changed, 90 insertions, 51 deletions
diff --git a/tools/qdoc3/ditaxmlgenerator.cpp b/tools/qdoc3/ditaxmlgenerator.cpp
index 24ecea5..667bf80 100644
--- a/tools/qdoc3/ditaxmlgenerator.cpp
+++ b/tools/qdoc3/ditaxmlgenerator.cpp
@@ -91,6 +91,7 @@ QString DitaXmlGenerator::sinceTitles[] =
*/
QString DitaXmlGenerator::ditaTags[] =
{
+ "",
"alt",
"apiDesc",
"APIMap",
@@ -286,9 +287,11 @@ void DitaXmlGenerator::writeStartTag(DitaTag t)
Pop the current DITA tag off the stack, and write the
appropriate end tag to the DITA XML file.
*/
-void DitaXmlGenerator::writeEndTag()
+void DitaXmlGenerator::writeEndTag(DitaTag t)
{
- tagStack.pop();
+ DitaTag top = tagStack.pop();
+ if (t > DT_NONE && top != t)
+ qDebug() << "Expected:" << t << "ACTUAL:" << top;
xmlWriter().writeEndElement();
}
@@ -583,7 +586,7 @@ int DitaXmlGenerator::generateAtom(const Atom *atom,
int skipAhead = 0;
QString hx, str;
static bool in_para = false;
- QString guid, hc;
+ QString guid, hc, attr;
switch (atom->type()) {
case Atom::AbstractLeft:
@@ -694,15 +697,12 @@ int DitaXmlGenerator::generateAtom(const Atom *atom,
break;
case Atom::DivLeft:
{
- QString attr = atom->string();
+ attr = atom->string();
DitaTag t = currentTag();
if ((t == DT_section) || (t == DT_sectiondiv))
- t = DT_sectiondiv;
+ writeStartTag(DT_sectiondiv);
else if ((t == DT_body) || (t == DT_bodydiv))
- t = DT_bodydiv;
- else
- t = DT_p;
- writeStartTag(t);
+ writeStartTag(DT_bodydiv);
if (!attr.isEmpty()) {
if (attr.contains('=')) {
int index = 0;
@@ -729,7 +729,8 @@ int DitaXmlGenerator::generateAtom(const Atom *atom,
}
break;
case Atom::DivRight:
- writeEndTag(); // </sectiondiv>
+ if ((currentTag() == DT_sectiondiv) || (currentTag() == DT_bodydiv))
+ writeEndTag(); // </sectiondiv>, </bodydiv>, or </p>
break;
case Atom::FootnoteLeft:
// ### For now
@@ -1414,6 +1415,30 @@ int DitaXmlGenerator::generateAtom(const Atom *atom,
writeStartTag(DT_tbody);
}
writeStartTag(DT_row);
+ attr = atom->string();
+ if (!attr.isEmpty()) {
+ if (attr.contains('=')) {
+ int index = 0;
+ int from = 0;
+ QString values;
+ while (index >= 0) {
+ index = attr.indexOf('"',from);
+ if (index >= 0) {
+ ++index;
+ from = index;
+ index = attr.indexOf('"',from);
+ if (index > from) {
+ if (!values.isEmpty())
+ values.append(' ');
+ values += attr.mid(from,index-from);
+ from = index+1;
+ }
+ }
+ }
+ attr = values;
+ }
+ xmlWriter().writeAttribute("outputclass", attr);
+ }
xmlWriter().writeAttribute("valign","top");
break;
case Atom::TableRowRight:
@@ -1421,16 +1446,40 @@ int DitaXmlGenerator::generateAtom(const Atom *atom,
break;
case Atom::TableItemLeft:
{
+ QString values = "";
writeStartTag(DT_entry);
- QStringList spans = atom->string().split(",");
- if (spans.size() == 2) {
- if (inTableHeader ||
- (spans[0].toInt() != 1) ||
- (spans[1].toInt() != 1)) {
- QString s = "span(" + spans[0] + "," + spans[1] + ")";
- xmlWriter().writeAttribute("outputclass",s);
+ for (int i=0; i<atom->count(); ++i) {
+ attr = atom->string(i);
+ if (attr.contains('=')) {
+ int index = 0;
+ int from = 0;
+ while (index >= 0) {
+ index = attr.indexOf('"',from);
+ if (index >= 0) {
+ ++index;
+ from = index;
+ index = attr.indexOf('"',from);
+ if (index > from) {
+ if (!values.isEmpty())
+ values.append(' ');
+ values += attr.mid(from,index-from);
+ from = index+1;
+ }
+ }
+ }
+ }
+ else {
+ qDebug() << "ATTR:" << attr;
+ QStringList spans = attr.split(",");
+ if (spans.size() == 2) {
+ if ((spans[0].toInt()>1) || (spans[1].toInt()>1)) {
+ values += "span(" + spans[0] + "," + spans[1] + ")";
+ }
+ }
}
}
+ if (!values.isEmpty())
+ xmlWriter().writeAttribute("outputclass",values);
if (matchAhead(atom, Atom::ParaLeft))
skipAhead = 1;
}
diff --git a/tools/qdoc3/ditaxmlgenerator.h b/tools/qdoc3/ditaxmlgenerator.h
index 785b10a..4676770 100644
--- a/tools/qdoc3/ditaxmlgenerator.h
+++ b/tools/qdoc3/ditaxmlgenerator.h
@@ -82,6 +82,7 @@ class DitaXmlGenerator : public PageGenerator
};
enum DitaTag {
+ DT_NONE,
DT_alt,
DT_apiDesc,
DT_APIMap,
@@ -407,7 +408,7 @@ class DitaXmlGenerator : public PageGenerator
void addLink(const QString& href, const QStringRef& text);
void writeDitaMap();
void writeStartTag(DitaTag t);
- void writeEndTag();
+ void writeEndTag(DitaTag t=DT_NONE);
DitaTag currentTag();
private:
diff --git a/tools/qdoc3/doc.cpp b/tools/qdoc3/doc.cpp
index 36c1d94..e54b7dd 100644
--- a/tools/qdoc3/doc.cpp
+++ b/tools/qdoc3/doc.cpp
@@ -403,9 +403,14 @@ class DocParser
Location cachedLoc;
int cachedPos;
- DocPrivate *priv;
- enum ParaState { OutsidePara, InsideSingleLinePara, InsideMultiLinePara };
- ParaState paraState;
+ DocPrivate* priv;
+ enum ParagraphState {
+ OutsidePara,
+ InSingleLinePara,
+ InMultiLinePara
+ };
+ QStack<ParagraphState> paragraphStateStack;
+ ParagraphState paraState;
bool inTableHeader;
bool inTableRow;
bool inTableItem;
@@ -452,6 +457,7 @@ void DocParser::parse(const QString& source,
priv = docPrivate;
priv->text << Atom::Nop;
+ paragraphStateStack.clear();
paraState = OutsidePara;
inTableHeader = false;
inTableRow = false;
@@ -561,18 +567,11 @@ void DocParser::parse(const QString& source,
break;
#endif
case CMD_DIV:
- p1 = getArgument(true);
leavePara();
- if (p1.contains('=')) {
- enterPara(Atom::DivLeft, Atom::DivRight,p1);
- openedCommands.push(cmd);
- }
- else {
- append(Atom::DivLeft, p1);
- openedCommands.push(cmd);
- enterPara();
- }
-
+ p1 = getArgument(true);
+ //enterPara(Atom::DivLeft, Atom::DivRight, p1);
+ append(Atom::DivLeft, p1);
+ openedCommands.push(cmd);
break;
case CMD_ENDDIV:
leavePara();
@@ -658,7 +657,7 @@ void DocParser::parse(const QString& source,
if (closeCommand(cmd)) {
leavePara();
append(Atom::FootnoteRight);
- paraState = InsideMultiLinePara; // ###
+ paraState = InMultiLinePara; // ###
}
break;
case CMD_ENDIF:
@@ -1339,7 +1338,7 @@ void DocParser::parse(const QString& source,
if (ch.isSpace()) {
++pos;
if ((ch == '\n') &&
- (paraState == InsideSingleLinePara ||
+ (paraState == InSingleLinePara ||
isBlankLine())) {
leavePara();
newWord = false;
@@ -1904,10 +1903,10 @@ void DocParser::enterPara(Atom::Type leftType,
pendingParaRightType = rightType;
pendingParaString = string;
if (leftType == Atom::SectionHeadingLeft) {
- paraState = InsideSingleLinePara;
+ paraState = InSingleLinePara;
}
else {
- paraState = InsideMultiLinePara;
+ paraState = InMultiLinePara;
}
skipSpacesOrOneEndl();
}
diff --git a/tools/qdoc3/htmlgenerator.cpp b/tools/qdoc3/htmlgenerator.cpp
index 2f990b0..e095685 100644
--- a/tools/qdoc3/htmlgenerator.cpp
+++ b/tools/qdoc3/htmlgenerator.cpp
@@ -524,14 +524,9 @@ int HtmlGenerator::generateAtom(const Atom *atom,
break;
case Atom::DivLeft:
out() << "<div";
- if (!atom->string().isEmpty()) {
- if (atom->string().contains('='))
- out() << " " << atom->string() << ">";
- else
- out() << " class=\"" << atom->string() << "\">";
- }
- else
- out() << ">";
+ if (!atom->string().isEmpty())
+ out() << " " << atom->string();
+ out() << ">";
break;
case Atom::DivRight:
out() << "</div>";
@@ -1106,13 +1101,8 @@ int HtmlGenerator::generateAtom(const Atom *atom,
}
break;
case Atom::TableRowLeft:
- if (!atom->string().isEmpty()) {
- out() << "<tr ";
- if (atom->string().contains('='))
- out() << " " << atom->string() << ">";
- else
- out() << " class=\"" << atom->string() << "\">";
- }
+ if (!atom->string().isEmpty())
+ out() << "<tr " << atom->string() << ">";
else if (++numTableRows % 2 == 1)
out() << "<tr class=\"odd\">";
else