diff options
-rw-r--r-- | src/config.h | 5 | ||||
-rw-r--r-- | src/configimpl.h | 30 | ||||
-rw-r--r-- | src/configimpl.l | 121 | ||||
-rw-r--r-- | src/xmlgen.cpp | 15 | ||||
-rwxr-xr-x | templates/xml/doxyfile.xsd | 53 | ||||
-rwxr-xr-x | testing/runtests.py | 27 |
6 files changed, 231 insertions, 20 deletions
diff --git a/src/config.h b/src/config.h index 45fd4f8..1858897 100644 --- a/src/config.h +++ b/src/config.h @@ -61,6 +61,11 @@ namespace Config */ void compareDoxyfile(TextStream &t); + /*! Writes a the used settings of the current configuartion as XML format + * to stream \a t. + */ + void writeXMLDoxyfile(TextStream &t); + /*! Parses a configuration file with name \a fn. * \returns TRUE if successful, FALSE if the file could not be * opened or read. diff --git a/src/configimpl.h b/src/configimpl.h index d90fe8c..0cf909b 100644 --- a/src/configimpl.h +++ b/src/configimpl.h @@ -78,14 +78,16 @@ class ConfigOption protected: virtual void writeTemplate(TextStream &t,bool sl,bool upd) = 0; virtual void compareDoxyfile(TextStream &t) = 0; + virtual void writeXMLDoxyfile(TextStream &t) = 0; virtual void convertStrToVal() {} virtual void emptyValueToDefault() {} virtual void substEnvVars() = 0; virtual void init() {} + virtual bool isDefault() { return true; } - void writeBoolValue(TextStream &t,bool v); - void writeIntValue(TextStream &t,int i); - void writeStringValue(TextStream &t,const QCString &s); + void writeBoolValue(TextStream &t,bool v,bool initSpace = true); + void writeIntValue(TextStream &t,int i,bool initSpace = true); + void writeStringValue(TextStream &t,const QCString &s,bool initSpace = true); void writeStringList(TextStream &t,const StringVector &l); QCString m_spaces; @@ -109,7 +111,8 @@ class ConfigInfo : public ConfigOption m_doc = doc; } void writeTemplate(TextStream &t, bool sl,bool); - void compareDoxyfile(TextStream &){}; + void compareDoxyfile(TextStream &) {} + void writeXMLDoxyfile(TextStream &) {} void substEnvVars() {} }; @@ -133,8 +136,10 @@ class ConfigList : public ConfigOption StringVector getDefault() { return m_defaultValue; } void writeTemplate(TextStream &t,bool sl,bool); void compareDoxyfile(TextStream &t); + void writeXMLDoxyfile(TextStream &t); void substEnvVars(); void init() { m_value = m_defaultValue; } + bool isDefault(); private: StringVector m_value; StringVector m_defaultValue; @@ -161,7 +166,9 @@ class ConfigEnum : public ConfigOption void writeTemplate(TextStream &t,bool sl,bool); void convertStrToVal(); void compareDoxyfile(TextStream &t); + void writeXMLDoxyfile(TextStream &t); void init() { m_value = m_defValue; } + bool isDefault() { return m_value == m_defValue; } private: std::vector<QCString> m_valueRange; @@ -191,9 +198,11 @@ class ConfigString : public ConfigOption QCString *valueRef() { return &m_value; } void writeTemplate(TextStream &t,bool sl,bool); void compareDoxyfile(TextStream &t); + void writeXMLDoxyfile(TextStream &t); void substEnvVars(); void init() { m_value = m_defValue; } - void emptyValueToDefault() { if(m_value.isEmpty()) m_value=m_defValue; }; + void emptyValueToDefault() { if (m_value.isEmpty()) m_value=m_defValue; }; + bool isDefault() { return m_value.stripWhiteSpace() == m_defValue.stripWhiteSpace(); } private: QCString m_value; @@ -224,7 +233,9 @@ class ConfigInt : public ConfigOption void substEnvVars(); void writeTemplate(TextStream &t,bool sl,bool upd); void compareDoxyfile(TextStream &t); + void writeXMLDoxyfile(TextStream &t); void init() { m_value = m_defValue; } + bool isDefault() { return m_value == m_defValue; } private: int m_value; int m_defValue; @@ -253,7 +264,9 @@ class ConfigBool : public ConfigOption void setValueString(const QCString &v) { m_valueString = v; } void writeTemplate(TextStream &t,bool sl,bool upd); void compareDoxyfile(TextStream &t); + void writeXMLDoxyfile(TextStream &t); void init() { m_value = m_defValue; } + bool isDefault() { return m_value == m_defValue; } private: bool m_value; bool m_defValue; @@ -269,6 +282,7 @@ class ConfigObsolete : public ConfigOption { m_name = name; } void writeTemplate(TextStream &,bool,bool); void compareDoxyfile(TextStream &) {} + void writeXMLDoxyfile(TextStream &) {} void substEnvVars() {} }; @@ -281,6 +295,7 @@ class ConfigDisabled : public ConfigOption { m_name = name; } void writeTemplate(TextStream &,bool,bool); void compareDoxyfile(TextStream &) {} + void writeXMLDoxyfile(TextStream &) {} void substEnvVars() {} }; @@ -481,6 +496,11 @@ class ConfigImpl */ void compareDoxyfile(TextStream &t); + /*! Writes a the used settings of the current configuartion as XML format + * to stream \a t. + */ + void writeXMLDoxyfile(TextStream &t); + void setHeader(const char *header) { m_header = header; } ///////////////////////////// diff --git a/src/configimpl.l b/src/configimpl.l index cf5386e..98b1f5b 100644 --- a/src/configimpl.l +++ b/src/configimpl.l @@ -37,6 +37,7 @@ #include "portable.h" #include "message.h" #include "lang_cfg.h" +#include "language.h" #include "configoptions.h" #include "fileinfo.h" #include "dir.h" @@ -128,18 +129,19 @@ static QCString convertToComment(const QCString &s, const QCString &u) return result; } -void ConfigOption::writeBoolValue(TextStream &t,bool v) +void ConfigOption::writeBoolValue(TextStream &t,bool v,bool initSpace) { - t << " "; + if (initSpace) t << " "; if (v) t << "YES"; else t << "NO"; } -void ConfigOption::writeIntValue(TextStream &t,int i) +void ConfigOption::writeIntValue(TextStream &t,int i,bool initSpace) { - t << " " << i; + if (initSpace) t << " "; + t << i; } -void ConfigOption::writeStringValue(TextStream &t,const QCString &s) +void ConfigOption::writeStringValue(TextStream &t,const QCString &s,bool initSpace) { char c; bool needsEscaping=FALSE; @@ -149,7 +151,7 @@ void ConfigOption::writeStringValue(TextStream &t,const QCString &s) const char *p=se.data(); if (p) { - t << " "; + if (initSpace) t << " "; while ((c=*p++)!=0 && !needsEscaping) needsEscaping = (c==' ' || c== ',' || c=='\n' || c=='\t' || c=='"' || c=='#'); if (needsEscaping) @@ -351,7 +353,7 @@ void ConfigList::writeTemplate(TextStream &t,bool sl,bool) t << "\n"; } -void ConfigList::compareDoxyfile(TextStream &t) +bool ConfigList::isDefault() { auto get_stripped = [](std::string s) { return QCString(s.c_str()).stripWhiteSpace(); }; auto is_not_empty = [get_stripped](std::string s) { return !get_stripped(s).isEmpty(); }; @@ -359,8 +361,7 @@ void ConfigList::compareDoxyfile(TextStream &t) size_t valCnt = std::count_if(m_defaultValue.begin(),m_defaultValue.end(),is_not_empty); if ( valCnt != defCnt) { - writeTemplate(t,TRUE,TRUE); - return; + return false; } auto it1 = m_value.begin(); auto it2 = m_defaultValue.begin(); @@ -375,13 +376,37 @@ void ConfigList::compareDoxyfile(TextStream &t) { if (get_stripped(*it1) != get_stripped(*it2)) // not the default, write as difference { - writeTemplate(t,TRUE,TRUE); - return; + return false; } ++it1; ++it2; } } + return true; +} + +void ConfigList::compareDoxyfile(TextStream &t) +{ + if (!isDefault()) writeTemplate(t,TRUE,TRUE); +} + +void ConfigList::writeXMLDoxyfile(TextStream &t) +{ + t << " <option id='" << m_name << "'"; + t << " default='" << (isDefault() ? "yes" : "no") << "'"; + t << " type='stringlist'"; + t << ">"; + t << "\n"; + for (const auto &p : m_value) + { + QCString s=p.c_str(); + t << " <value>"; + t << "<![CDATA["; + writeStringValue(t,s,false); + t << "]]>"; + t << "</value>\n"; + } + t << " </option>\n"; } void ConfigEnum::writeTemplate(TextStream &t,bool sl,bool) @@ -403,7 +428,19 @@ void ConfigEnum::writeTemplate(TextStream &t,bool sl,bool) void ConfigEnum::compareDoxyfile(TextStream &t) { - if (m_value != m_defValue) writeTemplate(t,TRUE,TRUE); + if (!isDefault()) writeTemplate(t,TRUE,TRUE); +} + +void ConfigEnum::writeXMLDoxyfile(TextStream &t) +{ + t << " <option id='" << m_name << "'"; + t << " default='" << (isDefault() ? "yes" : "no") << "'"; + t << " type='string'"; + t << ">"; + t << "<value>"; + writeStringValue(t,m_value,false); + t << "</value>"; + t << "</option>\n"; } void ConfigString::writeTemplate(TextStream &t,bool sl,bool) @@ -425,7 +462,21 @@ void ConfigString::writeTemplate(TextStream &t,bool sl,bool) void ConfigString::compareDoxyfile(TextStream &t) { - if (m_value.stripWhiteSpace() != m_defValue.stripWhiteSpace()) writeTemplate(t,TRUE,TRUE); + if (!isDefault()) writeTemplate(t,TRUE,TRUE); +} + +void ConfigString::writeXMLDoxyfile(TextStream &t) +{ + t << " <option id='" << m_name << "'"; + t << " default='" << (isDefault() ? "yes" : "no") << "'"; + t << " type='string'"; + t << ">"; + t << "<value>"; + t << "<![CDATA["; + writeStringValue(t,m_value,false); + t << "]]>"; + t << "</value>"; + t << "</option>\n"; } void ConfigInt::writeTemplate(TextStream &t,bool sl,bool upd) @@ -454,7 +505,19 @@ void ConfigInt::writeTemplate(TextStream &t,bool sl,bool upd) void ConfigInt::compareDoxyfile(TextStream &t) { - if (m_value != m_defValue) writeTemplate(t,TRUE,TRUE); + if (!isDefault()) writeTemplate(t,TRUE,TRUE); +} + +void ConfigInt::writeXMLDoxyfile(TextStream &t) +{ + t << " <option id='" << m_name << "'"; + t << " default='" << (isDefault() ? "yes" : "no") << "'"; + t << " type='int'"; + t << ">"; + t << "<value>"; + writeIntValue(t,m_value,false); + t << "</value>"; + t << "</option>\n"; } void ConfigBool::writeTemplate(TextStream &t,bool sl,bool upd) @@ -484,7 +547,19 @@ void ConfigBool::writeTemplate(TextStream &t,bool sl,bool upd) void ConfigBool::compareDoxyfile(TextStream &t) { - if (m_value != m_defValue) writeTemplate(t,TRUE,TRUE); + if (!isDefault()) writeTemplate(t,TRUE,TRUE); +} + +void ConfigBool::writeXMLDoxyfile(TextStream &t) +{ + t << " <option id='" << m_name << "'"; + t << " default='" << (isDefault() ? "yes" : "no") << "'"; + t << " type='bool'"; + t << ">"; + t << "<value>"; + writeBoolValue(t,m_value,false); + t << "</value>"; + t << "</option>\n"; } void ConfigObsolete::writeTemplate(TextStream &,bool,bool) {} @@ -1117,6 +1192,17 @@ void ConfigImpl::compareDoxyfile(TextStream &t) } } +void ConfigImpl::writeXMLDoxyfile(TextStream &t) +{ + t << "<?xml version='1.0' encoding='UTF-8' standalone='no'?>\n"; + t << "<doxyfile xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"doxyfile.xsd\" version=\"" << getDoxygenVersion() << "\" xml:lang=\"" << theTranslator->trISOLang() << "\">\n"; + for (const auto &option : m_options) + { + option->writeXMLDoxyfile(t); + } + t << "</doxyfile>\n"; +} + void ConfigImpl::convertStrToVal() { for (const auto &option : m_options) @@ -2093,6 +2179,11 @@ void Config::compareDoxyfile(TextStream &t) ConfigImpl::instance()->compareDoxyfile(t); } +void Config::writeXMLDoxyfile(TextStream &t) +{ + ConfigImpl::instance()->writeXMLDoxyfile(t); +} + bool Config::parse(const QCString &fileName,bool update) { bool parseRes = ConfigImpl::instance()->parse(fileName,update); diff --git a/src/xmlgen.cpp b/src/xmlgen.cpp index 8489a3c..86f3081 100644 --- a/src/xmlgen.cpp +++ b/src/xmlgen.cpp @@ -1898,6 +1898,7 @@ void generateXML() ResourceMgr::instance().copyResource("xml.xsd",outputDirectory); ResourceMgr::instance().copyResource("index.xsd",outputDirectory); + ResourceMgr::instance().copyResource("doxyfile.xsd",outputDirectory); QCString fileName=outputDirectory+"/compound.xsd"; std::ofstream f(fileName.str(),std::ofstream::out | std::ofstream::binary); @@ -1935,6 +1936,20 @@ void generateXML() } f.close(); + fileName=outputDirectory+"/Doxyfile.xml"; + f.open(fileName.str(),std::ofstream::out | std::ofstream::binary); + if (!f.is_open()) + { + err("Cannot open file %s for writing\n",fileName.data()); + return; + } + else + { + TextStream t(&f); + Config::writeXMLDoxyfile(t); + } + f.close(); + fileName=outputDirectory+"/index.xml"; f.open(fileName.str(),std::ofstream::out | std::ofstream::binary); if (!f.is_open()) diff --git a/templates/xml/doxyfile.xsd b/templates/xml/doxyfile.xsd new file mode 100755 index 0000000..71b9851 --- /dev/null +++ b/templates/xml/doxyfile.xsd @@ -0,0 +1,53 @@ +<?xml version='1.0' encoding='utf-8' ?> +<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> + <xsd:import namespace="http://www.w3.org/XML/1998/namespace" schemaLocation="xml.xsd"/> + + <xsd:element name="doxyfile" type="DoxygenFileType"/> + + <xsd:complexType name="DoxygenFileType"> + <xsd:sequence> + <xsd:element name="option" type="OptionType" minOccurs="0" maxOccurs="unbounded"/> + </xsd:sequence> + <xsd:attribute name="version" type="xsd:string" use="required"/> + <xsd:attribute ref="xml:lang" use="required"/> + </xsd:complexType> + + <xsd:complexType name="OptionType"> + <xsd:sequence> + <xsd:element name="value" type="valueType" minOccurs="0" maxOccurs="unbounded"/> + </xsd:sequence> + <xsd:attribute name="id" type="xsd:string" use="required"/> + <xsd:attribute name="default" type="defaultType" use="required"/> + <xsd:attribute name="type" type="typeType" use="required"/> + </xsd:complexType> + + <xsd:simpleType name="valueType"> + <xsd:restriction base="xsd:string"> + </xsd:restriction> + </xsd:simpleType> + + <xsd:simpleType name="defaultType"> + <xsd:restriction base="xsd:string"> + <xsd:enumeration value="yes"/> + <xsd:enumeration value="no"/> + </xsd:restriction> + </xsd:simpleType> + + <xsd:simpleType name="typeType"> + <xsd:restriction base="xsd:string"> + <xsd:enumeration value="int"/> + <xsd:enumeration value="bool"/> + <xsd:enumeration value="string"/> + <xsd:enumeration value="stringlist"/> + </xsd:restriction> + </xsd:simpleType> + +</xsd:schema> + +<!-- +<?xml version='1.0' encoding='UTF-8' standalone='no'?> +<doxyfile xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="doxyfile.xsd" version="1.9.2" xml:lang="en-US"> + <option id='DOXYFILE_ENCODING' default='yes' type='string'><![CDATA[UTF-8]]></option> +<value><![CDATA[d:/Programs/CGAL/cgal_fork/AABB_tree/doc/AABB_tree/]]></value> +--> + diff --git a/testing/runtests.py b/testing/runtests.py index f981c55..236a1c3 100755 --- a/testing/runtests.py +++ b/testing/runtests.py @@ -305,12 +305,39 @@ class Tester: msg += (xmllint_out,) failed_xmlxsd=True # + doxyfile_xml = [] + doxyfile_xml.append(glob.glob('%s/Doxyfile.xml' % (xmlxsd_output))) + doxyfile_xml.append(glob.glob('%s/*/*/Doxyfile.xml' % (xmlxsd_output))) + doxyfile_xml = ' '.join(list(itertools.chain.from_iterable(doxyfile_xml))).replace(self.args.outputdir +'/','').replace('\\','/') + doxyfile_xsd = [] + doxyfile_xsd.append(glob.glob('%s/doxyfile.xsd' % (xmlxsd_output))) + doxyfile_xsd.append(glob.glob('%s/*/*/doxyfile.xsd' % (xmlxsd_output))) + doxyfile_xsd = ' '.join(list(itertools.chain.from_iterable(doxyfile_xsd))).replace(self.args.outputdir +'/','').replace('\\','/') + exe_string = '%s --noout --schema %s %s' % (self.args.xmllint,doxyfile_xsd,doxyfile_xml) + exe_string1 = exe_string + exe_string += ' %s' % (redirx) + exe_string += ' %s more "%s/temp"' % (separ,xmlxsd_output) + + xmllint_out = xpopen(exe_string,exe_string1,getStderr=True) + if xmllint_out: + xmllint_out = re.sub(r'.*validates','',xmllint_out).rstrip('\n') + else: + msg += ('Failed to run %s with schema %s for files: %s' % (self.args.xmllint,doxyfile_xsd,doxyfile_xml),) + failed_xmlxsd=True + if xmllint_out: + xmllint_out = clean_header(xmllint_out) + if xmllint_out: + msg += (xmllint_out,) + failed_xmlxsd=True + # compound_xml = [] compound_xml.append(glob.glob('%s/*.xml' % (xmlxsd_output))) compound_xml.append(glob.glob('%s/*/*/*.xml' % (xmlxsd_output))) compound_xml = ' '.join(list(itertools.chain.from_iterable(compound_xml))).replace(self.args.outputdir +'/','').replace('\\','/') compound_xml = re.sub(r' [^ ]*/index.xml','',compound_xml) compound_xml = re.sub(r'[^ ]*/index.xml ','',compound_xml) + compound_xml = re.sub(r' [^ ]*/Doxyfile.xml','',compound_xml) + compound_xml = re.sub(r'[^ ]*/Doxyfile.xml ','',compound_xml) compound_xsd = [] compound_xsd.append(glob.glob('%s/compound.xsd' % (xmlxsd_output))) |